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

int main(void)
{
	int  a,b,c,d,e,t,i=5;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	while(i>0){
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(b<c){
		t=b;
		b=c;
		c=t;
	}
	if(c<d){
		t=c;
		c=d;
		d=t;
	}
	if(d<e){
		t=d;
		d=e;
		e=t;
	}
	i--;
}
printf("%d %d %d %d %d\n",a,b,c,d,e);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
using namespace std;
    
int main() {

    long long n,x,m; cin >> n >> x >> m;
    vector<long long> id(m,-1);
    vector<long long> ans(m,0);
    long long res;
    long long j = 0;
    long long len =0;
    while (id[x] == -1)
    {
        id[x] = len;
        ans.at(j) = x;
        x = (x*x)%m;
        len++;
        j++;
    }

    long long loop; loop = len - id[x];
    long long count; count = (n-id[x])/loop;
    long long value=0;
    for(long long i = id[x] ; i < len ; i++){
        value += ans[i];
    }

////////////////ここまではできてるはず


    res = 0;
    if (n < len)
    {
        res = 0;
        for (long long i = 0; i < n; i++)
        {
            res += ans[i];
        }
        
    }
    else
    {
        for (long long i = 0; i < id[x]; i++)
        {
            res += ans[i];
        }
        res = res + count * value;
        long long amari = (n-id[x])%loop + id[x];
        for (long long i = id[x]; i < amari; i++)
        {
            res += ans[i];
        } 
    }
    



    
    cout << res << endl;
    

return 0;

}

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

  using namespace std;
  using namespace std::chrono; 

  typedef long long int ll;

  #define MOD (ll)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  ll t;cin>>t;while(t--)
  #define forn(i,a,n) for (int i = a; i < n; ++i)
  #define f first
  #define s second
  #define all(x) x.begin(), x.end()

  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define debug(x...)
  #endif
  
  ll powD(ll x,ll y){
    ll res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x)%MOD;
      x = (x*x)%MOD;
      y = y>>1;
    }
    return res;
  }


  /*CHECK FOR CORNER CASES FOR GOD'S SAKE*/
  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cntr = 0;
    forn(i,0,n){
      if(s[i] == 'R')
        cntr++;
    }
    int mis = 0;
    forn(i,0,cntr){
      if(s[i] == 'W')
        mis++;
    }
    cout<<mis<<endl;   
  }
   
  


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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    vector<long long> c(100001);
    rep(i, n) {
        cin >> a[i] >> b[i];
        c[a[i]] += b[i];
    }
    long long cnt = 0;
    rep(i, 100001) {
        cnt += c[i];
        if (cnt >= k) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 4724
program a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h1, m1, h2, m2, k
    integer(int32):: t1, t2


    read*, h1, m1, h2, m2, k

    t1 = 60*h1+m1
    t2 = 60*h2+m2

    print'(i0)', t2-t1-k
end program a

Measured memory_bytes: 2924
import sys
from numba import njit


@njit('i8(i8)')
def solve(X):
    money = 100
    res = 0
    while (money < X):
        money *= 1.01
        money = int(money)
        res += 1
    return res


def main():
    input = sys.stdin.buffer.readline
    X: int = int(input())
    print(solve(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 108316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int x;
    cin >> x;

    int k;
    cin >> k;

    vector<int> r(k);
    for (int i = 0; i < k; i++) {
        cin >> r[i];
    }

    int q;
    cin >> q;

    int a = 0, b = x, c = 0, e = 0;
    int i = 0, s = 0;
    for (int j = 0; j < q; j++) {
        int t, y;
        cin >> t >> y;

        for (; i < k && r[i] < t; i++) {
            int d = r[i] - s;
            s = r[i];
            if (i % 2 == 0) {
                e = max(e - d, 0);
                c -= d;
                a = max(a, 0 - c);
            } else {
                e = min(e + d, x);
                c += d;
                b = min(b, x - c);
            }
        }

        y = a < b ? (y <= a ? a : y < b ? y : b) + c : e;

        y += (t - s) * (i % 2 == 0 ? -1 : 1);
        y = min(max(y, 0), x);

        cout << y << '\n';
    }

    return 0;
}

Measured memory_bytes: 1664
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range (M)]
import sys
sys.setrecursionlimit(10**8)

edge = [[] for _ in range(N)]
for u,v in AB:
    edge[u-1].append([v-1,1])
    edge[v-1].append([u-1,1])


import heapq
def dijkstra(S, N, Edge):
    # S: start vertex
    # N: number of vertices
    # Edge: adjacent list [node, cost]
    
    INF = 10**20
    dist = [INF]*N
    dist[S] = 0
    que = [[0, S]]
    parent = [0]*N
    heapq.heapify(que)
    
    while que:
        c, v = heapq.heappop(que)
        if dist[v] < c: continue

        for nv, nc in Edge[v]:
            if c+nc < dist[nv]:
                dist[nv] = c+nc
                parent[nv] = v
                heapq.heappush(que, [c+nc, nv])
    
    return parent

parent = dijkstra(0, N, edge)
print('Yes')
for i in range(1,N):
    print(parent[i]+1)


Measured memory_bytes: 169228
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    COUT("Yes");
  } else {
    COUT("No");
  }
  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);
        long N = sc.nextLong();
        System.out.println( solve(N) );
    }

    private static int solve(long N) {
        // Nがさほど大きくないので sqrt(N)の範囲で因数を探し
        // F(factor, N/factor)してminを探す
        int max = (int)Math.ceil(Math.sqrt(N));

        // 2/maxにできるだろうけど面倒くさいしいいよね...
        int min = 10;
        for (int i = 1; i <= max; i++) {
            if( N % i == 0 ) {
                min = Math.min(F(i, N/i), min);
            }
        }
        return min;
    }

    private static int F(long a, long b) {
        return Math.max( String.valueOf(a).length(), String.valueOf(b).length() );
    }
}


Measured memory_bytes: 22100
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a = sorted(nl())

if a[0]==a[1] and a[1]!=a[2]:
  print("Yes")
elif a[0]!=a[1] and a[1]==a[2]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A[2][N];
    for (int i = 0; i < N; i++) 
    {
        cin >> A[0][i];
    }
    for (int i = 0; i < N; i++) 
    {
        cin >> A[1][i];
    }
    int res = 0;
    int cum = 0;

    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N - k; i++)
        {
            cum += A[0][i];
            //cout << cum << endl;
        }
        for (int j = N - k - 1; j < N; j++)
        {
            cum += A[1][j];
            //cout << A[1][j] << endl;
            //cout << cum << endl;
        }
        if (res < cum) res = cum;
        //cout << res << endl;
        cum = 0;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

long double ans(uint64_t x, long double p) {
    return (x / 2) / p;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    uint64_t x, P;
    cin >> x >> P;
    long double p = P / 100.0;
    cout << setprecision(9);

    if (x % 2 == 1) {
        cout << fixed << 1.0 + p * ans(x - 1, p) + (1.0 - p) * ans(x + 1, p);
    } else {
        cout << fixed << ans(x, p);
    }
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int N,a;
    cin >> N;

    int min1,max1;
    cin >> min1;
    max1 = min1;

    for(int i = 1;i<N;i++){
        cin >>a;
        min1 = min(min1,a);
        max1 = max(max1,a);
    }

    cout << max1-min1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 100;

int min(int a, int b){
    return a > b ? b : a;
}

int main()
{
    int n;
    int rc[N+1];
    int mat[N + 1][N] = {};
    cin >> n;

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

    // 行列の長さl
    for (int l = 2; l < n + 1; l++)
    {
        // i番目の積 積の数は : n - l + 1
        for (int i = 1; i < n - l + 2; i++)
        {
            mat[l][i] = (1 << 21);
            for (int k = 1; k < l; k++)
            {
                mat[l][i] = min(mat[l][i], mat[k][i] + mat[l - k][i + k] + rc[i-1] * rc[i+k-1] * rc[i+l-1]);
            }
        }
    }

    cout << mat[n][1] << endl;
}


Measured memory_bytes: 3156
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
	    int[] a1=new int[n];
	    int[] a2=new int[n];
 
		for(int i=0;i<n;i++)
		{
			a1[i]=sc.nextInt();
			a2[i]=sc.nextInt();
		}
 
		HashMap<String,Integer> s=new HashMap<String,Integer>();
      
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i!=j)
				{
			int x=(a1[j]-a1[i]);
			int y=(a2[j]-a2[i]);
			String input=String.valueOf(x)+"-"+String.valueOf(y);
			if(s.containsKey(input))
			s.put(input,s.get(input)+1);
			else
			s.put(input,1);
				}
			}
		}
		int max=0;
		for (Integer val : s.values())
		{
			//System.out.println(val);
			if (max<val) 
			max= val;
		}
 
		System.out.println(n-max);
 
	}
}


Measured memory_bytes: 25556
//long challenge
// This code is done by me.

#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<set>
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>
// some unique define keywords

#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define mod 1000000007


// this code is prepared by deepakdpk
// please don't cheat
// code and improve
//All good.


using namespace std;

ll npow(ll base, ll exp) {
  int reaction=12345;
  base %= mod;
  ll ans = 1;
  while (exp > 0) {
    if (exp & 1) ans = ((ll)ans * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  int pract;
  int dact;
  return ans;
}

ll factorial(ll n)
{
    ll i = n;
    ll fact=1;
    while (n / i != n) {
        fact = fact * i;
        i--;
    }
    int dear=123;
    int say;
    return fact;
}



int main()
{
   ll a,b,x;
   cin>>a>>b>>x;
   if(a>x)
    cout<<"NO"<<endl;
   else if(x-a>=b)
    cout<<"NO"<<endl;
   else
    cout<<"YES"<<endl;

    return 0;

    }








































Measured memory_bytes: 3616
#import<cstdio>
#import<algorithm>
int main(){for(int n,m,f,i;scanf("%d%d",&n,&m),n|m;printf("%d\n",f)){int a[200010]={0};for(i=1;i<=n+m;i++)scanf("%d",a+i);std::sort(a,a+n+m+1);f=0;for(i=1;i<=m+n;i++)f=std::max(f,a[i]-a[i-1]);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> v;
  vector<bool> vv(n);
  int ans=0;
  REP(i,n){
    int a;
    cin >> a;
    v.push_back(a);
  }
  IREP(i,n){
    if (i+1 > n / 2)
    {
      if (v[i] == 0)
      {
        vv[i] = false;
      }
      else
      {
        vv[i] = true;
        ans++;
      }
    }
    else
    {
      int tmp=0;
      for(int j=(i+1)*2;j<=n-(n%(i+1));j+=i+1){
        if(vv[j-1]==true){
          tmp++;
        }
      }
      if(tmp%2==1&&v[i]==0){
        vv[i]=true;
        ans++;
      }
      else if(tmp%2==0&&v[i]==1){
        vv[i]=true;
        ans++;
      }
      else{
        vv[i]=false;
      }
    }
  }
  cout << ans << endl;
  int ans2=0;
  REP(i,n){
    if(vv[i]==true){
      cout << i+1;
      ans2++;
      if(ans2==ans){
        cout << endl;
      }
      else{
        cout << " ";
      }
    }
  }
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
int main(){
	int A,B;
	cin>>A;
	cin>>B;
        cout<<(A+B)%24<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    ll ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3868
N = int(input())
h = list(map(int, input().split()))
dp = []
#to 1
dp.append(0)
#to 2
dp.append(abs(h[0] - h[1]))
for i in range(2, N):
    dp.append(min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])))
print(dp[N - 1])

Measured memory_bytes: 13928
from math import hypot
def dijkstra(s,n,cost):
    d=[float("inf")]*n
    used=[False]*n
    d[s]=0
    while True:
        v=-1
        for i in range(n):
            if(not used[i])and v==-1:
               v=i
            elif(not used[i])and d[i]<d[v]:
                v = i
        if v==-1:
            break
        used[v]=True
        for j in range(n):
            d[j]=min(d[j],d[v]+cost[v][j])
    return d
xs,ys,xt,yt,n,*t=map(int,open(0).read().split())
e=[(xs,ys,0)]+list(zip(t[::3],t[1::3],t[2::3]))+[(xt,yt,0)]
cost=tuple([float('inf')]*(n+2)for i in range(n+2))
for i,(x,y,z)in enumerate(e):
    for j,(a,b,c)in enumerate(e):
        cost[i][j]=max(0,hypot(x-a,y-b)-z-c)
print(dijkstra(0,n+2,cost)[-1])

Measured memory_bytes: 78428
while True :
    N, M, P = map(int, input().split())
    if N == 0 and M == 0 and P == 0 :
        break
    
    Sum = 0
    for i in range(N) :
        x = int(input())
        Sum += x
        if i == M - 1 :
            winner = x
    if winner == 0 :
        print(0)
    else :
        print(int(Sum * 100 * (100 - P) / 100 / winner))


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

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

  vector<int> A1(N);
  vector<int> A2(N);
  for (int i = 0; i < N; i++) {
    cin >> A1.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> A2.at(i);
  }

  // 行別の累積和
  vector<int> S1(N + 1, 0);
  vector<int> S2(N + 1, 0);
  for (int i = 0; i < N; i++) {
    S1.at(i + 1) = S1.at(i) + A1.at(i);
    S2.at(i + 1) = S2.at(i) + A2.at(i);
  }

  int ans = 0;
  // 下に移動するタイミング
  for (int j = 1; j <= N; j++) {
    int num = S1.at(j) + S2.at(N) - S2.at(j - 1);
    ans = max(ans, num);
  }

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int h, w;
int mp[501][501];
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	rep(i, h)rep(j, w) cin >> mp[i][j];

	vector<P> x;
	vector<P> y;

	rep(i, h) {
		if (i % 2 == 0) {
			for (int j = 0; j < w; ++j) {
				if (mp[i][j] % 2 != 0) {
					if (j == w - 1) {
						if (i == h - 1) continue;
						mp[i + 1][j]++;
						mp[i][j]--;
						y.emplace_back(P(i + 1, i + 2));
						x.emplace_back(P(j + 1, j + 1));
						continue;
					}
					mp[i][j + 1]++;
					mp[i][j]--;
					y.emplace_back(P(i + 1, i + 1));
					x.emplace_back(P(j + 1, j + 2));
				}
			}
		}
		else {
			for (int j = w - 1; j >= 0; --j) {
				if (mp[i][j] % 2 != 0) {
					if (j == 0) {
						if (i == h - 1) continue;
						mp[i + 1][j]++;
						mp[i][j]--;
						y.emplace_back(P(i + 1, i + 2));
						x.emplace_back(P(j + 1, j + 1));
						continue;
					}
					mp[i][j - 1]++;
					mp[i][j]--;
					y.emplace_back(P(i + 1, i + 1));
					x.emplace_back(P(j + 1, j));
				}
			}
		}
	}

	dunk(x.size());
	rep(i, x.size()) {
		cout << y[i].first << ' ' << x[i].first << ' '
			<< y[i].second << ' ' << x[i].second << endl;
	}

	return 0;
}

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

#define INF (1<<30)

int main(void){
	int s,i,n,min=INF,ans=0;
	bool flag=false;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> s;
		ans += s;
		if(s%10!=0 && s<min){
			min = s;
			flag = true;
		}
	}
	if(ans%10==0 && flag){
		ans -= min;
	}else if(ans%10==0){
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

namespace abc167A
{
  public class MainClass
  {
    public static void Main(string[] args)
    {
      long[] X = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
      for(int i = 0; i < X.Length; i++){
        if(X[i] == 0){Console.WriteLine(i + 1);}
      }
    }
  }
}

Measured memory_bytes: 27812
n, d = map(int, input().split())
s = []
for _ in range(n):
    s.append([int(i) for i in input().split()])
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        y = (sum([(s[i][k] - s[j][k]) ** 2 for k in range(d)]))
        if (y ** 0.5) % 1 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3188
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){
    int n;
    cin>>n;
    vector <int> v(n);
    for(int i=0;i<n;i++){cin>>v[i];}
    sall(v);long double res=v[0];
    for(int i=1;i<n;i++){
        res=(res+v[i])/2;
    }
    cout<<res<<endl;
}
int main()
{
    FOR(i,R){solution();}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void){
    long long N,K;
    long long N_MAX = 100000;
    long long a, b;
    long long A[N_MAX+5];

    cin >> N >> K;

    for(long long i=0;i<=N_MAX;i++){
        A[i] = 0;
    }

    for(long long i=0;i<N;i++){   
        cin >> a >> b;
        A[a] = A[a] + b;
    }
    long long sum=0;
    for(long long i=0;i<=N_MAX;i++){
        sum = sum + A[i];
        if(sum >= K){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int r,x,y,W,H;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(0<=x-r && 0<=y-r){
		if(W>=x+r && H>=y+r) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 1816
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
ans = []

if S > K:
   z = list(range(K+1))
else:
  z = list(range(S+1))
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K*2 - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Measured memory_bytes: 3188
X, K, D = list(map(int, input().split()))
X = abs(X)

zan = X%D


K2 = K-X//D
if K2 < 0:
  print(X-D*K)
else:
  if K2%2 == 0:
  	print(zan)
  else:
  	print(D-zan)

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

int solve( vector< int > num ) {
	int s = 1, t = 1, ans = 0, sum = num[1] == 0;
	int cap = num[0];
	int N = num.size();

	while( s < N ) {
		while( t + 1 < N && sum <= cap) {
			sum += num[++t] == 0;
		}

		ans = max(ans, t - s);
		sum -= num[s++] == 0;

	}

	return ans;
}

int main() {
	int n, k;

	while( true ) {
		cin >> n >> k;
		if( !n && !k ) {
			break;
		}

		vector< int > num(1000001, 0);

		for(int i = 0; i < k; i++) {
			int tmp;
			cin >> tmp;
			num[tmp] = 1;
		}

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

Measured memory_bytes: 8968
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    const lint MOD = 1e9 + 7;
    lint N; cin >> N;
    vec<lint> A_list(N);
    range(i, 0, N) cin >> A_list.at(i);
    lint num_0s = 0;
    range(i, 0, N) num_0s += (A_list.at(i) == 0);
    lint ans = 1;
    unordered_map<lint, lint> num_remaining = {{-1, 3}};
    range(i, 0, N) {
        lint A = A_list.at(i);
        ans *= num_remaining[A - 1];
        ans %= MOD;
        num_remaining[A - 1] -= 1;
        num_remaining[A] += 1;
    }
    cout << ans << "\n";
}

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

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

    vector<int> dp(3);

    for(int i=0; i<n; i++){
      vector<int> newdp(3,0);
      vector<int> c(3);
      for(int j=0; j<3; j++) cin>>c[j];

      for(int k=0; k<3; k++){
        for(int j=0; j<3; j++){
          if(j!=k) newdp[j] = max(newdp[j], dp[k]+c[j]);
        }
      }

    dp = newdp;
    }

    cout<<max({dp[0],dp[1],dp[2]});
}


Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  a = input()
  if a == 'AC':
    ac += 1
  if a == 'WA':
    wa += 1
  if a == 'TLE':
    tle += 1
  if a == 'RE':
    re += 1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 9192
p = [1]*300003
p[0] = p[1] = 0
for i in xrange(2,300003):
    if p[i] and i%7 in (1,6):
        p[2*i::i] = [0]*len(p[2*i::i])
    else:
        p[i] = 0
prime = [i for i in xrange(2,300003) if p[i]]

while 1:
    N = int(raw_input())
    if N == 1: break
    ans = [p for p in prime if N%p == 0]
    print "%d: %s"%(N," ".join(map(str,ans)))

Measured memory_bytes: 7724
a, b = map(int, input().split())

order = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

if order.index(a) > order.index(b):
    print('Alice')
elif order.index(a) < order.index(b):
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 3060
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc2(n,s);
	if(le(s)&1)prN;
	else{
		v=le(s)/2;
		fu(i,0,v-1)if(s[i]!=s[v+i])re prN,0;
		prY;
	}
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Measured memory_bytes: 3188
# coding: utf-8
# Your code here!

b1,b2,b3 = map(int,input().split())
if (b1==1 and b2==0 and b3==0):
    print("Close")
elif(b1==0 and b2==1 and b3==0):
    print("Close")
elif(b1==1 and b2==1 and b3==0):
    print("Open")
elif(b1==0 and b2==0 and b3==1):
    print("Open")
else:
    print("Close")


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int bitcount(unsigned n) {
    n = (n&0x55555555) + ((n&0xaaaaaaaa)>>1);
    n = (n&0x33333333) + ((n&0xcccccccc)>>2);
    n = (n&0x0f0f0f0f) + ((n&0xf0f0f0f0)>>4);
    n = (n&0x00ff00ff) + ((n&0xff00ff00)>>8);
    n = (n&0x0000ffff) + ((n&0xffff0000)>>16);
    return n;
}

int main() {
    while(true) {
        int C, R;
        cin >> R >> C;
        if(!C && !R) break;

        vector<unsigned> cols(C, 0);
        for(int i = 0; i < R; ++i) {
            for(int j = 0; j < C; ++j) {
                int n;
                scanf("%d", &n);
                cols[j] = (cols[j]<<1) | n;
            }
        }

        int ans = 0;
        for(int pat = 0; pat < (1<<R); ++pat) {
            int cnt = 0;
            for(int i = 0; i < C; ++i) {
                unsigned r = cols[i] ^ pat;
                int c = bitcount(r);
                cnt += max(c, R-c);
            }
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 988
#include<cstring>
#include<cstdio>
int main()
{
	char st[200];
	int i,n=0;
	scanf("%s",st);
	for(i=0;i<strlen(st);i++)
	{
		if(st[i]=='C') n=1;
		if(st[i]=='F'&&n==1)
		{
			n=2;
			break;
		}
	}
	if(n==2) printf("Yes\n");
	else printf("No\n");
}

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

int main(){
  int e,y,a,b,c;
  cin>>e>>y;
  if(e==0){
    a=y-1868;
    if(a<=43){
      cout<<"M"<<a+1<<endl;
    }else if(44<=a && a<=57){
      b=a-43;
      cout<<"T"<<b<<endl;
    }else if(58<=a && a<=120){
      b=a-57;
      cout<<"S"<<b<<endl;
    }else{
      b=a-120;
      cout<<"H"<<b<<endl;
    }
  }else if(e==1){
    c=y+1867;
    cout<<c<<endl;
  }else if(e==2){
    c=y+1911;
    cout<<c<<endl;
  }else if(e==3){
    c=y+1925;
    cout<<c<<endl;
  }else{
    c=y+1988;
    cout<<c<<endl;
  }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
int dp[3005][3005];
int main()
{
	int n,s;
	scanf("%d%d",&n,&s);
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		for (int j=0;j<=s;j++)
		{
			dp[i][j]=(2*dp[i-1][j])%mod;
			if (j>=a)
			dp[i][j]=(dp[i][j]+dp[i-1][j-a])%mod;
		}
	}
	printf("%d",dp[n][s]);
}

Measured memory_bytes: 39044
<?php
  	fscanf(STDIN, '%d %d', $appleNum, $taste);
	if($taste >= 0){
      $eat = $taste;
    }elseif($taste + $appleNum > 0){
      $eat = 0;
    }else{
      $eat = $taste + $appleNum - 1;
    }

	for($i = 0; $i < $appleNum; $i++){
      $sum += $taste + $i;
    }
	$sum -= $eat;

echo $sum;


Measured memory_bytes: 4728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
char S[MAXN];
int ans;

int main() {
	register int i; char c;
	scanf("%s", S + 1); N = strlen(S + 1); ans = N;
	for(c = 'a'; c <= 'z'; ++c) {
		int las = 0, res = 0;
		for(i = 1; i <= N; ++i)
			if(S[i] == c)
				res = max(res, i - las - 1), las = i;
		res = max(res, N + 1 - las - 1);
		ans = min(ans, res);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<int, int>

int main() {
  int check[110001] = { };
  REP(i, 110001) check[i] = -1;
  REP(i, 1000){
    int x = i*(i+1)/2;
    if(x<110001) check[x] = i;
  }
  int n;
  cin >> n;
  if(check[n] == -1){
    cout << "No" << endl;
    return 0;
  }
  int p = check[n];
  cout << "Yes" << endl;
  cout << p+1 << endl;
  vector<int> ans[p+1];
  int c = 1;
  REP(i, p+1){
    FOR(j, i+1, p+1){
      ans[i].pb(c);
      ans[j].pb(c);
      c++;
    }
  }
  REP(i, p+1){
    cout << p << " ";
    REP(j, p){
      cout << ans[i][j];
      if(j == p-1) cout << endl;
      else cout << " ";
    }
  }
  return 0; 
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int N;
const int maxN=2*1e5+10;
string S[maxN];

int main(){
    cin >> N;
    map<string, int> mp;
    for(int i=0;i<N;i++){
        cin >> S[i];
        mp[S[i]]++;
    }
    int max=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second>max) max = itr->second;
    }
    vector<string> v;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second==max) v.push_back(itr->first);
    }
    sort(v.begin(), v.end());
    for(int i=0;i<v.size();i++){
        cout << v[i] << endl;
    }
    return 0;

}

Measured memory_bytes: 28656
import java.util.*;

public class Main {
    class Node {
        int key;
        Node left = null, right = null, parent = null;
        Node(int key) {
            this.key = key;
        }
    }

    Node tree;

    boolean needPrefix = true;
    void inorder(Node t) {
        needPrefix = false;
        inorder_(t);
    }
    void inorder_(Node t) {
        if (t == null) {
            return;
        }
        if (t.left != null) {
            inorder_(t.left);
        }
        if (needPrefix) {
            System.out.print(" ");
        }
        System.out.print(t.key);
        needPrefix = true;
        if (t.right != null) {
            inorder_(t.right);
        }
    }

void preorder(Node t) {
        needPrefix = false;
        preorder_(t);
    }
    void preorder_(Node t) {
        if (t == null) {
            return;
        }
        if (needPrefix) {
            System.out.print(" ");
        }
        System.out.print(t.key);
        needPrefix = true;
        if (t.left != null) {
            preorder_(t.left);
        }
        if (t.right != null) {
            preorder_(t.right);
        }
    }


    void insert(Node z) {
       Node y = null;
       Node x = tree;
       while (x != null) {
           y = x;
           if (z.key < x.key) {
               x = x.left;
           } else {
               x = x.right;
           }
       }
       z.parent = y;
       if (y == null) {
           this.tree = z;
       } else if (z.key < y.key) {
           y.left = z;
       } else {
           y.right = z;
       }
    }

boolean find(Node t, int k) {
        if (t == null) return false;
        if (t.key == k) return true;
        if (t.key > k) return find(t.left, k);
        else return find(t.right, k);
    }
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String inst = sc.next();
            if ("insert".equals(inst)) {
                insert(new Node(sc.nextInt()));
            }else if ("find".equals(inst)) {
                if (find(tree, sc.nextInt())) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            } else {
                inorder_(tree);
                System.out.println();
                preorder_(tree);
                System.out.println();
            }
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


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

vector<vector<int>> a(3, vector<int>(3, 0));
vector<int> b;
int n;

int main() {
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j) cin >> a[i][j];
  cin >> n;
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> b[i];
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 3; ++j)
      for(int k = 0; k < 3; ++k)
        if(a[j][k] == b[i]) a[j][k] = -1;
  }
  bool ch = 0;
  for(int i = 0; i < 3; ++i) {
    int cnt = 0, cnt2 = 0;
    for(int j = 0; j < 3; ++j) {
      if(a[i][j] == -1) ++cnt;
      if(a[j][i] == -1) ++cnt2;
    }
    if(cnt == 3 || cnt2 == 3) ch = 1;
  }
  int cnt3 = 0;
  for(int i = 0; i < 3; ++i)
    if(a[i][i] == -1) ++cnt3;
  if(cnt3 == 3) ch = 1;
  cnt3 = 0;
  for(int i = 0; i < 3; ++i)
    if(a[i][2 - i] == -1) ++cnt3;
  if(cnt3 == 3) ch = 1;
  if(ch)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

const long long MOD=1e9+7;

bool hasMaxMatching(const vector<vector<int>>& tree){
    int n=tree.size();
    vector<bool> visited(n,false);
    vector<bool> matched(n,false);
    vector<int> preds(n,0);
    matched[0]=true;
    stack<int> si;
    si.push(1);
    visited[1]=true;
    while(!si.empty()){
        int cur=si.top();
        for(int i:tree[cur]){
            if(!visited[i]){
                si.push(i);
                preds[i]=cur;
                visited[i]=true;
            }
        }
        if(cur==si.top()){
            if(!matched[cur]&&!matched[preds[cur]]){
                matched[cur]=true;
                matched[preds[cur]]=true;
            }
            else if(!matched[cur] && matched[preds[cur]]){
                return false;
            }
            si.pop();
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<vector<int>> tree(n+1);
    for(int i=1; i<n; i++){
        int x,y;
        cin>>x>>y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    bool b=hasMaxMatching(tree);
    cout<<(b?"Second":"First");
    
    
    return 0;
}


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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int64> xs(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> xs[i];
  }
  sort(xs.begin(), xs.end());
  reverse(xs.begin(), xs.end());
  int64 sum = 0;
  for (int i = 0; i < n; i++) {
    sum += xs[2 * i + 1];
  }
  cout << sum << endl;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int,input().split(" ")))
b = [0 for a in range(n)]
b[0] = a[0]
answer = 0
for i in range(n-1):
    b[i+1] = b[i] + a[i+1]
# print(b)
for i in b:
    if i == 0:
        answer += 1;
minimum = min(b)
for i in range(n):
    b[i] -= minimum
# print(b)
# c = [0 for a in range(max(b)+1)]
setb = set(b)
# print(setb)
c = {}
for key in setb:
    c[str(key)] = 0

for i in range(n):
    c[str(b[i])] += 1

for v in c.values():
    if v > 1:
        answer += v * (v-1) // 2
# print(c)
# print(sum(c))
print(answer)

Measured memory_bytes: 62772
import scala.io.StdIn.readLine

object Main {
  def sum(n:Int, s:Int, x:Int):Int = {
    if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }
    else { for(i <- x+1 to (if(s<9) s else 9) ) yield sum(n-1,s-i,i) }.sum
  }

  def getSum(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0) print(sb.result)
    else {
      println(sum(r(0),r(1),-1))
      getSum(sb)
    }
  }

  def main(args:Array[String]) = getSum(new StringBuilder)
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<ll> a(n + 1), b(n);
    for(int i = 0; i <= n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] < b[i]){
            int m = min((b[i] - a[i]), a[i + 1]);
            ans += a[i];
            ans += m;
            a[i + 1] -= m;
            b[i] -= a[i];
        }else{
            ans += b[i];
            b[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n;

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n;
        int an = 0;
        for (int i = 0, a; i < n; i++) {
                cin >> a;
                an = __gcd(a, an);
        }
        cout << an;
return 0;
}


Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	int answer = 0, current = 0;
	for(auto &c : s)
	{
		current = (c == 'A' || c == 'C' || c == 'G' || c == 'T' ? current + 1 : 0);
		answer = max(answer, current);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3620
/*
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int N;
int vector<ll> a(100001, 0);

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", &a[i]);
	
	
	
    return 0;
}
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
string A, B;
 
int main(void){
	
	cin >> A >> B;
	
	if(A == B) printf("EQUAL\n");
	else if(A.size() > B.size()) printf("GREATER\n");
	else if(A.size() < B.size()) printf("LESS\n");
	else{
	    for(int i = 0; i < A.size(); ++i){
	        if(A[i] > B[i]){ printf("GREATER\n"); return 0; }
	        if(A[i] < B[i]){ printf("LESS\n"); return 0; }
	    }
	}

    return 0;
}

Measured memory_bytes: 256
// F - Absolute Minima
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int q;
	cin >> q;
	multiset<long long> s;
	multiset<long long>::iterator it;
	long long count = 0, x = 0, ans = 0;
	while (q--) {
		int op;
		cin >> op;
		if (op == 1) {
			long long a, b;
			cin >> a >> b;
			s.insert(a);
			ans += b;
			if (count == 0) {
				it = s.begin();
				x = *it;
			} else {
				long long t = x;
				ans += abs(a - x);
				if (a >= x && count % 2 == 0) x = *++it, ans -= x - t;
				else if (a < x && count % 2 == 1) x = *--it;
			}
			count++;
		} else if (op == 2) {
			cout << x << ' ' << ans << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	if(e - a <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256