akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec a;
  rep(i, N){
    ll b;
    cin >> b;
    if(b>(i+1)){
      cout << -1;
      return 0;
    }
    a.insert(a.begin()+(b-1), b);
  }

  rep(i, a.size()){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n),sum(n+1);
    cins(all(a));
    SORT(a);
    rep(i,n) sum[i+1] = a[i];
    rep(i,n) sum[i+1] += sum[i];
    ll l = -1,r = 400000;
    while(r-l > 1){
        ll mid = (r+l)/2;
        ll cnt = 0,same = 0;
        rep(i,n){
            if (a[n-1]+a[i] < mid) continue;
            cnt += n-(upper_bound(all(a),mid-a[i])-a.begin());
            same += upper_bound(all(a),mid-a[i])-lower_bound(all(a),mid-a[i]);
        }
        if (cnt <= m && same+cnt >= m){
            l = mid;
            break;
        }
        cnt += same;
        if (cnt > m) l = mid;
        else r = mid;
    }
    ll ans = 0;
    ll cnt = 0;
    rep(i,n){
        if (a[n-1]+a[i] < l) continue;
        //PRINT(l-a[i]);
        ll index = upper_bound(all(a),l-a[i])-a.begin();
        cnt += n-(upper_bound(all(a),l-a[i])-a.begin());
        ans += sum[n]-sum[index]+a[i]*(n-index);
    }
    ans += l*(m-cnt);
    PRINT(ans);
}


Measured memory_bytes: 1792
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */

public class Main{
	
	

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String k = s.next();
		
		int ctr=0;
		for(int i=1;i<n;i++) {
			if(k.charAt(i)!=k.charAt(i-1)) {
				ctr++;
			}
		}
		System.out.println(ctr+1);
	}
}

Measured memory_bytes: 24996
#include <iostream>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    int count = 0, S_size = S.size() - 1;
    
    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[S_size - i]){
            count++;
        }
            
    }
    
    cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=1000;i++)
    {
    	if((a*i)%b==c)
    	{
    		cout<<"YES"<<endl;
			return 0; 
		}
	}
	cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

ll modPow(ll n, ll p, ll mod) {
    n %= mod;
    // return (n^p) % mod
    if (p == 0)
        return 1;
    ll res = modPow(n * n % mod, p / 2, mod);
    if (p % 2 == 1)
        res = res * n % mod;
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    ll mod = 1e9 + 7;
    vector<ll> cnt(K + 1, 0);
    for (ll g = K; g >= 2; g--) {
        ll ng = K / g;
        cnt[g] = modPow(ng, N, mod);
        for (int k = 2; k * g <= K; k++) {
            cnt[g] -= cnt[k * g];
            while (cnt[g] < 0) {
                cnt[g] += mod;
            }
        }
        ans = (ans + cnt[g] * g) % mod;
    }

    cnt[1] = modPow(K, N, mod);
    for (int i = 2; i <= K; i++) {
        cnt[1] -= cnt[i];
        while (cnt[1] < 0) {
            cnt[1] += mod;
        }
    }
    ans = (ans + cnt[1]) % mod;
    cout << ans % mod << endl;
}


Measured memory_bytes: 4060
N=int(input())

L=list(map(int,input().split()))

M=[0 for i in range(N+1)]
M[0]=1
if N==0:
    if L[0]==1:
        print(1)
        exit()
    else:
        print(-1)
        exit()
if L[0]==1:
    print(-1)
    exit()

for i in range(1,N+1):
    M[i]=M[i-1]*2-L[i]
    if M[i]<0:
        print(-1)
        exit()
#print(L)
#print(M)

M[-1]=0
for i in range(1,N+1):
    if M[-1-i]<(M[-i]+L[-i]+1)//2:
        print(-1)
        exit()
    elif (M[-i]+L[-i])>=M[-1-i] and M[-1-i]>=(M[-i]+L[-i]+1)//2:
        continue
    else:
        M[-1-i]=(M[-i]+L[-i])
#print(L)
#print(M)
print(sum(L)+sum(M))

Measured memory_bytes: 706020
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//imos
int main(){
    ll a,b,x;
    cin >> a >> b >> x;

    string res = "YES";
    if(a > x)
    {
        res = "NO";
    }
    if(a+b < x)res = "NO";

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

bool ok(int x, int w)
{
    bool ret = true;
    rep (i, w - 2)
    {
        int l = x & 1;
        int r = (x >> 1) & 1;
        if (l & r) ret = false;
        x >>= 1;
    }
    return ret;
}

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

    int h, w, k;
    cin >> h >> w >> k;
    --k;

    s64 dp[h + 1][w];
    rep (i, h + 1) rep (j, w) dp[i][j] = 0;
    dp[0][0] = 1;

    rep (i, h)
    {
        rep (j, w)
        {
            rep (p, 1 << (w - 1))
            {
                if (!ok(p, w)) continue;
                if (j == 0)
                {
                    if ((p >> j) & 1) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
                    else dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
                }
                else if (j == w - 1)
                {
                    if ((p >> (j - 1)) & 1) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - 1]) % MOD;
                    else dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
                }
                else
                {
                    if ((p >> j) & 1) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
                    else if ((p >> (j - 1)) & 1) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - 1]) % MOD;
                    else dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
                }
            }
        }
    }

    cout << dp[h][k] << "\n";
    return 0;
}



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

#define mod 1000000007
#define ten5 100005
#define ten6 1000005
#define PI 3.1415926

typedef long long LL;


int num[ten6];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<long long int> pq;
    //vector<long long int> vint;
    //map<string,int> mp;
    //map<string,int>::iterator iter;
    cin>>s;
    a=s.size();
    for(i=0;i<a;i++)
    {
        if(s[i]=='<')
            num[i+1]=num[i]+1;
    }
    /*for(i=0;i<=a;i++) cout<<num[i]<<' ';
    cout<<endl;*/
    for(i=a-1;i>=0;i--)
    {
        if(s[i]=='>')
            num[i]=max(num[i+1]+1,num[i]);
    }
    /*for(i=0;i<=a;i++) cout<<num[i]<<' ';
    cout<<endl;*/
    for(i=0;i<=a;i++) sum+=num[i];
    cout<<sum;
    return 0;
}



Measured memory_bytes: 2820
#include <stdio.h>
 
class Dice4{
public:
    int number[6];
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
};
 
int main(){
    int n,k,j;
    scanf("%d",&n);
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
                &array[i].number[3],&array[i].number[4],&array[i].number[5]);
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


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

int main() {
	int N,M,b=1;
	cin>>N>>M;
	int Q[2*M],T[N+1];
	for(int i=1;i<N+1;i++) T[i]=0;
	for(int i=0;i<2*M;i++) cin>>Q[i];
	for(int i=0;i<2*M;i++) T[(Q[i])]++;
	for(int i=1;i<N+1;i++){
	    //cout<<T[i]<<endl;
	    if(T[i]%2!=0){
	        b=0; 
	        break;
	    }
	}
	if(b==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
L = input().rstrip("\n")
mod = 1000000007

dp = [[0,0] for _ in range(len(L))]
for i,s in enumerate(L):
    if i == 0:
        dp[0][1] = 2
        dp[0][0] = 1
        continue
    if s == "0":
        dp[i][1] = dp[i-1][1]
        dp[i][0] = (dp[i-1][0]*3) % mod
    else:
        dp[i][1] = dp[i-1][1]*2 % mod
        dp[i][0] = (dp[i-1][0]*3+dp[i-1][1]) % mod

print((dp[-1][0]+dp[-1][1]) % mod)



Measured memory_bytes: 19648
import sys
sys.setrecursionlimit(10**6)

def dfs(v, p, c):
    res[v] = c
    for next in link[v]:
        if next[0] == p:
            continue
        if next[1] % 2:
            dfs(next[0], v, 1-c)
        else:
            dfs(next[0], v, c)


N = int(input())
link = [[]  for _ in range(N)]
res = [0] * N
for i in range(N-1):
    u, v, w = map(int, input().split())
    link[u-1].append([v-1, w])
    link[v-1].append([u-1, w])
    
dfs(0, -1, 1)
#print(link)
for i in range(N):
    print(res[i])

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

a.insert(0,0)
a.append(0)

all_sum = 0
for i in range(0,N+1):
    all_sum += abs(a[i+1] - a[i])


for i in range(1, N+1):
    if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:
        print(all_sum)
    elif a[i-1] <= a[i]  and a[i-1] >=  a[i+1]:
        #増減
        print(all_sum - abs(a[i] - a[i-1]) * 2)
    elif  a[i-1] <= a[i]  and a[i-1] <= a[i+1]:
        #増減
        print(all_sum - abs(a[i] - a[i+1]) * 2)
    elif a[i-1] >= a[i]  and a[i-1] >=  a[i+1]:
        #減増
        print(all_sum - abs(a[i] - a[i+1]) * 2)
    elif a[i-1] >= a[i]  and a[i-1] <=  a[i+1]:
        #減増
        print(all_sum - abs(a[i] - a[i-1]) * 2)
    else:
        print(i, "yukkuri")

Measured memory_bytes: 13928
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    int N; cin >> N;
    string S; cin >> S;
    char c[3];
    int ans = 0;
    rep(i,10) {
        rep(j,10) {
            rep(k,10) {
                c[0] = i;
                c[1] = j;
                c[2] = k;
                int num = 0;
                rep(l,N) {
                    if (num < 3 && S[l] - '0' == c[num]) ++num;
                }
                if (num == 3) ++ans;
            }
        }
    }
    out(ans);

    return 0;
}










Measured memory_bytes: 888
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
num_P = 0
num_Q = 0

li = list(permutations(range(1, N + 1)))

#print(P, Q, li)
print(abs(li.index(P) - li.index(Q)))

Measured memory_bytes: 13844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
map<int,int>mp;

int ask(int i){
if(mp.count(i))return mp[i];
cout<<i<<endl;
cout.flush();
cin>>s;
if( s == "Vacant" )exit(0);
return mp[i]=(s=="Male");
}

int main(){

int n ;
cin>>n;
ask(0);

int low =0 , high = n-1;
while( low <= high ){
    if( low+1>=high )ask(low),ask(high);

    int mid = (low+high)>>1;
    if( ask(0) == ask(mid) ){

                if( (mid&1) )
                    high=mid-1;
                else
                    low=mid+1;

        }else{

                if( (mid&1) )
                    low=mid+1;
                else
                    high=mid-1;

        }
}

return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

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

    ll a,b,q;
    cin >> a >> b >> q;
    vector <ll> s;
    vector <ll> t;
    ll smin,smax,tmin,tmax;
    smin = INT64_MAX;
    smax = INT64_MIN;
    tmin = INT64_MAX;
    tmax = INT64_MIN;

    for (ll i=0;i<a;i++){
        ll p;
        cin >> p;
        s.push_back(p);
        if(smin > p){
            smin = p;
        }
        if(smax < p){
            smax = p;
        }
    }
    for (ll i=0;i<b;i++){
        ll p;
        cin >> p;
        t.push_back(p);
        if(tmin > p){
            tmin = p;
        }
        if(tmax < p){
            tmax = p;
        }

    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    for (ll i=0;i<q;i++){
        ll x;
        cin >> x;
        ll sl,sr,tl,tr;
        sl = sr = tl = tr = -1;
        if(smin <= x){
            sl = *(--lower_bound(s.begin(), s.end(), x));
        }
        if(smax >= x){
            sr = *lower_bound(s.begin(), s.end(), x);
        }
        if(tmin <= x){
            tl = *(--lower_bound(t.begin(), t.end(), x));
        }
        if(tmax >= x){
            tr = *lower_bound(t.begin(), t.end(), x);
        }
        ll tmp1, tmp2, tmp3, tmp4;
        int flag1, flag2, flag3, flag4;
        flag1 = flag2 = flag3 = flag4 = 0;
        if(sl != -1 and tl != -1){
            tmp1 = max(abs(x-sl), abs(x-tl));
            flag1 = 1;
        }
        if(sl != -1 and tr != -1){
            tmp2 = min(abs(x-sl), abs(x-tr)) + abs(sl-tr);
            flag2 = 1;
        }
        if(sr != -1 and tl != -1){
            tmp3 = min(abs(x-tl), abs(x-sr)) + abs(tl-sr);
            flag3 = 1;
        }
        if(sr != -1 and tr != -1){
            tmp4 = max(abs(x-sr), abs(x-tr));
            flag4 = 1;
        }
        ll ans = INT64_MAX;
        if(flag1){
            if(ans > tmp1){
                ans = tmp1;
            }
        }
        if(flag2){
            if(ans > tmp2){
                ans = tmp2;
            }
        }
        if(flag3){
            if(ans > tmp3){
                ans = tmp3;
            }
        }
        if(flag4){
            if(ans > tmp4){
                ans = tmp4;
            }
        }
        cout << ans << endl;



    }
}

Measured memory_bytes: 3060
#include<stdio.h>
int main(void) {
int N, K;
char S[50];
scanf("%d", &N);
scanf("%d", &K);
scanf("%s", S);
switch (S[K-1]) {
  case 'A':
  S[K-1] = 'a'; break;
  case 'B':
  S[K-1] = 'b'; break;
  case 'C':
  S[K-1] = 'c'; break;
}
printf("%s", S);
  return 0;
}


Measured memory_bytes: 1652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int d[] = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int cnt = d[n / 2] - d[n / 2 - 1];
		System.out.println(cnt);
	}
}


Measured memory_bytes: 53224
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<int, int, custom_hash> mp;
int main()
{
	boost;
	int n, i;
	cin >> n;
	vector <int> v(n);
	fo(i, 0, n)
	cin >> v[i];

	for(int x : v)
	mp[x]++;
	
	if(mp[1] == 1) cout << 1;
	else if(mp[1] > 1) cout << 0;
	else {
		sort(all(v));
		v.erase(unique(all(v)), v.end());
		
		int ans = 0;
		for(int x : v) {
			if(mp[x] > 1) continue;
			bool ok = 1;
			for(int i = 2; i <= sqrt(x); i++) {
				if(x % i == 0) {
					if(mp[i] || mp[x / i]) {
						ok = 0;
						break;
					}
				}
			}
			if(ok) ans++;
		}
		cout << ans;
	}
}


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

using lint = long long;

lint s, c;

lint f(lint x) {
    return min(s+x, (c-2*x)/2);
}

int main() {
    cin >> s >> c;

    lint l = 0, r = 1e12;

    while (r-l>2) {
        lint m1 = (l*2+r)/3, m2 = (l+2*r)/3;

        if (f(m1) < f(m2)) l = m1;
        else r = m2;
    }

    lint ans = 0;

    for (lint i=l; i<=r; i++) {
        ans = max(ans, f(i));
    }

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

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	for (int i = 0; i < 3; i++) {
		int a, b, c, d, e, f;
		cin >> a >> b >> c >> d >> e >> f;
		f -= c;
		if (f < 0) {
			f += 60;
			e--;
		}
		e -= b;
		if (e < 0) {
			e += 60;
			d--;
		}
		d -= a;
		cout << d << " " << e << " " << f << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) ((int)v.size())
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

struct CHT{
    vector<pll> P;
    inline ll f(pll t, ll x){
        return t.va * x + t.vb;
    }
    lf get_cross(pll q, pll r){
        return lf(r.vb - q.vb) / (q.va - r.va);
    }
    int p = 0;
    void ins(pll t){
        while(P.size() > 1 && get_cross(t,P[sz(P)-2]) > get_cross(t,P[sz(P)-1])) P.pop_back();
        P.push_back(t);
        p = min(p, sz(P) - 1);
    }
    ll func(ll x){
        while(p + 1 < P.size() && f(P[p+1], x) <= f(P[p], x)) ++p;
        return f(P[p], x);
    }
} C;

int n;
ll h[200005], d[200005];
ll X;

int main(){
    fio;
    cin >> n >> X;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 2; i <= n; i++){
        C.ins({-2ll * h[i-1], d[i-1] + h[i-1] * h[i-1]});
        d[i] = h[i] * h[i] + X + C.func(h[i]);
    }
    cout << d[n] << '\n';
}

Measured memory_bytes: 9456
n = int(input())
t = [0]*(n+1)
x = [0]*(n+1)
y = [0]*(n+1)
saitan = 0

ans = 'Yes'

for i in range(1,n+1):
	t[i],x[i],y[i] = map(int,input().split())
	saitan = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
	if t[i]-t[i-1] < saitan:
		ans = 'No'
	elif (t[i]-t[i-1])%2 != saitan%2:
		ans = 'No'

print(ans)

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

int main()
{
    long long x;
    cin >> x;
    long long money = 100;
    int ans = 0;
    while(x > money)
    {
        long long int t = money /100;
        ans += 1;
        money += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using vector = std::vector<std::pair<char, int> >;
using iterator = vector::iterator;

auto print_pair = [](auto x){std::cout << x.first << " " << x.second;};

auto print_vector = [](iterator begin, iterator end){
                      while (begin != end)
                        {
                          print_pair(*begin);
                          std::cout << std::endl;
                          begin++;
                        }
                    };


iterator partition(iterator begin, iterator end)
{
  auto pivot = *(end-1);
  auto swap = [](iterator a, iterator b){
                auto tmp = *a;
                *a = *b;
                *b = tmp;
              };

  auto left_end = begin - 1;
  for (auto itr = begin; itr<end; ++itr)
    {
      if ((*itr).second <= pivot.second)
        {
          ++left_end;
          swap(itr, left_end);
        }
    }

  return left_end;
}

int merge(iterator begin, iterator mid, iterator end)
{
  auto itr = begin;

  vector left, right;

  for (auto tmp=begin; tmp<mid; ++tmp) left.push_back(*tmp);
  for (auto tmp=mid; tmp<end; ++tmp) right.push_back(*tmp);
  left.push_back(std::make_pair('Z', 1000000001));
  right.push_back(std::make_pair('Z', 1000000001));

  auto itr_left = left.begin();
  auto itr_right = right.begin();

  int ncomp = 0;
  while (itr != end)
    {
      if ((*itr_left).second <= (*itr_right).second)
        {
          *itr = *itr_left;
          ++itr_left;
        }
      else
        {
          *itr = *itr_right;
          ++itr_right;
        }
      ++itr;
      ++ncomp;
    }

  return ncomp;
}

int mergeSort(iterator begin, iterator end)
{
  if ((begin+1) == end)
    {
      return 0;
    }

  auto n = std::distance(begin, end);
  auto mid = begin + n/2;

  int nct;
  nct = mergeSort(begin, mid);
  nct += mergeSort(mid, end);
  nct += merge(begin, mid, end);

  return nct;
}



void quicksort(iterator begin, iterator end)
{
  if (begin+1 == end) return;
  auto mid = partition(begin, end);
  quicksort(begin, mid);
  quicksort(mid, end);
}

int main ()
{
  int n;
  vector vec;

  std::cin >> n;
  for (int i=0; i<n; ++i)
    {
      char tmpchar;
      int tmpint;
      std::cin >> tmpchar >> tmpint;
      vec.push_back(std::make_pair(tmpchar, tmpint));
    }

  vector vec_cp = vec;

  quicksort(vec.begin(), vec.end());
  mergeSort(vec_cp.begin(), vec_cp.end());
  if (vec == vec_cp) std::cout << "Stable\n";
  else std::cout << "Not stable\n";

  //std::cout << "quicksort\n";
  print_vector(vec.begin(), vec.end());

  //std::cout << "mergeSort\n";
  //print_vector(vec_cp.begin(), vec_cp.end());
}




Measured memory_bytes: 5616
import re
import numpy as np

N, M, C = [int(item) for item in re.split(r"\s", input())]
B = [int(item) for item in re.split(r"\s", input())]

A = []
for _ in range(N):
    A.append([int(item) for item in re.split(r"\s", input())])

A = np.array(A)
B = np.array(B)

success = 0
for n in range(N):
    if (A[n] * B).sum() + C > 0:
        success = success + 1

print(success)


Measured memory_bytes: 18664
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 n: integer;
 m: integer;
begin
 get(n);
 get(m);
 if n=m then
  put_line("Yes");
 else
  put_line("No");
 end if;
end hoge;

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

int main() {
    int n;
    cin>>n;
    long long max=-10000000000001,min=100000000000001;
    for(int i=0;i<n;i++){
        long long r;
        cin>>r;
        if(max<r-min) max=r-min;
        if(min>r) min=r;
    }
    cout<<max<<endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N; cin >> N;

	if (N % 10 == 3) {
		cout << "bon" << endl;
	}else if (N % 10 == 2 or N % 10 == 4 or N % 10 == 5 or N % 10 == 7 or N % 10 ==9) {
		cout << "hon" << endl;
	}else {
		cout << "pon" << endl;
	}

	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k){
        cout << n*x << endl;
    }else{
        cout << k*x + (n-k)*y << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
int main(){
	i64 A,B;cin>>A>>B;int T;
	per(i,60,0){
		if(((1ll<<i)&B)){
			if((1ll<<i)&A)
				A^=(1ll<<i),B^=(1ll<<i);
			else{
				T=i;break;
			}
		}
	}if(A==B){
		puts("1");
		return 0;
	}//cout<<T<<endl;
	int k=-1;
	per(i,T-1,0)if(B&(1ll<<i)){k=i;break;}
	i64 l1=A,r1=(1ll<<T)+(1ll<<(k+1))-1;
	i64 l2=(1ll<<T)+A,r2=(1ll<<(T+1))-1;
	i64 ans=0;
	if(l2>r1)
		ans=r2-l2+1+r1-l1+1;
	else
		ans=max(r2,r1)-min(l1,r1)+1;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef pair<int,string> p;

int main(){
	int n,m,d;
	while(cin>>n,n){
		bool hoge[n][30];
		p res[n];
		rep(i,n){
			rep(j,30)hoge[i][j]=false;
			cin>>res[i].second>>m;
			res[i].first=0;
			rep(j,m){cin>>d;hoge[i][d]=true;}
		}
		rep(i,30){
			int num=0;
			rep(j,n)if(hoge[j][i])num++;
			rep(j,n)if(hoge[j][i])res[j].first+=(n-num+1);
		}
		sort(res,res+n);
		cout<<res[0].first<<" "<<res[0].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	}

	static int euclid(int a,int b){
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	}
}

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

class Node:
    def __init__(self, idd, neighbors):
        self.idd = idd
        self.neighbors = neighbors
        self.dist = -1
        
    def __repr__(self):
        return "{0} {1}".format(self.idd, self.dist)
    
def breadthFirstSearch(Nodes):
    stack = [Nodes[0]]
    Nodes[0].dist = 0
    while len(stack) > 0:
        current = stack.pop(0)
        for v in current.neighbors:
            v_node = Nodes[v-1]
#             print('current:{}, v_node:{}'.format(current, v_node))
            if(v_node.dist == -1):
                v_node.dist = current.dist + 1
                stack.append(v_node)
            else:
                v_node.dist = v_node.dist if v_node.dist < current.dist + 1 else current.dist + 1
    return Nodes

Nodes = [None] * n
for i in range(n):
    row = [int(tt) for tt in input().split()]
    Nodes[row[0]-1] = Node(row[0], [ row[j + 2] for j in range(row[1])])

Nodes = breadthFirstSearch(Nodes)
for node in Nodes:
    print(node)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n; cin >>n;
  int a[n][3],dp[n][3];
  for(int i=0; i<n; i++) for(int j=0; j<3; j++) cin >>a[i][j];
  dp[0][0]=a[0][0]; dp[0][1]=a[0][1]; dp[0][2]=a[0][2];
  for(int i=1; i<n; i++){
    dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
    dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
    dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
  }
  cout <<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
return 0;}

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

using namespace std;

int Swap(vector<int> x)
{
  int y;
  sort(x.begin(),x.end());
  y=x[0];
  return y;
}

int main()
{
  int a,b,m;
  cin>>a>>b>>m;
  
  vector<int> A(a);
  vector<int> B(b);
  
  for(int i=0;i<a;i++)
    cin>>A[i];
  for(int i=0;i<b;i++)
    cin>>B[i];
  
  int Amin=Swap(A);
  int Bmin=Swap(B);
  int Smin=Amin+Bmin;
  
  vector<int> X(m);
  vector<int> Y(m);
  vector<int> C(m);
  for(int i=0;i<m;i++)
    cin>>X[i]>>Y[i]>>C[i];
  
  vector<int> S(m);
  int Smin777=0;
  for(int i=0;i<m;i++)
  {
    S[i]=A[X[i]-1]+B[Y[i]-1]-C[i];
    if(i==0)
    {
      Smin777=S[i];
    }
    if(S[i]<Smin777)
      Smin777=S[i];
  }
  cout<<min(Smin,Smin777)<<endl;
}

Measured memory_bytes: 2552
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>d;
    for(int e=0;e<d;e++){
        cin>>a>>b>>c;
        if(a*a==b*b+c*c){
            cout<<"YES"<<endl;
        }else if(b*b==a*a+c*c){
            cout<<"YES"<<endl;
        }else if(c*c==a*a+b*b){
            cout<<"YES"<<endl;
        }else{cout<<"NO"<<endl;
        }
    }
    return 0;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x-k+1; i <= x+k-1; i++) {
    printf("%d\n", i);
  }
   return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (x, n) = readLine()!!.split(" ").map { it.toInt() }
    val pp = if (n == 0) listOf() else readLine()!!.split(" ").map { it.toInt() }

    var min = Int.MAX_VALUE
    var diff = 0

    // forward
    for (i in x..101) {
        if (!pp.contains(i)) {
            min = i
            diff = i-x
            break
        }
    }

    // backwards
    for (i in x downTo 0) {
        if (!pp.contains(i)) {
            val tmpDiff = x-i
            if (diff == tmpDiff) {
                min = Math.min(min, i)
            }
            if (diff > tmpDiff) {
                min = i
            }
            break
        }
    }

    println(min)
}

Measured memory_bytes: 36448
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    string s;cin >> s;
    int y = 1,m= 1;
    if(s[2] > '1' ){y = 0;}
    if(s[2] == '1' && s[3] > '2'){y = 0;}
    if(s[2] == '0' && s[3] == '0'){y = 0;}

    if(s[0] > '1'){m = 0;}
    if(s[0] == '1' && s[1] > '2'){m = 0;}
    if(s[0] == '0' && s[1] == '0'){m = 0;}
    
    if(y == 1 && m == 1)cout << "AMBIGUOUS" << endl;
    else if(y==1)cout << "YYMM" << endl;
    else if(m==1)cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  } 
}


Measured memory_bytes: 3176
#include<iostream>
int main(){
	int a, b, c,x=0;
	std::cin >> a >> b >> c;
	for (int i=a;i<= b; ++i){
		if (c%i == 0){
			++x;
		}
	}
	std::cout << x<<"\n";
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    ll N;
    sll(N);
    cout << N/2 + N%2 <<endl;
}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

Measured memory_bytes: 3252
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    ll a[100] = {};
    a[0] = 2;
    a[1] = 1;

    for(int i = 2; i < 90; ++i){
        a[i] = a[i-1] + a[i-2];
    }

    int n;
    cin >> n;
    cout << a[n] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int a[10000];
    int b[10000];
    int not_zero=1;
    int i=0;

    while(not_zero){
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
        if(a[i]==0 && b[i]==0){
            not_zero=0;
        }
        i++;
    }

    for(int h=0;h<i-1;h++){
        if(a[h]<b[h]){
            printf("%d %d\n",a[h],b[h]);
        }else{
            printf("%d %d\n",b[h],a[h]);
        }
    }

    return 0;
}


Measured memory_bytes: 1952
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int input_low = 0;
		int house_number = 0;
		int floar_number = 0;
		int room_number = 0;
		int person = 0;

		// テキスト入力
		Scanner sc = new Scanner(System.in);

		// A大学の公舎を作る
		int school_house[][][];
		school_house = new int[4][3][10];

		// 入力の数だけ回す
		while (sc.hasNext()) {

			// 入力行数
			input_low = sc.nextInt();
			break;
		}

		// 入力行数分回す
		for (int i = 0; i < input_low; i++) {

			while (sc.hasNext()) {
				// 部屋の指定
				house_number = sc.nextInt();
				floar_number = sc.nextInt();
				room_number = sc.nextInt();
				person = sc.nextInt();
				break;
			}

			// 部屋に人を放り込む
			int now_person = school_house[house_number - 1][floar_number - 1][room_number - 1];
			school_house[house_number - 1][floar_number - 1][room_number - 1] = now_person
					+ person;

		}

		// 出力
		for (int hi = 0; hi < 4; hi++) {
			for (int fi = 0; fi < 3; fi++) {
				for (int ri = 0; ri < 10; ri++) {
					System.out.print(" " + school_house[hi][fi][ri]);
				}
				System.out.print("\n");
			}
			// 最後の行を表示
			while (hi < 3) {
				System.out.println("####################");
				break;
			}
		}

	}

}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ll ans = 0;
  ll sum = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] == 0) {
      ans += sum/2;
      sum = 0;
      continue;
    }
    sum += a[i];
  }
  ans += sum/2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4028
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define w(x) int x;cin>>x;while(x--)

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ll long long

void abc()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
}


class disjoint {
public:
	int components;

	vector<int> size;
	vector<int> id;

	disjoint(int n) {
		components = n;
		size.resize(n + 1, 1);
		id.resize(n + 1);

		for (int i = 0; i < n; i++) {
			id[i] = i;
		}
	}

	int find(int p) {

		while (id[p] != p) {
			p = id[p];
		}
		return p;
	}

	bool unions(int p, int q) {
		int root1 = find(p);
		int root2 = find(q);

		if (root1 == root2) return false;

		if (size[root1] < size[root2]) {
			size[root2] += root1;
			id[root1] = root2;
		}
		else {
			size[root1] += root2;
			id[root2] = root1;

		}

		components--;
		return true;
	}
};




int main()
{
	abc();


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

	disjoint g(n);

	while (m--) {
		int x, y;
		cin >> x >> y;
		g.unions(x, y);
	}

	cout << g.components - 1;



}

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

int main(){
  int N;
  cin >> N;
  
  for(int i=8 ;i>0;i--){
    int x,y,z,sum;
    y =pow(10,i);
    z =pow(10,i-1);
    x = N%y/z;
    sum += x;
    
    if( i == 1 ){
      if( N%sum == 0 ){
        cout << "Yes" <<endl;}
      
      else{
        cout << "No" << endl;}
      }
  }
}

Measured memory_bytes: 256
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

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

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

int main()
{
    int a = inputValue();
    int b = inputValue();
    int x = inputValue();
    if(x > (a * a * b / 2.0)){
        double tanS = 2.0 * (a * a * b - x) / (a * a * a);
        double ans = atan(tanS) * 180 / 3.1415926535;
        cout << setprecision(10) << ans << endl;
    }else{
        double tanS = 2.0 * x / (a * b * b);
        double ans = 90 - (atan(tanS) * 180 / 3.1415926535);
        cout << setprecision(10) << ans << endl;
    }
}


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

int main(){
    int d[30][30],n,c,ans=1e9;
    cin >> n >> c;
    for(int i = 0;i < c;i ++){
        for(int j = 0;j < c;j ++){
            cin >> d[i][j];
        }
    }
    map<int,int> mp0,mp1,mp2;
    for(int i = 0;i < n;i ++){
        for(int j = 0;j < n;j ++){
            int col;
            cin >> col;
            if((i+j)%3==0) mp0[col-1] ++;
            if((i+j)%3==1) mp1[col-1] ++;
            if((i+j)%3==2) mp2[col-1] ++;
        }
    }
    for(int i = 0;i < c;i ++){
        int s0 = 0;
        for(auto ite = mp0.begin();ite != mp0.end();++ite){
            s0 += d[ite->first][i]*ite->second;
        }
        for(int j = 0;j < c;j ++){
            if(i==j) continue;
            int s1 = 0;
            for(auto ite = mp1.begin();ite != mp1.end();++ite){
                s1 += d[ite->first][j]*ite->second;
            }
            for(int k = 0;k < c;k ++){
                if(i==k||j==k) continue;
                int s2 = 0;
                for(auto ite = mp2.begin();ite != mp2.end();++ite){
                    s2 += d[ite->first][k]*ite->second;
                }
                ans = min(ans,s0+s1+s2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, raw_input().split())
        print "NO" if (xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1) else "YES"
    except:
        break

Measured memory_bytes: 4208