akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int k; string s, t = ""; cin >> k >> s;
  rep(i, s.size()){
    if(i < k) t += s[i];
    else{
      t += "...";
      break;
    }
  }
  cout << t << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;
using P = pair<int,int>;

ll n,m,sum;
string s,t;

int main() {
  cin >> n;
  rep(i,n)rep(j,n)rep(k,n){
    sum+=__gcd(i+1,__gcd(j+1,k+1));
  }
  cout << sum << endl;
}

Measured memory_bytes: 3640
n,k=map(int,input().split())
r=[0]*(n+1)
for i in range(k):
    for x in list(map(int,input().split()))[1:]:r[x]=i
a=[0]*(n+1)
for _ in [0]*int(input()):
    p,q=map(int,input().split())
    if r[p]==r[q]:a[q]=a[p]=1
print(sum(a))

Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
	int n;
	cin>>n;
	int a[n];
	int h=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%5==0 || a[i]%3==0){
				continue;
			}
			else{
			h=1;	
			}
		}
	}
	if(h==1){
		cout<<"DENIED";
	}
	else{
		cout<<"APPROVED";
	}
}



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


int main() {
    ll d,n; cin >> d >> n;
    if(n==100) n++;
    rep(i,d) n*=100;
    cout << n << endl;
}

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

int main()
{
	int l1=0,l2=0,d=0,
		countT=0,countH=0;
	
	while(scanf("%d,%d,%d",&l1,&l2,&d)!=EOF){
		if((l1 != l2) && ((l1*l1 + l2*l2) == d*d)){
			countT++;
		}else if( l1 == l2 && ((l1*l1 + l2*l2) != d*d)){
			countH++;
		}
	}
	printf("%d\n%d\n",countT,countH);
	
	return 0;
}

/*
	ツ閉スツ行ツ四ツ陛督形 + ツつキツづ猟づづ個角ツつェツ陳シツ角ツ　ツィツ　ツ陳キツ陛サツ形
	ツ閉スツ行ツ四ツ陛督形 + ツつキツづ猟づづ個陛督つェツ督卍つオツつ「ツィツ　ツづ青つオツつェツつス*/

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "YES" : "NO"));}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans=0;
  int tmp=0;
  rep(i,s.size()){
    if(s[i]=='I'){
      tmp++;
    } else {
      tmp--;
    }
    chmax(ans,tmp);
  }
  prt(ans);
}


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

int main(){
  char a[10];
  int k,n;

  scanf("%d",&n);
  for(k=0;k<n;k++){
    int b[3]={};
    int t=0;
    int out=0;
    for(;;){
      scanf("%s",a);
      if(strcmp(a,"HIT")==0){
	b[0]++;
	if(b[0]!=1){
	  b[1]++;
	  if(b[1]!=1){
	    b[2]++;
	    if(b[2]!=1){
	      t++;
	    }
	  }
	}
      }
      else if(strcmp(a,"HOMERUN")==0){
	t++;
	if(b[0]){
	  t++;
	  b[0]=0;
	}
	if(b[1]){
	  t++;
	  b[1]=0;
	}
	if(b[2]){
	  t++;
	  b[2]=0;
	}
      }
      else if(strcmp(a,"OUT")==0)
	out++;
      if(out==3)
	break;
    }
    printf("%d\n",t);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int L, R, d;

int get(int x)
{
    int ret = 0;
    for (int i = 1; i <= x;++i)
    {
        if(i%d==0)
            ret++;
    }
    return ret;
}

void solve()
{
    cin >> L >> R >> d;
    cout << get(R) - get(L - 1) << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

int main(){
    int n,x;
    cin>>n>>x;
    int a[n];
    cin>>a[0];
    long long ans=0;
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]+a[i-1]>x){
            ans+=min(a[i],a[i]+a[i-1]-x);
            a[i]=a[i]-min(a[i],a[i]+a[i-1]-x);
            if(a[i]+a[i-1]>x){
                ans+=a[i-1]-x;
                a[i-1]=a[i-1]-x;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
        ll N; cin >> N;
        vector<ll> A(N, 0);
        map<ll,ll> m;
        ll sum = 0;
        rep(i, N) {
                cin >> A[i];
                m[A[i]]++;
                sum += A[i];
        }
        ll Q; cin >> Q;
        vector<ll> ans(Q, 0);
        vector<ll> B(Q, 0);
        vector<ll> C(Q, 0);
        rep (i, Q) {
                cin >> B[i] >> C[i];
                ll dif = C[i] - B[i];
                ll bnum = m[B[i]];
                ll cnum = m[C[i]];
                sum += (dif * bnum);
                m[B[i]] = 0;
                m[C[i]] = cnum + bnum;
                ans[i] = sum;
        }
        rep(i, Q) {
                cout << ans[i] << endl;
        }
}


Measured memory_bytes: 12180
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll A,B;
  cin >> A >> B;
  if(A<10&&B<10){
    cout << A*B << endl;
  }else{
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,n,a,b,c,flg,LDM[3][2];
  while(1){
    for(i=0;i<3;i++)LDM[i][0]=0,LDM[i][1]=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d%*c%d%d",&a,&b,&c);
      if(a>=11&&a<15)flg=0;
      else if(a>=18&&a<21)flg=1;
      else if(a>=21||a<2)flg=2;
      else flg=3;
      if(flg!=3){
      if(c<b) c+=60;

      if(c-b<=8){
	LDM[flg][0]++,LDM[flg][1]++;
      }
      else LDM[flg][0]++;
      }
    }
    if(LDM[0][0]==0) printf("lunch no guest\n");
    else printf("lunch %d\n",(int)((double)(LDM[0][1])/(double)(LDM[0][0])*100));
    if(LDM[1][0]==0) printf("dinner no guest\n");
    else printf("dinner %d\n",(int)((double)(LDM[1][1])/(double)(LDM[1][0])*100));
    if(LDM[2][0]==0) printf("midnight no guest\n");
    else printf("midnight %d\n",(int)((double)(LDM[2][1])/(double)(LDM[2][0])*100));
  }
  return 0;   
}
  

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

#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a>b) a=b;
  if(a>c) a=c;
  if(d>e) d=e;
  cout<<a+d-50<<endl;
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc,char const *argv[]) {
   ios_base::sync_with_stdio(false); cin.tie(0);
   int n,m;
   cin>>n>>m;
   n--,m--;
   cout<<n*m<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c=0;
    cin>>a;
    int x[a];
    cin>>b;
    for(int i=0;i<a;i++){
        cin>>x[i];
        if((b-x[i])*(b-x[i])<x[i]*x[i]){
            if(b<x[i]){
                c=c+(x[i]-b)*2;
            }else{
                c=c+(b-x[i])*2;
            }
        }else{
            c=c+x[i]*2;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int m = fs.nextInt();
        final int x = fs.nextInt();
        final int y = fs.nextInt();
        final int[] xArr = fs.nextIntArray(n);
        final int[] yArr = fs.nextIntArray(m);
        Utils.shuffleSort(xArr);
        Utils.shuffleSort(yArr);
        boolean solve = false;
        for (int z = x + 1; z <= y; z++) {
            if (xArr[n - 1] < z && z <= yArr[0]) {
                solve = true;
                break;
            }
        }
        System.out.println(solve ? "No War" : "War");
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32952
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int flag=0;
	int x[101],y[101];
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		if(n>=2)
		{
			if(x[i]==y[i] && x[i-1]==y[i-1] && x[i-2]==y[i-2])
				flag=1;
		}
	}
	if(flag==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll x; cin >> x;
    ll d = x/11;
    ll r = x%11;

    ll ans = 2*d;

    if(r == 0) cout << ans << endl;
    else if(r <= 6) cout << ans + 1 << endl;
    else cout << ans + 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a;
    int b;
    cin>>a >>b;
    int d=a/b;
    int r=a%b;
    double fa=a;
    double fb=b;
    double f=fa/fb;
    printf("%d %d %.5f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <ctime>
#include <random>

#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
//ifstream cin("input.txt"); ofstream cout("output.txt");
//ifstream cin("umbrella.in"); ofstream cout("umbrella.out");
struct str {
	ll x, y, z;
};
vector<str> A;
int n, m;
ll check(int a, int b, int c) {
	vector<pair<ll,ll>> kek(n);
	for (int i = 1; i <= n; i++) {
		ll x = A[i].x*a + A[i].y*b + A[i].z*c;
		kek[i - 1] = { x, i };
	}
	sort(kek.rbegin(), kek.rend());
	int m2 = m;
	ll ansx = 0, ansy = 0, ansz = 0;
	for (int i = 0; i < n && m2; i++) {
			m2--;
			ansx += 1 * A[kek[i].second].x;
			ansy += 1 * A[kek[i].second].y;
			ansz += 1 * A[kek[i].second].z;
	}
	return abs(ansx) + abs(ansy) + abs(ansz);
}
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> n >> m;
	A.resize(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> A[i].x >> A[i].y >> A[i].z;
	}
	ll ans = 0;
	ans = max(ans, check(1, 1, 1));
	ans = max(ans, check(1, 1, -1));
	ans = max(ans, check(1, -1, 1));
	ans = max(ans, check(1, -1, -1));
	ans = max(ans, check(-1, 1, 1));
	ans = max(ans, check(-1, 1, -1));
	ans = max(ans, check(-1, -1, 1));
	ans = max(ans, check(-1, -1, -1));
	cout << ans;
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3e5 + 5;

typedef pair<int,int>   ii;

vector<int> add[N];
vector<int> rem[N];

vector<int> dvs[N];

int t[N];

int upd(int p,int v)    {
    for(; p < N ; p += p & -p)
        t[p] += v;
}
int get(int p)  {
    int ans = 0;
    for(; p > 0 ; p -= p & -p)
        ans += t[p];
    return  ans;
}

int ans[N];

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

    for(int i = 1 ; i < N ; ++i)
    for(int j = i ; j < N ; j += i)
        dvs[j].pb(i);

    int m;  cin >> m;
    int n;  cin >> n;

    for(int i = 0 ; i < m ; ++i)    {
        int l;  cin >> l;
        int r;  cin >> r;

        add[l].pb(l);
        rem[r].pb(l);
    }

    for(int i = 1 ; i <= n ; ++i)   {
        for(int x : add[i]) upd(x,1);
        for(int x : dvs[i])
            ans[x] += get(i),
            ans[x] -= get(i - x);

        for(int x : rem[i]) upd(x,-1);
    }
    for(int i = 1 ; i <= n ; ++i)
        cout << ans[i] << "\n";
}

Measured memory_bytes: 52352
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	
	int i,j,a,b,c,n;
	cin>>n;
	int ara[n];
 
	int k=0;
	for(i=0;i<n;i++)
	{
		 cin>>ara[i];
		 if(ara[i]%2==0)
		 {
		 	if(ara[i]%3==0||ara[i]%5==0)
		 	{
		 	  continue;
			 }
			 else
			 {
			 		cout<<"DENIED\n";
		 		return 0;
			 	
			 }
		 }
	}
	 cout<<"APPROVED\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k)cout<<x-k*d<<endl;
    else {
      long long cnt=x/d;
      long long ans=x%d;
      k-=cnt;
      if(k%2)cout<<d-ans<<endl;
      else cout<<ans<<endl;
    }
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio> 
using namespace std;
const int maxn = 2000;
const int oo = (int) 1e9 + 1;
int n,x,y,x1,y1,x2,y2;
int a[maxn+1];
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> x >> y;
	for (int i=1; i<=n; i++)
	cin >> a[i];
	a[0]=a[1];
	cout << max(abs(a[n]-y),abs(a[n-1]-a[n]));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, K, A));
    }

    private static int solve(int N, int K, int[] A) {
        int sum = 0;
        for (int i=0; i<N; i++) {
            sum += A[i];
        }
        List<Integer> divideList = divideList(sum);
        Collections.sort(divideList, Collections.reverseOrder());

        int[] r = new int[N];
        for (int d : divideList) {
            // System.err.println("\nd=" + d);
            int divSum = 0;
            for (int i=0; i<N; i++) {
                r[i] = A[i]%d;
                divSum += r[i];
            }
            Arrays.sort(r);
            /*
            System.err.print("r=");
            for (int i=0; i<N; i++) {
                System.err.print(r[i] + " ");
            }
            System.err.println();
             */

            int split = N - divSum / d;
            // System.err.println("split=" + split);
            int ops = 0;
            for (int i=0; i<split; i++) {
                ops += r[i];
            }
            // System.err.println(ops);
            if (ops > K) continue;
            ops = 0;
            for (int i=split; i<N; i++) {
                ops += d - r[i];
            }
            // System.err.println(ops);
            if (ops > K) continue;

            return d;
        }

        return 1;
    }

    private static List<Integer> divideList(int sum) {
        List<Integer> list = new ArrayList<>();

        for (int i=1; i<=Math.sqrt(sum); i++) {
            if (sum%i == 0) {
                list.add(i);
                list.add(sum/i);
            }
        }

        return list;
    }
}

Measured memory_bytes: 25396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
int main()
{
 ll n,a,b,ti=0;
   cin>>n;
 vector< pair<ll,ll> >v;

 for(int i=0;i<n;i++)
 {
     cin>>a>>b;
     v.pb(make_pair(b,a));
 }
 sort(v.begin(),v.end());

 ti=v[0].second;
 int flag=1;
 if(ti>v[0].first)
    flag=0;
 for(int i=1;i<v.size();i++)
 {
    ti+=v[i].second;
    if(ti>v[i].first)
        flag=0;
 }
 if(flag==0)
    cout<<"No\n";
 else
    cout<<"Yes\n";
return 0;
}


Measured memory_bytes: 6384
def dcg(a, b):
    if (b == 0):
        return a
    else:
        return dcg(b, a % b)


ans = 0
n = int(input())
for k in range(1, n+1):
    for b in range(k + 1, n + 1):
        for c in range(b + 1, n + 1):
            gcd1 = dcg(k, b)
            gcd2 = dcg(gcd1, c)
            ans += gcd2

ans *= 6

tmp = 0

for k in range(1, n+1):
    for b in range(k+1, n+1):
        gcd = dcg(k,b)
        tmp += gcd
        
tmp *= 6

tmp2 = sum(range(1,n+1))

print(ans+tmp+tmp2)

Measured memory_bytes: 74584
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return x * modpow(x * x % mod, n / 2) % mod;
	return  modpow(x * x % mod, n / 2) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return ans;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

int n;
set<int>o1, e1;
vector<P>o, e;
map<int, int>o2, e2;
signed main() {
	cin >> n;
	rep(i, n) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			e1.insert(v);
			e2[v]++;
		}
		else {
			o1.insert(v);
			o2[v]++;
		}
	}
	for (auto s : o1) o.emplace_back(P(o2[s],s));
	for (auto s : e1) e.emplace_back(P(e2[s],s));
	greater_sort(o); greater_sort(e);
	if (o[0].second != e[0].second) {
		cout << n - o[0].first - e[0].first << endl;
	}
	else if (o.size() == 1 && e.size() == 1) {
		cout << n / 2 << endl;
	}
	else {
		cout << min(n - o[0].first - e[1].first, n - o[1].first - e[0].first) << endl;
	}
}

Measured memory_bytes: 13556
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int maxWeight = scan.nextInt();
    
    int[] weights = new int[n];
    int[] values = new int[n];
    
    for (int i = 0; i < n; i++) {
      weights[i] = scan.nextInt();
      values[i] = scan.nextInt();
    }
    scan.close();

    long result = solve(n, weights, values, maxWeight);
    System.out.println(result);
  }
  
  private final static int MAX_VALUE = 100*1000;
  
  private static long solve(int N, int[] weights, int[] values, int maxWeight){
    long[] minWeight = new long[MAX_VALUE + 1];
    Arrays.fill(minWeight, Long.MAX_VALUE);
    minWeight[0] = 0;

    for (int k = 0; k < N; k++) {
      for (int val = MAX_VALUE - values[k]; val >= 0; val--) {
        if (minWeight[val] == Long.MAX_VALUE) {
          continue;
        }

        int newValue = val + values[k];
        long newWeight = minWeight[val] + weights[k];
        long currentMinWeight = minWeight[newValue];

        if (newWeight < currentMinWeight) {
          minWeight[newValue] = newWeight;
        }
      }
    }

    for (int value = MAX_VALUE; value > 0; value--) {
      if (minWeight[value] <= maxWeight) return value;
    }

    return 0;
  }
}

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

int main() {
  ll n, k, c, r = 0;
  cin >> n >> k;
  vector<ll> a(n + 1), b(n + 1, -1);
  map<int, int> p;
  for (ll i = 1; i <= n; i++) cin >> a[i];

  int i = 1, j = 0;
  while (b[i] == -1) {
    p[j] = i;
    b[i] = j;
    i = a[i];
    j++;
  }
  c = j - b[i];

  if (k < b[i])
    cout << p[k] << endl;
  else {
    cout << p[(k - b[i]) % c + b[i]] << endl;
  }
}

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

int main(){
    ll w, h;
    cin >> w >> h;
    ll p, q;
    priority_queue<P,vector<P>,greater<P>> que;
    rep(i,w) {
        cin >> p;
        que.push(P(p,0));
    }
    rep(i,h) {
        cin >> q;
        que.push(P(q,1));
    }
    ll ans = 0;
    ll n = 0;
    p = w + 1; q = h + 1;
    while(!que.empty()){
        P a = que.top();
        que.pop();
        if(a.second == 0) {
            ans += a.first*q;
            p--;
        } else {
            ans += a.first*p;
            q--;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 6512
n = gets.to_i
A = gets.split.map(&:to_i)
ans = 0
i = 0

while i < n-1
  if A[i] == A[i+1]
    i += 1
    next
  end

  if A[i] < A[i+1]
    while(i != n-1 && A[i].to_i <= A[i+1].to_i)
      i += 1
    end
  elsif A[i] > A[i+1]
    while(i != n-1 && A[i].to_i >= A[i+1].to_i)
      i += 1
    end
  end
  i += 1
  ans += 1
end
ans += 1 unless A[i].nil?

puts ans

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

#define rep(i,n) for(int i = 0;i < n; i++)
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if(k !=1){
    cout << n - k << endl;
    }else{
        cout << 0 << endl;
    }
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int k, t;
	cin >> k >> t;

	vector<int> a(t);
	rep(i, t) {
		cin >> a[i];
	}

	sort(rall(a));

	out(max(a[0] - 1 - (k - a[0]), 0));

	return 0;
}

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

using namespace std;

int main()
{
    int n;
    int x[100011], y[100011], t[100011];
    bool ans = true;

    cin >> n;

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for (int i = 1; i < n + 1; i++)
        cin >> t[i] >> x[i] >> y[i];

    for (int i = 0; i < n; i++)
    {
        if (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i] ||
            (t[i + 1] - t[i] - abs(x[i + 1] - x[i]) - abs(y[i + 1] - y[i])) % 2 == 1)
        {
            ans = false;
            break;
        }
    }

    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstring>


// 2, 3, 5, 4, 1, 6
class BiasedDice
{
private:
	enum { N = 29, NOF = 6, NOW = 4 };	// N: table size, NOF: num of face, NOW: num of way
	int blocks[N][N];	// block table
	int heights[N][N];	// height table
	
	// dice table
	static const int dice[NOF][NOF];
	// rotation
	static const int rotation[NOW][NOF];
	// 隣接点
	static const struct Next{int x, y;} d[NOW];
	
	int current[NOF];
	int x, y;
public:
	BiasedDice()
	{
		std::memset(blocks, 0, sizeof(blocks));
		std::memset(heights, 0, sizeof(heights));
		initPos();
	}
	// テーブルポジションをイニシャライズ
	void initPos() { x = y = N / 2; }
	// カレントダイス設定 t:上面 f:正面
	void setCurrent(int t, int f);
	// ダイス追加
	void putDice(int t, int f);
	// 回転処理 n: SWNE 0123
	void rotate(int n);
	// 結果表示
	void showResult();
	
};

// dice table
const int BiasedDice::dice[BiasedDice::NOF][BiasedDice::NOF] = {
	{2, 4, 5, 3, 6, 1},
	{2, 3, 5, 4, 1, 6},
	{1, 4, 6, 3, 2, 5},
	{1, 2, 6, 5, 3, 4},
	{1, 5, 6, 2, 4, 3},
	{1, 3, 6, 4, 5, 2}
};
// rotation
const int BiasedDice::rotation[BiasedDice::NOW][BiasedDice::NOF] = {
	{4, 1, 5, 3, 2, 0},
	{0, 4, 2, 5, 3, 1},
	{5, 1, 4, 3, 0, 2},
	{0, 5, 2, 4, 1, 3}
};
const struct BiasedDice::Next BiasedDice::d[BiasedDice::NOW] = {
	{0, 1},
	{1, 0},
	{0, -1},
	{-1, 0}
};
// カレントダイス設定 t:上面 f:正面
void BiasedDice::setCurrent(int t, int f)
{
	t %= NOF;
	std::memcpy(current, dice[t], sizeof(current));
	for (int k = 0; current[0] != f; ++k) {
		for (int i = 0; i < 4; ++i) {
			current[i] = dice[t][(i + k) % 4];
		}
	}
}
// ダイス追加
void BiasedDice::putDice(int t, int f)
{
	initPos();
	setCurrent(t, f);
	
	while (heights[x][y] != 0) {
		int i;
		for (i = NOF; i > 3; --i) {
			int j;
			for (j = 0; j < 4; ++j) if (current[j] == i) break;
			if (j < 4 && heights[x + d[j].x][y + d[j].y] < heights[x][y]) {
				rotate(j);
				break;
			}
		}
		if (i == 3) break;
	}
	++heights[x][y];
	blocks[x][y] = current[4];
}
// 回転処理 n: SENW 0123
void BiasedDice::rotate(int n)
{
	int temp[NOF];
	std::memcpy(temp, current, sizeof(current));
	for (int i = 0; i < NOF; ++i) {
		current[i] = temp[rotation[n][i]];
	}
	x += d[n].x;
	y += d[n].y;
}
// 結果表示
void BiasedDice::showResult()
{
	int result[7] = {0};
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			++result[blocks[i][j]];
		}
	}
	for (int i = 1; i < NOF; ++i) {
		std::cout << result[i] << ' ';
	}
	std::cout << result[NOF] << std::endl;
}

int main()
{
	int n;
	while (std::cin >> n, n) {
		BiasedDice dice;
		while (n--) {
			int t, f;
			std::cin >> t >> f;
			dice.putDice(t, f);
		}
		dice.showResult();
	}
	
	return 0;
}

Measured memory_bytes: 1168
n = int(input())
A = list(map(int,input().split()))
L = [0]*((n+1)//2)
ans = 1
mod = 10**9+7
for i in A:
    L[i//2] += 1
if n % 2 == 0:
    for i in L:
        if i != 2:
            print(0)
            exit()
        ans *= 2
        ans %= mod
    print(ans)
else:
    if L[0] != 1:
        print(0)
        exit()
    for i in range(1,(n+1)//2):
        if L[i] != 2:
            print(0)
            exit()
        ans *= 2
        ans %= mod
    print(ans)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b:i--)

int main() {
    // your code goes here
    ll n;
    bool ans=true;
  cin >> n;
    rep(i,1,n){
        ll a;
        cin >> a;
        if((a%2==0)&&(a%3!=0)&&(a%5!=0)) ans=false;
    }
    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

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

int main()
{
  long long n;
  cin>>n;
  long long sum = 0;
  for(int i=1;i<=n;i++)
  {
    if(i%3 == 0 || i%5 == 0)
      continue;
    else
      sum += i;
  }
  cout<<sum;

  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int judge(int a[],int b[],int max,int now,int n,int op){
    REP(i,n){
        if(a[i]==1){
            now+=op;
            if(now>max || now<1)return 0;
        }
        if(b[i]==1){
            if(!(now-op>max || now-op<1))now-=op;
        }
    }
    return 1;
}

int main()
{
    int h,w,n,sr,sc;
    scanf("%d%d%d%d%d",&h,&w,&n,&sr,&sc);
    char a[200005]={};
    char b[200005]={};
    scanf("%s%s",a,b);
    int au[200005]={};
    int ad[200005]={};
    int ar[200005]={};
    int al[200005]={};
    int bu[200005]={};
    int bd[200005]={};
    int br[200005]={};
    int bl[200005]={};
    REP(i,n){
        if(a[i]=='L')al[i]=1;
        if(a[i]=='R')ar[i]=1;
        if(a[i]=='U')au[i]=1;
        if(a[i]=='D')ad[i]=1;
        if(b[i]=='L')bl[i]=1;
        if(b[i]=='R')br[i]=1;
        if(b[i]=='U')bu[i]=1;
        if(b[i]=='D')bd[i]=1;
    }
    int ans=judge(au,bd,h,sr,n,-1)*judge(ad,bu,h,sr,n,1)*judge(ar,bl,w,sc,n,1)*judge(al,br,w,sc,n,-1);
    if(ans==0){
        printf("NO\n");
    }
    else printf("YES\n");
    return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
typedef long long ll;
//#define mod 1000000007

using namespace std;

bool cal(ll a, ll b) {
    cout<<a<<" "<<b<<endl;
	if (a << 1 > b) 
		return 1; 
	b >>= 1; 
	if (a << 1 > b) 
		return (b - a) & 1; 
	if (b & 1) 
		return (b - a) & 1; 
	return cal(a, b >> 1); 
}
  bool mo(const ll &a,const ll  &b){
      return abs(a)>abs(b);
  }
  ll mod=1e9+7;
  ll cal(ll A[], int n, int k) 
{ 
    sort(A, A + n); 
  
    // variable to store final product of all element 
    // of sub-sequence of size k 
    ll product = 1; 
  
    // CASE I 
    // If max element is 0 and 
    // k is odd then max product will be 0 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    // CASE II 
    // If all elements are negative and 
    // k is odd then max product will be 
    // product of rightmost-subarray of size k 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) {
            product *= A[i]%mod; 
            product%=mod;
        }
        return product%mod; 
    } 
  
    // else 
    // i is current left pointer index 
    int i = 0; 
  
    // j is current right pointer index 
    int j = n - 1; 
  
    // CASE III 
    // if k is odd and rightmost element in 
    // sorted array is positive then it 
    // must come in subsequence 
    // Multiplying A[j] with product and 
    // correspondingly changing j 
    if (k & 1) { 
        product *= A[j]%mod;
        product%=mod;
        j--; 
        k--; 
    } 
  
    // CASE IV 
    // Now k is even 
    // Now we deal with pairs 
    // Each time a pair is multiplied to product 
    // ie.. two elements are added to subsequence each time 
    // Effectively k becomes half 
    // Hence, k >>= 1 means k /= 2 
    k >>= 1; 
  
    // Now finding k corresponding pairs 
    // to get maximum possible value of product 
    for (int itr = 0; itr < k; itr++) { 
  
        // product from left pointers 
        ll left_product = (A[i] * A[i + 1]); 
  
        // product from right pointers 
        ll right_product = (A[j] * A[j - 1]); 
  
        // Taking the max product from two choices 
        // Correspondingly changing the pointer's position 
        if (left_product > right_product) { 
            product *= (left_product%mod);
            product%=mod;
            i += 2; 
        } 
        else { 
            product *= right_product%mod;
            product%=mod;
            j -= 2; 
        } 
    } 
  
    // Finally return product 
    return product%mod; 
}
 
main() {
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll ans=cal(arr,n,k);
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 5144
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp ^= scanner.nextInt();
        }

        System.out.println(tmp == 0 ? "Yes" : "No");
    }
}


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

maxVal = max(A)+1
isPrime = [0] * maxVal
isDuplicate = [0] * maxVal
isDivisible = [0] * maxVal

for i in range(len(A)-1):
    if A[i] == A[i+1]:
        isDuplicate[A[i]] = 1

for i in range(len(A)):
    if not isDivisible[A[i]]:
        isPrime[A[i]] += 1

        j = 2
        while A[i] * j < maxVal:
            isDivisible[A[i] * j] = 1

            j += 1

ans = isPrime.count(1)

print(ans)


Measured memory_bytes: 116216
N,x=list(map(int,input().split()))
a=list(map(int, input().split()))

answer=0

for i in range(1,N):
    s=a[i]+a[i-1]
    
    if s>x:
        answer=answer+s-x
        a[i]= max(0,a[i]-s+x)           
       
print(answer)

Measured memory_bytes: 14132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;


int main(void){
  int n,i;
  double x[10],y[10];
  vector<int> p;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> x[i] >> y[i];
    p.push_back(i);
  }
  
  int t=0,f,k;
  double ans=0;
  do{
    for (i=1;i<n;i++){
      f=p[i-1];
      k=p[i];
      ans+=sqrt((x[f]-x[k])*(x[f]-x[k])+(y[f]-y[k])*(y[f]-y[k]));
    }
    t++;
  }while (next_permutation(p.begin(),p.end()));
  
  printf("%.12lf\n",ans/t);
  
  return 0;
}

Measured memory_bytes: 256
from itertools import product
h, w, k = map(int, input().split())
CHOCO = [list(map(int, input())) for _ in range(h)]
INF = 10**5

it = ["01"]*(h-1)
ans = INF
for x in product(*it):
    cnt = sum(map(int, x))
    agg = [[0]*(w) for _ in range(cnt+1)]
    *ls, = map(int, x+('1',))
    for i in range(w):
        prev = c = 0
        for j, split in enumerate(ls):
            if split:
                agg[c][i] = prev+CHOCO[j][i]
                prev = 0
                c += 1
            else:
                prev += CHOCO[j][i]

    tmp = [0]*(cnt+1)
    cannot_split = False

    for xyz in zip(*agg):
        cannot_split = False
        can_continue = True
        for i, x in enumerate(xyz):
            if x > k:
                cannot_split = True
                break
            if x+tmp[i] > k:
                can_continue = False
                break

        if cannot_split:
            break

        if can_continue:
            for i, x in enumerate(xyz):
                tmp[i] += x
                continue
        else:
            for i, x in enumerate(xyz):
                tmp[i] = x
            cnt += 1

    if cannot_split:
        continue

    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 53120
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const int MAX = 210000;
long long n, m;
int N;

int a[MAX], b[MAX];
set<pair<int,int> > black;
map<pair<int,int>, int> alt;


bool judge(int x, int y) {
    if (black.count(pair<int,int>(x, y))) return true;
    else return false;
}


int num[15];
void solve() {
    long long all = (n - 2) * (m - 2);
    memset(num, 0, sizeof(num));
    
    alt.clear();
    black.clear();
    for (int i = 0; i < N; ++i) {
        black.insert(pair<int,int>(a[i], b[i]));
        for (int j1 = -1; j1 <= 1; ++j1) {
            for (int j2 = -1; j2 <= 1; ++j2) {
                int ai = a[i] + j1, bi = b[i] + j2;
                if (ai < 1 || ai >= n-1 || bi < 1 || bi >= m-1) continue;
                alt[pair<int,int>(ai, bi)] = 0;
            }
        }
    }
    
    for (map<pair<int,int>, int>::iterator it = alt.begin(); it != alt.end(); ++it) {
        int x = it->first.first;
        int y = it->first.second;
        int tmp = 0;
        for (int j1 = -1; j1 <= 1; ++j1) {
            for (int j2 = -1; j2 <= 1; ++j2) {
                int nx = x + j1, ny = y + j2;
                if (judge(nx, ny)) ++tmp;
            }
        }
        //cout << x << ", " << y << ": " << tmp << endl;
        num[tmp]++;
    }
    
    for (int i = 1; i <= 9; ++i) all -= num[i];
    
    cout << all << endl;
    for (int i = 1; i <= 9; ++i) cout << num[i] << endl;
}


int main() {
    while (cin >> n >> m >> N) {
        for (int i = 0; i < N; ++i) {
            scanf("%d %d", &a[i], &b[i]);
            --a[i], --b[i];
        }
        solve();
    }
}





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

using namespace std;

#define ll long long int

int main() 
{
    string s;
    int i,j;
    getline(cin,s);
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int X;
  cin >> X;
  cout << (X / 500) * 1000 + (X % 500 / 5) * 5 << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0

for i in range(n):
  ans += b[a[i]-1]

for i in range(n-1):
  if(a[i+1] == (a[i]+1)):
    ans += c[a[i]-1]

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef long long ll;
ll N;
int main(){
	cin>>N;
	vector<int> vec;
	while(N!=0){
		if (N%2==1 || N%2==-1){
			vec.push_back(1);
			N--;
		}else{
			vec.push_back(0);
		}
		N/=-2;
	}
	if (vec.empty()){
		vec.push_back(0);
	}
	reverse(vec.begin(),vec.end());
	for(auto ite:vec){
		cout<<ite;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, y = input().split()

    a = int(x, 16)
    b = int(y, 16)

    if a < b:
        print("<")
    elif a > b:
        print(">")
    else:
        print("=")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61884
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

bool check(int n) {
  int count = 0;

  repf(i, 1, sqrt(n)) {
    if(count > 8) {
      break;
    }

    if(n % i == 0) {
      count += 2;
    }
  }

  return count == 8;
}

int main() {
  int n;
  cin >> n;

  int count_num = 0;

  repf(i, 1, n + 1) {
    if(i % 2 != 1) {
      continue;
    }
    if(check(i)) {
      count_num++;
    }
  }

  cout << count_num << endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int f = 0;
  int x = n;
  while (x > 0) {
    f += x % 10;
    x /= 10;
  }
  if (n % f == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 888
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    d,t,s = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if s*t >= d:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9172
import Data.List
cmb n k = foldl' (\a i->div (a*(n-i+1)) i) 1 [1..k]
main=do
    [n,p]<-map read.words<$>getLine::IO[Int]
    as<-map read.words<$>getLine::IO[Int]
    let en = length $ filter even as
    let os = n-en
    print $ if p==0 then f1 en os else f2 en os
--
f1 en os = 2^en * (1 + sum (map (cmb os) [2,4..os]))
f2 en os = 2^en * sum (map (cmb os) [1,3..os])


Measured memory_bytes: 764
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define f first
#define s second
#define eb emplace_back
#define sz(s) ((int) s.size ())
#define all(s) (s.begin (), s.end ())

using namespace std;

typedef long long ll;

const int N = (int) 1e6 + 5;
const int mod = (int) 1e9 + 7;

int n, dp[N];
ll s;

inline void solve () {
        scanf ("%d", &n);
        dp[0] = 1; dp[1] = n; s = n + 1;
        for (int i = 2; i <= n; i++) {
                dp[i] = ((n - 1) * 1LL * (n - 1) + s - dp[i - 2] + n - i + 1) % mod;
                s += dp[i];
        }
        printf ("%d\n", dp[n]);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arr = new long[110000];
        long sum = 0;
        for(int i = 0; i < N; i++) {
            long A = sc.nextLong();
            sum += A;
            arr[(int)A]++;
        }
        int q = sc.nextInt();
        for(int i = 0; i < q; i++) {
            long B = sc.nextInt();
            long C = sc.nextInt();

            sum += (C-B) * arr[(int)B];
            arr[(int)C] += arr[(int)B];
            arr[(int)B] = 0;
            System.out.println(sum);
        }
    }
}


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

int main(){
	int N,K,P;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>K>>P;
		if(K%P!=0){
			cout<<K%P<<endl;
		}else{
			cout<<P<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3100
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int k = sc.nextInt();
    int n = sc.nextInt();
    int alist[] = new int[n];
    for(int i = 0; i < n; i++){
      alist[i] = sc.nextInt();
    }
    
    int distMax = 0;
    
    for(int i = 0; i < n-1; i++){
      distMax = Math.max(alist[i+1]-alist[i], distMax);
    }
    distMax = Math.max(alist[0]-(alist[n-1]-k), distMax);
    System.out.println(k - distMax);
  }
}

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

const int MAXN = 100+10;
int a[MAXN];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;++i)	cin>>a[i];
	long long ans=1;
	long long sum=1;
	for(int i=0;i<N;++i)
	{
		sum*=3;
		if(a[i]%2==0)	ans*=2;
		else ans*=1;
	}
	cout<<sum-ans<<endl;
	return 0;
}

Measured memory_bytes: 256