akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


struct App {
    n: usize,
    adj: Vec<Vec<(usize, i64)>>,
    mem: Vec<Option<(i64, i64)>>,
    ok: bool,
    uniq: Option<i64>,
}

impl App {
    fn input() -> App {
        let n = read();
        let m= read();
        let mut adj: Vec<Vec<(usize, i64)>> = vec![vec![]; n];

        for _ in 0..m {
            let u = read::<usize>() - 1;
            let v = read::<usize>() - 1;
            let s = read::<i64>();
            adj[u].push((v, s));
            adj[v].push((u, s));
        }

        return App {
            n: n,
            adj: adj,
            mem: vec![None; n],
            ok: true,
            uniq: None,
        };
    }

    fn dfs(&mut self, v: usize, t: (i64, i64)) {
        // println!("{} {:?}", v, t);
        if let Some(s) = self.mem[v] {
            if s.1 == t.1 {
                self.ok &= (t == s);
            } else {
                let x = -(t.0 * t.1 + s.0 * s.1);
                self.ok &= (x % 2 == 0);
                let x = x / 2;
                self.ok &= x >= 1;

                if let Some(y) = self.uniq {
                    self.ok &= (x == y);
                } else {
                    self.uniq = Some(x);
                }
            }
        } else {
            self.mem[v] = Some(t);

            for &(tv, s) in self.adj[v].clone().iter() {
                let tt = (s - t.0, -t.1);
                self.dfs(tv, tt);
            }
        }
    }

    fn solve(&mut self) {
        self.dfs(0, (0, 1));

        if !self.ok {
            println!("0");
            return;
        }

        let mut ma: i64 = 1_000_000_010;
        let mut mi: i64 = 1;
        for i in 0..self.n {
            if let Some((a, b)) = self.mem[i] {
                if b == 1 {
                    mi = std::cmp::max(mi, 1 - a);
                } else {
                    ma = std::cmp::min(ma, a - 1);
                }
            } else {
                panic!();
            }
        }

        println!("{}",
            if let Some(a) = self.uniq {
                if mi <= a && a <= ma {
                    1
                } else {
                    0
                }
            } else {
                std::cmp::max(0, ma - mi + 1)
            });
    }
}



fn main() {
    let mut app = App::input();
    app.solve();
}


Measured memory_bytes: 30076
#include <iostream>
#include<algorithm>
#include<iomanip>
#include <string>
#include<math.h>
using namespace std;
int main() {
	long long int a, happiness=0,b;
	cin >> a;
	happiness = happiness + (a / 500)*1000;
	b = a % 500;
	happiness = happiness + (b / 5) * 5;
	cout << happiness << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

void solve(){
	int x;
	cin >> x;
	cout << (x ^ 1) << endl;	
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3640
l=[]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split()))
	l.append([item[1],item[0]])

dp=[[False for j in range(W+1)] for i in range(n+1)]

def solve(i,w):
	if dp[i][w]==False:
		if i==n:
			res=(0)
		elif w-l[i][0]<0:
			res=(solve(i+1,w))
		else:
			a=solve(i+1,w)
			b=l[i][1]+solve(i+1,w-l[i][0])
			if b>a:
				res=(b)
			else:
				res=(a)
		dp[i][w]=res
		return(res)
	else:
		return(dp[i][w])

print(solve(0,W))

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

void Solve(){
	int n;
	cin>>n;
	cout<<(n + 1) / 2;

	return;
}
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin>>q;
	while(q--){
		Solve();
	}
}


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

static const int MAX_NUM   = 101;
static const int NIL       = 10000001;
static const int NO_VISIT  = 0;
static const int NOW_VISIT = 1;
static const int END_VISIT = 2;

void SSSP(int *pMatrix, int num)
{
    int i;
    int mincost;
    int target;
    int lcost[MAX_NUM];
    int parent[MAX_NUM];
    int state[MAX_NUM];
    int *pList;

    for (i = 0; i < num; i++) {
        lcost[i]  = NIL;
        parent[i] = -1;
        state[i]  = NO_VISIT;
    }

    lcost[0]  = 0;
    parent[0] = 0;
    state[0]  = NOW_VISIT;

    for (;;) {
        mincost   = NIL;
        for (i = 0; i < num; i++) {
            if ((lcost[i] < mincost) && (state[i] != END_VISIT)) {
                target = i;
                mincost = lcost[i];
            }
        }
        if (mincost == NIL) {
            break;
        }

        state[target] = END_VISIT;
        pList = pMatrix + MAX_NUM * target;
        for (i = 0; i < num; i++) {
            if ((*(pList + i) + lcost[target]) < lcost[i]) {
                lcost[i]  = *(pList + i) + lcost[target];
                state[i]  = NOW_VISIT;
                parent[i] = target;
            }
        }
    }

    for (i = 0; i < num; i++) {
        printf("%d %d\n", i, lcost[i]);
    }

    return;
}

int main(void)
{
    int i, j;
    int num;
    int tmp;
    int target, elem, cost;
    int matrix[MAX_NUM][MAX_NUM];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        for (j = 0; j < num; j++) {
            matrix[i][j] = NIL;
        }
    }

    for (i = 0; i < num; i++) {
        scanf("%d %d", &target, &tmp);
        for (j = 0; j < tmp; j++) {
            scanf("%d %d", &elem, &cost);
            matrix[target][elem] = cost;
        }
    }

    SSSP(&matrix[0][0], num);

    return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	char s[110];
	scanf("%s",s);
	int i = 0;
	while (s[i] != '\0')
	{
		if (i%2 != 0 && s[i]=='R')
		{
			printf("No\n");
			return(0);
		}
		if (i%2 == 0 && s[i]=='L')
		{
			printf("No\n");
			return(0);
		}
		i++;
	}
	printf("Yes\n");
	return(0);
}


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

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==5 && B==5 && C==7)
        cout<<"YES"<<endl;
    else if(A==5 && B==7 && C==5)
        cout<<"YES"<<endl;
    else if(A==7 && B==5 && C==5)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}



Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    d = {}
    for a in range(1, 10):
        for b in range(1, 10):
            cnt = 0
            # 1桁の整数が条件を満たすケース
            if a == b and a <= n:
                cnt += 1
            # 2桁以上の整数で条件を満たすケース
            i = 1
            while True:
                _min = a * (10**i) + b  # 整数が a0000b

                _max = a * (10**i) + b
                _i = i - 1
                while _i > 0:
                    _max += 9 * (10**_i)  # 整数が a999b
                    _i -= 1
                if _max <= n:
                    cnt += 10**(i - 1)
                    i += 1
                    continue
                elif _min > n:
                    break
                else:  # a0..0b <= b < a9..9b
                    cnt += ((n - _min) // 10) + 1
                    break
            d[10 * a + b] = cnt
    ans = 0
    for a in range(1, 10):
        for b in range(1, 10):
            ans += d[a * 10 + b] * d[b * 10 + a]
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62556
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    double head;
    vector<double> dp(n/2+1,1.0) ;
    for(int i=1;i<=n;i++){
        cin>>head;
        for(int j=n/2;j>0;j--){
            dp[j]=dp[j]*head+dp[j-1]*(1-head);
        }
        dp[0]=dp[0]*head;
    }
    cout<<setprecision(10)<<fixed<<dp[n/2]<<"\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < (i##_MACRO); i++)
#define RANGE(i, a, b) for(int i = (a), i < (b), i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % static_cast<int>(1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	char s[101];
	scanf("%d", &n);
	scanf("%s", s);
	if(n % 2) {
		puts("No");
		return 0;
	}

	REP(i, n / 2) {
		if(s[i] != s[i + n / 2]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
int main(void)
{
    char str[1001],p[1001],t[8],tmp;
    int q,a,b,i,j,k;
    scanf("%s%d",str,&q);
    for(i=0;i<q;i++){
        scanf("%s%d%d",t,&a,&b);
        if(strcmp(t,"print")==0){
            for(j=a;j<=b;j++)printf("%c",str[j]);
            puts("");
        }
        else if(strcmp(t,"reverse")==0){
            for(j=a;j<b;j++){
                for(k=b;k>j;k--){
                    tmp=str[k-1];
                    str[k-1]=str[k];
                    str[k]=tmp;
                }
            }
        }
        else{
            scanf("%s",p);
            j=a;
            k=0;
            while(j<=b){
                str[j]=p[k];
                j++;
                k++;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>

int main(){

  int w,q;
  int wall[100];
  int i,j;
  char dami[5],action;
  int n,haba;
  int count;
  int mark;
  int mark2;
 
 
  while(1){ 
    scanf("%d %d",&w,&q);
    if(w==0 && q==0)break;
 
    for(i=0;i<w;i++){
      wall[i]=-1;
    }
 
    for(i=0;i<q;i++){
      scanf("%s",dami);
      action=dami[0];
 
      if(action=='s'){
 
	scanf("%d %d",&n,&haba);
	count=0;
	for(j=0;j<w;j++){
 
	  if(count==0 && wall[j]<0){
	    mark=j;
	    count++;
	  }else if(wall[j]<0){
	    count++;
	  }else if(wall[j]>=0){
	    count=0;
	  }
 
	  if(count==haba){
	    mark2=j;
	    break;
	  }
	}
 
 
	if(count==haba){
	  printf("%d\n",mark);
	  for(j=mark;j<=mark2;j++){
	    wall[j]=n;
	  }
	}else {
	  printf("impossible\n");
	}
      }else if(action=='w'){
	scanf("%d",&n);
	for(j=0;j<w;j++){
	  if(wall[j]==n){
	    wall[j]=-1;
	  }
	}
      }
    }
 
    printf("END\n");
 
  }
 
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

ll onlyRateB[222222];
ll onlyRateW[222222];
ll two_pow[222222];

void calOnlyRate(ll b, ll w) {
	REP(i, 222222)two_pow[i] = (i > 0 ? two_pow[i-1] * 2 % MOD : 1);
	ll br = 0;
	ll wr = 0;
	REP(i, b+w) {
		if(i >= b){
			ll now = mod_div(combination(i - 1, b - 1), two_pow[i]);
			wr = (wr + now) % MOD;
		}
		if(i >= w){
			ll now = mod_div(combination(i - 1, w - 1), two_pow[i]);
			br = (br + now) % MOD;
		}
		onlyRateB[i] = br;
		onlyRateW[i] = wr;
	}
}

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

	ll b, w;cin >> b >> w;
	calOnlyRate(b, w);
	REP(i, b + w){
		ll B = onlyRateB[i];
		ll W = onlyRateW[i];
		ll marble = (1 + 2 * MOD - B - W) % MOD;
		ll ans = (B + mod_div(marble, 2)) % MOD;
		cout << ans << endl;
 	}

	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0); 
    int n;
    cin >> n;
    int cnt = 0 , maxi = 0;
    for(int i = 0; i < n ; ++i){
        char c;
        cin >> c;
        if(c == 'I'){
            cnt++;
        }else{
            cnt--;
        }
        maxi = max(maxi,cnt);
    }
    cout << maxi;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,k,d=MI()
x=abs(x)
if x//d>k:
    ans=abs(x-d*k)
    print(ans)
else:
    k=k-x//d
    pos=x-d*(x//d)
    if k%2==0:
        print(pos)
    else:
        print(abs(pos-d))
        
    
        
        
        
        
        
        
    
    
    
        
        
        
        
        
            
            

Measured memory_bytes: 65620
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        map<string,int> total, prev;
        vi god;
        string date;
        REP(i, n) {
            string d, h, e, p;
            cin >> d >> h >> e >> p;
            if (d != date) {
                date = d; prev.clear(); god.clear();
            }
            int m = stoi(h.substr(0,2)) * 60 +
                    stoi(h.substr(3,2));
            if (p == "000") {
                god.push_back(m);
                continue;
            }
            if (e == "I") {
                prev[p] = m;
            } else {
                for (int j = 0; j < SZ(god); j += 2) {
                    total[p] += max(min((j+1<SZ(god)?god[j+1]:INF),m) - max(god[j],prev[p]), 0);
                }
            }
        }
        int ma = 0;
        for (auto &tp : total) {
            chmax(ma, tp.second);
        }
        cout << ma << endl;
    }

    return 0;
}



Measured memory_bytes: 3256
#include<stdio.h>
#define MAX 100000

int linerSearch(int[], int, int);

main()
{
  int i, n1, n2, S[MAX], T[MAX], count=0;
  
  scanf("%d", &n1);
  for(i=0; i<n1; i++)
    {
      scanf("%d", &S[i]);
    }
  
  scanf("%d", &n2);
  for(i=0; i<n2; i++)
    {
      scanf("%d", &T[i]);
    }
  
  for(i=0; i<n2; i++)
    {
      count += linerSearch(S, T[i], n1);
    }
  printf("%d\n", count);
  
  return 0;
}


int linerSearch(int A[], int key, int n)
{
  int i=0; 
  
  A[n] = key;
  
  while(A[i] != key)
    {
      i++;
      
      if(i == n)
	{
	  return 0;
	}
    }
  
  return 1;
}

Measured memory_bytes: 652
#include <stdio.h>
int main(void){
  char buf[60];
  long long int a, b, k;
  fgets(buf, 60, stdin);
  sscanf(buf, "%lld %lld %lld", &a, &b, &k);
  if(k >= a + b) printf("0 0\n");
  else if(k >= a) printf("0 %lld\n", a + b -k);
  else printf("%lld %lld\n", a - k, b);
  return 0;
}


Measured memory_bytes: 128
import sys

def Partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1, A

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

i, b=Partition(a, 0, n-1)
print(' '.join(map(str, b[0:i])),'['+str(b[i])+']',' '.join(map(str, b[i+1:])))


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

#define line_buf 512
#define ll long long int

int main(){

    int i,j,k;
    int N,count=0;
    char line[line_buf];

    fgets(line,sizeof(line),stdin);

    for(i=0;i<3;i++)if(strncmp(&line[i],"o",1)==0)count += 100;

    printf("%d",count+700);


}


Measured memory_bytes: 128
let m = 1000000007

let () =
  let n = read_int () in
  let s1 = read_line () in
  read_line () |> ignore;
  let rec doit i ps =
    if i = n then ps
    else if i = n - 1 || s1.[i] <> s1.[i+1] then doit (i + 1) (true :: ps)
    else doit (i + 2) (false :: ps) in
  match doit 0 [] with
  | [] -> assert false
  | p :: ps ->
    let _, s = List.fold_left (fun (q, s) p ->
      match q, p with
      | true, true -> true, s * 2 mod m
      | true, false -> false, s * 2 mod m
      | false, true -> true, s
      | false, false -> false, s * 3 mod m)
      (if p then true, 3 else false, 6) ps in
    Printf.printf "%d\n" s

Measured memory_bytes: 2432
# さっき通らなかった配るDP
N,K=map(int,input().split())
H=list(map(int,input().split()))
INF=10**9
add_list=[INF]*K

H.extend(add_list)

dp=[INF]*(N+100) #Kの分追加
dp[0]=0
for n in range(N):
    for k in range(1,K+1):
        dp[n+k]=min(dp[n+k], dp[n]+abs(H[n]-H[n+k]))
print(dp[N-1])

Measured memory_bytes: 52448
from collections import Counter

MOD = 998244353

N = int(input())
D = [int(i) for i in input().split()]

counter = Counter(D)
# print("counter: {}".format(counter))

if D[0] != 0:
    ans = 0
else:
    ans = 1
    count = 1
    for i, item in enumerate(sorted(counter.items(), key=lambda x: x[0])):
        # print("ans: {}".format(ans))
        # print("i: {}, item: {}".format(i, item))
        if i != item[0]:
            ans = 0
            break
        if item[0] == 0 and item[1] != 1:
            ans = 0
            break

        ans *= (count ** item[1]) % MOD
        count = item[1]
print(ans % MOD)


Measured memory_bytes: 21980
#include <iostream>
using namespace std;
int main(){
	int t[100100];
    int n;
    cin >> n;
    int i = 1;
    while(n --)
    {
        cin >> t[i];
        i ++;
    }
    int m;
    cin >> m;
    while(m --)
    {
        int p, x;
        cin >> p >> x;
        int c;
        c = t[p];
        t[p] = x;
        int sum = 0;
        for(int j = 1; j < i; j ++)
        {
            sum += t[j];
        }
        cout << sum <<endl;
        t[p] = c;
    }
    return 0;
}


Measured memory_bytes: 504
#include<stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);

	if(a > b)
		printf("a > b\n");
	else if(a < b)
		printf("a < b\n");
	else
		printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2112
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

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

int main() {
	ll ans = 0;
	ll tmp;
	int t; cin >> t;
	ll n, m, a, b;
	REP(i, t){
		cin >> n >> m >> a >> b;
		cout << floor_sum(n, m, a, b) << endl;
	}
	//cout << ans << endl;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
MOD = 10**9+7

N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for x,y in XY:
    x,y = x-1,y-1
    es[x].append(y)
    es[y].append(x)

dp = [[1,1] for i in range(N)]
def rec(v,p=-1):
    for to in es[v]:
        if to==p: continue
        rec(to,v)
        dp[v][0] *= (dp[to][0] + dp[to][1])
        dp[v][1] *= dp[to][0]
        dp[v][0] %= MOD
        dp[v][1] %= MOD
rec(0)

print(sum(dp[0]) % MOD)

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

int main() {
    int N;
    cin >> N;
    vector<int> r1(N);
    rep(i, 0, N) cin >> r1[i];
    vector<int> r2(N);
    rep(i, 0, N) r2[i] = i+1;
    int ans = 0;
    rep(i, 0, N){
        if(r2[r1[i]-1] == r1[i] && r2[i] == r1[r1[i]-1])ans++;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char S[20];
	scanf("%s", S);

	if (S[5] == '1') {
		printf("TBD");
	}
	else if (S[6] == '1' || S[6] == '2' || S[6] == '3' || S[6] == '4') {
		printf("Heisei");
	}
	else {
		printf("TBD");
	}


}

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

int main() {
	int n, k;
	string s;
	cin >> n >> s >> k;

	char keyWord = s.at(k - 1);

	for (int i = 0; i < n; i++)
	{
		if (s.at(i) != keyWord)
		{
			s.at(i) = '*';
		}
	}
	
	cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int minimum(int, int);

int main(){
    char s[100001];
    int cnt0=0, cnt1=0, i=0;

    scanf("%s", s);

    while(s[i] != '\0'){
        if(s[i] == '0')
            cnt0++;
        else
            cnt1++;
        
        i++;
    }

    printf("%d\n", minimum(cnt0, cnt1)*2);

    return 0;
}

int minimum(int a, int b){
    if(a < b)
        return a;
    else
        return b;
}

Measured memory_bytes: 256
import sys
n=input()
list = n.split(" ")
n=int(list[0])
k=int(list[1])

trees = []
for i in range(n):
  trees.append(int(input()))

def merge_sort(alist):
  if len(alist) <= 1:
    return alist
  
  mid = int(len(alist)/2)
  left = alist[:mid]
  right = alist[mid:]
  
  left = merge_sort(left)
  right = merge_sort(right)
  
  return merge(left, right)

def merge(left,right):
  sorted_list = []
  left_index = 0
  right_index = 0
  
  while left_index < len(left) and right_index < len(right):
    if left[left_index] >= right[right_index]:
      sorted_list.append(left[left_index])
      left_index += 1
    else:
      sorted_list.append(right[right_index])
      right_index += 1
      
  if left:
    sorted_list.extend(left[left_index:])
    
  if right:
    sorted_list.extend(right[right_index:])
    
    return sorted_list

trees = merge_sort(trees)

ans=sys.maxsize
flag=0
temp = []

for i in range(len(trees)-k+1):
  diff = trees[i]-trees[i+k-1]
  if(diff==0):
    ans=0
    break
  if(ans>diff):
    ans=diff
  temp.clear()

print(ans)

Measured memory_bytes: 9372
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll x;
    cin >> x;
    ll p = 100;
    for(int i=1;i<=5000;++i) {
        p *= 1.01;
        if(x <= p) {
            cout << i << endl;
            return 0;
        }
    }
}


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

#define EB insert
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

vector<set<int>> v;
bool ok[N];
int cnt;
void dfs(int s,int p = -1){
	ok[s] = 1;
  cnt++;
	for(auto x : v[s]){
		if(!ok[x]){
			dfs(x,s);
		}
	}
}

int32_t main(){
	IOS;
	int tt = 1; 
	// cin >> tt;
	while(tt--){
		int n,m; cin >> n >> m;
		v.resize(n);
		for(int i = 0; i < n; i++) ok[i] = 0;
		
		for(int i = 0; i < m; i++){
			int a,b; cin >> a >> b;
			a--,b--;
			v[a].EB(b);
			v[b].EB(a);
		}
    int ans = 0;
		for(int i = 0; i < n; i++){
			if(!ok[i]){
				cnt = 0;
				dfs(i);
        ans = max(ans, cnt);
				}
			}

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


Measured memory_bytes: 40916
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] hajime = new char[3];
		char[] owari = new char[3];

		for(int i=0; i<3; i++) {
			String str = sc.next();
			hajime[i] = str.charAt(0);
			owari[i] = str.charAt(str.length() -1);
		}
		
		if(owari[0] == hajime[1] && owari[1] == hajime[2]) {
			System.out.print("YES");
		}else {
			System.out.print("NO");
		}

	}
}

Measured memory_bytes: 22740
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int c = 0;
		if (s[a] == '-') {
			c++;
		} else {
			c = 0;
		}
		for (int i = 0; i < s.length; i++) {
			if (i != a && s[i] == '-') {
				c = 0;
			}
		}
		if (c != 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  int N; cin>>N;
  int x[N];
  ll S=0;
  for(int i=0; i<N; i++){
    cin>>x[i];
    S+=x[i];
  }
  ll p=S/N;
  ll ans1=0,ans2=0;
  for(int i=0; i<N; i++){
    ans1+=(p-x[i])*(p-x[i]);
    ans2+=(p+1-x[i])*(p+1-x[i]);
  }
  cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
   int n;
   cin >> n;
   bool a[9] = {};
   int count3200 = 0;
   rep(i, n) {
       int rate;
       cin >> rate;
       rate = rate / 400;
       if(rate == 0)
           a[rate] = true;
       else if(rate == 1)
           a[rate] = true;
       else if(rate == 2)
           a[rate] = true;
       else if(rate == 3)
           a[rate] = true;
       else if(rate == 4)
           a[rate] = true;
       else if(rate == 5)
           a[rate] = true;
       else if(rate == 6)
           a[rate] = true;
       else if(rate == 7)
           a[rate] = true;
        else{
            rate = 8;
            a[rate] = true;
            count3200++;
        }
   }

   int count = 0;
   rep(i,8){
       if(a[i])
           count++;
   }
   int min_color = count;
   if(min_color == 0)
       min_color = 1;
   int max_color = count + count3200;
   cout << min_color << " " << max_color << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0, count = 0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami,mado[100];
	int manji;
	cin >> a >> b >> c >> f;
	g = min(b, f) - max(a, c);
	if (g <= 0) {
		g = 0;
	}
	cout <<  g<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
const int INF = 1e9 + 7;
using namespace std;

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

	int n, k; cin >> n >> k;
	vector<int> h, dp(n, INF);

	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		h.pb(x);
	}

	dp[0] = 0;
	for(int i = 1; i < n; i++) {
	    for(int j = 1; j <= k && i-j >= 0; j++) {
	    	dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
	    }
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1276
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #pragma GCC optimization ("unroll-loops")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  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 deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
     ll x,k,d;
     cin >> x >> k >> d;
     x = abs(x);
     if(x/k <d){
     	 ll o = x/d;
     	 if((k - o)%2==0){
     	 	cout << (x%d);
     	 }
     	 else{
     	 	cout << (d-(x%d));
     	 }
     }
     else{
     	 cout << (x - (k*d));
     }
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    double[] v = new double[n];
    String[] str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      v[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(v);
    for(int i=0; i<n-1; i++) {
      v[i+1] = (v[i]+v[i+1])/2.00000;
    }
    System.out.println(v[n-1]);
  }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
const int N = 1e5 + 10;
map<string, int>mp;
string a[110];
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		a[i] = s;
		mp[s]++;
	}
	int m;
	scanf("%d", &m);
	for(int i = 0; i < m; i++){
		string ss;
		cin>>ss;
		mp[ss]--;
	}
	int maxx = 0;
	for(int i = 0; i < n;i++){
		if(mp[a[i]] > 0)
			maxx = max(maxx, mp[a[i]]);
	}
	printf("%d\n",maxx);

}

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

int min3(int a, int b, int c){
    if( a < b ) return a < c ? a : c;
    return b < c ? b : c;
}

struct trio{
    int up;
    int left;
    int ver;
    trio(int a, int b, int c) : up(a), left(b), ver(c) {}
};


int main(){
    int n;
    while( cin >> n, n ){
        vector< string > board(n);
        vector< vector< trio > > dp(n, vector< trio >(n, trio(0,0,0)));
        for(int i = 0; i < n; i++){
            cin >> board[i];
        }
        int max_ver = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if( board[i][j] == '*' ) continue;
                if( i ) dp[i][j].up = dp[i-1][j].up + 1;
                else dp[i][j].up = 1;
                if( j ) dp[i][j].left = dp[i][j-1].left + 1;
                else dp[i][j].left = 1;
                if( i*j ) dp[i][j].ver = min3(dp[i-1][j-1].ver + 1,
                                              dp[i-1][j].up + 1,
                                              dp[i][j-1].left + 1);
                else dp[i][j].ver = 1;
                if( dp[i][j].ver > max_ver ){
                    max_ver = dp[i][j].ver;
                }
            }
        }
        cout << max_ver << endl;
    }
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	s[3] = '8';
	cout<<s;
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 237832
#include<stdio.h>

void swap(int *x,int *y){
  int tmp;

  tmp = *x;
  *x = *y;
  *y = tmp;
}

void bubbleSort(int a[], int n){
  int i,j,k;

  k=0;
  for(i=0; i<n-1; i++){
    for(j=n-1; j>=i; j--){
      if(a[j]<a[j-1]){
        swap(&a[j],&a[j-1]);
        k++;
      }
    }
  }
  for(i = 0; i<n-1; i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",k);
}

int main(void){
  int i,n;

  scanf("%d",&n);

  int z[n];

  for(i = 0; i<n; i++){
    scanf("%d",&z[i]);
  }

  bubbleSort(z,n);

  return 0;
}



Measured memory_bytes: 2092
n,m=map(int,input().split())
s=[list(map(int, input().split())) for i in range(n)] 
s.sort()
s.append([0,0])
a=0
b=0
for i in range(n+1):
    if a<m:
        a+=s[i][1]
        b+=s[i][0]*s[i][1]
    else:
        b-=(a-m)*s[i-1][0]
        break
        
print(b)

Measured memory_bytes: 27756
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace std;
 
int main()
{
   FAST/**/
   
   string s;
   cin>>s;
   
   rep(s.length())
        cout<<"x";
   
   return 0;        
}  

Measured memory_bytes: 256
fun main (args:Array<String>) {
    val (blackStone, blackX) = readLine()!!.split(" ").map(String::toInt)
    val min = blackX - (blackStone - 1)
    val max = blackX + (blackStone - 1)
    for(i in min..max){
        print("${i} ")
    }
}

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

int n;
vector<int> v;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	if(n == 0)
		v.push_back(0);
	while(n != 0){
		if(n % 2 == 0){
			v.push_back(0);
		}else{
			v.push_back(1);
			--n;
		}
		n /= (-2);
	}
	reverse(v.begin(), v.end());
	for(int i=0; i<v.size(); ++i)
		cout << v[i];
	cout << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
int main(){
    cin>>a;
    if(a<1200){
        cout<<"ABC"<<endl;
    }else if(a>=1200&&a<2800){
        cout<<"ARC"<<endl;
    }else {
        cout<<"AGC"<<endl;
    }

}


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

int modnum = 1e9 + 7;

void findagc( std::vector< long long > &agc){
    for(int i=0; i<agc.size(); i++){
        int tmp = i % 64;
        if(tmp == 6 || tmp == 9 || tmp == 18){
            agc[i] = 0;
        }
        tmp = i / 4;
        if(tmp == 6 || tmp == 9 || tmp == 18){
            agc[i] = 0;
        }
        if(i == 22 || i == 30 || i == 54){
            agc[i] = 0;
        }
    }
}

int main(){
    int N;
    std::cin >> N;
    
    if(N == 3){
        std::cout << 61 << std::endl;
        return 0;
    }
    
    std::vector< long long > agc(256, 1);
    findagc(agc);
    
    for(int i=4; i<N; i++){
        std::vector< long long > new_agc(256, 0);
        for(int j=0; j<256; j++){
            int index_msb3 = (j % 64) * 4;
            for(int k=0; k<4; k++){
                new_agc[index_msb3 + k] = (new_agc[index_msb3 + k] + agc[j]) % modnum;
            }
        }
        agc = new_agc;
        findagc(agc);
    }
    
    long long ans = 0;
    for(int j=0; j<256; j++){
        ans = (ans + agc[j]) % modnum;
    }
    
    std::cout << ans << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	void printList(int ar[], int n);
	ios::sync_with_stdio(false);
	int cnt;
	cin >> cnt;
	int ar[cnt];
	for (int i = 0; i < cnt; i++)
		cin >> ar[i];

	for (int i = 0; i < cnt; i++) {
		int v = ar[i];
		int j = i - 1;
		while (j >= 0 && ar[j] > v) {
			ar[j + 1] = ar[j];
			j--;
		}
		ar[j + 1] = v;
		printList(ar, cnt);
	}
	return 0;
}

void printList(int ar[], int n) {
	for (int i = 0; i < n; i++) {
		if(i > 0) cout << " ";
		cout << ar[i];
	}
	cout<< endl;
}

Measured memory_bytes: 3120
main(a,b){scanf("%d%d",&a,&b);if(a==2) puts("No");else if(a-4&&a-6&&a-9&&a-11) puts(b==1||b==3||b==5||b==7||b==8||b==10||b==12?"Yes":"No");else puts(b==4||b==6||b==9||b==11?"Yes":"No");}

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

typedef long long int ll;

int main()
{
    ll x;
    cin >> x;
    if(x >= 400 && x < 600){
        cout << 8;
    }
    else if(x < 800){
        cout << 7;
    }
    else if(x < 1000){
        cout << 6;
    }
    else if(x < 1200){
        cout << 5;
    }
    else if(x < 1400){
        cout << 4;
    }
    else if(x < 1600){
        cout << 3;
    }
    else if(x < 1800){
        cout << 2;
    }
    else{
        cout << 1;
    }
    
    return 0;
    
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if (n % sum(n) == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static int sum(int n) {
        int total = 0;
        while (n != 0) {
            total += n % 10;
            n = n / 10;
        }
        return total;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string name;
  int x, y;
  
  cin >> x >> y;
  while((x != 0) || (y != 0)){
     if(x < y){
         cout << x << " " << y << endl;
     } else {
         cout << y << " " << x << endl;
     }
     cin >> x >> y;
  }

}



Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>

#define MAX_N (100000)
#define MAX_M (200000)
#define MAX_C (1000000)
#define INF (1000000000)

using namespace std;

void dfs(const set<pair<int, pair<int, int>>> &adj_list0s,
         set<pair<int, int>> &us, vector<vector<int>> &adj_lists, int i, int c,
         int v) {
  // printf("i = %d, c = %d, v = %d\n", i, c, v);
  adj_lists[i].push_back(v);
  adj_lists[v].push_back(i);
  for (auto it = adj_list0s.lower_bound(make_pair(i, make_pair(c, 0))),
            it_end = adj_list0s.lower_bound(make_pair(i, make_pair(c + 1, 0)));
       it != it_end; ++it) {
    const int j = it->second.second;
    if (us.find(make_pair(c, j)) == us.end()) {
      us.insert(make_pair(c, j));
      dfs(adj_list0s, us, adj_lists, j, c, v);
    }
  }
}

int ps[MAX_M], qs[MAX_M], cs[MAX_M];

int main(int argc, char *argv[]) {
  // read inputs
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d %d", &ps[i], &qs[i], &cs[i]);
    ps[i]--;  // NOTE : modified input
    qs[i]--;  // NOTE : modified input
    cs[i]--;  // NOTE : modified input
  }

  // create graph
  // create adj_list0ss
  set<pair<int, pair<int, int>>> adj_list0s;
  set<pair<int, int>> us;
  for (int i = 0; i < M; i++) {
    const int p = ps[i], q = qs[i], c = cs[i];
    adj_list0s.insert(make_pair(p, make_pair(c, q)));
    adj_list0s.insert(make_pair(q, make_pair(c, p)));
  }
  // create adj_lists
  vector<vector<int>> adj_lists(N, vector<int>());
  int v = N;
  for (pair<int, pair<int, int>> icj : adj_list0s) {
    const int i = icj.first, c = icj.second.first, j = icj.second.second;
    if (us.find(make_pair(c, i)) == us.end()) {
      adj_lists.push_back(vector<int>());
      // printf("starting i = %d, c = %d\n", i, c);
      us.insert(make_pair(c, i));
      dfs(adj_list0s, us, adj_lists, i, c, v);
      // printf("finished i = %d, c = %d\n", i, c);
      v++;
    }
  }
  // for (int i = 0; i < v; i++) {
  //   printf("i = %d:", i);
  //   for (int j : adj_lists[i]) {
  //     printf(" %d", j);
  //   }
  //   printf("\n");
  // }

  // calculate shortest distance
  vector<int> ds(v, -2);
  queue<int> que;
  que.push(0);
  ds[0] = 0;
  while (!que.empty()) {
    const int i = que.front();
    const int d = ds[i];
    que.pop();
    for (int j : adj_lists[i]) {
      if (ds[j] < 0) {
        que.push(j);
        ds[j] = d + 1;
      }
    }
  }
  printf("%d\n", ds[N - 1] / 2);

  return 0;
}


Measured memory_bytes: 66184
#include <iostream>

using namespace std;

int main()
{
	int N, a[100] = { 0 }, A=0, B=0;

	cin >> N;
	int i, j, temp;
	for (i = 0; i < N; i++)
		cin >> a[i];

	for (i = 0; i < N-1; i++) {						//a[0]から降順で最大
		for (j = i+1; j < N; j++) {
			if (a[i] < a[j]) {
				temp = a[i]; a[i] = a[j]; a[j] = temp;
			}
		}
	}

	for (i = 0; i < N; i++) {
		A += a[i];
		i++;
		if (i < N)
			B += a[i];
	}

	cout << A - B << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll h,w,n,ans=0;
    cin >> h >> w >> n;
    ans=n/max(h,w);
    if (n%max(h,w)!=0)ans++;
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}


Measured memory_bytes: 1788