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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int h;
int n;
int b[111][2][2],bl[5][2][2][2],tmp[5][111][2][2];
int dx[]={1,1,1,0,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,0,-1,1,0,-1};

int dfs(int crt){
  if(crt==n)return 0;
  int res=0;
  memcpy(tmp[crt],b,sizeof(b));
  rep(dir,9){
    bool ok=true;
    rep(i,2)rep(j,2)rep(k,2){
      if(bl[crt][i][j][k]==1){
        int nj=j+dx[dir],nk=k+dy[dir];
        if(nj<0||nj>=2||nk<0||nk>=2)ok=false;
      }
    }
    if(ok){
      int minh=100;
      int cnt=0;
      for(int nh=100;nh>=-1;nh--){
        ok=true;
        rep(i,2)rep(j,2)rep(k,2){
          int nj=j+dx[dir],nk=k+dy[dir];
          if((nj>=0&&nj<2&&nk>=0&&nk<2&&nh+i>=0&&bl[crt][i][j][k]&&b[nh+i][nj][nk])||(bl[crt][i][j][k]&&nh+i<0))ok=false;
        }
        if(ok)minch(minh,nh);
        else break;
      }
      rep(i,2)rep(j,2)rep(k,2){
        int nj=j+dx[dir],nk=k+dy[dir];
        if(nj>=0&&nj<2&&nk>=0&&nk<2&&minh+i>=0&&bl[crt][i][j][k]){
          b[minh+i][nj][nk]=1;
        }
      }
      for(int nh=100;nh>=0;nh--){
        bool del=true;
        rep(j,2)rep(k,2){
          if(b[nh][j][k]==0)del=false;
        }
        if(del){
          cnt++;
          repl(i,nh,100)rep(j,2)rep(k,2){
            b[i][j][k]=b[i+1][j][k];
            b[i+1][j][k]=0;
          }
        }
      }
      maxch(res,dfs(crt+1)+cnt);
    }
    memcpy(b,tmp[crt],sizeof(b));
  }
  return res;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>h>>n;
    if(h==0)break;
    memset(b,0,sizeof(b));
    rep(i,h)rep(j,2){
      string s;
      cin>>s;
      rep(k,2){
        b[i][j][k]=s[k]=='#';
      }
    }
    rep(i,n)rep(j,2)rep(k,2){
      string s;
      cin>>s;
      rep(l,2){
        bl[i][j][k][l]=s[l]=='#';
      }
    }
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>

using namespace std;

int N, K;
vector<int> W;

bool ok(int p)
{
    int left = p, count = 1;
    for (auto i : W)
    {
        if (left < i)
        {
            if (p < i) return false;
            left = p;
            count++;
            if (count > K) return false;
        }
        left -= i;
    }
    return true;
}

int main(void)
{
    cin >> N >> K;
    W.resize(N);
    for (auto &i : W) cin >> i;
    int l = 0, r = 2e9;
    while(l + 1< r)
    {
        //lは詰めない　rは詰める
        int m = (l + r) / 2;
        if (ok(m)) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,ddx,ddy;
ll x[100005],y[100005];
char s[300004];


int main(){
	cin>>s;
	for(i=0;i<=2;i++){
		if(s[i]=='a')a++;
		if(s[i]=='b')b++;
		if(s[i]=='c')c++;
	}
	if(a*b*c){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}

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

int main() {
	// your code goes here
    int n = 55556;
    vector <int> vect;
    vector<char> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i] && (long long)i * i <= n) 
        {
            for (int j = i * i; j <= n; j += i)
            {
                is_prime[j] = false;
            }
        }
    }
    for (int i = 0; i <= n; i++)
    {
        if(is_prime[i] == true && i%5 == 1)
        {
            vect.push_back(i);
        }
    }
    int m = 0;
    cin>>m;
    for(int i = 0; i < m; i++)
    {
        cout<<vect[i]<<" ";
    }

}


Measured memory_bytes: 3212
import java.util.*;

public class Main {
        static int RMAX = 100001;
        static boolean[] primes = new boolean[RMAX];
        static int[] count2017num = new int[RMAX];
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                StringBuilder sb = new StringBuilder(1000000);
                int Q = sc.nextInt();
                e();
                for (int i = 0; i < Q; i++) {
                        int l = sc.nextInt();
                        int r = sc.nextInt();
                        sb.append(count2017num[r] - count2017num[l - 1]);
                        sb.append('\n');
                }
                System.out.print(sb);
        }

        static void e() {
                for (int i = 2; i < RMAX; i++) {
                        primes[i] = true;
                }
                for (int i = 2; i < RMAX; i++) {
                        if (!primes[i]) {
                                continue;
                        }
                        for (int j = 2; j * i < RMAX; j++) {
                                primes[i * j] = false;
                        }
                }
                int counter = 0;
                for (int i = 1; i < RMAX; i++) {
                        if (primes[i] && primes[(i + 1) / 2]) counter++;
                        count2017num[i] = counter;
                }
        }
}


Measured memory_bytes: 66644
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define eb emplace_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool mm[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	int n,k; cin>>n>>k;
	vl x,y;
	int z = 0;
	fore(i,0,n){
		lli a; cin>>a;
		if(a<0)x.pb(abs(a));
		if(a>0)y.pb(a);
		if(a==0)z++;
	}

	auto impar = [&](){
		fore(i,0,sz(y))x.pb(y[i]);
		fore(i,0,z)x.pb(0);
		sort(all(x));
		lli res = 1;
		fore(i,1,k) res = (res*x[i])%	MOD;
		res=(res*(MOD-x[0])%MOD)%MOD;
		return res;
	};

	auto par=[&](){
		int a = 0, b = k&1;
		lli prod = 1,aux;
		sort(all(x),greater<lli>());
		sort(all(y),greater<lli>());
		fore(i,0,k/2){
			if(a>=sz(x)-1 and b>=sz(y)-1)return impar();
			if(a>=sz(x)-1){
				aux = (y[b]*y[b+1])%MOD;
				b+=2;
				prod = (prod *aux)%MOD;
				continue;
			}
			if(b>=sz(y)-1){
				lli aux = (x[a]*x[a+1])%MOD;
				prod = (prod *aux)%MOD;
				a+=2;
				continue;
			}
			lli aux = 1;
			if(x[a]*x[a+1]>y[b]*y[b+1]){
				aux = (x[a]*x[a+1])%MOD;
				a+=2;
			}
			else{
				aux = (y[b]*y[b+1])%MOD;
				b+=2;
			}
			prod = (prod *aux)%MOD;
		}
		if(k&1)prod = (prod * y[0])%MOD;
		return prod;
	};

	auto solve = [&](){
		if(k>sz(x)+sz(y))return 0LL;
		if(sz(y)+sz(x)/2*2>=k and (k%2==0 or sz(y)))return par();
		return impar();
	};
	cout<<solve()<<ENDL;
}


Measured memory_bytes: 6068
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	int odd = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a % 2) { ++odd; }
	}

	cout << (odd % 2 ? "NO" : "YES") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, t, ans;
	cin >> a >> b >> t;

	ans = t / a * b;
	cout << ans << "\n";

	
	return 0;
}


Measured memory_bytes: 256
import queue

k = int(input())

q = queue.Queue()
for i in range(1, 10):
  q.put(i)
  
for x in range(k):
  if x == k-1:
    print(q.get())
    exit()
  num = q.get()
  if num%10 != 0:
    q.put(10*num + num%10 - 1)
  q.put(10*num + num%10)
  if num%10 != 9:
    q.put(10*num + num%10 + 1)
    

Measured memory_bytes: 13236
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*d++;printf("%d\n",s)){for(memset(z,t=60,2e4);s--;)for(j=i=d;--i;a?*p=fmin(*p,a),*z[t]>*p?t=i:0:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;d+~i++;t=a)for(s+=*z[t],*z[t]=0,a=j=d;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << 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; }

using namespace std;

long long com[51][51];
int main () {
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i ) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    //最大値
    long long sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    //小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }

    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}

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

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

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b > a) {
        int temp = a;
        a = b;
        b = temp;
    }
    if (b == 0) {
        return a;
    }
    return (b, b % a);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef struct{
  char index[31];
  int page;
}Index;
int main(){
  Index book[100];
  Index tmp;
  int i,j,n=0;
  char change[31];
  while(scanf("%s %d",book[n].index,&book[n].page) != EOF){
    n++;
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(strcmp(book[j].index,book[j-1].index) < 0){
	tmp=book[j];
	book[j]=book[j-1];
	book[j-1]=tmp;
      }
    }
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(strcmp(book[j].index,book[j-1].index) == 0 && book[j].page < book[j-1].page){
	tmp=book[j];
	book[j]=book[j-1];
	book[j-1]=tmp;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i == 0){
      printf("%s\n%d",book[i].index,book[i].page);
      strcpy(change,book[i].index);
    }
    else if(strcmp(change,book[i].index) == 0){
      printf(" %d",book[i].page);
      strcpy(change,book[i].index);
    }
    else if(strcmp(change,book[i].index) != 0){
      printf("\n%s\n%d",book[i].index,book[i].page);
      strcpy(change,book[i].index);
    }
  }
  printf("\n");
  return (0);
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 n,p;
  cin >> n >> p;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }
  i64 ans = 1;
  for(i64 i = 2;i * i <= p;i++) {
    i64 cnt = 0;
    i64 a = p;
    while(a % i == 0) {
      cnt++;
      a /= i;
    }

    if(n <= cnt) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;

  int ans = 1e9;
  for(int i = 0; i <= max(x, y); ++i) {
    int sum_a = max((x-i)*a, 0);
    int sum_b = max((y-i)*b, 0);

    ans = min(ans, i*2*c + sum_a + sum_b);
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;



int main()
{
    int a,b;
    cin >> a >> b;
    if(a>=1 && a<=9 && b>=1 && b<=9){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }


   
    

    return 0;
}

Measured memory_bytes: 256
/*1_2_A.c*/
#include<stdio.h>
int main(void){
   int a,b;
   scanf("%d %d",&a,&b);
   if(a<b){
      printf("a < b\n");
      return 0;
   }
   else if(a>b){
      printf("a > b\n");
      return 0;
   }
   else{
      printf("a == b\n");
   }
   return 0;
}

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

int main() {
  ll x, n = 100, i = 0;
  cin >> x;
  while(x > n){
    n = n + (round)(n/100);
    ++i;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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 T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,C;
    cin >> A >> B >> C;
    if(A == B && B == C){
        if(A%2==0) cout << -1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    int ans = 0;

    while(A%2==0 && B%2==0 && C%2==0){
        int a = (B+C) / 2;
        int b = (A+C) / 2;
        int c = (A+B) / 2;
        A = a, B = b, C = c;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long solve(int a, int b, int c){
    c = min(a+b+1, c);
    return b + c;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
  	cout << solve(a, b, c) << endl;
  	return 0;
}

Measured memory_bytes: 256
S=list(input())
T=list(input())
 
num=1000
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for j in range(len(T)):
        if s[j]!=T[j]:
            cnt+=1
    num=min(num, cnt)
print(num)

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

int main()
{
   int N,c=0;
  double X, Y, D;
  cin>>N>>D;
  for(int i=0; i<N; ++i)
  {
  	cin>>X>>Y;
  	double d=pow(X,2)+pow(Y,2);
    if(pow(d,0.5)<=D)
      c++;
  }
  cout<<c;

   
   return 0;
}

Measured memory_bytes: 4292
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def dfs(maze, H, W, sh, sw, gh, gw):
    visited = [[False] * W for _ in range(H)]
    visited[sh][sw] = True
    q = deque([(sh, sw)])
    while q:
        h, w = q.pop()
        if h == gh and w == gw:
            return True
        for dh, dw in [(1, 0), (-1, 0), (0, -1), (0, 1)]:
            nh = h + dh
            nw = w + dw
            if 0 <= nh < H and 0 <= nw < W:
                if not visited[nh][nw]:
                    if maze[nh][nw] == ".":
                        visited[nh][nw] = True
                        q.append((nh, nw))
    return False


def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    seen = [[False] * W for _ in range(H)]

    def dfs(x, y, black, white):
        q = deque([(x, y)])
        while q:
            X, Y = q.pop()
            if seen[X][Y]:
                continue
            seen[X][Y] = True
            if S[X][Y] == "#":
                black += 1
            else:
                white += 1
            for i in range(4):
                nx = X + dx[i]
                ny = Y + dy[i]
                if not (0 <= nx < H and 0 <= ny < W):
                    continue
                if S[X][Y] == S[nx][ny]:
                    continue
                if seen[nx][ny]:
                    continue
                q.append((nx, ny))
        return black, white

    answer = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == ".":
                continue
            if seen[h][w]:
                continue
            black = 0
            white = 0
            black, white = dfs(h, w, black, white)
            answer += black * white

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21044
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

flag = False
cnt = 0

for i in range(10000000000):
    for j in range(n):
        if a[j] % 2 == 0:
            a[j] = int(a[j] / 2)
        else:
            flag = True
            break
    if flag == True:
        break
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	char a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	a[k-1]=a[k-1]+32;
	for(int i=0;i<n;i++)
	cout<<a[i];
}

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(is, 1 << h) {
        rep(js, 1 << w) {

            int cnt = 0;
            rep(i, h) {
                rep(j, w) {
                    if (is >> i & 1) continue;
                    if (js >> j & 1) continue;
                    if (s[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <list>

#define MAX 100000

typedef struct _contents
{
        int number;
        int parents;
        int depth;
        int status;
        std::vector< int > con_node;
} contents_t;

using namespace std;
array< contents_t, MAX > node;
int main()
{
        array< contents_t, MAX > node;
        int num, degree, id, count = 0, tmp, i;

        for ( i = 0 ; i < node.size() ; i++ )
        {
                node[i].number = i;
                node[i].parents = -1;
                node[i].depth = 0;
        }

        cin >> num;
        count = num;
        while ( num > 0 )
        {
                cin >> id;
                cin >> degree;
                for ( int j = 0 ; j < degree ; j++ )
                {
                        cin >> tmp;
                        node[id].con_node.push_back( tmp );
                        node[tmp].parents = id;
                }
                num = num - 1;
        }

        for ( int j = 0 ; j < count ; j++ )
        {
                printf( "node %d: parent = %d, depth = ", j, node[j].parents );

                tmp = j;
                while ( node[tmp].parents != -1 )
                {
                        tmp = node[tmp].parents;
                        node[j].depth++;
                }
                cout << node[j].depth << ", ";
                if ( node[j].parents == -1 )
                {
                        printf( "root, ");
                }
                else
                {
                        if ( node[j].con_node.size() == 0 )
                        {
                                printf( "leaf, ");
                        }
                        else if ( node[j].con_node.size() != 0 )
                        {
                                printf( "internal node, ");
                        }
                }

                printf( "[" );
                for ( i = 0 ; i < node[j].con_node.size() ; i++ )
                {
                        if ( i == node[j].con_node.size()-1 || node[j].con_node.size() == 0 )
                        {
                                printf( "%d", node[j].con_node[i] );
                        }
                        else
                        {
                                printf( "%d, ", node[j].con_node[i] );
                        }
                }
                printf( "]\n" );
        }

        return 0;
}



Measured memory_bytes: 11856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vi l(n);
    rep(i,n) cin >> l[i];
    
    int ans = 0;
    rep(i,n)rep(j,n)rep(k,n){
        if(i<j && j<k){
            if(l[i]==l[j] || l[j]==l[k] || l[k] == l[i]) continue;
            if((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(void){
    ll N, Q, sum = 0;
    string S;
    cin >> N >> Q >> S;
    vector<ll> l(Q),r(Q), count_ac(N+1);
    for(int i=0; i<N-1; i++){
        if(S.at(i)=='A' && S.at(i+1)=='C'){
            sum++;
        }
        count_ac[i+1] += sum;
    }
    count_ac[N] = count_ac[N-1];
    for(int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
        cout << count_ac[r[i]-1] - count_ac[l[i]-1] << endl;
    }
}

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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


    ll n;
    cin >> n;
    while(n)
    {
        if (n%10==7) return cout << "Yes\n" , 0;
        n /= 10;
    }

    cout << "No\n";

    return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000], inv[1100000];

int mod_fact(int n, int m) {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i % m;
        inv[i] = m - inv[m % i] * (m / i) % m;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % m;
    }
}

int N, M, K;
int mod = 1e9 + 7;

signed main() {
    cin >> N >> M >> K;
    mod_fact(220000, mod);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int a = ((i * (i + 1) / 2 + (N - i - 1) * (N - i) / 2) * M +
                     (j * (j + 1) / 2 + (M - j - 1) * (M - j) / 2) * N) % mod;
            (a *= fact[N * M - 2] * fact_inv[K - 2] % mod * fact_inv[N * M - K] % mod) %= mod;
            (ans += a) %= mod;
        }
    }
    (ans *= inv[2]) %= mod;
    cout << ans << endl;

}

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

int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int c[h][w];
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<a[i]; j++){
            int p = cnt/w;
            int q = cnt%w;
            if(p%2 == 0){
                c[p][q] = i+1;
            }
            else{
                c[p][w-1-q] = i+1;
            }
            cnt++;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << c[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

int dfs(int n, int N, int M, vector<int>& a, vector<int>& b, vector<int>& c, vector<int>& d, vector<int>& A){
  if(n == N){
    int Q = a.size();
    
    int score = 0;
    for(int i = 0; i < Q; i++){
      if(A[b[i]] - A[a[i]] == c[i]) score += d[i];
    }
    
    return score;
  }
  
  int ret = 0;
  for(int i = A[n]; i <= M; i++){
    A[n + 1] = i;
    ret = max(dfs(n + 1, N, M, a, b, c, d, A), ret);
  }
  
  return ret;
}

int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  
  vector<int> a(Q), b(Q), c(Q), d(Q), A(N + 1, 1);
  for(int i = 0; i < Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  
  int s = dfs(0, N, M, a, b, c, d, A);
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N 200 + 5

int m, sz, cur, A[N], S[N];
LL n, C[N][N];
vector<int> Vec[N];

LL Calc(int l)
{
	return (1LL << (l - 1)) - 1;
}

void Prepare()
{
	for (int i = 0; i <= m; i ++)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; j ++)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
}

int main()
{
	scanf("%lld", &n);
	
	for (m = 1; Calc(m) <= n; m ++) ;
	n -= Calc(-- m);
	cur ++, sz = m;
	for (int i = 1; i <= m; i ++)
	{
		A[i] = cur;
		Vec[i].push_back(cur);
	}
	
	Prepare();
	
	while (n > 0)
	{
		int mx = 0;
		for (int i = 1; i <= m; i ++)
			if (C[m][i] <= n && C[m][i] > C[m][mx])
				mx = i;
		cur ++, sz += 2;
		Vec[mx].insert(Vec[mx].begin() + (mx > 0 ? 1 : 0), cur);
		Vec[m].push_back(cur);
		n -= C[m][mx];
	}
	
	printf("%d\n", sz);
	for (int i = 0, j = 0; i <= m; i ++)
		for (int x : Vec[i])
			printf("%d%c", x, (++ j) == sz ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

#define int long long

signed main() {
	int n, t, t1, t2, sum = 0;
	cin >> n >> t >> t1;
	n--;
	while (n--) {
		cin >> t2;
		if (t2 - t1 > t)
			sum += t;
		else
			sum += (t2 - t1);

		t1 = t2;
	}

	cout << sum + t << endl;

	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    t[i + 1][j + 1] = (c == '#');
  }
  string ans = "Yes";
  rep(i, h) rep(j, w) {
    if (t[i + 1][j + 1] == false) continue;
    if ((t[i][j + 1] || t[i + 2][j + 1] || t[i + 1][j] || t[i + 1][j + 2]) ==
        false)
      ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int64_t> L(N+1);

    L.at(0) = 2;
    L.at(1) = 1;
    for (int i = 2; i<=N; i++) {
        L.at(i) = L.at(i-1) + L.at(i-2);
    }
    cout << L.at(N);
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	a := readInt()
	b := readInt()

	println(minInt(n*a, b))
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
    long long int n, k, i, a, length, curr, temp, data[200001], flag[200001], len;
    cin>>n>>k;
    for(i=1;i<=n;i+=1)
    {
        flag[i]=0;
        cin>>data[i];
    }
    if(data[1]==1)
    {
        cout<<1<<endl;
    }
    else
    {
        curr=1;
        length=0;
        flag[1]=0;
        while(flag[data[curr]]==0)
        {
            length+=1;
            curr = data[curr];
            flag[curr]=length;
        }
        len = length+1-flag[data[curr]];  
        if(k<flag[data[curr]])
        {
            temp=0;
            long long int temp_curr=1;
            while(temp!=k)
            {
                temp_curr = data[temp_curr];
                temp+=1;
            }
            cout<<temp_curr<<endl;
        }
        else
        {
            long long int temp_len = (k-flag[data[curr]])%len;
            temp=0;
            i=data[curr];
            while(temp!=temp_len)
            {
                i = data[i];
                temp+=1;
            }
            cout<<i<<endl;
        }
    }
}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
map<ll,ll> mpX,mpY;
vector<pll> P;
void input(){
    fast_io();
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll x,y; cin >> x >> y;
        mpX[x] = 0;
        mpY[y] = 0;
        P.emplace_back(x,y);
    }
}

int solve(){
    vector<ll> X,Y;
    for(auto &p:mpX) {
        p.second = X.size();
        X.push_back(p.first);
    }
    for(auto &p:mpY) {
        p.second = Y.size();
        Y.push_back(p.first);
    }
    sort(P.begin(),P.end());
    ull ans = (1LL<<64)-1;
    for (int xl = 0; xl < N-1; xl++)
    for (int xr = xl+1; xr < N; xr++)
    for (int yl = 0; yl < N-1; yl++)
    for (int yr = yl+1; yr < N; yr++){
        int pointsN = 0;
        for (int k = xl; k <= xr; k++)
        {
            if(Y[yl] <= P[k].second && P[k].second <=Y[yr]) pointsN++;
        }
        if(pointsN>=K){
            ull S = (X[xr]-X[xl])*(Y[yr]-Y[yl]);
            ans = min(ans,S);
        }
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char a[1200],*str;

	scanf("%[^\n]",a);
	str = a;
	while(*str != '\0'){
		if(isupper(*str))
			printf("%c",tolower(*str));
		else
			printf("%c",toupper(*str));
		str++;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

int main(){
    int dp[1001][1001];
    string x, y;
    int q, n, xl, yl, ans;
    cin>>q;
    for(int k = 0; k < q; k++){
        cin>>x>>y;
        for(int i = 0; i <= 1000; i++){
            for(int j = 0; j <= 1000; j++){
	            dp[i][j]=0;
            }
            xl = x.size();
            yl = y.size();
            ans = 0;
        }
        for(int i = 1; i <= xl; i++){
            for(int j = 1; j <= yl; j++){
	            if(x[i-1] == y[j-1]){
	                dp[i][j] = dp[i-1][j-1]+1;
            	}else{
            	    dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            	}
            }
        }
    cout<<dp[xl][yl]<<endl;
    }
  return 0;
}


Measured memory_bytes: 7068
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int x[100100], y[100100];
char c[100100];

int board[2][2010][1010];

int sum(int p, int y0, int x0, int y1, int x1) {
    return board[p][y1][x1] - board[p][y1][x0] - board[p][y0][x1] + board[p][y0][x0];
}

int calc(int i, int j) {
    int ret = 0;
    for (int p = 0; p < 2; p++) {
        int v = sum(p, 0, 0, i-1, j-1);
        v += sum(1-p, k, 0, i-1+k, j-1);
        v += sum(p, i-1, j-1, k, k);
        v += sum(1-p, i-1+k, j-1, 2*k, k);
        v += sum(1-p, 0, j-1, i-1, k);
        v += sum(p, k, j-1, i-1+k, k);
        v += sum(1-p, i-1, 0, k, j-1);
        v += sum(p, i-1+k, 0, 2*k, j-1);
        ret = max(ret, v);
    }
    return ret;
}

int solve() {
    for (int i = 0; i < n; i++) {
        x[i] %= (2*k);
        y[i] %= (2*k);
        if (x[i] >= k) {
            x[i] -= k;
            if (y[i] < k) {
                y[i] += k;
            } else {
                y[i] -= k;
            }
        }

        if (c[i] == 'B') {
            board[0][y[i]+1][x[i]+1]++;
        } else {
            board[1][y[i]+1][x[i]+1]++;
        }
    }

    for (int i = 1; i <= 2*k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int p = 0; p < 2; p++) {
                board[p][i][j] += board[p][i-1][j] + board[p][i][j-1] - board[p][i-1][j-1];
            }
        }
    }

    int res = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            res = max(res, calc(i, j));
        }
    }
    return res;
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> c[i];
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,i,ans;
    cin >> N;

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    if(N % 1000 == 0){
        cout << 0 << endl;
        return 0;
    }
    
    int j = N / 1000;
    i = (j + 1) * 1000;

    ans = i - N;
    
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3640
def GCD(x, y):
    if x < y:
        if y % x == 0:
            print(str(x))
        else :
            GCD(x, y%x)
    elif x > y:
        if x % y == 0:
            print(str(y))
        else :
            GCD(y, x%y)
    else :
        print(str(x))

if __name__ == '__main__':
    a, b = map(int, input().split())
    GCD(a, b)


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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

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

    ll k,a,b;
    cin >> k >> a >> b;

    for(ll i=a; i<=b; i++){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

main()
{
	int a,b,i;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	for(i=0;i<9;i++){
		scanf("%d",&b);
		a-=b;
	}
	printf("%d\n",a);
	}
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

	int n;
	int sum = 0;
	string num;
	cin >> num;
	while (num != "0"){
		for (unsigned int i = 0; i < num.size(); i++){
			n = num[i] - '0';
			sum += n;
		}
		cout << sum << '\n';
		sum = 0;
		cin >> num;
	}

	return 0;
}


Measured memory_bytes: 3228
N,X,M=map(int,input().split())
dist=[0 for i in range(M)]
A=X
loopin=-1
loopout=-1
ans=[0]
for i in range(N+1):
    if dist[A]!=0:
        loopin=dist[A]
        loopout=i
        ans.append(ans[-1]+A)
        break
    else:
        dist[A]=i
        ans.append(ans[-1]+A)
        A=(A*A)%M
if loopin==-1:
    print(ans[N])
    exit()
#print(roopin,roopout)
#print(ans)
A=X
loop=loopout-loopin
def solve(l,r):
    assert 0<=l and l<=r
    if r<=loopout:
        return ans[r]-ans[l]
    if l<loopin:
        return ans[loopin]-ans[l]+solve(loopin,r)
    x=(l-loopin)//loop
    y=(r-loopin)//loop
    #x*loop+loopin<=l<(x+1)*loop+loopin
    #y*loop+loopin<=r<(y+1)*loop+loopin
    if x==y:
        return ans[r-y*loop]-ans[l-x*loop]
    #以降はx<y
    tmp1=ans[l-x*loop]-ans[loopin]
    tmp2=(ans[loopout]-ans[loopin])*(y-x)
    tmp3=ans[r-y*loop]-ans[loopin]
    #print(l,r,x,y,tmp1,tmp2,tmp3)
    return tmp1+tmp2+tmp3
print(solve(0,N))


Measured memory_bytes: 73356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <string.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef pair<int, int> P;
typedef vector<P> vp;
const int INF = (1<<31) - 1;
const int MAX_N = 1 << 17;

int n, dat[2 * MAX_N - 1];

void init(int n_){
	n = 1;
	while(n < n_)
		n *= 2;
		
	for(int i = 0; i < 2 * n - 1; ++i)
		dat[i] = INF;
}

void update(int k, int a){
	k += n - 1;
	dat[k] = a;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l)
		return INF;
		
	if(a <= l && r <= b)
		return dat[k];
	else{
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}

int main() {
	int N, q, com, x, y;
	cin >> N >> q;
	init(N);
	for(int i = 0; i < q; ++i){
		scanf("%d%d%d\n", &com, &x, &y);
		if(com){
			printf("%d\n", query(min(x, y), max(x, y) + 1, 0, 0, n));
		}
		else{
			update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 2256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
x,n = map(int, input().split())
if n!=0:
  p = list(map(int,input().split()))
  for i in range(0,101):
    if x-i not in p:
      print(x-i)
      break
    elif x+i not in p:
      print(x+i)
      break
else:
  print(x)

Measured memory_bytes: 61840
#define CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{
	int a; 
	int b;
	int c;

	scanf("%d", &a); scanf("%d", &b); scanf("%d", &c);

	if (a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    string s; 
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        if(s[i] == 'o') cnt++;
        
    }
    cout << 700 + cnt * 100 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  multiset<int> s;
  rep(i,N) {
    int a;
    cin >> a;
    s.insert(a);
  }
  int ans = -INF;
  srep(i,1,100010) {
    int t = s.count(i-1)+s.count(i)+s.count(i+1);
    ans = max(ans,t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992