akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const int N = 1e5 + 5;
vii intervals;
int dp[N];
int n;
int compute(int i)
{
    if(i == n) return 0;
    if(dp[i] != -1) return dp[i];
    int ans = ninf;
    // take 
    int pos = int( lower_bound(intervals.begin(), intervals.end(), mp(intervals[i].ss, -1)) - intervals.begin());
    ans = MAX2(ans, 1+compute(pos));
    // leave
    ans = MAX2(ans, compute(i+1));
    return dp[i] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n;
    int i;
    FOR0(i, n)
    {  
        dp[i] = -1;
        int x, l;
        cin>>x>>l;
        int le = x -l, ri = x + l;
        intervals.pb(mp(le, ri));
    }
    sort(intervals.begin(), intervals.end());
    int ans = compute(0);
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
long long A[200000];
long long B[200000];
long long sort_A[200000];
long long sort_B[200000];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }

  for(int i = 0; i < N; i++){
    sort_A[i] = A[i];
    sort_B[i] = B[i];
  }

  sort(sort_A, sort_A + N);
  sort(sort_B, sort_B + N);
  if(N % 2 == 1){
    long long min_median = sort_A[N / 2];
    long long max_median = sort_B[N / 2];
    cout << max_median - min_median + 1 << endl;
  } else {
    long long min_median_doubled = sort_A[N / 2 - 1] + sort_A[N / 2];
    long long max_median_doubled = sort_B[N / 2 - 1] + sort_B[N / 2];
    cout << max_median_doubled - min_median_doubled  + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 9824
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
#include<string>
#include<vector>
int mark[152];
using namespace std;
int main(){
    ll int n,m,count=0,i;

    cin>>n>>m;
    ll int num[n+10];

    for(int i=0;i<n;i++) cin>>num[i];

    sort(num,num+n);

    for(i=0;i<n;i++){
        if(m==0||m<num[i]){
            cout<<count<<endl;
            return 0;
        }
        else{

        m-=num[i];
        count++;
        }

    }

    if(m>0) count--;

    cout<<count<<endl;





}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll c;
ld m,h,w,n,i,p=0;
cin>>h>>w>>n;
m=max(h,w);
//cout<<n<<" :"<<m<<endl;
p=ceil(n/m);
if(n==0)
{
    p==0;
}
cout<<p<<endl;

return 0;
}


Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
k1=0
k2=0

if C%B==0:
  k1=C//B
else:
  k1=C//B+1
if A%D==0:
  k2=A//D
else:
  k2=A//D+1
if k1<=k2:
  print("Yes")
else:
  print("No")
      

Measured memory_bytes: 9176
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Main {
	String fileName = "input.txt";
	final boolean isDebug = false;
	//final boolean isDebug = true;
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	final int MOD = (int)1e9+7;
	final long INF = Long.MAX_VALUE / 2;
	//final int INF = Integer.MAX_VALUE / 2;
	
	//System.out.println();はつかわない！！
	void solve() throws Exception{
		int N = in.nextInt(), K = in.nextInt();
		if(K != 1) out.println((N - K));
		else out.println("0");
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}
	
	void m() throws Exception {
		if(isDebug) in = new FastScanner(new FileInputStream(fileName));
		solve();
		out.flush();
	}
	/* end main */
}
/* end Main */

class FastScanner {
	Reader input;

	FastScanner() {this(System.in);}
	FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}
	
	int nextInt() {return (int) nextLong();}

	long nextLong() {
		try {
			int sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			long ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) return ret * sign;
				ret *= 10;
				ret += b - '0';
			}
		} catch (IOException e) {
			e.printStackTrace();
			return -1;
		}
	}

	double nextDouble() {
		try {
			double sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			double ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) break;
				ret *= 10;
				ret += b - '0';
			}
			if (b != '.') return sign * ret;
			double div = 1;
			b = input.read();
			while ('0' <= b && b <= '9') {
				ret *= 10;
				ret += b - '0';
				div *= 10;
				b = input.read();
			}
			return sign * ret / div;
		} catch (IOException e) {
			e.printStackTrace();
			return Double.NaN;
		}
	}

	char nextChar() {
		try {
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			return (char) b;
		} catch (IOException e) {
			e.printStackTrace();
			return 0;
		}
	}

	String nextStr() {
		try {
			StringBuilder sb = new StringBuilder();
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			while (b != -1 && !Character.isWhitespace(b)) {
				sb.append((char) b);
				b = input.read();
			}
			return sb.toString();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
}

Measured memory_bytes: 21460
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

using P=pair<ll,ll>;
void solve(){
  ll n,m,c;
  cin>>n>>m>>c;
  vector<ll>l(c);
  rep(i,c)cin>>l[i];
  vector<P>p(n);
  priority_queue<P>pq;
  rep(i,n){
    cin>>p[i].second>>p[i].first;
    p[i].second--;
    pq.emplace(p[i]);
  }
  ll ans=0;
  int cnt=0;
  while(!pq.empty()){
    auto x=pq.top();
    pq.pop();
    if(l[x.second]>0){
      ans+=x.first;
      ++cnt;
      l[x.second]--;
    }
    if(cnt>=m)break;
  }
  cout<<ans<<endl;
}

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



Measured memory_bytes: 7140
n = int(input())

scores = []
for i in range(1, n+1):
    c, s = input().split()
    scores.append(("{0}{1}{2:03d}".format(c, "0" * (10 - len(c)), 101 - int(s)), i))

for c, ind in sorted(scores):
    print(ind)


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

int main(){
    char c, p;
    int cnt = -2;
    scanf("%c", &c);
    printf("%c", c);
    while(c != '\n'){
        p = c;
        scanf("%c", &c);
        cnt += 1;
    }
    printf("%d%c\n", cnt, p);
    return 0;
}


Measured memory_bytes: 128
N=int(input())
ans=[0]*(N+1)
for x in range(1,int(N**0.5)+2):
  for y in range(1,int(N**0.5)+2):
    for z in range(1,int(N**0.5)+2):
      if x**2+y**2+z**2+x*y+x*z+y*z<=N:
        ans[x**2+y**2+z**2+x*y+x*z+y*z]+=1

for i in range(1,N+1):
  print(ans[i])

Measured memory_bytes: 9656
#### 132_E

import queue
import sys
sys.setrecursionlimit(300000)
 
n,m=map(int,input().split())

edges=[[] for i in range(3*n)]
for _ in range(m):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    u0,u1,u2=u,u+n,u+2*n
    v0,v1,v2=v,v+n,v+2*n
    edges[u0].append(v1)
    edges[u1].append(v2)
    edges[u2].append(v0)
    
s,t=map(int,input().split())
s,t=s-1,t-1
    
def bfs(s,t):
    que=queue.Queue()
    que.put(s)
    d[s]=0
    visit[s]=True
    while not que.empty():
        q=que.get()
        if q==t:
            return d[t]
        for z in edges[q]:
            if visit[z]==False:
                que.put(z)
                d[z]=d[q]+1
                visit[z]=True
    return d[t]
                
visit=[False for _ in range(3*n)]
d=[-1 for _ in range(3*n)]

print(bfs(s,t)//3)

Measured memory_bytes: 105104
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	string s;
	char c[5] = { 'M', 'A', 'R', 'C', 'H' };
	int a[5];
	for (int i = 0; i < 5; ++i) 
		a[i] = 0;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		for (int i = 0; i < 5; ++i)
			if (s[0] == c[i])
				a[i]++;
	}
	int count = 0;
	for (int i = 0; i < 5; ++i) {
		if (a[i] > 0)
			count++;
	}
	long long res = 0;
	for (int i = 0; i<5; ++i)
		for (int j = i + 1; j < 5; ++j)
		{
			long long sum = 0;
			for (int k = j + 1; k < 5; ++k) {
				sum += a[k];
			}
			res += sum * a[i] * a[j];
		}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import heapq

n,m=map(int,input().split())
a=list(map(lambda x: int(x)*-1,input().split()))
heapq.heapify(a)

for _ in range(m):
    Min=heapq.heappop(a)
    Min=(-Min//2)*-1
    heapq.heappush(a,Min)
print(sum(a)*-1)


Measured memory_bytes: 14204
#include <iostream>

using namespace std;

int n, k;
int x[100005], y[100005];
char c[100005];
int dif[4005][3005];
int sum[4005][3005];
int ans[2005][1005];

int main(void)
{
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
	
	for(int i = 0; i < n; i++){
		int X = x[i] % (2*k) + 1, Y = y[i] % (2*k) + 1;
		if(c[i] == 'B'){
			dif[X][Y]++;
			dif[X+k][Y]--;
			dif[X][Y+k]--;
			dif[X+k][Y+k]++;
		}
		else{
			dif[X+k][Y]++;
			dif[X+2*k][Y]--;
			dif[X+k][Y+k]--;
			dif[X+2*k][Y+k]++;
		}
	}
	
	for(int x = 1; x <= 4*k; x++){
		for(int y = 1; y <= 3*k; y++){
			sum[x][y] = sum[x-1][y] + sum[x][y-1] - sum[x-1][y-1] + dif[x][y];
		}
	}
	
	for(int x = 1; x <= 4*k; x++){
		for(int y = 1; y <= 3*k; y++){
			int X = x-1, Y = y-1;
			if((X/k + Y/k) % 2) ans[X%k+k][Y%k] += sum[x][y];
			else ans[X%k][Y%k] += sum[x][y];
		}
	}
	
	int Ans = 0;
	for(int x = 0; x < 2*k; x++){
		for(int y = 0; y < k; y++){
			Ans = max(Ans, ans[x][y]);
		}
	}
	cout << Ans << endl;
	return 0;
}

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

int main(void) {
    int N, A;
    cin >> N >> A;

    int amari;
    amari = N - (500 * (N/500));

    if ((0 <= amari) && (amari <= A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

vector<vector<int>> g;
vector<bool> v;
vector<int64_t> c;
vector<int64_t> p;

void dfs(const int s, int64_t x) {
    if(v[s]) return;
    v[s] = true;
    x += p[s]; c[s] += x;

    for (int elm : g[s]) {
        if(not v[elm]) dfs(elm, x);
    }
}

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

    g.assign(n, vector<int>(0));
    for (auto i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    p.assign(n, 0);
    for (auto i = 0; i < q; i++) {
        int a, b; cin >> a >> b;
        p[a - 1] += b;
    }

    v.assign(n, false);
    c.assign(n, 0);
    dfs(0, 0);

    for (auto i = 0; i < n; i++) {
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25856
#include <cstdio>
using namespace std;
typedef long long int64;
int64 sum[200005];
int64 xorsum[200005];
int main(){
    int i, j, n;
    int64 ans=0;
    
    scanf("%d", &n);
    for(i=1; i<=n; i++){
        scanf("%lld", &sum[i]);
        xorsum[i]=sum[i]^xorsum[i-1];
        sum[i]+=sum[i-1];
    }
    for(i=j=1; i<=n; i++){
        while(j<=n and (sum[j]-sum[i-1])==(xorsum[j]^xorsum[i-1])) j++;
        ans+=j-i;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;

class Main{
  static String s;
  static int n;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    boolean[] ngn=new boolean[10];
    for(int i=0;i<k;i++){
      ngn[sc.nextInt()]=true;
    }
    while(true){
      String gaku=String.valueOf(n);
      boolean flag=true;
      for(int i=0;i<gaku.length();i++){
        if(ngn[gaku.charAt(i)-'0']){
          flag=false;
          break;
        }
      }
      if(flag){
        break;
      }
      n++;
    }
    System.out.println(n);
  }
}

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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  bool a = true;
  for(int i=1;i<=N;i++){
   
    if( S.at(i - 1)  == S.at(N - i) ){
      continue;
    }
    else{
      a = false;
      break;
    }
  }
   for(int i=1;i<=(N-1)/2;i++){
   
    if( S.at(i - 1)  == S.at((N-1)/2 - i) ){
      continue;
    }
    else{
      a = false;
      break;
    }
  }
  
 
  
   
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
 

}


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

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

	int s = N % 10;
	string yomi="aaa";
	if (s == 2 || s == 4 || s == 5 || s == 7 || s == 9) {
		yomi = "hon";
	}
	else if (s == 0 || s == 1 || s == 6 || s == 8) {
		yomi = "pon";
	}
	else if (s==3) {
		yomi = "bon";
	}

	cout << yomi << endl;
}

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

int main() {
	int n;
	cin >> n;
	int s[n];
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		sum += s[i];
	}
	if(sum % 10 != 0) cout << sum << endl;
	else{
		sort(s, s+n);
		int min = sum;
		for(int i = 0; i < n; i++){
			if(min > s[i] && (s[i] % 10) != 0) min = s[i];
		}
		cout << sum - min << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     int n,x,t;
     cin>>n>>x>>t;
     int sum=n/x+(n%x>0?1:0);
     cout<<sum*t;

}

signed main()
{
        FIO
        // #ifndef ONLINE_JUDGE
        //   freopen("input.txt","r",stdin);
        //   freopen("output.txt","w",stdout);
        // #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
#include <cmath>
using namespace std;
#define ll long long 
const ll MOD = 1e9 + 7;
 
vector<int> graph[100005];
ll dp[100005] = {0}; 
 
ll dfs(int cur_node){
    if (dp[cur_node] != -1)
        return dp[cur_node];
    if (graph[cur_node].empty())
        return 0;
    for (auto x: graph[cur_node]) {
        dp[cur_node] = max(dp[cur_node], 1 + dfs(x));
    }
    return dp[cur_node];
}
 
int main()
{
    int N, M;
    cin >> N >> M;
    for (int i=0; i<M; ++i) {
        int src, dst;
        cin >> src >> dst;
        graph[src].push_back(dst);
    }
    // Create an imaginary vertex which is connected to every vertex in graph and consider this as the starting point.
    for (int i=1; i<=N; ++i)
        graph[0].push_back(i);
     
    fill(dp, dp+100005, -1);
    // dfs(0);    
    
    // int max = 0;
    // for (int i=0; i<=N; ++i) {
    //     if (dp[i] > max) {
    //         max = dp[i];
    //     }
    // }
    // -1 is done to compensate for the path from fake vertex to every other vertex.
    cout << dfs(0) - 1;    
    
    return 0;
}

Measured memory_bytes: 8440
n = int(input())
a_lst = [int(input()) for i in range(n)]

new_lst = list(set(a_lst))
new_lst.sort()

if len(new_lst)==1:
    for _ in range(n):
        print(new_lst[-1])

else:
    maximum = new_lst[-1]
    semi_maximum = new_lst[-2]
    count = a_lst.count(maximum)

    for i in range(n):
        a = a_lst[i]

        if a==maximum:
            if count==1:
                print(semi_maximum)
            elif count>1:
                print(maximum)
        elif a<maximum:
            print(maximum)

Measured memory_bytes: 17164
n,m = map(lambda x: int(x),input().split())
err = 0
ans_count = 0

dict = {}
dict_err = {}
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if not (p in dict.keys()) :
        dict[p] = s
        if s == 'WA' :
            dict_err[p] = 1
        elif s == 'AC' :
            ans_count += 1

    elif (p, 'WA') in dict.items() and s == 'WA':
        err = dict_err[p] + 1
        dict_err[p] = err
    elif (p, 'WA') in dict.items() and s == 'AC':
        dict[p] = s
        ans_count += 1

for i,j in dict.items() :
    if j == 'WA' :
        dict_err.pop(i)
print(ans_count,sum(dict_err.values()))


Measured memory_bytes: 19940
def m():
    n = int(input())
    L = 32
    a = [0] * L
    b = [0] * L
    b[0], b[1] = 1, -2
    ans = ["0"] * L
    for i in range(L):
        a[i] = (-2) ** i

    for i in range(2, L):
        b[i] = a[i] + b[i-2]
    
    def solve(p):
        if p == 0:
            return
        if p < 0:
            for j in range(1, L, 2):
                if p >= b[j]:
                    p -= a[j]
                    ans[j] = "1"
                    solve(p)
                    break
        else:
            for j in range(0, L, 2):
                if p <= b[j]:
                    p -= a[j]
                    ans[j] = "1"
                    solve(p)
                    break
    solve(n)
    ans.reverse()
    return int("".join(ans))


print(m())

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

using namespace std;

int a, b;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+";
    } else if (a * b == 15) {
        cout << "*";
    } else {
        cout << "x";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
const int inf = 0x3f3f3f3f;
const int MAXN = 2e5 + 10;
#define LOCAL

int a[MAXN];

int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	int t;
	cin >> t;
	rep(i, t) {
		cin >> a[i];
	}
	sort(a, a + t, greater<int>());
	std::vector<int> v;
	v.push_back(a[0]);
	for (int i = 1; i < t; i++) {
		v.push_back(a[i]);
		v.push_back(a[i]);
	}
	ll ans= 0;
	rep(i, t - 1) {
		ans += v[i];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6076
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
int len;
string s, t, s2, t2, t3, t4;
int main ()
{
    cin >> s;
    len = s.size();
    if(len % 2 == 0) cout << "No" << endl;
    else
    {
        t = s;
        reverse(t.begin(), t.end());
        if(s != t)
        {
            cout << "No" << endl;
            exit(0);
        }
        t = s.substr(0, (len-1)/2);
        ///show(t);
        t2 = t;
        reverse(t2.begin(), t2.end());
        if(t != t2)
        {
            cout << "No" << endl;
            exit(0);
        }
        t3 = s.substr(((len+3)/2)-1);
        ///show(t3);
        t4 = t3;
        reverse(t4.begin(), t4.end());
        if(t3 != t4)
        {
            cout << "No" << endl;
            exit(0);
        }
        cout << "Yes" << endl;
    }
}


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

int main()
{
	int n,x,a[101],ans=1,d[101];
	cin>>n>>x;
	d[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		d[i+1]=d[i]+a[i];
		if(d[i+1]<=x)
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void search(int n,int m){
  int h[2000],w[2000];

  rep(i,n){
    cin>>h[i];
  }
  rep(i,m){
    cin>>w[i];
  }

  map<int,int> a,b;

  rep(i,n){
    int sum=0;
    FOR(j,i,n){
      sum+=h[j];
      a[sum]++;
    }
  }
  rep(i,m){
    int sum=0;
    FOR(j,i,m){
      sum+=w[j];
      b[sum]++;
    }
  }

  int ans=0;

  for(auto itr=a.begin();itr!=a.end();itr++){
    ans += itr->second*b[itr->first];
  }

  cout<<ans<<endl;

}




int main(){
  int n,m;

  while(1){
    cin>>n>>m;
    if(n==0) break;

    search(n,m);
  }

  return 0;
}



Measured memory_bytes: 34372
#include<iostream>
using namespace std;
typedef long long ll;

ll a[100001];

int main() {
    int N;
    ll x, count = 0;
    cin >> N >> x;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] <= x) continue;
        else {
            ll sub_num = (a[i] + a[i + 1]) - x;
            count += sub_num;
            if (sub_num <= a[i + 1]) a[i + 1] -= sub_num;
            else {
                sub_num -= a[i + 1];
                a[i + 1] = 0;
                a[i] -= sub_num;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    string s1 , s2;
    cin >> s1 >> s2;

    int count = 0;


    for(int i=0; i<s2.length(); i++)
    {
        if(s2[i]==s1[i])
            count++;
    }

    cout << count << endl;





    return 0;
}



Measured memory_bytes: 256
n, *a = gets().split(' ').map(&:to_i)

l = []
n.times {|i|
	l[i] = gets().to_i
}

mp_min = 9999
for i in 0 ... (1 << (n * 2))
	g = [[], [], []]
	gi = []
	gcount = [0, 0, 0, 0]
	for j in 0 ... n
		k = ((i >> (j * 2)) & 3)
		g[k].push(l[j]) if k < 3
		gi[j] = k
		gcount[k] += 1
	end
	next if gcount[0] == 0 || gcount[1] == 0 || gcount[2] == 0

	mp = 0
	g.each_with_index {|ge, ii|
		mp += (ge.length - 1) * 10 + (ge.inject(0, &:+) - a[ii]).abs
	}
	mp_min = mp if mp_min > mp
end

puts mp_min


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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 namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

int n;
set<string> ans;

void dfs(string str, char maxch) {
  if (str.size() == n) {
    cout << str << endl;
    return;
  }

  for (char ch = 'a'; ch <= maxch; ch++) {
    if (ch == maxch) dfs(str + ch, maxch + 1);
    else dfs(str + ch, maxch);
  }
}

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  cin >> n;
  dfs("", 'a');
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
const ll MOD=998244353;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

int main()
{
        io;
        //////////////////////////////////
        ll n,i,j,k;
        vll v(5,0);
        for(i=0;i<5;i++)
        {
            cin>>v[i];
        }
        for(i=0;i<5;i++)
        {
            if(v[i]==0) 
            {
                cout<<i+1; return 0;
            }
        }
        //////////////////////////////////
        cer;
}

Measured memory_bytes: 3580
open Printf
open Scanf

let id x = x
let pair x y = x, y

let s, t = scanf "%s %s" pair
let n = String.length s

let t = String.uppercase t

let tbl = Hashtbl.create 50

let swap c1 c2 s =
  String.iteri (fun i c -> if c = c1 then s.[i] <- '*') s;
  String.iteri (fun i c -> if c = c2 then s.[i] <- c1) s;
  String.iteri (fun i c -> if c = '*' then s.[i] <- c2) s

let () =
  for i = 0 to n - 1 do
    if not (Hashtbl.mem tbl s.[i]) then begin
      Hashtbl.add tbl s.[i] true;
      swap s.[i] t.[i] s
    end
  done;
  print_endline @@ if s = t then "Yes" else "No"


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;
string s;
vector<VL> G;
vector<map<char, ll>> cnt;

const ll NMAX = 1e6;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modmul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }

signed main() {
    cin >> N;
    cominit();
    ll ans = 0, pre = 0;
    FOR(k, (N + 1) / 2, N) {
        ll tmp = modmul(modmul(fac[k], fac[N - k - 1]), comb(k - 1, N - k - 1));
        (ans += modmul(tmp - pre + MOD, k)) %= MOD;
        pre = tmp;
    }
    cout << ans << "\n";
}

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

int main()
{
    int m, f, r;
    char g;
    
    while (true) {
        scanf("%d %d %d", &m, &f, &r);
        if (m == -1 and f == -1 and r == -1) break;
        
        if (m == -1 or f == -1) g = 'F';
        else if (m + f >= 80) g = 'A';
        else if (m + f >= 65) g = 'B';
        else if (m + f >= 50) g = 'C';
        else if (m + f >= 30) {
            if (r >= 50) g = 'C';
            else g = 'D';
        }
        else g = 'F';
        
        printf("%c\n", g);
    }
}



Measured memory_bytes: 3204
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int all = 100 * r + 10 * g + b;
        System.out.println(all % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
 int i,f,n;
 f=0;
 cin >> n;
 while(f==0)
 {
  f=1;
  for(i=2;i<=sqrt(n);i++)
  {
   if(n%i==0)
   {
    f=0;
    break;
   }
  }
  n++;
 }
 cout << --n;
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();

		long sum = 0;
		long lt = 0;
		for( int i=0 ; i< (1<<(n-1)) ; i++ ) {
			int bit = i;
			lt = (s.charAt(0)-'0');
			for( int j=1 ; j<n ; j++) {
				if( (bit&1) == 0 ) {
					lt = lt*10 + (s.charAt(j)-'0');
				} else {
					sum += lt;
					lt = (s.charAt(j)-'0');
				}
				bit >>= 1;
			}
			sum += lt;
		}
		
		System.out.println(sum);
	}
		

}



Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10 ** 9)


def func(v, c):
    for next_v, w in graph[v]:
        if color[next_v] == -1:
            color[next_v] = (c + w) & 1
            func(next_v, c + w) 

n = int(input())
graph = [[] for _ in range(n)]
color = [-1] * n

for _ in range(n-1):
    u, v, w = map(int, sys.stdin.readline().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))


color[0] = 0
func(0, 0)

for i in color:
    print(i)


Measured memory_bytes: 159920
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int c = Math.abs(x - a);
		int d = Math.abs(x - b);
		
		if (c < d) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}

Measured memory_bytes: 21716
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=5010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,K,a[N],res,f[N];
signed main()
{
    n=read(), K=read();
    for(ri int i=1;i<=n;i++) a[i]=read(), res+=a[i];
    sort(a+1,a+1+n);
    f[0]=1;
    for(ri int i=n;i;i--)
    {
        int qwq=1;
        for(ri int j=0;j<K;j++) if(f[j]&&j>=K-res) { qwq=0; break; }
        if(qwq) { printf("%lld\n",i); return 0; }  
        for(ri int j=K-1;~j;j--) if(j>=a[i]) f[j]|=f[j-a[i]];
        res-=a[i];
    }
    puts("0");
    return 0;
}

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

const int mx = 2e3 , INF = 1e9 ;

int h , w , S[mx][mx] ;

using pii = pair<int,int> ;

pii C , D ;

struct shortest_path
{
    int djikstra()
    {
        int d[mx][mx] ;
        for(int i = 0 ; i <= h + 5 ; ++i)
        {
            for(int j = 0 ; j <= w + 5 ; ++j)
            {
                d[i][j] = INF ;
            }
        }
        d[C.first][C.second] = 0 ;
        priority_queue<pair<int,pii> , vector<pair<int,pii> >, greater<pair<int,pii> > > q ;
        q.push({0,C}) ;
        while(!q.empty())
        {
            pii v = q.top().second ;
            int d_v = q.top().first ;
            q.pop() ;
            if(d_v!=d[v.first][v.second]) continue ;
            for(int i = -1 ; i <= 1 ; ++i)
            {
                for(int j = -1 ; j <= 1 ; ++j)
                {
                    if(abs(i)==abs(j)) continue ;
                    pii to = {v.first+i,v.second+j} ;
                    if(to.first>h || to.second>w || to.first<1 || to.second<1 || !S[to.first][to.second]) continue ;
                    if(d[v.first][v.second]<d[to.first][to.second])
                    {
                        d[to.first][to.second] = d[v.first][v.second] ;
                        q.push({d[to.first][to.second],to}) ;
                    }
                }
            }
            for(int i = -2 ; i <= 2 ; ++i)
            {
                for(int j = -2 ; j <= 2 ; ++j)
                {
                    pii to = {v.first+i,v.second+j} ;
                    if(to.first>h || to.second>w || to.first<1 || to.second<1 || !S[to.first][to.second]) continue ;
                    if((d[v.first][v.second] + 1) < d[to.first][to.second])
                    {
                        d[to.first][to.second] = d[v.first][v.second] + 1 ;
                        q.push({d[to.first][to.second],to}) ;
                    }
                }
            }
        }
        if(d[D.first][D.second]==INF) return -1 ;
        else return d[D.first][D.second] ;
    }
};

int main()
{
    scanf("%d%d",&h,&w) ;
    scanf("%d%d",&C.first,&C.second) ;
    scanf("%d%d",&D.first,&D.second) ;
    for(int i = 1 ; i <= h ; ++i)
    {
        string s ;
        cin>>s ;
        for(int j = 0 ; j < w ; ++j)
        {
            if(s[j]=='.') S[i][j+1] = 1 ;
        }
    }
    shortest_path pq ;
    printf("%d\n",pq.djikstra()) ;
    return 0 ;
}


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

using namespace std;

typedef long long ll;

ll loN, highN, K, A[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> K;
	for (int i = 1; i <= K; ++i){
		cin >> A[i];
	}
	loN = highN = 2;
	for (int i = K; i >= 1; --i){
		//cout << loN << ' ' << highN << '\n';
		loN = ((loN+A[i]-1)/A[i])*A[i];
		highN = ((highN/A[i])*A[i]+A[i]-1);

		if (highN < loN){
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << loN << ' ' << highN << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
	vector<unsigned long long>Factorial(100001);
	Factorial.at(1) = 1;
	for (int i = 2; i <= 100000; i++) {
		Factorial.at(i) = Factorial.at(i - 1) * i % 1000000007;
	}
	long long N, M;
	cin >> N >> M;
	if (abs(N - M) >= 2) {
		cout << 0 << endl;
	}
	else {
		if (N == M)cout << 2 * 
			Factorial.at(N) * Factorial.at(M) % 1000000007 << endl;
		else cout << Factorial.at(N) * Factorial.at(M) % 1000000007 << endl;
	}
}

Measured memory_bytes: 1024
import math
import copy

n=int(input())
a=11
l=[]
while a<=55555:
    flag=True
    b=copy.deepcopy(a)
    a+=10
    for i in range(2,math.floor(math.sqrt(a))+1):
        if b%i==0:
            flag=False
    if flag:
        l.append(b)
    if len(l)==n:
        break
for i in range(n):
    print(l[i],end=' ')

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;
class Main
{
	 public static void  main (String[] args) throws IOException
    {
       try{
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       int a=0;
       a=Integer.parseInt(br.readLine());
       	int n[][]=new int[a][2];
       	for(int i=0;i<n.length;i++)
       	{
       	  String c[]=br.readLine().split(" ");
           n[i][0]=Integer.parseInt(c[0]);
           n[i][1]=Integer.parseInt(c[1]);
       	}
       	boolean b=false;
       	for(int i=0;i<n.length-2;i++)
       	{
       		if(n[i][0]==n[i][1]&&n[i+1][0]==n[i+1][1]&&n[i+2][0]==n[i+2][1])
       		{
       			System.out.println("Yes");
       			b=true;
       			break;
       		}
       	}
       	if(b==false)
       	{
       		System.out.println("No");
       	}
       	}
    catch(Exception e){}
}}


Measured memory_bytes: 32816
A = int(input())
B = int(input())
C = int(input())

X = int(input())

judg = 0

for i in range(A+1):
    a = 500 * i
    for ii in range(B+1):
        b = 100 * ii
        for iii in range(C+1):
            c =  50 * iii
            if a + b + c == X:
                judg += 1
            sum = 0

print(judg)            



Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:https://www.ioi-jp.org/joi/2008/2009-yo-prob_and_sol/2009-yo-t4/2009-yo-t4.html>
ñ‚ëËï∂============================================================
ì~ÇÃä¶Ç¢Ç†ÇÈì˙ÅCJOIëæòYåNÇÕçLèÍÇ…ÇÕÇ¡ÇΩîñïXÇäÑÇ¡ÇƒóVÇ‘Ç±Ç∆Ç…ÇµÇΩÅD
çLèÍÇÕí∑ï˚å`Ç≈ÅC ìåêºï˚å¸Ç… m å¬ÅC ìÏñkï˚å¸Ç… n å¬ÅC Ç¬Ç‹ÇËÅC m Å~ n ÇÃãÊâÊÇ…ãÊêÿÇÁÇÍÇƒÇ¢ÇÈÅD
Ç‹ÇΩÅC îñïXÇ™óLÇÈãÊâÊÇ∆ñ≥Ç¢ãÊâÊÇ™Ç†ÇÈÅD JOIëæòYåNÇÕÅCéüÇÃÉãÅ[ÉãÇ…ÇµÇΩÇ™Ç¡ÇƒÅCîñïXÇäÑÇËÇ»Ç™ÇÁãÊâÊÇà⁄ìÆÇ∑ÇÈÇ±Ç∆Ç…ÇµÇΩÅD
îñïXÇ™Ç†ÇÈÇ«ÇÃãÊâÊÇ©ÇÁÇ‡îñïXÇäÑÇËénÇﬂÇÈÇ±Ç∆Ç™Ç≈Ç´ÇÈÅD
ìåêºìÏñkÇÃÇ¢Ç∏ÇÍÇ©ÇÃï˚å¸Ç…ó◊ê⁄ÇµÅC Ç‹ÇæäÑÇÁÇÍÇƒÇ¢Ç»Ç¢îñïXÇÃÇ†ÇÈãÊâÊÇ…à⁄ìÆÇ≈Ç´ÇÈÅDà⁄ìÆÇµÇΩêÊÇÃãÊâÊÇÃîñïXÇÇ©Ç»ÇÁÇ∏äÑÇÈÅD
JOIëæòYåNÇ™îñïXÇäÑÇËÇ»Ç™ÇÁà⁄ìÆÇ≈Ç´ÇÈãÊâÊêîÇÃç≈ëÂílÇãÅÇﬂÇÈÉvÉçÉOÉâÉÄÇçÏê¨ÇπÇÊÅD
ÇΩÇæÇµÅC 1 ÅÖ m ÅÖ 90ÅC1 ÅÖ n ÅÖ 90 Ç≈Ç†ÇÈÅD ó^Ç¶ÇÁÇÍÇÈì¸óÕÉfÅ[É^Ç≈ÇÕÅC à⁄ìÆï˚ñ@ÇÕ20ñúí ÇËÇí¥Ç¶Ç»Ç¢ÅD
=================================================================
âê‡=============================================================
ñ‚ëËï∂Ç…Ç‡Ç†ÇÈÇÊÇ§Ç…à⁄ìÆï˚ñ@ÇÕ20ñúí ÇË(2*10^6)Çí¥Ç¶Ç»Ç¢ÇÁÇµÇ¢ÇÃÇ≈,Ê√ó~Ç…êîÇ¶è„Ç∞ÇÈ
ìûíBçœÇÃÉtÉâÉOä«óùîzóÒÇÕÅAÇ§Ç‹Ç≠égÇ¶ÇŒÇPÇ¬Ç≈ëSÇƒégÇ¢Ç‹ÇÌÇ∑Ç±Ç∆Ç™â¬î\
================================================================
*/
vector<vector<int>> masu;
vector<vector<int>> checked;

int dy[4] = { 1,0,-1,0 };
int dx[4] = { 0,1,0,-1 };
ll dfs(ll x, ll y, ll dep) {
	ll res = dep;
	for (int i = 0; i < 4;i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (masu[nx][ny] == 0) continue;
		if (checked[nx][ny] == 1)continue;
		checked[nx][ny] = 1;
		res = max(res, dfs(nx, ny, dep + 1));
		checked[nx][ny] = 0;
	}
	return res;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll m, n;
    while(cin >> m >> n,m){
	masu.assign(n + 2, vector<int>(m + 2, 0));
	checked.assign(n + 2, vector<int>(m + 2, 0));
	for (int i = 1; i <= n;i++) for (int j = 1; j <= m;j++) cin >> masu[i][j];
	ll res = 0;
	for (int i = 1;i <= n;i++) {
		for (int j = 1; j <= m;j++) {
			if (masu[i][j] == 0)continue;
			checked[i][j] = 1;
			res = max(res, dfs(i, j, 1));
			checked[i][j] = 0;
		}
	}
	cout << res << endl;
    }
	return 0;
}



Measured memory_bytes: 3240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    static class edge {
        int from, to, cost;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int v = Integer.parseInt(str[0]);
        int e = Integer.parseInt(str[1]);
        int r = Integer.parseInt(str[2]);

        edge[] es = new edge[e];
        for (int i = 0; i < e; i++) {
            str = br.readLine().split(" ");
            edge ed = new edge();
            ed.from = Integer.parseInt(str[0]);
            ed.to = Integer.parseInt(str[1]);
            ed.cost = Integer.parseInt(str[2]);

            es[i] = ed;
        }

        long[] distance = new long[v];
        Arrays.fill(distance, Long.MAX_VALUE);
        distance[r] = 0;
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < e; j++) {
                edge ed = es[j];
                if (distance[ed.from] != Long.MAX_VALUE)
                    distance[ed.to] = Long.min(distance[ed.to], distance[ed.from] + ed.cost);
            }
        }

        boolean update = false;
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < e; j++) {
                edge ed = es[j];
                if (distance[ed.from] != Long.MAX_VALUE) {
                    if(distance[ed.to] > distance[ed.from] + ed.cost){
                        distance[ed.to] = distance[ed.from] + ed.cost;
                        update = true;
                    }
                }
            }
            if (update) break;
        }

        if (update) {
            System.out.println("NEGATIVE CYCLE");
        } else {
            for (int i = 0; i < distance.length; i++) {
                if (distance[i] == Long.MAX_VALUE) {
                    System.out.println("INF");
                } else {
                    System.out.println(distance[i]);
                }
            }
        }
    }
}

Measured memory_bytes: 28264
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	vector<int>a;//入力
	int x = 0, n;
	int i = 0, j = 0, in; //内部で使用;
	int ans = 0; //出力

	cin >> n;
	while (cin >> in) {
		a.push_back(in);
	}

	rep(i, n) {
		while (a[j] != i + 1) {
			j++;
		}
		cout << j+1 <<" " ;
		j = 0;
	}
	cout << "\n";
}



Measured memory_bytes: 1400
#include <cstdio>

main(){
  int dp[2][11];
  char c;
  while(scanf("%c", &c) != EOF && c != '0'){
    for(int i=0;i<11;i++) dp[0][i] = 0;
    int ans = 0;
    dp[0][c-'0'] = 1;
    for(int i=0;scanf("%c", &c)&&c!='\n';++i){
      int ct = i%2, nt = (i+1)%2;
      for(int j=0;j<11;++j) dp[nt][j] = 0;
      if(c != '0') dp[nt][c-'0'] += 1;
      for(int j=0;j<11;++j) dp[nt][(j*10+c-'0')%11] += dp[ct][j];
      ans += dp[nt][0];
    }
    printf("%d\n", ans);
  }
}

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

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

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

int main()
{
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  ll CC = B / C - A / C;
  ll DD = B / D - A / D;
  ll CD = lcm(C, D);
  ll CDCD = B / CD - A / CD;

  cout << (B - A) - (CC + DD) + (CDCD) << endl;
}

Measured memory_bytes: 256