akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char n){
  if(n=='A') return 1;
  else if(n=='C') return 2;
  else if(n=='G') return 3;
  else if(n=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++){
    H[i][0]='\0';
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 16096
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int main(void){
	uint32_t n, m;
	scanf("%"SCNu32"%"SCNu32, &n, &m);
	for(uint32_t i=m/2; i>0; i--){
		printf("%"PRIu32" %"PRIu32"\n", i, m-i+1);
	}
	for(uint32_t i=(m+1)/2; i>0; i--){
		printf("%"PRIu32" %"PRIu32"\n", m+i, m*2-i+2);
	}
}



Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int a;
    string s;
    cin >> a >> s;
    
    if(a >= 3200)
        cout << s << "\n";
    else
        cout << "red" << "\n";
    return 0;
}


Measured memory_bytes: 256
n, blue, red = map(int, input().split())

number = n // (blue + red)          
count_blue = number * blue          
number2 = n - number * (blue + red) 
if blue ==0:
    print("0")
    exit()
if number2 > blue:
    count_blue += blue
else:
    count_blue += number2

print(count_blue)

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll>a(x);
  rep(i,x) cin >> a[i];
  vector<ll>b(y);
  rep(i,y) cin >> b[i];
  vector<ll>c(z);
  rep(i,z) cin >> c[i];
  vector<ll>AB;
  rep(i,x){
    rep(j,y){
      AB.push_back(a[i]+b[j]);
    }
  }
  sort(AB.rbegin(),AB.rend());
  vector<ll>ABC;
  for (int i = 0; i < min(k,(int)AB.size()); ++i){
    rep(j,z){
      ABC.push_back(AB[i]+c[j]);
    }
  }
  sort(ABC.rbegin(),ABC.rend());
  rep(i,k){
    cout << ABC[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 43368
#include<bits/stdc++.h>
#define e(i,n) for(int i=0;i<n;i++)
using namespace std;int n,q,p;long long x[110],y[110],z[110],a[110][2],b[110][2],c[110][2],s;int main(){cin>>n>>q;e(i,2*n){cin>>x[i]>>y[i]>>z[i];a[i/2][i%2]=x[i],b[i/2][i%2]=y[i],c[i/2][i%2]=z[i];}sort(x,x+n*2);sort(y,y+n*2);sort(z,z+n*2);s=0;e(i,n*2-1)e(j,n*2-1)e(k,n*2-1){p=0;e(t,n){bool o=1;e(r,2){if(a[t][0]>x[i+r]||x[i+r]>a[t][1])o=0;if(b[t][0]>y[j+r]||y[j+r]>b[t][1])o=0;if(c[t][0]>z[k+r]||z[k+r]>c[t][1])o=0;}if(o)p++;}if(p>=q)s+=(x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);}cout<<s<<endl;return 0;}

Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long A, B, N;
    cin >> N >> A >> B;
    long long T = N / (A+B);
    long long amari = N % (A+B);
    long long result = A * T + min(A, amari);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef struct {
    long int A;
    int B;
} shop_t;
int cmp( const void *p, const void *q ) {
    return ((shop_t*)p)->A - ((shop_t*)q)->A;
}
int main(void){
    int N, M, cnt = 0, itr = 0;
    long long int ans = 0;
    scanf("%d %d%*c", &N, &M);
    shop_t shop[N];
    for (int i = 0; i < N; i++) scanf("%ld %d%*c", &shop[i].A, &shop[i].B);
    qsort(shop, N, sizeof(shop_t), cmp);
    while (cnt < M) {
        if (shop[itr].B < M - cnt) {
            ans += shop[itr].A * shop[itr].B;
            cnt += shop[itr].B;
            itr++;
        }
        else {
            ans += shop[itr].A * (M - cnt);
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
#define endl "\n"

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    vector<ll> dp(N);
    for (int i = 0; i < N; ++i) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            if (i + j < N) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
        }
    }

    cout << dp[N - 1] << endl;
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    vector<pair<int, int>> P(N);
    map<pair<int, int>, int> cnt;
    for(int i = 0; i < N; ++i) {
        cin >> P[i].first >> P[i].second;
    }
    for(int i = 0; i < N; ++i) {
        for(int j = i+1; j < N; ++j) {
            auto tmp = make_pair(P[j].first - P[i].first, P[j].second - P[i].second);
            if(tmp.first < 0) {
                tmp.first = -tmp.first;
                tmp.second = -tmp.second;
            }else if(tmp.first * tmp.second == 0) {
                tmp.first = abs(tmp.first);
                tmp.second = abs(tmp.second);
            }
            if(tmp.first != 0 || tmp.second != 0) cnt[tmp]++;
        }
    }

    int maxc = 0;
    for(auto x: cnt) {
        maxc = max(maxc, x.second);
    }
    cout << N-maxc << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  int N,A;
  cin >> N>>A;
  ll ct=0;
  int y;

  vector<int> x;
  x.push_back(0);
  rep(i,N){
  cin>>y;
  x.push_back((y-A));
}

  ll dp[N+1][50*N*2+1];//j= 1~N,k= j個までの時のkになる選び方dp

  rep(j,N+1){
    rep(k,50*N*2+2){
        if(j==0&&k==50*N){
          dp[j][k]=1;
        }
        else if(j>=1&&(k-x[j]<0||k-x[j]>2*50*N)){
          dp[j][k]=dp[j-1][k];
        }
        else if(j>=1){
          dp[j][k]=dp[j-1][k]+dp[j-1][k-x[j]];
        }
        else dp[j][k]=0;
      }
    }

  cout << dp[N][50*N]-1 <<endl;
  return 0;
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


vector<int> stable, ntable,table;
bool visited[1000000];

signed main() {
	int s=6, n=9;
	for (int i = 1; i < 10; i++) {
		if(s <= 100000)stable.push_back(s);
		if(n <= 100000)ntable.push_back(n);
		s *= 6;
		n *= 9;
	}
	for (int i : stable) {
		table.push_back(i);
	}
	for (int i : ntable) {
		table.push_back(i);
	}

	//BFSをする
	int N, one, ans=100000;
	cin >> N;
	queue<pair<int, int>> q;
	visited[N] = true;
	q.push(make_pair(0, N));
	while (!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();
		if (p.second < 6) {
			int nowans = p.first + p.second;
			if (nowans < ans) ans = nowans;

		}
		for (int i : table) {
			if (p.second < i) continue;
			if (visited[p.second - i]) continue;
			visited[p.second - i] = true;
			q.push(make_pair(p.first + 1, p.second - i));
		}
	}

	cout << ans << "\n";


	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  string s, t;
  cin>>s>>t;

  int a, b;
  cin>>a>>b;

  string u;
  cin>>u;

  if(s==u) a--;
  else b--;

  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int ans = 0;
    vector<int> N(3);
    for(int i=0; i<3; i++){
        cin >> N[i];
    }
    int K;
    cin >> K;
    for(int i=0; i<3; i++){
        int max = *max_element(N.begin(), N.end());
        if(N[i] == max){
            for(int j=0; j<K; j++){
                N[i] = N[i] * 2;
            }
        }
        ans = ans + N[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

string s;
long long l,c,r,i;

int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin >> s;

l= s.length();
c = l-1;

for (int i = 0; i<c; i++){
	if (i>=c-i)
		break;
	if (s[i] != s[c-i]){
		r++;
	}
	
}

cout << r;

return 0;
}



Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int K, X;
  cin >> K >> X;

  int beg = X - (K-1);
  int end = X + (K-1);

  for(int i=beg; i <= end; ++i) {
    cout << i << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
  #include <cstdio>
  #include <algorithm>
  #include <cstring>
  #include <string>
  #include <cmath>
  using namespace std;
 #define ll long long
  const int N=10005;
 const int mod=1e9+7;
 const int maxn=1e7;
 long long int a[101];
 long long int gcd(ll x,ll y)
 {     long long int c,m=x,n=y;
    while(y!=0){
      c=x%y;
      x=y;     y=c;    }
   return m/x*n; }
int main()
 {
    int n;
    cin>>n;
     long long int m,s,l;
     cin>>m;
    if(n==1) cout<<m<<endl;
    else if(n>1){
         cin>>l;
      s=gcd(l,m);
         for(int i=0;i<n-2;i++){
             cin>>m;
            s=gcd(s,m);
         }
         cout<<s<<endl;
     }
     return 0;
 }

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

using namespace std;
const ll maxn=+100,inf=1e9,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll
#define pii pair <int, int>

int n, k, a[maxn][maxn], c[maxn][maxn], nw[maxn][maxn];

main()
{
	cin >> n >> k;
	forn(1, i, n)
	{
		forn(1, j, n)
		{
			cin >> a[i][j];
		}
		c[i][i] = 1;
	}
	while(k)
	{
		if(k&1)
		{
			forn(1, it, n)
			{
				forn(1, i, n)
				{
					forn(1, j, n)
					{
						nw[i][j] += (c[i][it] * a[it][j]) % mod;
						nw[i][j] %= mod;
					}
				}
			}
			forn(1, i, n)
			{
				forn(1, j, n)
				{
					c[i][j] = nw[i][j];
					nw[i][j] = 0;
				}
			}
		}
		forn(1, it, n)
		{
			forn(1, i, n)
			{
				forn(1, j, n)
				{
					nw[i][j] += (a[i][it] * a[it][j]) % mod;
					nw[i][j] %= mod;
				}
			}
		}
		forn(1, i, n)
		{
			forn(1, j, n)
			{
				a[i][j] = nw[i][j];
				nw[i][j] = 0;
			}
		}
		/*forn(1, i, n)
		{
			forn(1, j, n)
			{
				cout << a[i][j] << " ";
			}
			cout << endl;
		}*/
		k /= 2;
	}
	int ans = 0;
	forn(1, i, n)
	{
		forn(1, j, n)
		{
			ans += c[i][j];
			ans %= mod;
//			cout << c[i][j] << " ";
		}
//		cout << endl;
	}
	cout << ans;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    function<void(int, int, int)> dfs = [&](int mask, int a, int b) {
        if (__builtin_popcount(mask) == 1) {
            cout << a << " " << b << " ";
        } else {
            int c = 1 << (__builtin_ffs(a ^ b) - 1);
            int d = 1 << (__builtin_ffs(mask ^ c) - 1);
            dfs(mask ^ c, a, a ^ d);
            dfs(mask ^ c, a ^ d ^ c, b);
        }
    };
    if (__builtin_popcount(a ^ b) % 2 == 0) {
        cout << "NO"
             << "\n";
    } else {
        cout << "YES"
             << "\n";
        dfs((1 << n) - 1, a, b);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}



int main(){
    string S;cin >> S;
    int ans = 0;
    int ma = 0;
    for(int i=0;i<=2;i++){
        if(S[i] == 'R')ans++;
        else ans = 0;
        ma = max(ma,ans);
    }

    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 3636
H, W, K = map(int, input().split())
S = []
for _ in range(H):
  S.append(input())
hsummation = [[int(S[0][k])]for k in range(W)]
for k in range(W):
  for j in range(1, H):
    hsummation[k].append(hsummation[k][j-1] + int(S[j][k]))

ans = float('inf')
anskouho = 0
h = -1
binhh = []
for j in range(2**(H-1)):
  h += 1
  binh = "0"*(H-len(str(bin(h)))+1)+str(bin(h))[2:]
  c = 0
  for k in range(len(binh)):
    if binh[k] == '1':
      c += 1
  binhh.append([binh, c])
binhh.sort(key = lambda x:x[1] , reverse= True)

for j in range(2**(H-1)):
  hlist=[]
  for k in range(H-1):
    if binhh[j][0][k] == '1':
      hlist.append(k)
  hlist.append(-1)
  anskouho = len(hlist)-1
  now = 0
  while now < W:
    counter = [0 for _ in range(len(hlist))]
    while now < W:
      counter[0] += hsummation[now][hlist[0]]
      if counter[0] > K:
        anskouho += 1
        break
      for l in range(1, len(hlist)):
        counter[l] += - hsummation[now][hlist[l-1]] + hsummation[now][hlist[l]]
        if counter[l] > K:
          anskouho += 1
          break
      else:
        now += 1
        continue
      break
    if anskouho > ans:
      break
  else:
    ans = anskouho
print(ans)

Measured memory_bytes: 70172
#include<iostream>
#include<string>
using namespace std;

int main(){
  string s;
  cin>>s;
  int sumofDigits=0;
  long long sum;
  for(int i=0;i<s.size();i++){
    sum=s[0]-'0';
    sumofDigits+=s[i]-'0';
  }
  for(int i=1;i<s.size();i++){
    sum=s[i]-'0'+sum*10;
  }
  if(sum%sumofDigits==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll a[N]; rep(i,N) cin >> a[i];
  ll b[N]; rep(i,N) cin >> b[i];
  ll da[N]; rep(i,N) da[i] = a[i] ^ a[(i+1)%N];
  ll db[2*N]; rep(i,2*N) db[i] = b[i%N] ^ b[(i+1)%N];
  // debug(da,da+N);
  // debug(db,db+2*N);

  ll m1 = pow(10,9)+7, m2 = 998244353;
  ll x1 = (1<<10)%m1, x2 = (1<<10)%m2;
  ll d1 = 1; rep(i,N-1) { d1 *= x1; d1 %= m1; }
  ll d2 = 1; rep(i,N-1) { d2 *= x2; d2 %= m2; }

  ll lha[2] = {};
  rep(i,N) { 
    lha[0] *= x1; lha[0] %= m1; 
    lha[0] += da[i]%m1; lha[0] %= m1;
    lha[1] *= x2; lha[1] %= m2; 
    lha[1] += da[i]%m2; lha[1] %= m2;
  }
  ll lhb[N+1][2] = {};
  rep(i,N) { 
    lhb[0][0] *= x1; lhb[0][0] %= m1; 
    lhb[0][0] += db[i]; lhb[0][0] %= m1;
    lhb[0][1] *= x2; lhb[0][1] %= m2; 
    lhb[0][1] += db[i]; lhb[0][1] %= m2;
  }
  rep(i,N) {
    lhb[i+1][0] = lhb[i][0] - (((db[i]%m1)*d1)%m1); lhb[i+1][0] = ((lhb[i+1][0]%m1)+m1)%m1;
    lhb[i+1][0] *= x1; lhb[i+1][0] %= m1; 
    lhb[i+1][0] += db[N+i]%m1; lhb[i+1][0] %= m1;
    lhb[i+1][1] = lhb[i][1] - (((db[i]%m2)*d2)%m2); lhb[i+1][1] = ((lhb[i+1][1]%m2)+m2)%m2;
    lhb[i+1][1] *= x2; lhb[i+1][1] %= m2; 
    lhb[i+1][1] += db[N+i]%m2; lhb[i+1][1] %= m2;
  }

  // cout << lha[0] << " " << lha[1] << endl;
  // cout << endl;
  // rep(i,N) cout << lhb[i][0] << " " << lhb[i][1] << endl;

  // bool exist = false;

  if (lha[0]==lhb[0][0]&&lha[1]==lhb[0][1]) {
    cout << 0 << " " << (a[0]^b[0]) << endl;
  }
  for (int i=N-1; i>0; i--) {
    if (lha[0]==lhb[i][0]&&lha[1]==lhb[i][1]) {
      cout << N-i << " " << (a[0]^b[i]) << endl;
      // exist = true;
    }
  }
  // if (!exist) cout << endl;
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

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; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	ll n,r;
	cin >> n >> r;
	if(n >= 10)cout << r << endl;
	else cout << r + 100*(10 - n) << endl;
	return 0;
}

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

int main() {
    cin.tie(0), ios::sync_with_stdio(0);

    int n;
    while(cin>>n){
        int temp;
        bool answer = true;
        vector<int> input_data;
        for (int i = 0; i < n; ++i) {
            cin >> temp;
            if(temp%2==0){
                input_data.push_back(temp);
            }
        }
        for(auto &t:input_data){
            if(t%3!=0 && t%5!=0){
                answer = false;
                break;
            }
        }
        if(answer){
            cout << "APPROVED" << endl;
        }
        else{
            cout << "DENIED" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll X, Y;
  cin >> X >> Y;

  // ---------------------
  // 

  int cnt = 0;
  while (X <= Y) {
    cnt++;
    X = X * 2;
  }

  cout << cnt << endl;
  
  return 0;
  
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1LL;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0LL;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class ModuloOperator {
 public:
  ll mo_modulo;

  ModuloOperator(ll modulo) { mo_modulo = modulo; }

  ll add(ll a, ll b) {
    ll ret = a + b;
    ret %= mo_modulo;
    return ret;
  }

  ll sub(ll a, ll b) {
    ll ret = a - b;
    if (ret < 0)
      ret += mo_modulo;
    else
      ret %= mo_modulo;
    return ret;
  }

  ll mul(ll a, ll b) {
    ll ret = a * b;
    ret %= mo_modulo;
    return ret;
  }

  ll div(ll a, ll b) { return mul(a, pow(b, mo_modulo - 2)); }

  ll pow(ll x, ll y) {
    ll res = 1LL;

    x %= mo_modulo;

    while (y > 0) {
      if (y & 1) {
        res = mul(res, x);
      }

      y = y >> 1;
      x = mul(x, x);
    }

    return res;
  }
};
/////////////////////////////////////////////////////////////

ll n, m, k;

ll ans;

ModuloOperator mo(MOD);

int main(void) {
  // Here your code !
  scanf("%lld %lld %lld", &n, &m, &k);

  int size = (int)(n * m + 3);
  CombinationModulo cm(size);

  ans = 0;

  ll base_comb = cm.comb((int)(n * m - 2), (int)(k - 2));

  for (ll i = 1; i <= n - 1; ++i) {
    ll slide_size = n - i;

    ll times = mo.mul(mo.mul(slide_size, mo.mul(m, m)), base_comb);
    ll commit = mo.mul(i, times);

    ans = mo.add(ans, commit);
  }

  for (ll i = 1; i <= m - 1; ++i) {
    ll slide_size = m - i;

    ll times = mo.mul(mo.mul(slide_size, mo.mul(n, n)), base_comb);
    ll commit = mo.mul(i, times);

    ans = mo.add(ans, commit);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4992
A=list(map(int,input().split()))
N=int(input())

for i in range(3):
	if A[i]*2<A[i+1]:
		A[i+1]=A[i]*2

k=[0.25, 0.5, 1, 2]
ans=0
for i in range(4)[::-1]:
	ans += (N//k[i])*A[i]
	N-=k[i]*(N//k[i])
	if N==0:break


print(int(ans))



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;
const int INF = 1000000007;

int n, H;

int main() {

	FAST;

	cin >> H >> n;
	vector <int> v(n + 1), w(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> v[i] >> w[i];
	}
	int V = 0;
	for (int i = 1; i <= n; i ++) {
		V = max(V, v[i]);
	}
	int M = V + H;
	vector <int> dp(M + 1, INF);
	dp[0] = 0;
	for (int x = 0; x < M; x ++) {
		for (int k = 1; k <= n; k ++) {
			if (x - v[k] >= 0) {
				dp[x] = min(dp[x], w[k] + dp[x - v[k]]);
			}
		}
	}
	int ans = INF;
	for (int x = H; x < M; x ++) {
		ans = min(ans, dp[x]);
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  bool vis[n+1];
  int a[n+1];
  memset(vis, false, sizeof(vis));
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1, cnt=0; !vis[i]; i = a[i], cnt++){
    if(i == 2){
      cout << cnt << endl;
      return 0;
    }
    vis[i] = true;
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int main() {
	cout << fixed << setprecision(9);
	int n, k; ld t, u, v, l;
	cin >> n >> k >> t >> u >> v >> l;
	ld d[202];
	d[0] = 0;
	rep1(i, n) {
		cin >> d[i];
	}
	d[n+1] = l;
	ld time = 0; int poss = 0; ld restime = 0;
	rep(i, n+1) {
		ld dis = d[i + 1] - d[i];
		if (dis < v*restime) {
			restime -= dis / v;
			time += dis / v;
		}
		else {
			dis -= v * restime; time += restime;
			int cnt = (int)(eps+dis / (v * t));
			if (cnt + 1 <= poss) {
				poss -= cnt+1;
				dis -= (double)cnt*v*t;
				restime = t - dis / v;
				time += (double)cnt*t;
				time += dis / v;
			}
			else {
				dis -= (double)poss*v*t;
				restime = 0;
				time += (double)poss*t;
				time += dis / u; poss = 0;
			}
		}
		if (poss +1 <= k) {
			poss++;
		}
		else {
			restime = t;
		}
		if (restime == 0) {
			restime = t; poss--;
		}
	}
	cout << time << endl;
	return 0;
}


Measured memory_bytes: 3292
#include<stdio.h>
int main(void){
    double a,b,c,d,e,f;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
            f=(f-c/a*d)/(e-b/a*d);
            c=c/a-f*b/a;
            printf("%.3f %.3f\n",c,f);
    }
    return 0;
}

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

#define vi vector<int>
#define vs vector<string>

vs BubbleSort(vs A, int N) {

    bool flag = true;
    string tmp;
    int i = 0;
    while (flag) {
        flag = false;
        for (int j = N - 1; j > i; j--) {
            if (int(A[j][1]) < int(A[j - 1][1])) {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = true;
            }
        }
        i++;
    }

    return A;
}

vs SelectionSort(vs A, int N) {

    int minj;
    string tmp;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (int(A[j][1]) < int(A[minj][1])) minj = j;
        }
        if (i != minj) {
            tmp = A[minj];
            A[minj] = A[i];
            A[i] = tmp;
        }
    }

    return A;
}


bool JudgeStable(vs B, vs C, int N) {
    for (int i = 0; i< N; i++) {
        if (B[i] != C[i]) return false;
    }
    return true;
}

void PrintVector(vs A, int N) {
   for (int k = 0; k < N; k++) {
        cout << A[k];
        if (k != N - 1) {
            cout << " ";
        }
        else {
            cout << endl;
        }
    }
}

int main() {

    int N;
    cin >> N;

    string tmp;
    vs A;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }

    // bubble sort
    vs B;
    B = BubbleSort(A, N);
    PrintVector(B, N);
    cout << "Stable" << endl;

    // selection sort
    vs C;
    C = SelectionSort(A, N);
    PrintVector(C, N);
    if (JudgeStable(B, C, N)) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int f(int n){
  if(n%2==0) return n/2;
  else return 3*n + 1;
}

bool hako[1111111];
int hako2[1111111];
int main(){
  int s;
  cin>>s;

  hako2[1]=s;
  hako[s]=true;
  for(int i=2;i<1111111;i++){
    hako2[i]=f(hako2[i-1]);
    if(hako[hako2[i]]){
      cout<<i<<endl;
      return 0;
    }
    else{
      hako[hako2[i]]=true;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

const int N = 2e5 + 10;
int a[N], b[N];

void add(int l, int r) {
  b[l]++;
  b[r + 1]--;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int iter = 1; iter <= k; iter++) {
    for (int i = 1; i <= n; i++) {
      a[i] = b[i];
      b[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      add(max(1, i - a[i]), min(n, i + a[i]));
    }
    bool ok = true;
    for (int i = 1; i <= n; i++) {
      b[i] += b[i - 1];
      if (b[i] != n) {
        ok = false;
      }
    }
    if (ok) {
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
} 

Measured memory_bytes: 5180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int sec = min(b, d) - max(a, c);
    if (sec > 0)
        cout << sec << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

                    ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll sumA[MAXN],sumB[MAXN];
int main()
{
    FAST
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        sumA[i+1]=sumA[i]+a;
    }
    for(int i=0;i<m;i++)
    {
        ll b;
        cin>>b;
        sumB[i+1]=sumB[i]+b;
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        if(sumA[i]<=k){
            ll mx=k-sumA[i];
            ll pt=upper_bound(sumB,sumB+m+1,mx)-sumB;
            ans=max(ans,i+pt-1);

        }

    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 6708
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1005;
const int mod = 1e9 + 7;

int n, m;
LL k;
char s[N][N];

struct Matrix {
	LL a[2][2];
};

Matrix operator * (Matrix x, Matrix y) {
	Matrix ans;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			LL res = 0;
			for (int k = 0; k < 2; ++k) {
				res = (res + x.a[i][k] * y.a[k][j]) % mod;
			}
			ans.a[i][j] =res;
		}
	}
	return ans;
}

LL Qpow(LL x, LL p) {
	LL ans = 1;
	while (p) {
		if (p & 1) ans = ans * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return ans;
}

int main() {
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	if (k <= 1) return 0 * puts("1");
	LL f = 0, c = 0, c1 = 0, c2 = 0, d = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i][j] == '#') ++c;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (s[i][1] == s[i][m] && s[i][1] == '#') f |= 1, ++c1;
	}
	for (int i = 1; i <= m; ++i) {
		if (s[1][i] == s[n][i] && s[1][i] == '#') f |= 2, ++c2;
	}
	if (f == 3) return 0 * puts("1");
	if (f == 0) return 0 * printf("%lld\n", Qpow(c, k - 1));
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (f == 1 && j < m && s[i][j] == '#' && s[i][j + 1] == '#') ++d;
			if (f == 2 && i < n && s[i][j] == '#' && s[i + 1][j] == '#') ++d;
		}
	}
//	cout << c << ' ' << d << endl;
	Matrix res = (Matrix) {1, 0, 0, 1};
	Matrix x = (Matrix) {c , 0, -1, (f == 1) ? c1 : c2};
	k--;
	while (k) {
		if (k & 1) res = res * x;
		x = x * x ;
		k >>= 1;
	}
/*	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j)
			cout << res.a[i][j] << ' ';
		puts("");
		}*/
	LL ans = res.a[0][0] + d * res.a[1][0];
	ans = (ans % mod + mod) % mod;
	cout << ans << endl;
}


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

using namespace std;

const int N=305;

int ans,n,m,cnt[N];
queue <int> qu[N];
bool vi[N];

int main(){
	scanf("%d%d",&n,&m);
	ans=n;
	for(int i=1;i<=n;i++){
		for(int j=1,x;j<=m;j++)
			scanf("%d",&x),qu[i].push(x);
		cnt[qu[i].front()]++;
	}
	for(int i=1;i<m;i++){
		int mx=0;
		for(int i=1;i<=m;i++)if(cnt[i]>cnt[mx])mx=i;
		ans=min(ans,cnt[mx]);
		vi[mx]=true;
		for(int i=1;i<=n;i++)if(qu[i].front()==mx){
			cnt[qu[i].front()]--;
			while(vi[qu[i].front()])qu[i].pop();
			cnt[qu[i].front()]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N, M;
vp req;

signed main(void) {
    cin>>N>>M;
    rep(i, M) {
        int a,b;
        cin>>a>>b;
        req.pb(mp(b,a));
    }
    sort(all(req));
    int last_end=0;
    int cnt=0;
    for (auto e:req) {
        cerr<<"begin:"<<e.se<<", end:"<<e.fi<<endl;
        if (last_end<=e.se) {
            cnt++;
            last_end=e.fi;
        }
        cerr<<"cnt:"<<cnt<<endl;
        cerr<<"last_end:"<<last_end<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;

static int DP[21][50001];
	
int main(){
	int n,m;
	cin>>n>>m;

	int c[20];
	for(int i=0;i<m;i++)
		cin>>c[i];
		
	const int IMF=50000;

	for(int i=0;i<=m;i++)
		DP[i][0]=0;
	for(int j=0;j<=n;j++)
		DP[0][j]=IMF;

	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(j<c[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j]<DP[i][j-c[i-1]]+1)
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i][j-c[i-1]]+1;
			}
		}
	}
	
	cout<<DP[m][n]<<endl;
	
	return 0;
}

	

Measured memory_bytes: 7184
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  p=list(map(int,input().split()))
  dic={}
  for i in p:
    d=abs(i-x)
    if d in dic:
      dic[d].append(i)
    else:
      dic[d]=[i]
  sortdic = sorted(dic.items(), key=lambda x:x[0])
  chk=0
  ans=-1
  for k,v in sortdic:
    if chk==k:
      if chk!=0 and len(v)!=2:
        if v[0]>x:
          ans=x-k
        else:
          ans=x+k
        break
    else:
      ans=x-chk
      break
    chk+=1
  if ans==-1:
    ans=x-chk
  print(ans)

Measured memory_bytes: 9228
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <vector>
#define FORi(N) for(int i = 0; i < N; ++i)
#define FORj(N) for(int j = 0; j < N; ++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

vector<vector<ll>> child;
vector<bool> co(100001);
void nuru(bool iro, ll parent, ll i, vector<ll> &w) {
    co[i] = iro;
    //cout << i << endl;
    for(int j = 0; j < child[i].size() / 2; ++j) {
        if(child[i][j * 2] != parent) {
            if(child[i][j * 2 + 1] % 2 == 0) {
                nuru(iro, i, child[i][j * 2], w);
            } else {
                nuru(!iro, i, child[i][j * 2], w);
            }
        }
    }
}
int main() {
    ll N;
    cin >> N;
    vector<ll> u(N - 1), v(N - 1), w(N - 1);
    FORi(N+1) { child.push_back(vector<ll>()); }
    FORi(N - 1) {
        cin >> u[i] >> v[i] >> w[i];
        child[u[i]].push_back(v[i]);
        child[v[i]].push_back(u[i]);
        child[u[i]].push_back(w[i]);
        child[v[i]].push_back(w[i]);
    }
    nuru(true, 0, 1, w);
    FORi(N) { cout << co[i + 1] << endl; }
    return 0;
}


Measured memory_bytes: 12912
#include <iostream>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    int a[n];
    for (int b=0; b<n; b++){
        cin>>a[b];
    }
    for(int x=0; x<n; x++){
        cout<<a[x];
        if(x!= n-1)cout<<" ";
    }
    cout<<endl;
    for (int i=1; i<n; i++){
        int j=i-1;
        int key=a[i];
        while (j>=0 && a[j]>key){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
        for (int m=0; m<n; m++){
                cout<<a[m];
                if(m!=n-1)cout<<" ";
        }
        if(i!=n)
        cout<<endl;
    }
    //for(int i=0;i<n;i++)cout<<a[i]<<" ";
    return 0;
}



Measured memory_bytes: 3124
N = int(input())
#初期化
dp=[0]*N
for i in range(10):
  if 6**i-1 < N:
    dp[6**i-1] = 1
for i in range(10):
  if 9**i-1 < N:
    dp[9**i-1] = 1

#dp
for k in range(1,N):
  if dp[k] != 1:
    dp_list = []
    for j in range(10):
      if k >= 6**j:
        dp_list.append(dp[k-6**j])
      if k >= 9**j:
        dp_list.append(dp[k-9**j])
  
    dp[k] = 1+min(dp_list)

print(dp[N-1]%1000000007)

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

using namespace std;

int main(){
    int x, y; cin >> x >> y;
    int _x, _y;

    int a[] = {1, 3, 5, 7, 8, 10, 12};
    int b[] = {4, 6, 9, 11};
    int c[] = {2};

    for(int i = 0; i < 7; i++){
        if(x == a[i]) _x = 0;
        if(y == a[i]) _y = 0;
    }
    for(int i = 0; i < 4; i++){
        if(x == b[i]) _x = 1;
        if(y == b[i]) _y = 1;
    }
    if(x == c[0]) _x = 2;
    if(y == c[0]) _y = 2;

    if(_x == _y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,j;
	int ary1[3],ary2[3] = {0,0,0};
	scanf("%d %d %d",&ary1[0],&ary1[1],&ary1[2]);
	for(i = 0;i < 3;i++){
		if(ary1[0] > ary1[1]){
			ary2[0] = ary1[1];
			ary2[1] = ary1[0];
		}
		else{
			ary2[0] = ary1[0];
			ary2[1] = ary1[1];
		}
		for(j = 0;j < 2;j++){
			ary1[j] = ary2[j];
		}
		if(ary1[1] > ary1[2]){
			ary2[1] = ary1[2];
			ary2[2] = ary1[1];
		}
		else{
			ary2[1] = ary1[1];
			ary2[2] = ary1[2];
		}
		for(j = 0;j < 3;j++){
			ary1[j] = ary2[j];
		}
	}
	printf("%d %d %d\n",ary2[0],ary2[1],ary2[2]);
	return 0;
	
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int x, y;

	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0){
			break;
		}
		if (x > y){
			printf("%d %d\n", y, x);
		}
		else{
			printf("%d %d\n", x, y);
		}
		
	}

	

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);

  int ans = 0;
  rep(i,n){
    if(i==0||i==n-1) continue;
    else if(p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1)) ans++;
    else if(p.at(i+1)<p.at(i)&&p.at(i)<p.at(i-1)) ans++;
  }

  cout << ans;
}


Measured memory_bytes: 3648
num = [i for i in range (1,int(input())+1)]
ans = 0

if num[-1]<=9 :
	ans = num[-1]
elif num[-1]<=99 :
	ans = 9
elif num[-1]<=999 :
	ans = num[-1]-90
elif num[-1]<=9999:
	ans = 909
elif num[-1]<=99999 :
	ans = num[-1]-9090
else :
	ans = 90909

print(ans)

Measured memory_bytes: 44528
import math

numbers = ["0"]*4
numbers = input().split(" ")
healthOfT = int(numbers[0])
strengthOfT = int(numbers[1])
healthOfA = int(numbers[2])
strengthOfA = int(numbers[3])
times_T_win = math.ceil(healthOfA/strengthOfT)
times_A_win = math.ceil(healthOfT/strengthOfA)
if times_T_win <= times_A_win:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9128
#include <iostream>
#include <string>

int main(int argc, char** argv)
{
	std::string S, T;
	std::cin >> S >> T;
	T.erase(T.end() - 1);
	if (S == T)
	{

	}
	std::cout << (S == T ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k,a[500],sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    vector<int>div;
    for(int i=1;i*i<=sum;i++){
        if(sum%i==0){
            div.push_back(i);
            if(i*i!=sum)
                div.push_back(sum/i);
        }
    }
    sort(div.begin(),div.end(),greater<>());
    for(int i=0;i<div.size();i++){
        int na[500];
        sum=0;
        for(int j=0;j<n;j++){
            na[j]=a[j]%div[i];
            sum+=na[j];
        }
        sort(na,na+n,greater<>());
        int tmp=0;
        for(int j=0;j<sum/div[i];j++)
            tmp+=div[i]-na[j];
        if(tmp<=k){
            cout<<div[i]<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std; using namespace placeholders;

// using LL = long long; using ULL = unsigned long long;
// using VI = vector<int>; using VVI = vector<VI>;
// using VS = vector<string>;
// using SS = stringstream;
// using PII = pair<int,int>; using VPII = vector< pair<int,int> >;
// template < typename T = int > using VT = vector<T>;
// template < typename T = int > using VVT = VT< VT<T> >;
// template < typename T = int > using LIM = numeric_limits<T>;

// template < typename T > inline void input_n( VT< T > &out ) { copy_n( istream_iterator< T >( cin ), out.size(), out.begin() ); };
// template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
// template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) (c).begin(), (c).end()
#define AALL( a, t ) (t*)a, (t*)a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define EM( n ) emplace( n )
#define EB( n ) emplace_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const string AIDUNYAN = "AIDUNYAN";
const string AIZUNYAN = "AIZUNYAN";

bool nyan( string s )
{
	sort( ALL( s ) );
	do
	{
		if ( equal( ALL( s ), AIDUNYAN.begin() ) )
		{
			return true;
		}
	}
	while ( next_permutation( ALL( s ) ) );

	return false;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	string D;
	cin >> D;

	const int L = D.size();

	REP( i, 0, L )
	{
		if ( i + 8 <= L && nyan( D.substr( i, 8 ) ) )
		{
			copy( ALL( AIZUNYAN ), D.begin() + i );
			i += 7;
		}
	}

	cout << D << endl;

	return 0;
}

Measured memory_bytes: 1212
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX_N 1000

int l[MAX_N];
int r[MAX_N];
int people = 0;

int main() {
  int N;
  cin >> N;
  rep(i, N) cin >> l[i] >> r[i];

  rep(i, N) {
    people += r[i] - l[i] + 1;
  }

  cout << people << endl;

  return 0;
}

Measured memory_bytes: 256