akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
 
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;
 
int n, a[200005];
 
bool check(int m)
{
	if(m == 1) {
		for(int i = 1; i < n; i ++)
		if(a[i] <= a[i - 1]) return false;
		return true;
	}
	map<int, int> cur;
	for(int i = 1; i < n; i ++) {
		if(a[i] > a[i - 1]) continue;
		map<int, int>::iterator cc;
		while((cc = cur.upper_bound(a[i])) != cur.end()) cur.erase(cc);
		cur[a[i]] ++;
		int cp = a[i];
		while(cur[cp] >= m) {
			cur.erase(cp);
			cp --;
			cur[cp] ++;
			if(cp == 0) return false;
		}
	}
	return true;
}
 
int main()
{
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	int l = 1, r = n;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int out[510][510];
int main()
{
	int k;
	cin>>k;
	if(k==1){
		cout<<1<<endl;
		cout<<1<<endl;
		return 0;
	}
	int n=(k+3)/4*2;
	rep(i,n) rep(j,n){
		if(i%2==0) out[i][j]=(i+j)%n;
		else out[i][j]=(i+j)%n+n;
		if(out[i][j]>=k) out[i][j]-=n;
	}
	cout<<n<<endl;
	rep(i,n){
		rep(j,n){
			cout<<out[i][j]+1;
			if(j<n-1) cout<<" ";else cout<<endl;
		}
	}
}


Measured memory_bytes: 2176
//ABC101B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int sigma = 0;
	long long int num = n;
	while(num>0){
		sigma += num%10;
		num /= 10;
	}
	if(n%sigma == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main()
{   int n,a,b,i,m,k,x,y,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a<=c&&c<=b)||(c<=a&&b<=c))
    printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$numbers = explode(" ", fgets(STDIN));
$numbers_1 = array_slice($numbers, 0, $n/2);
$numbers_2 = array_slice($numbers, $n/2, $n);
$total_1 = get_total_numbers($numbers_1);
$total_2 = get_total_numbers($numbers_2);

function get_total_numbers($array){
	$total = 0;
	foreach($array as $number){
		$total += $number;
	}
	return $total;
}

function get_balance($mini_total, $more_total, $array){
	for($i=0; true; $i++){
		$mini_total+=$array[$i];
		$more_total-=$array[$i];
		if($more_total<$mini_total){
			$balance_1 = $mini_total-$more_total;
			$balance_2 = ($more_total+$array[$i]*2)-$mini_total;
			$ret = $balance_1 < $balance_2 ? $balance_1 : $balance_2;
			return $ret;
		}
	}
}

if($total_1 < $total_2){
	$balance = get_balance($total_1, $total_2, $numbers_2);
}else{
	$balance = get_balance($total_2, $total_1, array_reverse($numbers_1));
}

echo $balance . "\n";

?>


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

void solve()
{

    int n; cin>>n;
    int ans = 0;
    for (int a = 1; a <= n; ++a)
    {
        int lfb = 1;
        int rgb = n / a;
        if (rgb * a == n) -- rgb;
        ans += rgb - lfb + 1;
    }
    cout << ans << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << '\n';
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
	int n;
	int a,b,c,d;
	int cnt;
	int i,j,k,l;

	while(scanf("%d",&n) != EOF){
		cnt = 0;
		if(n <= 36){
			for(i = 0;i < 10;i++){
				for(j = 0;j < 10;j++){
					for(k = 0;k < 10;k++){
						for(l = 0;l < 10;l++){
							if(i+j+k+l == n)
								cnt++;
						}
					}
				}
			}
			printf("%d\n",cnt);
		}
		else
			printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 1036
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int dp[1002][10000];
int a[1002];
int open[1002];

int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < m; i++) {
      int b;
      cin >> a[i] >> b;
      
      int bit = 0;
      for (int j = 0; j < b; j++) {
        int c;
        cin >> c;
        c--;
        bit |= (1 << c);
      }
      open[i] = bit;
    }

    for (int i = 0; i < 1002; i++) {
      fill(dp[i], dp[i] + 10000, INT_MAX);
    }

    dp[0][0] = 0;

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < 10000; j++) {
        if (dp[i][j] == INT_MAX) {
          continue;
        }

        int nj = (j | open[i]);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a[i]);
      }
    }

    int last = (1 << n) - 1;
    if (dp[m][last] != INT_MAX) {
      cout << dp[m][last] << endl;
    } else {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const long long mod = 1e9 + 7;

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = min(B, D) - max(A, C);
	if(ans < 0) ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):    # 辺はN-1本
    u, v, w = map(int, input().split())
    G[u-1].append((v-1, w)) # GにGraph情報を格納(直接結合している頂点と距離)
    G[v-1].append((u-1, w))

used = [0] * N
used[0] = 1
q = deque([0])  # u=0 から開始
ans = [0] * N

while q:    # qがある間ループ
    u = q.popleft()
    color = ans[u]
    for v, w in G[u]:   # uに直接結合している頂点(v)と距離(w)
        if used[v]:
            continue
        if w % 2:   # 奇数ならuとvは別の色
            ans[v] = 1 - color
        else:       # 偶数ならuとvは同じ色
            ans[v] = color
        q.append(v) # 幅優先探索
        used[v] = 1

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

Measured memory_bytes: 39828
#include <stdio.h>

int main(void){
    int A, B, C;
  
    scanf("%d%d%d", &A, &B, &C);
  
    int i = 0;
  
    if(A == B && B != C) i = 1;
    if(B == C && A != C) i = 1;
    if(A == C && A != B) i = 1;
  
    if (i) {
      puts("Yes");
    } else {
      puts("No");
    }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<string> s(n);
    map<string, ll> m;
    rep(i, n)cin >> s[i];
    rep(i, n){
        sort(s[i].begin(), s[i].end());
        if(m[s[i]] != 0){
            ans += m[s[i]];
        }
        m[s[i]]++;
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 18424
N, M, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

visited = [False] * (N + 1)
visited[a] = True
visited[b] = True

A = [a]
while True:
    for a in E[a]:
        if not visited[a]:
            A.append(a)
            visited[a] = True
            break
    else:
        break

B = [b]
while True:
    for b in E[b]:
        if not visited[b]:
            B.append(b)
            visited[b] = True
            break
    else:
        break

ans = A[::-1] + B
print(len(ans))
print(*ans)

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

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int main() {
    char b;
    cin >> b;
    char ans;
    switch(b) {
        case 'A':
            ans = 'T';
            break;
        case 'C':
            ans = 'G';
            break;
        case 'G':
            ans = 'C';
            break;
        case 'T':
            ans = 'A';
            break;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int sm = 0;
int vis[N];

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c;
	 cout<<min(a+b, min(b+c,a+c)); 
return 0;
}




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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    string n;
    cin >> n;
    for(int i = 0; i < n.size(); i++){
        if(n[i] == '9') n[i] = '1';
        else n[i] = '9';
    }
    cout << n;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define Rep(i,a,n) for (int i=a;i<=n;i++)
#define Per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
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) { return b?gcd(b,a%b):a;}
// head
const int maxn =    1000010;
char s[maxn];
signed main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    Rep(i,1,n) s[i]-='0';
    int ans=0;
    bool jie=false;
    Per(i,1,n){
        if(s[i]+jie<10-s[i]-jie||(s[i]+jie==10-s[i]-jie&&s[i-1]<5)){
            ans+=jie+s[i];jie=false;
        }else{
            ans+=10-s[i]-jie;jie=true;
        }
    }
    if(jie) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
/*
vll a[mx];
ll l[mx],d[mx];
void dfs(ll x,ll y){
   l[x]=1; d[x]=y;
   for(ll i:a[x])
   if(!l[i])
   dfs(i,y+1);
}
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
*/
 /*sort(a,a+n);
    ll d=1;
    vll z;
    for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
        d++;
    }
    else{
            z.pb(d);
            d=1;
    }
    }
    z.pb(d);*/
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll a,b,z;
   cin>>a>>b;
   a--;
   b--;
   z=b/a;
   if(b%a) z++;
   cout<<z;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int n;
    cin >> n;
    
    rep(i, pow(2, n))
    {
        bitset<18> bit(i);
        cout << i << ":";
        rep(j, 18)
        {
            if (bit.test(j)) cout << " " << j;
        }
        cout << endl;
    }
}



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

long long n, t;
long long v[200005] = {0};

long long solve();

int main() {
  cin >> n >> t;
  for(int i = 0; i < n; ++i) cin >> v[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, fin = v[0] + t;
  for(int i = 1; i < n; ++i) {
    if(fin >= v[i])
      ans += v[i] - v[i - 1];
    else
      ans += t;
    fin = v[i] + t;
  }
  ans += t;
  return ans;
}

Measured memory_bytes: 1792
from sys import stdin

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

n = int(input())
edge = [[] for _ in range(n)]
weight = [[] for _ in range(n)]
for _ in range(n-1):
    i, j, k = map(int, input().split())
    i -= 1
    j -= 1
    edge[i].append(j)
    edge[j].append(i)
    weight[i].append(k)
    weight[j].append(k)

q, k = map(int, input().split())

k -= 1
# root = k
# DFS
distance = [-1] * n
distance[k] = 0
todo = [k]
while len(todo) > 0:
    i = todo.pop(-1)
    for j in range(len(edge[i])):
        if distance[edge[i][j]] == -1:
            distance[edge[i][j]] = distance[i] + weight[i][j]
            todo.append(edge[i][j])

ans = []
for _ in range(q):
    i, j = map(int, input().split())
    ans.append(distance[i-1] + distance[j-1])

for i in ans:
    print(i)


Measured memory_bytes: 109348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	
	reverse(h.begin(), h.end());
	for(int i = 0; i < n-1; ++i){
		if(h[i] < h[i+1]){
			h[i+1] -= 1;
			if(h[i] < h[i+1]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



ll divup(ll a, ll b) {
    if (a > 0) return (a-1)/b+1;
    else return a/b;
}

ll divlo(ll a, ll b) {
    if (a < 0) return (a+1)/b-1;
    else return a/b;
}

int dx[2] = {1, 0};
int dy[2] = {0, 1};


const int MAX = 1010;

int H, W, N;
int a[MAX][MAX];

pint dp[MAX][MAX];

int main() {
    while (cin >> H >> W >> N) {
        if (H == 0) break;
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                cin >> a[i][j];
    
        for (int i = 0; i < MAX; ++i) for (int j = 0; j < MAX; ++j) dp[i][j] = MP(0,0);
        if (a[0][0] == 0) dp[0][0] = MP(divup(N-1,2), divlo(N-1,2));
        else dp[0][0] = MP(divlo(N-1,2), divup(N-1,2));
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (i == 0 && j == 0) continue;
                int num = 0;
                if (i >= 1) num += dp[i-1][j].FI;
                if (j >= 1) num += dp[i][j-1].SE;
                if (a[i][j] == 0) dp[i][j] = MP(divup(num,2), divlo(num,2));
                else dp[i][j] = MP(divlo(num,2), divup(num,2));
                
                //cout << i << ", " << j << " : " << dp[i][j] << endl;
            }
        }
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                int num = dp[i][j].FI + dp[i][j].SE;
                if (num & 1) a[i][j] = 1 - a[i][j];
            }
        }
        int x = 0, y = 0;
        while (x != H && y != W) {
            x += dx[a[x][y]], y += dy[a[x][y]];
        }
        ++x; ++y;
        
        cout << x << " " << y << endl;
    }
    
    return 0;
}


Measured memory_bytes: 13080
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
  std::vector<int> A;
  int k, temp;
  for(int i=0;i<5;i++){
    std::cin >> temp;
    A.push_back(temp);
  }
  std::cin >> k;
  (A[4] - A[0] > k) ? std::cout << ":(" << '\n' :std::cout << "Yay!" << '\n';
  return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N, C, *L = map(int, open(0).read().split())
ls =[[0]*(C+1) for i in range(3)]
D = L[:C*C]
X = L[C*C:]
for i in range(N):
  for j in range(N):
    c = X[i*N+j]
    ls[(i+j)%3][c] += 1
cost = [[0]*(C+1) for i in range(3)]
for i in range(3):
  n = sum(ls[i])
  for j in range(1,C+1):
    for h in range(1,C+1):
      cost[i][j] += D[(h-1)*C+j-1]*ls[i][h]
  
ans = 10**10
for l in permutations(range(1,C+1),3):
  ans = min(ans, sum(cost[i][l[i]] for i in range(3)))
print(ans)

Measured memory_bytes: 21804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll  mod= 1e9+7;
#define int long long
 stack<int>st;
 vector<int>visited;
 vector<unordered_set<int>>graph;
 int curr=0;
void dfs(int i)
{
       visited[i]=1;
      
       for(auto v:graph[i]){
            if(visited[v]==0)
                dfs(v);
       }
       st.push(i);
}
void dfs1(int i)
{
       visited[i]=1;
        curr++;
       for(auto v:graph[i]){
            if(visited[v]==0)
                dfs1(v);
       }
}
void solve(){
    int n;
    int m;
    cin>>n>>m;
    int ans=1;
    graph.resize(n+1);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        graph[a].insert(b);
        graph[b].insert(a);
        //for(auto x:graph[a])
          //  graph[x].insert(b);
       //for(auto x:graph[b])
         //   graph[x].insert(a);
    }
    visited.resize(n+1,0);
   
    for(int i=1;i<=n;i++)
	{
	        if(visited[i]==0)
	            dfs(i);
	}
	for(int i=1;i<=n;i++)
	    visited[i]=0;
	while(st.size()>0)
	{
	        int u=st.top();
	        st.pop();
	        if(visited[u]==0){
	        dfs1(u);
	        ans=max(ans,curr);
	        curr=0;
	       }
	        
	}
	cout<<ans;
  

}
main()
{
   int t=1;
  // int t;
    //cin>>t;
    while(t--)
        solve();  
   return 0;   
}




Measured memory_bytes: 45500
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N;cin>>N;
	double BTC = 380000.0;
	double ans = 0.;
	rp(i,N){
		double x; string u; cin>>x>>u;
		if(u=="JPY"){
			ans += x;
		}
		else{
			ans += x*BTC;
		}
	}
	ote(ans);
}


Measured memory_bytes: 256
n = int(input())
c = list(map(int, input().split()))
MOD = 10**9 + 7

inv2 = pow(2, MOD - 2, MOD)
tmp = pow(2, n, MOD) * pow(2, n, MOD)

tmp %= MOD

c = sorted(c, reverse = True)
ans = 0
for i in range(n):
    ans += tmp * c[i] * (1 + inv2 * i)
    ans %= MOD
print((ans * inv2) % MOD)

Measured memory_bytes: 89036
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int denkyu[m] = {};
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        while(k--){
            int s;
            cin >> s;
            denkyu[i] |= 1<<(s-1);
        }
    }

    int p[m];
    for(int i=0;i<m;i++) cin >> p[i];

    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool flag=true;
        for(int j=0;j<m;j++){
            if(__builtin_popcount(denkyu[j] & i) % 2 != p[j]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

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

    int N;
    cin >> N;
    int A[N];
    double sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[N];
        sum += 1.0 / A[N];
    }
    cout << 1 / sum << endl;
    return 0;
}


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

const int MAX = 1e5+10;
const int INF = 1e9+10;

int n, k;
int vet[MAX];
int memo[MAX];

int pd(int i) {

    if(i == 0) return 0;

    if(memo[i] != -1) return memo[i];

    int ans = INF;

    for(int j = 1; j <= k; ++j) {
        if(i - j < 0) break;
        ans = min(ans, abs(vet[i] - vet[i-j]) + pd(i-j));
    }

    return memo[i] = ans;
}
int main() {
    memset(memo, -1, sizeof memo);
    cin>>n>>k;
    for(int i = 0; i < n; ++i) {
        cin>>vet[i];
    }
    int ans = pd(n - 1);
    cout<<ans<<"\n";
}


Measured memory_bytes: 7296
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=3e5+5,maxs=(1<<16) + 5;

int n,cnt[maxn],w[maxn],ans;
int goodst[maxs], dp[maxs];

int main(){	
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		++x;++y;
		w[x] ^= z;w[y] ^= z;
	}
	
	for(int i=1;i<=n;i++)++cnt[w[i]];
	for(int i=1;i<=15;i++)
		ans += cnt[i]/2, cnt[i]%=2;
	int lim=0;for(int i=1;i<=15;i++)lim |= (cnt[i] == 0?0:(1<<i)), ans += (cnt[i]!=0);
	for(int S=0;S<=(1<<16)-1;S++){
		int x=0;
		for(int i=0;i<=15;i++)
			if(S&(1<<i))x^=i;
		goodst[S] = 0;if(x==0)goodst[S] = 1;
	}
	
	for(int S=0;S<=(1<<16)-1;S++){
		if(S&1)continue;
		for(int T=S;T;T=(T-1)&S){
			if(goodst[T])
				dp[S] = max(dp[S], dp[S^T]+1);
		}
	}
	printf("%d\n",ans-dp[lim]);

	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	double t, a;
	cin >> t >> a;
	double diff_min=1E9;
	int select;
	for(int i=0; i<n; i++){
		double h;
		cin >> h;
		double temp=t-h*0.006;
		if(abs(temp-a)<diff_min){
			select=i;
			diff_min=abs(temp-a);
		}
	}
	cout << select+1 << endl;
	return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int ans[510][510];

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

	int N, M, Q;
	cin >> N >> M >> Q;

	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

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

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

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

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 3010;
const int MAX_T = 3010;

int dp1[MAX_N][MAX_T] = {}; // dp[i][j] : 1からiまでの食べ物を見て，j分以下の最大満足度
int dp2[MAX_N][MAX_T] = {}; // dp[i][j] : Nから数えてi番目までの食べ物を見て，

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

    int N,T; cin >> N >> T;
    VI A(N),B(N);
    REP(i,N){
        cin >> A[i] >> B[i];
    }

    FOR(i,1,N+1){
        REP(j,T){
            if(j-A[i-1] >= 0) dp1[i][j] = max(dp1[i-1][j],dp1[i-1][j-A[i-1]]+B[i-1]);
            else dp1[i][j] = dp1[i-1][j];
        }
    }

    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());

    FOR(i,1,N+1){
        REP(j,T){
            if(j-A[i-1] >= 0) dp2[i][j] = max(dp2[i-1][j],dp2[i-1][j-A[i-1]]+B[i-1]);
            else dp2[i][j] = dp2[i-1][j];
        }
    }

    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());


    int ans = 0;
    REP(i,N){
        REP(j,T){
            //dump(i)
            //dump(j)
            //dump(dp1[i][j])
            chmax(ans,dp1[i][j]+dp2[N-i-1][T-1-j]+B[i]);
            // iが2 3番目の食べ物 dp1[2] +
        }
    }
    cout << ans << endl;



}


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

int main(void) {
    int N,X;cin>>N>>X;
    vector<int> vc(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin>>vc[i];
        sum += vc[i];
    }
    sort(vc.begin(), vc.end());
    int result = N;
    result += (X - sum) / vc.at(0);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vd = std::vector<double>;
using vc = std::vector<char>;
using vb = std::vector<bool>;
using vs = std::vector<std::string>;
using vpii = std::vector<pii>;
using vvi = std::vector<vi>;
using vvb = std::vector<vb>;
using vvpii = std::vector<vpii>;
template<typename A> using fn = std::function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

template<typename T> struct Monoid {
  T id;
  std::function<T(T, T)> op;
  Monoid(T e, std::function<T(T, T)> f) : id(e), op(f) {}
};

template<typename T> class SegTree {
  vector<T> data;
  Monoid<T> monoid;
  int size = 1;

  T _fold(const int &a, const int &b, const int &k = 1, const int &l = 0, int r = -1) {
    if (r == -1) r = size;
    if (r <= a || b <= l) return monoid.id;
    if (a <= l && r <= b) return data[k];
    return monoid.op(_fold(a, b, k * 2, l, (l + r) / 2), _fold(a, b, k * 2 + 1, (l + r) / 2, r));
  }

public:
  SegTree(const int &n, const Monoid<T> &m) : monoid(m) {
    while (size < n) size *= 2;
    data = vector<T>(2 * size, monoid.id);
  }

  T get(const int &i) { return data[i + size]; }
  T fold(const int &a, const int &b) { return _fold(a, b, 1, 0, size); } // [a, b)

  void update(int i, const T &x) {
    i += size;
    data[i] = x;
    while (i /= 2) data[i] = monoid.op(data[i * 2], data[i * 2 + 1]);
  }
};

template<int upperInf = std::numeric_limits<int>::max() / 8> Monoid<int> minMonoid = {upperInf, [](int a, int b) { return min(a, b); }};

main {
  int n, q;
  cin >> n >> q;
  SegTree<int> t(n, minMonoid<2147483647>);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << t.fold(x, y + 1) << endl;
    } else {
      t.update(x, y);
    }
  }
}

Measured memory_bytes: 4952
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    ll x, ans = 0;
    cin >> x;
    if(x%11==0) ans = x/11 * 2;
    else if(x%11 < 7) ans = x/11 * 2 + 1;
    else ans = x/11 * 2 + 2;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, i, a[1000], dap=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>a[i];
    dap+=((i%2)&&(a[i]%2));
    }
    cout<<dap;
    
    
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[n+5];
	for(int i=0;i<n;i++)
	cin>>a[i];
	long long count=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
				{
				if((a[i]+a[j]<=a[k]) || a[i]+a[k]<=a[j] || a[j]+a[k]<=a[i])
				continue;
				else
				count++;
				}
			}
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){

	int n;
	int hit;
	int sum;

	while(1){
		cin>>n;
		if(n==0) break;
		sum=0;
		for(int i=0;i<n/4;i++){
			cin>>hit;
			sum+=hit;
		}
		cout<<sum<<endl;
	}
}

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

int ac[1000005];
int main() {
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  for(int i = 1; i <= s.size(); i++) {
    ac[i] += ac[i-1];
    if(s[i - 1] == 'A') {
      if(i < s.size() && s[i] == 'C') ac[i+1]++;
    }
  }

  for(int i = 0; i < q; i++) {
    int l,r;
    cin >> l >> r;
    int ans = 0;
    ans = ac[r] - ac[l - 1];
    if(l - 2 >= 0 && s[l-2] == 'A' && s[l-1] == 'C') ans--;
    cout << ans << endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n; cin >> n;
    int ans = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        ans += b - a + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

//Union-Find解答
int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> ed(m, vector<int> (2));

    rep(i,m){
        cin >> ed[i][0] >> ed[i][1];
        ed[i][0]--; ed[i][1]--;
    }

    int ans = 0;
    rep(_,m){
        bool jud = false;
        UnionFind<int> uf(n);
        rep(i,m){
            if(i == _) continue;
            uf.merge(ed[i][0],ed[i][1]  ,0);
        }

        rep(i,n){
            rep(j,n){
                if(i == j) continue;

                if(!uf.issame(i,j)){
                    jud = true;
                }

            }
        }
        if(jud) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        boolean h = true;
        boolean ok = true;
        for(int i = 0; i < S.length(); i++) {
        	if(h) {
        		if(S.charAt(i) != 'h')
        			ok = false;
        		h = false;
        	}
        	else {
        		if(S.charAt(i) != 'i')
        			ok = false;
        		h = true;
        	}
        }
        if(S.length() % 2 != 0)
        	ok = false;
        System.out.println(ok ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  ll ans=1e16;
  for(int s=0;s<(1<<n);s++){
    int x=0;
    for(int j=0;j<n;j++){
      if(s&(1<<j)) x++;
    }
    if(x<k) continue;
    ll ma=0;
    ll res=0;
    for(int j=0;j<n;j++){
      if(s&(1<<j)){
        if(ma>=a[j]){
          res=res+ma-a[j]+1;
          ma++;
        }
      }
      ma=max(ma,a[j]);
    }
    ans=min(ans,res);
  }
  cout<<ans<<endl;

  return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

long long factrial[1010101]; //階乗を保持
long long inverse[1010101];  //逆元を保持

class FermatCombination {
private:

public:
	FermatCombination(int size);
	long long combine(int n, int k);
	long long fast_pow(long long x, int n);
};

FermatCombination::FermatCombination(int size) {

	factrial[0] = 1;
	inverse[0] = 1;

	for (int i = 1; i <= size; i++) {
		factrial[i] = (factrial[i - 1] * i) % MOD;  // 階乗を求める
		inverse[i] = fast_pow(factrial[i], (int)MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
	}
}

long long FermatCombination::combine(int n, int k) {
	return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

long long FermatCombination::fast_pow(long long x, int n) { // x^n 計算量O(logn)
	long long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD; // 一周する度にx, x^2, x^4, x^8となる
		n >>= 1;         // 桁をずらす n = n >> 1
	}
	return ans;
}

/*==================================================*/
int manhattan(int x1,int y1,int x2,int y2){
    return abs(x1-x2)+abs(y1-y2);
}

int main(){
    int X,Y;
    cin >> X >> Y;
    if(!(Y-2*X<=0 && 2*Y-X>=0 && (X+Y)%3==0)){
        P(0);
    }else{
        int N,zeroX,zeroY;
        N=(X+Y)/3;
        zeroX=N;
        zeroY=2*N;

        int R = manhattan(zeroX, zeroY, X, Y)/2;

        FermatCombination fc(N);     // 初期化と nCi % mod の計算
	    long long ans = fc.combine(N, R); // nCr % modの値の取得

        //cout << N << " " << R << endl;
	    cout << ans << endl;
    }
    
}

Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {
	/**
	 * AC or WA
	 * @param 1 ≤ N ≤ 100
	 * @param 0 ≤ M ≤ N
	 */
	public static void main(String... args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == m) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

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

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int lens = s.size();
    int lent = t.size();

    int sint[lens];
    int tint[lent];
    for (int i=0; i<lens; ++i) sint[i] = s[i] - 'a';
    for (int i=0; i<lent; ++i) tint[i] = t[i] - 'a';
    sort(sint, sint+lens);
    sort(tint, tint+lent, greater<int>());

    int sint0[110] = {0};
    int tint0[110] = {0};
    for (int i=0; i<lens; ++i) sint0[i] = sint[i];
    for (int i=0; i<lent; ++i) tint0[i] = tint[i];

    bool can = false;
    for (int i=0; i<110; ++i) {
        if (sint0[i] < tint0[i]) {
            can = true;
            break;
        } else if (sint0[i] > tint0[i]) {
            break;
        }
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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

    vector<int> a(n);
    double s = 0;
    for (auto& x : a) {
        cin >> x;
        s += x;
    }
    s /= n;

    int idx = 0;
    double mi = 110;
    for (int i = 0; i < n; i++) {
        double t = abs(a[i] - s);
        if (t < mi) {
            idx = i;
            mi = t;
        }
    }

    cout << idx << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::string s;
    std::cin >> s;

    size_t a = 0, z = s.length();
    for (; s[a] != 'A'; a++);
    for (; s[z-1] != 'Z'; z--);

    std::cout << z - a  << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

  int A,B,C;

  std::cin >> A;
  std::cin >> B;
  std::cin >> C;
  
  
  if(B/A>=C){
    cout <<C <<endl;
  }else{
    cout <<B/A <<endl;
  }
  return 0;
   
}


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


Measured memory_bytes: 2140
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;

int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(n<m)n=m;
    printf("%d\n",(k+n-1)/n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a,b,c) min(a,min(b,c))
typedef long long ll;

void ans(bool qus){
    if (qus == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Ans(bool qust){
    if (qust == true)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

////////////////---START---////////////////

void solve(int a, int b, int c){
    bool s = (c >= a) && (b >= c);
    ans(s);
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    solve(a, b, c);
}

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

int G[110][110];
bool seen[110];
int d[110];
int N;

struct MyQueue{
    int num[110];
    int head = 0;
    int tail = 0;

    void enqueue( int n ){
        num[tail++] = n;
    }

    int dequeue(){
        return num[head++];
    }

    bool empty(){
        return head == tail;
    }
};

int main(){
    cin >> N;
    for( int i = 0; i < N; i++ ){
        int u, k; cin >> u >> k;
        u--;
        for( int j = 0; j < k; j++ ){
            int v; cin >> v;
            v--;
            G[u][v] = 1;
        }
    }

    MyQueue que;
    que.enqueue( 0 );
    seen[0] = 1;
    while( !que.empty() ){
        int u = que.dequeue();
        for( int v = 0; v < N; v++ ){
            if( G[u][v] && !seen[v] ){
                que.enqueue( v );
                d[v] = d[u] + 1;
                seen[v] = 1;
            }
        }
    }

    for( int i = 1; i < N; i++ ){
        if( d[i] == 0 ) d[i] = -1;
    }

    for( int i = 0; i < N; i++ ){
        cout << i + 1 << " " << d[i] << endl;
    }
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main{

	static Scanner scan = new Scanner(System.in);
	
	/**
	 * 入力した数字を反対側から出力するプログラム
	 * @param args
	 */
	public static void main(String[] args){
		int n = scan.nextInt();
	//	int n = Integer.parseInt(args[0]);
		int[] a= new int[100];
		for(int i= 1 ; i<n+1;i++){
			a[i-1] = scan.nextInt();
//			a[i-1] = Integer.parseInt(args[i]);
		}

		for(int i = 0;i <n;i++){
			System.out.print(a[n-i-1]);
			if(i != n-1)
				System.out.print(" ");
		}
		System.out.println("");//おまじない
	}
}



Measured memory_bytes: 26164
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long res = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 5 != 0 && i % 3 != 0) {
                res += i;
            }
        }

        System.out.println(res);

        sc.close();
    }
}


Measured memory_bytes: 35648
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      String S =sc.next();
      String T =sc.next();
      int count =0;
      
      for(int i=0;i<3; i++){
         if(S.charAt(i)==T.charAt(i)){
         count++;
         }
      }
      System.out.print(count);
    }
}

Measured memory_bytes: 23892