akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N, W;
    cin >> N >> W;

    int v[1010], w[1010];
    for(int i=0; i<N; i++){
        cin >> v[i] >> w[i];
    }

    int dp[110][10010] = {0};

    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j >= w[i]){
                dp[i + 1][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i][j]);
            }
            else{
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    cout << dp[N][W] << endl;

}


Measured memory_bytes: 7408
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,l[110];
    cin >> n;
    rep(i,n) cin >> l[i];
    int cnt = 0;
    rep(i,n)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
        int a[3]={l[i],l[j],l[k]};
        sort(a,a+3);
        if(a[0]<a[1]&&a[1]<a[2]&&a[0]+a[1]>a[2]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#define MAXN 200000
#define INF 2000000000
typedef long long ll;
using namespace std;

int L[MAXN/2 + 2], R[MAXN / 2 + 2];

ll merge(int A[], int left, int mid, int right){
	ll cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i] < R[j]) {
			A[k] = L[i++];
		}else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

ll mergeSort(int A[], int left, int right)
{
	int mid;
	ll v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right)/2;
		v1 = mergeSort(A, left, mid);
		v2 = mergeSort(A, mid, right);
		v3 = merge(A, left, mid, right);
		return v1 + v2 + v3;
	}else {
		return 0;
	}
}

int main(int argc, char *argv[]) {
	int n;
	scanf("%d", &n);
	int A[MAXN];
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	
	ll ans = mergeSort(A, 0, n);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll ans=0;
    cin>>n;
    vector<int> a(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }        
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int main() {
  ll n, c;
  cin>>n>>c;
  pair<ll, ll> xv[n];
  for (int i=0; i<n; i++) cin>>xv[i].first>>xv[i].second;
  ll c_acc[n+1], ac_acc[n+1];
  c_acc[0] = 0;
  c_acc[1] = xv[0].second - xv[0].first;
  for (int i=1; i<n; i++) {
    c_acc[i+1] = c_acc[i] + xv[i].second - (xv[i].first - xv[i-1].first);
  }
  ac_acc[n] = 0;
  ac_acc[n-1] = xv[n-1].second - (c - xv[n-1].first);
  for (int i=n-1; i>0; i--) {
    ac_acc[i-1] = ac_acc[i] + xv[i-1].second - (xv[i].first - xv[i-1].first);
  }
  ll max_c_acc[n+1];
  max_c_acc[0] = 0;
  for (int i=1; i<n+1; i++) {
    max_c_acc[i] = max(c_acc[i], max_c_acc[i-1]);
  }
  ll max_ac_acc[n+1];
  max_ac_acc[n] = 0;
  for (int i=n-1; i>=0; i--) {
    max_ac_acc[i] = max(ac_acc[i], max_ac_acc[i+1]);
  }
  ll ans = -1e15;
  for (int i=n-1; i>=0; i--) {
    ll tmp = ac_acc[i] - (c - xv[i].first) + max_c_acc[i];
    ans = max(max(tmp, ac_acc[i]), ans);
  }
  for (int i=0; i<n; i++) {
    ll tmp = c_acc[i+1] - xv[i].first + max_ac_acc[i+1];
    ans = max(max(tmp, c_acc[i+1]), ans);
  }
  cout<<max(ans, max_ac_acc[0])<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    double T,A; cin >> T >> A;
    vector<double> H(N); REP(i,N) cin >> H[i];
    int ans;
    double mn = INT_INF;
    REP(i,N){
        if(chmin(mn, abs(A-(T-H[i]*0.006)))) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 200002;

int n;
vector<int> g[MAX_N];

void read_input() {
	cin >> n;

	for (int i=1; i<n; ++i) {
		int u, v;
		cin >> u >> v;

		g[u].push_back(v);
		g[v].push_back(u);
	}
}

pair<int, int> bfs(int st) {
	queue<int> qu;
	qu.push(st);

	vector<int> d(n+1, -1);
	d[st] = 0;

	while (qu.size()) {
		int u = qu.front();
		qu.pop();

		for (auto v : g[u]) {
			if (d[v]==-1) {
				d[v] = d[u] + 1;
				qu.push(v);
			}
		}
	}

	pair<int, int> res(0, st);
	for (int i=1; i<=n; ++i)
		res = max(res, {d[i], i});

	return res;
}

void solve() {
	int u = bfs(1).second;
	int d = bfs(u).first + 1;
	// debug(d);

	if (d%3==2)
		puts("Second");
	else
		puts("First");
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".in", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);

	read_input();
	solve();
}

Measured memory_bytes: 13556
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    S = input()
    d = 1
    dp = [0] * 13
    dp[0] = 1
    dp_n = [None] * 13
    for s in reversed(S):
        for i in range(13):
            dp[i] %= N1097
            dp_n[i] = 0
        if s == '?':
            for s in range(10):
                diff = (s*d) % 13
                for i in range(13):
                    dp_n[(i+diff)%13] += dp[i]
        else:
            s = int(s)
            diff = (s*d) % 13
            for i in range(13):
                dp_n[(i+diff)%13] += dp[i]
        dp_n, dp = dp, dp_n
        d = (10 * d) % 13
    print(dp[5] % N1097)

main()


Measured memory_bytes: 70248
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <list>

using namespace std;
#define  INF  (INT_MAX/2)
#define  MAXV  10001
#define  MAXE 100001
#define  NIL  -1

list<int> ans;
bool vis[MAXV];
int head[MAXE], indegree[MAXV];
int cnt;

struct Edge {
  int  to, next=NIL;
} edge[MAXE];

void bfs(int u){
  queue<int> q;
  vis[u] = true;
  q.push(u);
  while (!q.empty()){
    u = q.front();
    ans.push_back(u);
    q.pop();

    for (int i=head[u];i!=NIL;i=edge[i].next){
      u=edge[i].to;
      if (!vis[u] && --indegree[u] == 0){
	vis[u] = true;
	q.push(u);
      }
    }
  }
}

void tpSort(int n){
  for (int i = 0; i < n; ++i) {vis[i] = false;}
  for (int i = 0; i < n; ++i) {
    if (indegree[i] == 0 && !vis[i]) {bfs(i);}
  }
}

void add(int u, int v){
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}

int main(void){
  int V, E, s, t;
  cin >> V >>E;
  cnt = 0;
  memset(head,NIL,sizeof(int)*(E+1));

  for (int i = 0; i < E; ++i){
    cin >> s>>t;
    indegree[t]++;
    add(s, t);
  }

  tpSort(V);
  for (list<int>::iterator itr=ans.begin(); itr!=ans.end();itr++){cout << *itr <<endl;}

  return 0;
}


Measured memory_bytes: 4372
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    N = int(input())

    #dp[i]:[..]左からi文字目がA,C,G,Tの場合の数
    dp = [[0]*4 for _ in range(N+1)]
    dp[1] = [1]*4
    for i in range(1,N+1):
        for j in range(4):
            dp[i][j] += sum(dp[i-1])
            dp[i][j] %= mod
        #3文字見る
        if i >= 2:
            dp[i][1] -= dp[i-2][0]*1 + dp[i-2][2]*1
            dp[i][2] -= dp[i-2][0]*1
        #4文字見る
        if i >= 3:
            #ACGC ATGC AGGCで×3
            dp[i][1] -= dp[i-3][0]*3
            #GACGはそもそも足してないので余計に引いた分足す
            dp[i][2] += dp[i-3][2]*1

    print(sum(dp[N])%mod)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//06
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(double h;cin>>h;){
    const double cn[]={48,51,54,57,60,64,69,75,81,91};
    const char *cs[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
    cout<<cs[lower_bound(cn,cn+sizeof(cn)/sizeof(cn[0]),h)-cn]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
#define INF (1 << 30)
int h,w,dp[2][1<<20][2],next,cur;
char mas[20][20],tmp[]="JOI";
int main(){
  cin >> h >> w;
  rep(i,h) rep(j,w) cin >> mas[i][j];
  dp[0][0][0] = next = 1;
  cur = 0;
  rep(x,h){
    rep(y,w){
      fill_n(dp[next][0],2*(1<<20),0);
      rep(bit,1<<w) rep(i,2) if(dp[cur][bit][i]) rep(j,3){
        int mkbit = bit & ~(1 << y) , mki = ( j == 0 );
        if( mas[x][y] != '?' && mas[x][y] != tmp[j] ) continue;
        if( (bit & 1 << y ) && j == 2) continue;
        if( i == 1 && j == 1 ) mkbit |= 1 << y - 1;
        dp[next][mkbit][mki] += dp[cur][bit][i];
        if(dp[next][mkbit][mki] >= 100000) dp[next][mkbit][mki] -= 100000;
      }
      swap(next,cur);
    }
    rep(bit,1<<w){
      dp[cur][bit][0] += dp[cur][bit][1];
      if(dp[cur][bit][0] >= 100000) dp[cur][bit][0] -= 100000;
      dp[cur][bit][1] = 0;
    }
  }

  int ans = 1;
  rep(i,h) rep(j,w) if(mas[i][j] == '?') ans = (ans * 3) % 100000;
  rep(bit,1<<w) ans = (ans - dp[cur][bit][0] + 100000) % 100000;
  cout << ans << endl;
}

Measured memory_bytes: 17544
#include<bits/stdc++.h>
using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int N;
int a[100];
int hist[128];
int main(void){
	
	cin >> N;
	int d, m;
	for(int i=0;i<N;i++){
		cin >> a[i];
		hist[a[i]]++;
	}
	sort(&a[0], &a[N]);
	d = a[N-1];
	
	bool orz = false;
	if (d%2){
		m = (d+1)/2;
		if (hist[m]!=2) orz = true;
		for(int i=m+1;i<=d;i++){
			if (hist[i]<2) orz = true;
		}
	}else{
		m = d/2;
		if (hist[m]!=1) orz = true;
		for(int i=m+1;i<=d;i++){
			if (hist[i]<2) orz = true;
		}
	}
	if (orz) cout << "Impossible" << endl;
	else cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n,m,k;
  cin >> n >> m >> k;
  vector<long long> a(n,0);
  vector<long long> b(m,0);
  vector<long long> suma(n,0);
  vector<long long> sumb(m,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i==0) suma[i]=a[i];
    else suma[i]=suma[i-1]+a[i];
  }
  for(int i=0;i<m;i++){
    cin >> b[i];
    if(i==0) sumb[i]=b[i];
    else sumb[i]=sumb[i-1]+b[i];
  }
  long long j=m-1,ans=0;
  long long l=sumb[m-1];
  for(int i=-1;i<n;i++){
    if(i==-1){
      while(true){
        if(l<=k) break;
        l-=b[j];
        j--;
        if(j==-1) break;
      }
    }
    else{
      if(suma[i]>k) break;
      while(true){
        if(l<=k-suma[i]) break;
        l-=b[j];
        j--;
        if(j==-1) break;
      }
    }
    ans=max(ans,j+i+2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s; cin >> s;
    int sum;
    string t;
    int n = s.size()-1;
    for(int bit=0;bit<(1<<n);++bit){
        sum = s[0]-'0';
        for(int i=0;i<n;++i){
            if(bit & (1<<i)){
                t[i] = '+';
                sum += s[i+1]-'0';
            }
            else{
                t[i] = '-';
                sum -= s[i+1]-'0';
            }
        }
        if(sum==7) break;
    }
    for(int i=0;i<n;++i){
        cout << s[i] << t[i];
    }
    cout << s[n] << "=7" << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
eight = 0

for i in range(1,N+1):
	yakusu = 0
	if i % 2 == 1:
		for j in range(1,N+1):
			if i % j == 0:
				yakusu += 1
	if yakusu == 8:
		eight += 1
		
print(eight)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int  A;  cin >> A;  // 入力値Ａ
  char OP; cin >> OP; // + or -
  int  B;  cin >> B;  // 入力値Ｂ

  if ( OP == '+' ) {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string n;
    cin >> n;

    if (n[1] == n[2] && n[2] == n[0] || n[2] == n[3] && n[1] == n[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int MOD=1000000007;
const int MOD=998244353;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// nCr mod を計算する O(n)
const int MAX_N = 1000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int n;
    ll m,K;
    cin>>n>>m>>K;

    if(n==1){
        cout<<m<<endl;
        return 0;
    }

    if(m==1){
        if(n-1==K) cout<<m<<endl;
        else cout<<0<<endl;
        return 0;
    }

    COMinit();
    ll ans=0;
    for(ll k=0;k<K+1;k++){
        ll tmp=COM(n-1,k);
        tmp=(tmp*m)%MOD;
        ll tmp1=modpow(m-1,n-1-k);
        tmp=(tmp*tmp1)%MOD;
        ans=(ans+tmp)%MOD;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 27068
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int H, W, K, sx, sy, tx, ty;
string c[1010101];
int mi[1010101];
bool vis[1010101];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W >> K >> sx >> sy >> tx >> ty;
	rep(y, 0, H) cin >> c[y];
	sx--; sy--; tx--; ty--;

	queue<int> que;
	rep(i, 0, 1010101) mi[i] = inf;

	que.push(sx * W + sy);
	vis[sx * W + sy] = true;
	mi[sx * W + sy] = 0;

	while (!que.empty()) {
		int q = que.front(); que.pop();

		int x = q / W;
		int y = q % W;

		if (x == tx && y == ty) {
			printf("%d\n", mi[q]);
			return;
		}

		rep(d, 0, 4) {
			int xx = x, yy = y;
			rep(k, 0, K) {
				xx += dx[d];
				yy += dy[d];

				if (xx < 0 || H <= xx || yy < 0 || W <= yy) break;
				if (c[xx][yy] == '@') break;
				
				int id = xx * W + yy;
				if (vis[id] && mi[q] + 1 != mi[id]) break;

				if (!vis[id]) {
					vis[id] = true;
					mi[id] = mi[q] + 1;
					que.push(id);
				}
			}
		}
	}

	printf("-1\n");
}







Measured memory_bytes: 41300
x1, y1, x2, y2 = gets.split(" ").map(&:to_i)

if x1 == x2 && y1 < y2
  y3 = y2
  y4 = y1
  x3 = x2 - (y2 - y1)
  x4 = x3
elsif x1 == x2 && y2 < y1
  y3 = y2
  y4 = y1
  x3 = x2 + (y1 - y2)
  x4 = x3
elsif y1 == y2 && x2 < x1
  x3 = x2
  x4 = x1
  y3 = y2 - (x1 - x2)
  y4 = y3
elsif y1 == y2 && x1 < x2
  x3 = x2
  x4 = x1
  y3 = y2 + (x2 - x1)
  y4 = y3
else
  w = y2 - y1
  h = x2 - x1
  x3 = x2 - w
  y3 = y2 + h
  x4 = x3 - h
  y4 = y3 - w
end

puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
#import sys
#input = sys.stdin.readline
#import heapq
#from fractions import gcd
#from collections import defaultdict
#sys.setrecursionlimit(10**9)
#map(int,input().split())

def main():
    s=input()
    k=int(input())
    n=len(s)
    cnt1=0
    tmp1=0
    ss=s*2
    nn=n*2
    sss=s*3
    nnn=n*3
    for i in range(n-1):
        if s[i]==s[i+1] and tmp1==0:
            cnt1+=1
            tmp1=1
        elif s[i]==s[i+1]:
            tmp1=0
        else:
            tmp1=0
    cnt2=0
    tmp2=0
    for i in range(nn-1):
        if ss[i]==ss[i+1] and tmp2==0:
            cnt2+=1
            tmp2=1
        elif ss[i]==ss[i+1]:
            tmp2=0
        else:
            tmp2=0
    cnt3=0
    tmp3=0
    for i in range(nnn-1):
        if sss[i]==sss[i+1] and tmp3==0:
            cnt3+=1
            tmp3=1
        elif sss[i]==sss[i+1]:
            tmp3=0
        else:
            tmp3=0
    if cnt2==2*cnt1:
        print(cnt1*k)
    elif cnt3-cnt2!=cnt2-cnt1:
        if k%2==0:
            print(cnt2*(k//2))
        else:
            print(cnt2*(k//2)+cnt1)
    else:
        print(cnt1+(cnt2-cnt1)*(k-1))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
edges = []
abc.each do|a, b, c|
  graph[a] << [b,c]
  r_graph[b] << [a,c]
  edges << [a,b,c]
end

def reachable(s, g)
  q=[s]
  result = Set.new([s])
  until q.empty?
    c = q.shift
    g[c].each do |to, _|
      next if result.include?(to)
      result.add(to)
      q.push(to)
    end
  end
  result
end

# 不要な閉路の削除
# 必要なノードの算出
from_1 = reachable(1, graph)
from_n = reachable(n, r_graph)
availables = from_1 & from_n

# BFする
INF = 10**13
dist = Array.new(n+1, INF)
dist[1]=0
updated = false

edges = edges.select {|from, to, cost| availables.include?(from) && availables.include?(to) }

n.times do
  updated = false
  edges.each do |from, to, cost|
    if dist[from]!=INF && dist[to] > dist[from]+cost
      dist[to] = dist[from]+cost
      updated = true
    end
  end
  break unless updated
end
if updated
  p -1
  exit
end

# 答えだす
#p availables
#p edges
#p dist
#p [dist[n]*-1, 0]
p [dist[n]*-1, 0].max


Measured memory_bytes: 4860
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int a[1010], b[1010];
int dp[10010];
int n;
int dfs(int hp, int pos)
{
    if(hp <= 0) return 0;
    if(dp[hp] != -1) return dp[hp];
    int i;
    int sum = 1e9;
    for(i=1;i<=n;i++)
    {
        sum = min(sum, dfs(hp-a[i], i) + b[i]);
    }
    return dp[hp] = sum;
}
int main()
{
    int i,j,x,y,k,ans,curr,temp,m;
    int tc;
    int h;
    scanf("%d %d",&h,&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i], &b[i]);
    }
    memset(dp, -1, sizeof(dp));
    int chaeng = dfs(h, 0);
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	int ans=0;
	for(int i=1;i<N;i++){
		if(A[i]==A[i-1]){
			A[i]=-1;
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    

    string s;
    cin>>s;
    Yn(s[2]==s[3]&&s[4]==s[5]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k,a,b,n,s,t;
	cin>>k>>a>>b;
	if(a>=k){cout<<"1"<<endl;return 0;}
	n=a-b;
	if(n<=0){
		cout<<"-1"<<endl;
		return 0;
	}
	s=k-a;
	if(s%n==0)t=s/n;
	else t=s/n+1;
	cout<<t*2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;
 
int H,W;
int A[22][22];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
 
int solve(int r,int c){
  int d[H][W],ret=0;
  rep(i,H) rep(j,W) d[i][j]=-1;
  d[r][c]=0;
  queue<pair<int,int>> que;
  que.push({r,c});
  while(que.size()){
    pair<int,int> p=que.front();
    que.pop();
    int i=p.first, j=p.second;
    rep(k,4){
      int ii=i+dx[k],jj=j+dy[k];
      if(ii<0||ii>=H) continue;
      if(jj<0||jj>=W) continue;
      if(A[ii][jj]==0) continue;
      if(d[ii][jj]==-1){
        d[ii][jj]=d[i][j]+1;
        que.push({ii,jj});
        ret=max(ret,d[ii][jj]);
      }
    }
  }
  return ret;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>H>>W;
  rep(i,H){
    string S; cin>>S;
    rep(j,W) A[i][j]=(S[j]=='.');
  }
  int ans=0;
  rep(i,H) rep(j,W) if(A[i][j]) ans=max(ans,solve(i,j));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e12;
ll dp[305][305];

int main() {
    // dp, N^3が間に合う、dp[j][k] jは最後の列(1-indexed)、kはいくつ削除したのか
    int N, K;
    cin >> N >> K;
    vector<int> H(N+1);
    rep(i, N) cin >> H[i+1];  // 1-indexed
    rep(i, N+1) rep(j, N+1) dp[i][j] = INF;
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        // iが現在位置
        for (int j = 0; j < i; j++) {
            // jは最後の列
            for (int k = K; k >= 0; k--) {
                // k回削除する
                if (k >= 0) {
                    dp[i][k] = min(dp[i][k], dp[j][k] + max(0, H[i]-H[j])); // i番目をそのまま使う
                }
            }
            for (int k = K+1; k >= 0; k--) {
                if (k - 1 >= 0) {
                    dp[j][k] = dp[j][k-1];
                } else {
                    dp[j][k] = INF;
                }
            }
        }
    }
    ll ans = INF;
    rep(i, N+1) rep(k, K+1) ans = min(ans, dp[i][k]);
    cout << ans << '\n';
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    char b;
    cin >> b;
    if(b == 'A'){
        cout << "T" << endl;
    }
    if(b == 'C'){
        cout << "G" << endl;
    }
    if(b == 'G'){
        cout << "C" << endl;
    }
    if(b == 'T'){
        cout << "A" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    string s;
    map<string,int>m;
    map<string ,int>::iterator it;
    cin>>n;
    int maxn=0;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        m[s]++;
        maxn=max(maxn,m[s]);
    }
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->second==maxn)
            cout<<it->first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25728
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()


ll n, k;
int main(){
	cin >> n >> k;
	cout << (n + k - 3) / (k - 1) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
#define bit(n, k) ((n) >> (k) & 1)

int main() {
    int n, m; cin >> n >> m;
    vector<long long> x(n), y(n), z(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
    long long ma = 0;
    for (int mask = 0; mask < 1 << 3; mask++) {
        vector<long long> v(n);
        for (int i = 0; i < n; i++) {
            long long &tmp = v[i];
            tmp += x[i] * (bit(mask, 0) ? 1 : -1);
            tmp += y[i] * (bit(mask, 1) ? 1 : -1);
            tmp += z[i] * (bit(mask, 2) ? 1 : -1);
        }
        sort(v.rbegin(), v.rend());
        ma = max(ma, accumulate(begin(v), begin(v) + m, 0LL));
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll a,b;
  cin>>a>>b;
  if(a==b) {
for(ll i=0;i<a;i++) {
cout<<a;
  
}
    cout<<endl;
  }

  else if(a<b) {
for(ll i=0;i<b;i++) {
cout<<a;
}
    cout<<endl;
  }
  
  else {
for(ll i=0;i<a;i++) {
  cout<<b;
}
    cout<<endl;
  }
}
  
  

  


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int a, b, c;


int main(){
    cin >> a >> b >> c;
    if(a == b && a != c)cout << " Yes" << endl;
    else if(a == c && a != b)cout << " Yes" << endl;
    else if(b == c && a != b)cout << " Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll rq,num=100,ans=0;
int main()
{
	scanf("%lld",&rq);
	while(num<rq) {
		num+=num/100;
		ans++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    vector<int> v;
    rep(i,s.size()){
        if(v.size()==0)v.push_back(s[i]);
        else{
            if(v[v.size()-1]!=s[i])v.pop_back();
            else v.push_back(s[i]);
        }
    }
    cout << s.size() - v.size();
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL INF=1e18;

int main(){
	int N;
	cin >> N;
	vector<LL> A(N), sum(N+1);
	rep(i,N) cin >> A[i];
	rep(i,N) sum[i+1]=sum[i]+A[i];
	LL ans=INF;
	for(int i=2; i<N-1; i++){
		LL sum_left=sum[i], sum_right=sum[N]-sum[i];
		LL mid_left=sum_left/2, mid_right=sum_right/2;
		int left=upper_bound(sum.begin(),sum.end(),mid_left)-sum.begin();
		int right=upper_bound(sum.begin(),sum.end(),sum[i]+mid_right)-sum.begin();
		rep(j,2){
			rep(k,2){
				LL p=sum[left-j], q=sum[i]-sum[left-j],
				r=sum[right-k]-sum[i], s=sum[N]-sum[right-k];
				if(left-j<=0 or left-j>=i) continue;
				if(right-k<=i or right-k>=N) continue;
				LL M=max({p,q,r,s}), m=min({p,q,r,s});
				ans=min(ans,M-m);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////
int n,m;
int v[10][10] = {};

ll dfs(int s,int use,ll cnt){
//cout << s << " " << use << " " << cnt << endl;
   if(use == (1<<n)-1){
   //if(cnt >= n-1 && s == n-1){
        ret 1;
    }
    
    ll ans = 0;
    rep(i,0,n){
        if(v[s][i] == 1 && !((use >> i) & 0x01)){
            ans += dfs(i,use|(1<< i),cnt+1);
        }
    }
  
    ret ans;
}
int main(){
    cin >> n >> m;
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        v[a-1][b-1] = 1;
        v[b-1][a-1] = 1;
    }

    P(dfs(0,1,0));
	return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++){
		if(i%2==1){
			if(a%2==1){
				a=a-1;
				a=a/2;
				b=b+a;
			//	cout<<b;
			}else{
				a=a/2;
				b=b+a;
			}
		}else{
			if(b%2==1){
				b=b-1;
				b=b/2;
				a=a+b;
			}else{
				b=b/2;
				a=a+b;
			}
		}
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
# AOJ 0068 Enclose Pins with a Rubber Band
# Python3 2018.6.22 bal4u

def cross(a, b):
	return a.real*b.imag - a.imag*b.real
	
# 凸包　入力: 座標リスト　リターン:凸包を構成する座標リスト
def convex_hull(p):
	pp = sorted(p, key=lambda x:(x.imag,x.real))  # y座標を優先して昇順、同じならx座標で昇順
	n = len(pp)
	ans, j = [0]*(n+1), 0
	for i in range(n):
		while j > 1 and cross(ans[j-1]-ans[j-2], pp[i]-ans[j-1]) < 0: j -= 1
		ans[j] = pp[i]
		j += 1
	k = j
	for i in range(n-2, -1, -1):
		while j > k and cross(ans[j-1]-ans[j-2], pp[i]-ans[j-1]) < 0: j -= 1
		ans[j] = pp[i]
		j += 1
	return ans[0:j-1]
	
while 1:
	n = int(input())
	if n == 0: break
	p = []
	for i in range(n):
		x, y = list(map(float, input().split(',')))
		p.append(complex(x, y))
	print(n - len(convex_hull(p)))


Measured memory_bytes: 5632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == '2') ans++;
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, S[13], H[13], C[13], D[13];
    cin>>n;
    for(int i=0;i<13;i++){
        S[i]=1;
        H[i]=1;
        C[i]=1;
        D[i]=1;
    }
    string x;
    int y;
    for(int i=0;i<=n;i++){
        cin>> x >> y;
        if(x=="S"){
            S[y-1]=0;
        }else if(x=="H"){
            H[y-1]=0;
        }else if(x=="C"){
            C[y-1]=0;
        }else if(x=="D"){
            D[y-1]=0;
        }
    }
    for(int i=0;i<13;i++){
        if(S[i])cout<<"S "<<i+1<<endl;
        }for(int i=0;i<13;i++){
            if(H[i])cout<<"H "<<i+1<<endl;
        }for(int i=0;i<13;i++){
            if(C[i])cout<<"C "<<i+1<<endl;
        }for(int i=0;i<13;i++){
            if(D[i])cout<<"D "<<i+1<<endl;
        }
    
        
}


Measured memory_bytes: 3168
# import math
# import fractions
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
 
 
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
 
div = a[0]
for i in range(1, n):
    div = gcd(div, a[i])
 
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14252
a,b,k = map(int,input().split())

s=[]

for i in range(k):
	if a+i not in s and a-1<a+i<b+1:	
		s.append(a+i)
for j in range(k) :
	if b-k+j+1 not in s and a-1<b-k+j+1<b+1:
		s.append(b-k+j+1)
for l in range(len(s)):
	print(s[l])
	






Measured memory_bytes: 3060
s = gets().split().map(&:to_i)

five, seven = 0, 0
3.times do |i|
	if s[i] == 5
		five += 1
	elsif s[i] == 7
		seven += 1
	end
end

if five == 2 && seven == 1
	puts "YES"
else
	puts "NO"
end

Measured memory_bytes: 1788
#include<stdio.h>



void swap( int *a, int *b){
	int c;
	c=*a;
	*a =*b;
	*b= c;
}


int main(){
	int valueMountain[100];
	
	for(int i = 0 ; i < 10;i++){
		scanf("%d",&valueMountain[i]);
	}
	
	for(int i= 0; i < 10;i++){
		for(int j=0; j < 10-1;j++){
			if(valueMountain[j] < valueMountain[j+1]){
			swap(&valueMountain[j+1],&valueMountain[j]);
			}
		}
	}
	for(int z=0;z < 3;z++){
		printf("%d\n",valueMountain[z]);
	}
	return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;

int a[maxn];
int n;

int id[maxn], num[maxn], top;
bool check(int MAX)
{
    //printf("%d\n",MAX);
    top=0;
    id[top]=1;
    num[top]=a[0];
    top++;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1]){
            num[top]=a[i]-a[i-1];
            id[top]=1;
            top++;
        }
        else{
            int last = a[i-1];
            while(last > a[i]){
                if(last - num[top-1] >= a[i]){
                    last-=num[top-1];
                    top--;
                }
                else{
                    num[top-1]-=(last-a[i]);
                    last=a[i];
                }
            }
            bool flag=0;
            for(int j=top-1; j>=0; j--)
            {
                if(id[j]<MAX){
                    if(num[j]==1){
                        id[j]++;
                        top=j+1;
                    }
                    else{
                        num[j]--;
                        num[j+1]=1;
                        id[j+1]=id[j]+1;
                        top=j+2;
                    }
                    flag=1;
                    break;
                }
                last-=num[j];
            }
            if(flag){
                if(last!=a[i]){
                    num[top]=a[i]-last;
                    id[top]=1;
                    top++;
                }
            }
            else {
                //printf("%d is fail\n",i);
                return false;
            }
        }
    }
    return true;
}
int main() {
    scanf("%d",&n);
    for(int i=0; i < n; i++)
    {
        //a[i]=2;
        scanf("%d", a + i);
    }
    //printf("%d",check(3));
    //return 0;
    int l = 1, r = n, ans=1;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid)){
            r=mid-1;
            ans=mid;
        }
        else{
            l=mid+1;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int a,b,c; cin>>a>>b>>c;
	int ans=0;
	for(int i=a;i<=b;i++){
		if(c%i==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3092
n, k = list(map(int,input().split()))
jump = list(map(int,input().split()))
arr = list(map(int,input().split()))
best = - (10**28)
VV = []
 
for i in range(n):
  if i not in VV:
    order = []
    prev_pos = i
    visited = []
    sub_best = 0
    order = []
    l = 0
 
    for jjj in range(n):
      order.append(arr[prev_pos])
      #sub_best = max(sub_best, sum(order))
      visited.append(prev_pos)
      VV.append(prev_pos)
      l += 1
 
      next_pos = jump[prev_pos] - 1
      prev_pos = next_pos
      if next_pos in visited:
        break
 
    if sum(order)<1:
      limit = min(k,l*2)
      ss = 0
    else:
      limit = (k % l) + l
      limit = min(k,limit)
      ss = sum(order) * ((k//l) - 1)
      ss = max(ss,0) 
 
    sub_best = ss
   # print(limit, order, ss, sub_best)
    
    order = order + order + order
    
    for chuj in range(1,limit+1):
      kk = sum(order[0:0+chuj])
      best = max(best, sub_best + kk)
      for op in range(len(order)-chuj):
        kk -= order[op]
        kk += order[op+chuj]
        best = max(best, sub_best + kk)
      
print(best)

Measured memory_bytes: 74792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 1000000 + 10000;
const int MOD = 1000000000 + 7;

int n;
int f[MAXN], s[MAXN];

void add(int &x, long long y)
{
	x = (x + y) % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;

	f[1] = n, s[1] = f[1];

	for(int i = 2; i <= n; i++)
	{
		f[i] = (f[i] + f[i - 1]) % MOD;
		f[i] = (f[i] + (i >= 4 ? s[i - 3] : 0)) % MOD;
		f[i] = (f[i] + (long long)(n - 1) * (n - 1)) % MOD;
		f[i] = (f[i] + (i >= 4 ? n - i + 2 : n - 1)) % MOD;

		s[i] = (s[i - 1] + f[i]) % MOD;
	}

	int ans = f[n];
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, m;

int main() {
    cin >> n >> m;
    M<ll, ll> v;
    REP(i, n) {
        ll a; cin >> a;
        v[a]++;
    };
    REP(i, m) {
        ll b, c; cin >> b >> c;
        v[c] += b;
    }

    ll sum = 0, cnt = 0;

    RFOR (i, v) {
        if (cnt + i->second < n) {
            sum += i->first * i->second;
            cnt += i->second;
        } else {
            sum += i->first * (n-cnt);
            break;
        }
    }
    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
using namespace std;
int main()
{
        int n,rep = 0;
        cin >> n;
        vector<int> p(n);
        for (int i = 0; i < n; i++)
                cin >> p[i];
        for (int i = 0; i < n; i++)
                if (p[i] != i + 1)
                        rep++;
        if (rep > 2)
                cout << "NO" << endl;
        else
                cout << "YES" << endl;
        return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int c[3]={1};
   string s;
   while(getline(cin,s)){
      swap(c[s[0]-'A'],c[s[2]-'A']);
   }
   if(c[0]) cout << "A" << endl;
   else if(c[1]) cout << "B" << endl;
   else cout << "C" << endl;
}

Measured memory_bytes: 1172