akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int j=n;
    while (1)
    {
        int k=0;
        for (int i=2;i*i<=n;i++)
        {
            if (j%i==0)
            {
                k=1;
                break;
            }
        }
        if (k==0)
        {
            break;
        }
        j++;
    }
    cout<<j;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D;
int main()
{
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(A+B==C+D)
		printf("Balanced");
	else if(A+B>C+D)
		printf("Left");
	else
		printf("Right");
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
//head

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

    ll n;
    cin >> n;

    ll ans = 0;
    if(n&1) {
        cout << 0 << endl;
    } else {
        ll p = 10;
        while(n / p != 0) {
            ans += (n / p);
            p *= 5;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
struct node{
    int ind;
    long long num;
    bool operator<(const node &tp)const{
        return num<tp.num;
    }
};
long long ans;
int n;
long long a[200020]={0};
long long b[200020]={0};
priority_queue<node>q;
int update(node t){
    long long num=b[(t.ind+1)%n]+b[(t.ind-1+n)%n];
    if(t.num-a[t.ind]<num)
        return 0;
    ans+=1ll*(t.num-a[t.ind])/num;
    t.num=(t.num-a[t.ind])%num+a[t.ind];
    b[t.ind]=t.num;
    if(t.num>a[t.ind]){
        q.push(t);
    }
    else if(t.num<a[t.ind])
        return 0;
    return 1;
}
int main()
{
    ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
        if(b[i]!=a[i])
        q.push({i,b[i]});
    }
    int flag=1;
    while(!q.empty()){
        if(q.top().num>a[q.top().ind]){
            flag=update(q.top());
            q.pop();
            if(!flag){
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> s(n);
    rep(i,n) cin>>s[i];
    ll res=0;
    rep(i,n) res+=s[i];
    if(res%10!=0) cout<<res<<endl;
    else{
        sort(s.begin(), s.end());
        rep(i,n){
            if(s[i]%10!=0){
                cout<<res-s[i]<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<" = "<<x<<endl
using namespace std;

typedef long long ll;
ll x,k,d;

int main()
{
	cin>>x>>k>>d;
	x=abs(x);
	ll tmp=x/d,ans=1000000000000000;
	if(tmp>=k) ans=x-k*d;
	else 
	{
		if((k-tmp)&1) ans=abs(x-(tmp+1)*d);
		else ans=x-tmp*d;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3760
#include<vector>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

const int MX = 100005;

typedef long long ll;
typedef pair<int,int> pii;

vector<int> T[MX];
int N, K;

int dfs(int x, int p, int l = 0){
	if( l > K/2 ) return 0;
	int cnt = 1;
	for(int c : T[x]){
		if( c == p ) continue;
		cnt += dfs(c, x, l+1);
	}
	return cnt;
}

int main()
{
	scanf("%d%d", &N, &K);
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		T[a].push_back(b);
		T[b].push_back(a);
	}
	int ans = 0;
	if( K%2 == 1){
		for(int i = 1; i <= N; i++){
			for(int c : T[i]){
				ans = max(ans, dfs(i, c) + dfs(c, i));
			}
		}
	}
	else{
		for(int i = 1; i <= N; i++){
			ans = max(ans, dfs(i, -1));
		}
	}
	printf("%d\n", N-ans);
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
//bitset<365> a;const double PI = acos(-1);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
  ll N;
  cin >> N;
  vector<ll> height(N);
  vector<ll> dp(N);
  for(auto &it:height) cin >> it;
  dp[0] = 0;
  dp[1] = abs(height[1] - height[0]);
  for(ll i = 2; i < N; ++i)
    dp[i] = min(dp[i - 1] + abs(height[i - 1] - height[i]), dp[i - 2] + abs(height[i - 2] - height[i]) );
  cout << dp[N - 1] << endl;
}


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

typedef long long ll;
int main(){
    ll k; cin>> k;
    if(k % 2 == 0 || k % 5 == 0){
        cout<< -1 << "\n";
        return 0;
    }
    ll mod = k*9;
    ll res = 7*10;
    ll cnt = 1;
    while(res % mod != 7){
        cnt++;
        res = res * 10 % mod;
    }
    cout<< cnt << "\n";
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<>();
    int sum = 0;
    int res;
    for (int i = 0; i < n; i++) {
      int hoge = sc.nextInt();
      sum += hoge;
      list.add(hoge);
    }
    res = list.size();
    for (int i: list) {
      if (i < (sum+4*m-1) / (4*m)) res--;
    }
    if (res >= m) System.out.println("Yes");
    else System.out.println("No");
    sc.close();
  }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b;

        a = sc.nextInt();
        b = sc.nextInt();

        if(a < b) System.out.println("a < b");
        else if(a > b) System.out.println("a > b");
        else System.out.println("a == b");

        sc.close();
    }
}


Measured memory_bytes: 26124
#include<cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	double sum=0;
	for(int i=1;i<=n;i++){
		double num;
		scanf("%lf",&num);
		sum+=1.0/num;
	}
	printf("%.6lf",1.0/sum);
	return 0;
}

Measured memory_bytes: 128
n, x = map(int, input().split())
array = [int(x) for x in input().split()]

array = sorted(array)
cnt = 0
for i in range(len(array)):
    if x >= array[i]:
        if len(array)-1 == i and x != array[i]:
            break
        cnt += 1
        x -= array[i]
    else:
        break
print(cnt if x == 0 else cnt)


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
 int s, m, h;
 scanf("%d", &s);

 m = 0;
 h = 0;

 if (s / (60 * 60) > 0) {
  h = s / (60 * 60);
  s = s % (60 * 60); 
  }

 if (s / 60 > 0) {
  m = s / 60;
  s = s % 60;
 }

 printf("%d:%d:%d\n", h, m, s);
 return 0;
}

Measured memory_bytes: 1780
import Data.List

main=do
    [a,b,c,x,y] <- map read.words<$>getLine
    print $ minimum $ if x > y
        then [a*x+b*y, c*2*y+(x-y)*a, x*2*c]
        else [a*x+b*y, c*2*x+(y-x)*b, y*2*c]

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
  
int main () {
    double a,b,c,s,l;
    cin >> a >> b >> c;
    s=a*b*sin(2*M_PI*c/360)/2;
    l=a+b+sqrt(a*a+b*b-2*a*b*cos(2*M_PI*c/360));
    cout  << setprecision(20) << s << endl << l <<  endl <<2*s/a << endl;
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int INF = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    VI a(N);
    int sum = 0;
    REP(i,N)
    {
        cin >> a[i];
        sum += a[i];
    }
    double ave = double(sum) / N;
    dump(ave)
    int resnum = 0;
    double dist = double(INF);
    REP(i,N)
    {
        double tmp = abs(a[i] - ave);
        dump(tmp)
        if(dist > tmp) 
        {
            dist = tmp;
            resnum = i;
        }
    }
    cout << resnum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	A--, B--, C--, D--;
	int rA = A, rB = B;
	while(true) {
		if(rA < N-1 && S[rA+1] == '.') rA++;
		else if(rA < N-2 && S[rA+2] == '.') rA += 2;
		else break;
	}
	while(true) {
		if(rB < N-1 && S[rB+1] == '.') rB++;
		else if(rB < N-2 && S[rB+2] == '.') rB += 2;
		else break;
	}
	if(rA < C || rB < D) {
		cout << "No\n";
		return 0;
	}
	if(C < D) {
		cout << "Yes\n";
		return 0;
	}
	for(int i = B; i <= D; i++) if(S[i] == '.' && S[i-1] == '.' && S[i+1] == '.') {
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 592
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
string A,B;
ll M;
ll dp[2][2][4][10][1000];
ll mod = 10000;
int main(){
	cin >> A >> B;
	cin >> M;

	ll n = B.length();

	dp[0][0][0][0][0] = 1;

	REP(i,n) {
		REP(j,2) {
			REP(k,4) {
				REP(l,10) {
					REP(m,M) {
						ll lim = (j ? 9 : B[i] - '0');
						REP(d,lim + 1) {
							if(k == 0) {
								if(d == 0) {
									(dp[1][j || d < lim][0][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
									continue;
								}
								(dp[1][j || d < lim][1][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 1) {
								if(d == l) {
									continue;
								}
								ll e = 2 + (d > l);
								(dp[1][j || d < lim][e][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 2) {
								if(d <= l) {
									continue;
								}
								(dp[1][j || d < lim][3][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 3) {
								if(d >= l) {
									continue;
								}
								(dp[1][j || d < lim][2][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}
						}
					}
				}
			}
		}
		REP(j,2) {
			REP(k,4) {
				REP(l,10) {
					REP(m,M) {
						dp[0][j][k][l][m] = dp[1][j][k][l][m];
						dp[1][j][k][l][m] = 0;
					}
				}
			}
		}
	}
	ll ans = 0;
	REP(j,2) {
		REP(k,4) {
			REP(l,10) {
				(ans += dp[0][j][k][l][0]) %= mod;
			}
		}
	}


	n = A.length();

	REP(j,2) {
		REP(k,4) {
			REP(l,10) {
				REP(m,M) {
					dp[0][j][k][l][m] = 0;
					dp[1][j][k][l][m] = 0;
				}
			}
		}
	}
	dp[0][0][0][0][0] = 1;

	REP(i,n) {
		REP(j,2) {
			REP(k,4) {
				REP(l,10) {
					REP(m,M) {
						ll lim = (j ? 9 : A[i] - '0');
						REP(d,lim + 1) {
							if(k == 0) {
								if(d == 0) {
									(dp[1][j || d < lim][0][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
									continue;
								}
								(dp[1][j || d < lim][1][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 1) {
								if(d == l) {
									continue;
								}
								ll e = 2 + (d > l);
								(dp[1][j || d < lim][e][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 2) {
								if(d <= l) {
									continue;
								}
								(dp[1][j || d < lim][3][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}else if(k == 3) {
								if(d >= l) {
									continue;
								}
								(dp[1][j || d < lim][2][d][(m * 10 + d) % M] += dp[0][j][k][l][m]) %= mod;
							}
						}
					}
				}
			}
		}
		REP(j,2) {
			REP(k,4) {
				REP(l,10) {
					REP(m,M) {
						dp[0][j][k][l][m] = dp[1][j][k][l][m];
						dp[1][j][k][l][m] = 0;
					}
				}
			}
		}
	}

	REP(k,4) {
		REP(l,10) {
			(ans += mod - dp[0][1][k][l][0]) %= mod;
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 4380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector <int> x(N);
  for (int i = 0; i < N; i++) cin >> x[i];
  
  int ans = 2000000000;
  for (int i = 0; i <= N-K; i++) {
		int a = abs(x[i]);
		int b = x[i+K-1];
		int c = abs(x[i]-x[i+K-1]);
    ans = min(ans, abs(x[i])+abs(x[i]-x[i+K-1]));
		ans = min(ans, abs(x[i+K-1])+abs(x[i]-x[i+K-1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
#define M(x) memset(x,0,sizeof(x))
#define dalao main
using namespace std;
ll n,a[200005],leftmax[200005],ans=0;
int dalao()
{
    ios::sync_with_stdio(false);
    cin>>n;
    leftmax[0]=-1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        leftmax[i]=max(leftmax[i-1],a[i]);//leftmax:包括自己和左边在内的max
    }
    for(int i=2;i<=n;i++)
    {
        if(a[i]<leftmax[i-1])
            ans+=leftmax[i-1]-a[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines;
      int x,y;

      while (true) {
        lines = br.readLine().split(" ");
        x = Integer.parseInt(lines[0]);
        y = Integer.parseInt(lines[1]);

        if(x==0 && y==0){ break; }

        if (x < y) {
          System.out.println(x + " " + y);
        } else {
          System.out.println(y + " " + x);
        }
      }
    }
  }
}


Measured memory_bytes: 27288
from collections import *

def dfs(l):
    if len(l)==N:
        print(''.join(l))
        return
    
    for a in range(ord('a'), ord(max(l))+2):
        l.append(chr(a))
        dfs(l)
        l.pop()
    
N = int(input())
dfs(deque(['a']))

Measured memory_bytes: 79212
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, a, len = 1;
	cin >> n >> a;
	int dp[100000];
	fill_n(dp, 100000, INT_MAX / 2);
	dp[0] = a;
	for (int i = 1; i < n; i++) {
		cin >> a;
		if (dp[len-1] < a) {
			dp[len++] = a;
		} else {
			int j = len - 1;
			for (; j >= 0; j--)
				if (dp[j] < a)
					break;
			dp[j+1] = a;
		}
	}
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 1552
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<i64> a(n);
	i64 sum = 0;
	for (auto& v : a)
	{
		cin >> v;
		sum += v;
	}

	i64 ans = INF, left = 0;
	REP(i, n)
	{
		left += a[i];
		if (i + 1 < n)
			ans = min(ans, abs(sum - 2 * left));
		if (ans == 0)
			break;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)

int n, A[1111111];
int main() {
	cin >> n;
	For(i,1,n) scanf("%d", &A[i]);
	int ans = 0;
	For(i,1,n) if (A[A[i]] == i && i < A[i]) ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n = input()
A = [int(i) for i in input().split()]

odd_flag = False
count = 0
while True:
    for i, j in enumerate(A):
        if j % 2 == 1:
            odd_flag = True
            break
        A[i] = j / 2
    if not odd_flag:
        count += 1
    else:
        break
        
print(count)

Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let ny:Vec<i32> = read_vec();
    let (n,y) = (ny[0],ny[1]);
    for i in 0..n+1 {
        for j in  0..n+1 -i  {
            let z = n - i - j;
            if i * 10000 + j * 5000 + 1000 * z == y {
                println!("{} {} {}",i,j,z);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}

Measured memory_bytes: 4352
import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] C = new int[N];
		int[][] A = new int[N][M];
		boolean possibility = false;

		int min = 0;
		for(int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			min += C[i];
			for(int j = 0; j < M; j ++) {
				A[i][j] = sc.nextInt();
			}
		}

		for (int i=0; i<(Math.pow(2,N)); i++) {
			int understand[] = new int[M];
			for(int j = 0; j < M; j ++) {
				understand[j] = 0;
			}
			boolean[] overX = new boolean[M];
			int price = 0;
			
			
			for (int j=0; j<N; j++) {
				if ((1&i>>j) == 1) {
					price += C[j];
					for (int k=0; k<M; k++) {
						understand[k] += A[j][k];
						if(understand[k] >= X) overX[k] = true;	
					}
					
				}


			}
			
			int count = 0;
			for(int l = 0; l < M; l ++) {
				if(overX[l] == true) count++;
			}
			if(count == M) {
				min = Math.min(min,price);
				possibility = true;
			}
			
			
		}



		if(possibility){
			System.out.println(min);
		}else {
			System.out.println(-1);
		}

	}



}




Measured memory_bytes: 37800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int s[100];

bool dp[101][10001];

int main(){
	cin >> n;
	rep(i,n)cin >> s[i];
	dp[0][0] = true;
	rep(i,n){
		rep(j,10001){
			if(j+s[i] <= 10000)dp[i+1][j+s[i]] |= dp[i][j];
			dp[i+1][j] |= dp[i][j];
		}
	}
	int ans = 0;
	rep(i,10001){
		if(i%10 == 0)continue;
		if(dp[n][i])ans = max(ans,i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n,k;cin>>n>>k;
  vector<pair<ll,ll>> v;
  ll index=0;
  for(ll i=1;i<=n;i++){
    ll a,b;cin>>a>>b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(), v.end());
  for(int i=0;i<(ll)v.size();i++){
    index+=v[i].second;
    if(k<=index){
      P(v[i].first);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 2420
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;
const ll ZERO = 0;

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;
}

int N;
ll dp[100010][3];
ll a[100010][3];
ll ans = 0;

int main()
{
  int N;
  cin >> N;
  rep(i, N)
  {
    rep(j, 3)
    {
      cin >> a[i + 1][j];
    }
  }

  rep(i, N)
  {
    rep(j, 3)
    {
      rep(k, 3)
      {
        if (j == k)
          continue;
        chmax(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
      }
    }
  }

  ll res = 0;
  rep(j, 3) chmax(res, dp[N][j]);
  cout << res << endl;
}

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

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}


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

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

using namespace std;

int main()
{
	int n,m,a,b;
	cin>>n>>m>>a>>b;
	
	int t=n*m;
	t=t-m*a;
	t=t-(n-a)*b;
	
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map( int, input().split())
hight = list(map( int, input().split()))

path_ = []
for i in range(m):
    path_.append(list( map( int, input().split())))

path = [[] for i in range(n)]
for pair in path_:
    path[pair[0]-1].append( pair[1])
    path[pair[1]-1].append( pair[0])

count = 0
for i in range(n):
    flag = 1
    if path[i] != []:
        for j in path[i]:
            if hight[i] <= hight[j-1]:
                flag = 0
                break
    if flag:
        count += 1

print(count)

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

r1 = sum(a)
flow = 0

for i in range(1, N):
    t = (a[i] + a[i - 1]) - x
    if flow != 0:
        a[i-1] -= flow
        t -= flow
        flow = 0

    if t > 0:
        if t > a[i]:
            t -= a[i]
            a[i - 1] -= t
            t = a[i]

        flow = t

a[-1] -= flow

r2 = sum(a)

print(r1 - r2)

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


int main(){
  string s,p;
  int i;
  cin>>s>>p;
  s+=s;
  string::size_type findOrNot= s.find(p);
  if (findOrNot != string::npos) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3208
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int a[200];
int main(){
	int n;
	while (cin>>n){
		int ans=0;
		for (int i=0;i<n;i++){
			cin>>a[i];
			ans+=a[i];
		}
		sort(a,a+n);
		if (ans%10==0){
			int k=0;
			for (int i=0;i<n;i++){
				if (a[i]%10!=0){
					k=a[i];
					break;
				}
			}
			if (k==0) cout<<0<<endl;
			else cout<<ans-k<<endl;
		}
		else{
			cout<<ans<<endl;
		}

	}
	return 0;
}

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

int a[3];

int main(){
    int k;
    for(int i=0; i < 3; i++) cin >> a[i];
    cin >> k;

    sort(a, a+3);

    for(int i=0; i < k; i++) a[2] *= 2;

    int ans = 0;
    for(int i=0; i < 3; i++) ans += a[i];

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

a, b = map(int, inp().split())
ans = -1
for i in range(10, 1003):
  A = int(i*0.08)
  B = int(i*0.1)
  if A==a and B==b:
    print(i)
    exit()
print(ans)    

Measured memory_bytes: 3064
from networkx import *
N,M = map(int,input().split())

if M==0:
  print(1)
  exit()
else:
  A = [list(map(int,input().split())) for m in range(M)]
  G = Graph()
  G.add_edges_from(A)
  print(len(max(connected_components(G),key=len)))

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

const int MAX_N = 2e5+10;

struct p
{
    int x, y, idx;
    bool operator<(const p& o) const
    {
        return x < o.x;
    }
};

int N;
p v[MAX_N];
int sz[MAX_N];

void solve()
{
	sort(v+1,v+N+1);
	set<int> unused, comp;
	for(int i=1;i<=N;++i) unused.insert(i);
	int mi = N+1;
	for(int i=1;i<=N;++i){
		int y=v[i].y;
		mi = min(mi, y);
		comp.insert(v[i].idx);
		unused.erase(y);
		if(unused.lower_bound(mi) == unused.end()){
			const int m = comp.size();
			for(int x : comp) sz[x] = m;
			comp.clear();
			mi = N+1;
		}
	}
	for(int i=1;i<=N;++i) cout<<sz[i]<<'\n';
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i){
	    cin >> v[i].x >> v[i].y;
	    v[i].idx=i;
	}
	solve();
	return 0;
}

Measured memory_bytes: 16096
#include <vector>
#include <iostream>
using namespace std;
#define min(x,y) (x<y)?x:y 
#define max(x,y) (x>y)?x:y

int main(void)
{
	int N;
	vector<int> a;
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	int judge = 1;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (judge == a[i])judge++;
		else ans++;
	}
	if (judge == 1)ans = -1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
def getmoney(p: int):
    if p == 3:
        return 100000

    elif p == 2:
        return 200000

    elif p == 1:
        return 300000

    else:
        return 0


x, y = list(map(int, input().split(" ")))

money = getmoney(x) + getmoney(y)

if x == 1 and y == 1:
    print(money + 400000)
else:
    print(money)


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */
namespace bits {
constexpr bool isContain(int bitmask, int i) { return bitmask & (1 << i); }
}  // namespace bits

int main() {
    /* code */
    string S;
    cin >> S;
    ll ans = 0;
    for (int bit = 0; bit < (1 << (S.length() - 1)); bit++) {
        size_t l = 0;
        for (int r = 0; r < S.length() - 1; ++r) {
            if (bits::isContain(bit, r)) {
                ans += stoll(S.substr(l, r - l + 1));
                l = r + 1;
            }
        }
        ans += stoll(S.substr(l));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
open Printf open Scanf
open Array

let iia k = init k (fun _ -> scanf " %d" @@ fun v -> v)
let binary_search ng ok f = let d = if ng <= ok then 1 else -1 in
  let rec f0 ng ok =
    if abs (ok - ng) <= 1 then ok
    else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok
  in f0 (ng-d) (ok+d)

let inf = 1000000000000
let hoge a =
  let n = length a + 2 in
  init n (fun i ->
  if i=0 then -inf
  else if i=n-1 then inf
  else a.(i-1))
let right a v = get a @@ binary_search 0 (length a - 1) (fun i -> a.(i) > v)
let left  a v = get a @@ binary_search (length a - 1) 0 (fun i -> a.(i) < v)

let () = scanf " %d %d %d" @@ fun a b q ->
  let s = hoge @@ iia a in
  let t = hoge @@ iia b in
  let x = iia q in
  sort compare s;
  sort compare t;
  iter (fun x ->
    let ls,rs = left s x, right s x in
    let lt,rt = left t x, right t x in
    let res = [|
      abs (x - min ls lt);
      abs (x-ls) + abs (rt-ls);
      abs (max rs rt - x);
      abs (rs-x) + abs (rs-lt);
      abs (x-lt) + abs (rs-lt);
      abs (rt-x) + abs (rt-ls);
    |] in
    printf "%d\n" @@ fold_left min inf res
  ) x




Measured memory_bytes: 8192
from typing import Set


def dfs(s: int) -> bool:
    return _dfs(s, set())


def _dfs(v: int, visited: Set[int]) -> bool:
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or _dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


if __name__ == "__main__":
    xn, yn, e = map(lambda x: int(x), input().split())
    edges = [set() for _ in range(xn)]  # type: ignore
    matched = [-1] * yn

    for _ in range(e):
        x, y = map(lambda x: int(x), input().split())
        edges[x].add(y)

    print(sum(map(dfs, range(xn))))



Measured memory_bytes: 8088
import math
n = int(input())
c = [0 for _ in range(n)]
ln = int(math.sqrt(n+1))

for x in range(1, ln+1):
  for y in range(1, ln+1):
    for z in range(1, ln+1):
      s = x*x + y*y + z*z + x*y + y*z + z*x
      if(s-1 < n):
        c[s-1] += 1
      else:
        break
        
for i in c:
  print(i)

Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char p[200005];
int main()
{
   ll a,b,c,d,k=0;
   cin>>a;
cin>>p;
ll ans=0;
for(int i=0;i<a;i++)
    if(p[i]=='R')
    ans++;
for(int i=0;i<ans;i++)
    if(p[i]=='R')
    k++;

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


Measured memory_bytes: 3832
n,k=map(int,input().split())
a=[i-1 for i in list(map(int,input().split()))]

logk=k.bit_length()
to=[[0]*n for i in range(logk)]

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

for i in range(logk-1):
  for j in range(n):
    to[i+1][j]=to[i][to[i][j]]

v=0
for i in range(logk,-1,-1):
  l=2**i
  if l<=k:
    v=to[i][v]
    k-=l

print(v+1)

Measured memory_bytes: 175876
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int n;
	while(cin >> n, n) {
		vector<pair<double,int> > v;
		for(int i = 0; i < n; i++) {
			pair<double,int> tmp;
			int id, h, w;
			cin >> id >> h >> w;
			tmp.first = fabs(22 - w / ((h / 100.0) * (h / 100.0)));
			tmp.second = id;
			v.push_back(tmp);
		}

		sort(v.begin(), v.end());
		cout << v[0].second << endl;
	}
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    int a=0;
    for(int i=1;i<n;i++)
        if(v[i]==v[i-1])
        {
            a++;
            i++;
        }
    cout<<a<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
#define N 100000
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
int n,m,a,b,v,d,c,Q;
vector<int> vct[N+5];
int clr[N+5];
bool fn[N+5][15];
struct st_{
	int pt, dis, cl;
}st[N+5];
void BFS(int x, int mxd, int mdcl){
	queue<P> que;
	que.push(P(x,mxd));
	while(!que.empty()){
		P tmp = que.front();
		que.pop();
		
		if(!clr[tmp.F])	clr[tmp.F] = mdcl;
		if(tmp.S){
			for(auto to:vct[tmp.F]) if(!fn[to][tmp.S-1]){
                fn[to][tmp.S-1] = true;
				que.push(P(to,tmp.S-1));
			}
		}
	}
}
int main(void){
	RII(n,m);
	REP(i,m){
		RII(a,b);
		vct[a].PB(b);
		vct[b].PB(a);
	}
	RI(Q);
	REPP(i,Q){
		RIII(v,d,c);
		st[i].pt = v, st[i].dis = d, st[i].cl = c;
	}
	for(int i=Q;i;--i){
		if(!fn[st[i].pt][st[i].dis])
			BFS(st[i].pt, st[i].dis, st[i].cl);
	}
	REPP(i,n) printf("%d\n",clr[i]);
}


Measured memory_bytes: 10024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> a, h;
vector<ll> fen;
int n;

void update(int id,ll val){
    while (id <= n){
        fen[id] = max(fen[id],val);
        id += (id & -id);
    }
}

ll get(int id){
    ll ans = 0;
    while (id){
        ans = max(ans,fen[id]);
        id -= (id & -id);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
    cin >> n;
    ll ans = 0;
    a.resize(n + 1);
    h.resize(n + 1);
    fen.resize(n + 1);
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++){
        ll val = get(h[i] - 1) + a[i];
        ans = max(ans,val);
        update(h[i],val);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
N,x = map(int,input().split())
A = [int(a) for a in input().split()]

A.sort()
ans = 0
for i in range(N):
    if A[i] == x:
        x -= A[i]
        ans += 1
        break
    elif A[i] < x and i != N-1:
        x -= A[i]
        ans += 1
    elif A[i] > x:
        break
print(ans)

Measured memory_bytes: 3064
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val spear = readLine()!!.split(" ").map(String::toInt).sorted()
    var ans = 0
    for (i in 0 until n * 2 - 1 step 2) {
        ans += spear[i]
    }
    println(ans)
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main() {

	string s;
	cin >> s;


	rep(i, s.size() - 1){
		if(i < s.size() - 2 && s[i] == s[i+2]){
			cout << i+1 << " " <<i+3 << endl;
			return 0;
		}
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int ans[100005],b[100005];
int main()
{
    int n;
    cin>>n;

    int q;
    cin>>q;
    string s;
    cin>>s;
    s='$'+s;
    int i;
    for(i=1;i<=n;i++)
    {
        if(s[i]=='C'&&s[i-1]=='A')
        {
            ans[i]+=1;
            b[i]=1;
        }
        ans[i]+=ans[i-1];
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        int flag=0;
        if(b[l]==1)
        {
            flag=1;
        }
        cout<<ans[r]-ans[l-1]-flag<<endl;
    }
}


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

const int MAXN = 1e5+5;
long long A[MAXN];

int main()
{
    int n;
    cin >> n;
   long long ans = 1;


   for(int i = 0; i < n; ++i)
   {
       cin >> A[i];
   }

    sort(A,A+n);
   for(int i = 0; i < n; ++i)
   {
       if(A[i] && 1000000000000000000ll / A[i] < ans)
       {
           ans = -1;
           break;
       }
       ans *= A[i];

   }

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

    return 0;
}


Measured memory_bytes: 4440
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){


	int a, b, d;
	double f,r,men,len;

	scanf("%lf", &r);


	men = r*r*M_PI;

    len = 2*r * M_PI;

	printf("%f %f\n", men,len);
fflush(stdin);

return 0;
}

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

int main(){
  string s;cin>>s;
  int n=s.size(),c=0,ans=0;
  REP(i,n){
    if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T') c++;
    else c=0;
    ans=max(ans,c);
  }
  cout<<ans;
}

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

int main(void){
    string s;
    cin >> s;
    
    if(s=="Sunny"){
        cout << "Cloudy";
    }
    else if(s=="Cloudy"){
        cout << "Rainy";
    }
    else{
        cout << "Sunny";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int numero, qtdNUM = 1, divisores; // qtdNUM = 1 pois já está incluindo o 105
    scanf("%d", &numero);
    if (numero < 105){
        printf("0\n");
    }
    else if (numero == 105){
        printf("1\n");
    }
    else{
        for (int i = 106; i <= numero; i++){
            if (i % 2 != 0){ // se o número for par nem entra no loop
                divisores = 2; // pois todo número é divisivel por 1 e ele mesmo
                for (int j = 3; j <= i/2; j += 2){ // pois um número ímpar nunca será divisivel por um par
                    if (i % j == 0){
                        divisores += 1;
                    }
                }
                if (divisores == 8){
                    qtdNUM += 1;
                }
            }
        }
        printf("%d\n", qtdNUM);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a.at(i);
  sort(all(a));
  if(a.at(n-1) == 0){
    YES;
    return 0;
  }
  if(n % 3 != 0){
    NO;
    return 0;
  }
  int m = n/3;
  long comp1 = a.at(0);
  rep(i,m){
    if(a.at(i) != comp1){
      NO;
      return 0;
    }
  }
  long comp2 = a.at(m);
  REP(i,m,2*m){
    if(a.at(i) != comp2){
      NO;
      return 0;
    }
  }
  long comp3 = a.at(2*m);
  REP(i,2*m,3*m){
    if(a.at(i) != comp3){
      NO;
      return 0;
    }
  }
  if(comp1 ^ comp2 ^ comp3) NO;
  else YES;
}

Measured memory_bytes: 1024
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit()
#include <stdbool.h>

#define SZ_FIELD 100
#define MAX_M 10000
#define QUE_SIZE 10000

typedef struct que_tbl
{
	int x;
	int y;
} que_t;

int N, M;
char field[SZ_FIELD][SZ_FIELD + 1];
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = { 0,-1, 0, 1};
que_t queue[QUE_SIZE];
int mx[MAX_M];
int my[MAX_M];
int que_in;
int que_out;
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_empty()
{
	return que_in == que_out;
}

void
que_push(int x, int y)
{
	queue[que_in].x = x;
	queue[que_in].y = y;
	que_in = (que_in + 1) % QUE_SIZE;

	if (que_in == que_out)
	{
		fprintf(stderr, "Queue overflow. size:%d\n", QUE_SIZE);
		cleanup(1);
	}
}

void
que_pop()
{
	if (que_out == que_in)
	{
		fprintf(stderr, "Queue underflow\n");
		cleanup(1);
	}

	que_out = (que_out + 1) % QUE_SIZE;
}

void
que_front(que_t *que)
{
	que->x = queue[que_out].x;
	que->y = queue[que_out].y;
}

void
dfs(int x, int y)
{
	field[y][x] = '.';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < N && 0 <= ny && ny < M && field[ny][nx] == '#')
			dfs(nx, ny);
	}
}

bool
bfs()
{
	que_t que;

	ix = 0;
	while (!que_empty())
	{
		que_front(&que); que_pop();
		int x = que.x, y = que.y;
		if (x == 0 || x == N - 1 || y == 0 || y == M - 1)
			return true;

		for (int i = 0; i < 4; ++i)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (0 <= nx && nx < N && 0 <= ny && ny < M)
			{
				if (field[ny][nx] == '.')
				{
					field[ny][nx] = ' ';
					que_push(nx, ny);
				}
				else if (field[ny][nx] == '#')
				{
					mx[ix] = nx, my[ix] = ny;
					ix++;
				}
			}
		}
	}

	return false;
}

int
solve()
{
	int cx, cy;

	for (cy = 0; cy < M; ++cy)
	{
		for (cx = 0; cx < N; ++cx)
		{
			if (field[cy][cx] == '&')
				break;
		}

		if (cx < N)
			break;
	}

	que_in = 0;
	que_out = 0;

	field[cy][cx] = ' ';
	que_push(cx, cy);

	int count = 0;
	while (!bfs())
	{
		que_in = 0;
		que_out = 0;

		for (int i = 0; i < ix; ++i)
		{
			que_push(mx[i], my[i]);
			dfs(mx[i], my[i]);
		}

		count++;
	}

	return count;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		scanf("%d%d", &N, &M);
		if (N == 0 && M == 0)
			break;

		for (int i = 0; i < M; ++i)
			scanf("%s", &field[i][0]);

		printf("%d\n", solve());
	}

	return 0;
}


Measured memory_bytes: 1852
<?php

fscanf(STDIN, "%s", $s);

if ($s === 'RRR') {
    echo 3;
} elseif (strpos($s, 'RR') !== false) {
    echo 2;
} elseif (strpos($s, 'R') !== false) {
    echo 1;
} else {
    echo 0;
}


Measured memory_bytes: 16156