akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

#include <queue>

using namespace std;



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

  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.rbegin(), v.rend());

  int biggest = v[0];
  int target = biggest / 2;

  int ansval = 0;

  for(int i=1;i<n;i++) {
    int val = v[i];
    if(abs(ansval - target) > abs(val - target))
      ansval = val;
  }
  cout << biggest << " " << ansval << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		while(true){
			String str = (a > b) ? b + " " + a : a + " " + b;
			System.out.println(str);
			a = sc.nextInt();
			b = sc.nextInt();
			if(a == 0 && b == 0) break;
		}
		
	}

}

Measured memory_bytes: 27140
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
list_ab = []
for _ in range(m):
    a, b = map(int, input().split())
    list_ab.append((a - 1, b - 1))

good = [True for _ in range(n)]
for a, b in list_ab:
    if h[a] <= h[b]:
        good[a] = False
    if h[a] >= h[b]:
        good[b] = False

answer = sum([int(i) for i in good])
print(answer)


Measured memory_bytes: 27996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;

int main()
{
	int n, k = 0;
	cin >> n >> k;;
	int num[n] = {0};
	int buf = 0;
	for (int i = 0; i < n; i++)
	{
		int buf = 0;
		cin >> buf;
		num[buf - 1] += 1;
	}
	sort(num, num + n);

	int ct = 0;
	for (int i = 0; i < n; i++)
	{
		if (num[i] > 0 )
		{
			ct++;
		}
	}
		int ans = 0;

	if (ct <= k)
	{
		cout << ans << "\n";
		return 0;

	}
	int r = 0;
	for (int i = 0; i < n; i++)
	{
		if (num[i] > 0)
		{
			ans += num[i];
			r++;
		}
		if (r == ct - k)
		{
			break;
		}
	}



	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        String s = in.nextLine();
        String t = in.nextLine();
        if(t.substring(0,t.length()-1).equals(s))
            System.out.println("Yes\n");
        else System.out.println("No\n");
    }
}

Measured memory_bytes: 32708
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import permutations
    from math import factorial

    N = int(readline())
    mat = []
    s = 0

    for _ in range(N):
        x, y = map(int, readline().split())
        mat.append([x, y])

    for per in permutations(range(N)):
        for i in range(N - 1):
            x1, y1 = mat[per[i]]
            x2, y2 = mat[per[i + 1]]
            s += ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5

    print(s / factorial(N))


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;

#define all(x) x.begin(), x.end()
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define en '\n'
#define debug(x) cout << #x  << " : " << x << en
#define debug2(x, y) cout << #x << " : " << x  << " " << #y << " : " << y << en

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

  int t;
  cin >> t;
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  while(t--) {
    string s;
    cin >> s;
    if(s == "AC") c1++;
    else if(s == "WA") c2++;
    else if(s == "TLE") c3++;
    else c4++;
  }
  cout << "AC x " + to_string(c1) << en;
  cout << "WA x " + to_string(c2) << en;
  cout << "TLE x " + to_string(c3) << en;
  cout << "RE x " + to_string(c4) << en;
  return 0;
}


Measured memory_bytes: 3716
#少なくとも表示が楽
#import numpy as np


P=10**9+7
N,K=map(int,input().split())
G=[]
for index in range(N):
    G.append(list(map(int,input().split())))
#こうするしかない
#G=np.matrix(G)

#print(np.dot(G,G))
#print(G*G)は正しくならないがおそらくversionの問題

def mul(x,y,p): #x[0]とlen(y)が同じなのは前提
    res=[[0]*(len(y[0])) for _ in range(len(x))]
    #res[index1][index2]を決定
    for index1 in range(len(x)):
        for index2 in range(len(y[0])):
            for index3 in range(len(y)):  #len(x[0])でも良い　
                res[index1][index2]=(res[index1][index2]+x[index1][index3]*y[index3][index2])%p
    return res


def pow(x,y,p):
    res=[[0]*(len(x)) for _ in range(len(x))]
    for index1 in range(len(x)):
        res[index1][index1]=1
    
    while y>0:
        if y&1==1:
            res=mul(res,x,p)
        x=mul(x,x,p)
        y=y>>1
    
    return res

#print(np.matrix(pow(G,2,P)))

#DP_K=np.matrix(pow(G,K,P))
DP_K=pow(G,K,P)

ans=0
for i in range(N):
    for j in range(N):
        #ans=(ans+DP_K[i,j])%P
        ans=(ans+DP_K[i][j])%P

print(ans)




Measured memory_bytes: 43132
use std::collections::VecDeque;
use std::io::stdin;

const INF: usize = 1 << 30;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let n: usize = itr.next().unwrap();
    let m = itr.next().unwrap();
    let mut edge = vec![vec![]; 200002];

    for _ in 0..m {
        s.clear();
        stdin().read_line(&mut s).ok();
        let mut itr = s.split_whitespace().map(|e| e.parse::<usize>().unwrap());
        let a = itr.next().unwrap() - 1;
        let b = itr.next().unwrap() - 1;
        edge[a].push(b);
        edge[b].push(a);
    }

    let mut queue = VecDeque::new();
    let mut ans = vec![INF; n];
    queue.push_back(0);
    while !queue.is_empty() {
        let now = queue.pop_front().unwrap();

        for &e in edge[now].iter() {
            if ans[e] == INF {
                ans[e] = now;
                queue.push_back(e);
            }
        }
    }
        println!("Yes");
        for e in ans.iter().skip(1) {
            println!("{}", e + 1);
        }
}


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

const long long MIN = -1e18;

int main(void) {
    long long N, K;
    cin >> N >> K;
    vector< long long > P(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        --P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    long long ans = MIN;
    for (int i = 0; i < N; i++) {
        vector< long long > v_score(N, 0);
        long long len = 0, score = 0, cur = i;
        do {
            cur = P[cur];
            ++len;
            score += C[cur];
            v_score[len - 1] = score;
        } while (cur != i);
        for (int j = 0; j < len; j++) {
            long long rest = K - j - 1;
            if (rest < 0) {
                break;
            }
            ans = max(ans, v_score[j] + max(0LL, v_score[len - 1]) * (rest / len));
        }
    }
    printf("%lld\n", ans);

    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, n) {
        cin >> x[i] >> v[i];
    }
    vector<ll> dp1(n, 0), dp2(n, 0);
    dp1[0] = v[0] - x[0];
    for (int i=1; i<n; ++i) dp1[i] = dp1[i-1]+v[i]-(x[i]-x[i-1]);
    for (int i=1; i<n; ++i) dp1[i] = max(dp1[i], dp1[i-1]);

    dp2[n-1] = v[n-1] - (c - x[n-1]);
    for (int i=n-2; i>=0; --i) dp2[i] = dp2[i+1]+v[i]-(x[i+1]-x[i]);
    for (int i=n-2; i>=0; --i) dp2[i] = max(dp2[i], dp2[i+1]);

    ll ans = max(0LL, dp2[0]);
    rep(i, n) {
        ll tmp = dp1[i];
        if (i+1<n and dp2[i+1]-x[i]>0) tmp += dp2[i+1] - x[i];
        ans = max(ans, tmp);
    }
    for (int i=n-1; i>=0; --i) {
        ll tmp = dp2[i];
        if (i >= 1 and dp1[i-1] - (c - x[i]) > 0) tmp += dp1[i-1] - (c - x[i]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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

int main()
{
  ll N, K;
  cin >> N >> K;
  
  ll amari = N % K;

  ll abs_val = abs(amari - K);
  if (amari > abs_val)
  {
	cout << abs_val << endl;
  }
  else
  {
    cout << amari << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int x[N],n,ans;
int main(){
	cin>>n;
	x[0]=N;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		if(x[i]==min(x[i],x[i-1]))ans++;
		x[i]=min(x[i],x[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[100005], b[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i <= n; ++i)
		cin >> arr[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		res += min(arr[i] + arr[i + 1], b[i]);
		arr[i + 1] = max(0LL, arr[i + 1] - max((b[i] - arr[i]), 0LL));
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int H, A;
  cin >> H >> A;
  if (H % A == 0) {
    cout << H / A << endl;
  } else {
    cout << H / A + 1 << endl;
  }
}

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

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    while(Q--){
        int l, r;
        cin >> l >> r;
        int ans = upper_bound(A.begin(), A.end(), r) - lower_bound(A.begin(), A.end(), l);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
n, t = map(int, input().split())
a = list(map(int, input().split()))

profit = -1
low = a[0]
for i in range(n):
    if a[i] < low:
        low = a[i]
    x = 0 if low > a[i] else a[i] - low
    if profit < x:
        profit = x

ans = 0
low = a[0]
for i in range(n):
    diff = a[i] - low
    if diff == profit:
        ans += 1
    if a[i] < low:
        low = a[i]

print(ans)

Measured memory_bytes: 63728
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin
        .read_line(&mut buf)
        .unwrap();

    let d: Vec<usize> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    if d[0] % 3 == 0 || d[1] % 3 == 0 || (d[0] + d[1]) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>cnt;
int t,n,i,a;
cin>>n;
while(n--)
{
cin>>a;
cnt[a]++;
}
        int ans=0;
    for(auto u: cnt){
        if(u.second>=u.first) ans+=(u.second-u.first);
  else ans+=u.second;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7984
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(max(a,c)-min(a,c) <= d or (max(a, b) - min(a, b) <= d and max(b, c) - min(b, c) <= d))cout<<"Yes"<<endl;
	else cout <<"No"<<endl;
}

Measured memory_bytes: 256
import math
a,b,n = map(int,input().split())
x = 0
ans = 0
if b > n:
    x = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
else:
    n = b-1
    ans = math.floor(a*n/b) - a*math.floor(n/b)
print(ans)


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

int n,a,b;

bool yymm(int a,int b)
{
	if (0<=a&&a<=99&&1<=b&&b<=12)  return true;
	else return false;
}

bool mmyy(int a,int b)
{
	if (0<=b&&b<=99&&1<=a&&a<=12)  return true;
	else return false;
}

signed main()
{
	cin>>n;
	a=n/100,b=n%100; 
	
	if (yymm(a,b)&&!mmyy(a,b))  cout<<"YYMM"<<endl;
	else if (!yymm(a,b)&&mmyy(a,b))  cout<<"MMYY"<<endl;
	else if (yymm(a,b)&&mmyy(a,b))  cout<<"AMBIGUOUS"<<endl;
	else cout<<"NA"<<endl;	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

N, M = map(int, input().split())

nl = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, D = map(int, input().split())
    nl[L].append((R, D))
    nl[R].append((L, -D))

# print(nl)
    
seen = [None for _ in range(N + 1)]

def dfs(v, d):
    # print("dfs ", v, d)
    seen[v] = d
    for next_v, D in nl[v]:
        next_d = d + D
        if seen[next_v] is None:
            dfs(next_v, next_d)
        else:
            if seen[next_v] != next_d:
                print('No')
                exit(0)
                
for v in range(1, N + 1):  # すべての連結成分に対してDFS
    if seen[v] is None:
        dfs(v, 0)

print('Yes')

Measured memory_bytes: 129012
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0.0
    for (i in 1..n) {
        var p = 1.0 / n
        var x = i
        while (x < k) {
            p *= 0.5
            x *= 2
        }
        ans += p
    }
    println(ans)
}


Measured memory_bytes: 36632
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e3 + 5;
const int MAXM = 1e3 + 5;
const int inf = 0x3f3f3f3f;
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};

char s[MAXN][MAXM];

struct Node
{
	int x,y,dis;
};
inline bool operator < (const Node &p,const Node &q){ return p.dis > q.dis;}

int dis[MAXN][MAXM];
bool vis[MAXN][MAXM];

int main(void)
{
	int n,m,sx,sy,tx,ty;
	scanf("%d%d",&n,&m);
	scanf("%d%d",&sx,&sy);
	scanf("%d%d",&tx,&ty);
	for(int i=1; i<=n; ++i)
		scanf("%s",s[i]+1);
	
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			dis[i][j] = inf;
	dis[sx][sy] = 0;
	
	priority_queue<Node> q;
	q.push((Node){sx,sy,0});
	
	while(!q.empty())
	{
		Node now = q.top(); q.pop();
		int x = now.x, y = now.y;
		if(vis[x][y]) continue;
		vis[x][y] = 1;
		
		for(int k=0; k<4; ++k)
		{
			int xx = x + dx[k];
			int yy = y + dy[k];
			if(xx>=1 && xx<=n && yy>=1 && yy<=m && s[xx][yy] != '#' &&dis[xx][yy] > dis[x][y])
			{
				dis[xx][yy] = dis[x][y];
				q.push((Node){xx,yy,dis[xx][yy]});
			}
		}
		for(int i=-2; i<=2; ++i)
			for(int j=-2; j<=2; ++j)
			{
				int xx = x + i, yy = y + j;
				if(xx>=1 && xx<=n && yy>=1 && yy<=m && s[xx][yy] != '#' && dis[xx][yy] > dis[x][y] + 1)
				{
					dis[xx][yy] = dis[x][y] + 1;
					q.push((Node){xx,yy,dis[xx][yy]});
				}
			}
	}
	
	if(dis[tx][ty] == inf) printf("-1");
	else printf("%d\n",dis[tx][ty]);
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> S(50);
    for (int i = 0; i < h; i++) {
        cin >> S[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (S[i][j] == '.') {
                int cnt = 0;
                for (int k = i - 1; k <= i + 1; k++) {
                    for (int l = j - 1; l <= j + 1; l++) {
                        if (k == -1 || k == h || l == -1 || l == w) {
                            continue;
                        }
                        if (k == i && l == j) {
                            continue;
                        }
                        if (S[k][l] == '#') {
                            cnt++;
                        }
                    }
                }
                S[i].replace(j, 1, to_string(cnt));
            }
        }
    }

    for (int i = 0; i < h; i++) {
        cout << S[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll c[502],s[502],f[502];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	for(int i=0;i<n;i++){
		ll sum=0;
		for(int j=i;j<n-1;j++){
			if(sum<=s[j]){
				sum=s[j]+c[j];
				continue;
			}
			ll now=(sum+f[j]-1)/f[j];
			sum=now*f[j]+c[j];
		}
		cout << sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

static const int N = 100;

int main()
{
  int n,A[N][N],i,j,k,l,m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&k,&l);
    k--;
    for(j=0;j<l;j++){
      scanf("%d",&m);
      m--;
      A[k][m] = 1;
    }
  }

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

  return 0;
}


  



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>

int main() {
	long int n;
	scanf("%ld", &n);
	if (n%2 == 0) {
		printf("%lf", 1.0/2.0);
	}else {
		printf("%lf", (n+1.0)/(2.0*n));
	}
	return 0;
}

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

typedef struct node{
	char key[25];
	int data;
	int priority;
	struct node *left;
	struct node *right;
}node;


int find(node *p,char str[]){

	while(p!=NULL){
		if(strcmp(p->key,str)==0)return p->data;
		else if(strcmp(p->key,str)>0)p=p->left;
		else p=p->right;
	}
	
	return 0;
	
}

void update(node *p,char str[],int x){

	while(p!=NULL){
		if(strcmp(p->key,str)==0){
			p->data=x;
			return;
		}
		else if(strcmp(p->key,str)>0)p=p->left;
		else p=p->right;
	}
	
	return;
	
}


node * makenode(char key[],int x,int y){
	node *new=malloc(sizeof(node));
	strcpy(new->key,key);
	new->data=x;
	new->priority=y;
	new->left=NULL;
	new->right=NULL;
	return new;
}

node *rightRotate(node *p){
	node *q=p->left;
	p->left=q->right;
	q->right=p;
	return q;
}

node *leftRotate(node *p){
	node *q=p->right;
	p->right=q->left;
	q->left=p;
	return q;
}


node* insert(node **t,char key[],int x,int priority){
	node *new;
	
	if((*t)==NULL)
		return new=makenode(key,x,priority);
	if (strcmp((*t)->key,key)==0)
		return *t;
	
	if(strcmp(key,(*t)->key)<0){
		(*t)->left=insert(&(*t)->left,key,x,priority);
		if((*t)->priority < (*t)->left->priority)
			(*t)=rightRotate((*t));
	}
	else {
		(*t)->right=insert(&(*t)->right,key,x,priority);
		if((*t)->priority < (*t)->right->priority)
			(*t)=leftRotate((*t));
	}
	
	return *t;
}

int main(){
	int q,x,com;
	char str[25];
	node *root=NULL;
	srand((unsigned)time(NULL));
	
	scanf("%d",&q);
	
	for(int i=0;i<q;i++){
		scanf("%d %s",&com,str);
		
		if(com==0){
			scanf("%d",&x);
			if(!find(root,str)){
				root=insert(&root,str,x,rand()%200001);
			}
			else {
				update(root,str,x);
			}
		}
		else if(com==1){
			printf("%d\n",find(root,str));
		}
		
	}
		
	return 0;
	
}


Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
using lli  = long long;
using ulli = unsigned long long;

// https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
struct UnionFind {
    vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;

    UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
        size.resize(N);
        for (int i = 0; i < N; i++) {
            par[i]  = i;
            size[i] = 1;
        }
    }

    int root(
        int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);       // xの根をrx
        int ry = root(y);       // yの根をry
        if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry;  // xとyの根が同じ時：xの根rxをyの根ryにつける
        // cout << x << ", " << rx << "), (" << y << ", " << ry << ")\n";
        size[ry] += size[rx];
        // cout << size[ry] << "\n";
    }
};

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

    UnionFind friends(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        friends.unite(a - 1, b - 1);
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt = max(friends.size[i], cnt);
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 4832
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
//rep(i, v.size()) v[i]=i;
#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

signed main(){
  int A, B, K;
  cin >> A >> B >> K;

  if(A >= K)cout << A - K << " " << B << endl;
  else if(A + B >= K)cout << 0 << " " << B - (K - A) << endl;
  else cout << 0 << " " << 0 << endl;

  //rep(i, K){
  //  if(A > 0)A--;
  //  else B--;
  //}

  //if(A < K){
  //  //A = 0;
  //  B = B - (K - A);
  //  A = 0;
  //}else if(A >= K){
  //  A -= K;
  //}

  //cout << A << " " << B << endl;
}


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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int h[100005];
typedef long long ll;
int main()
{
	int n,q,t1,t2;
	ll sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=ll(a[i]);
		h[a[i]]++;
	}
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&t1,&t2);
		sum+=ll(h[t1])*ll(t2-t1);
		printf("%lld\n",sum);
		h[t2]+=h[t1];
		h[t1]=0;
	}
	return 0;
}

Measured memory_bytes: 4600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String S, T1, T2;
            int N;
            N = int.Parse(Console.ReadLine());
            S = System.Console.ReadLine();
            int split = N / 2;
            int end = N - 1;
            if(N % 2 == 1)
            {
                Console.WriteLine("No");
            }
            else
            {
                T1 = S.Substring(0, split);
                T2 = S.Substring(split);
                if(T1 == T2)
                {
                    Console.WriteLine("Yes");                    
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

using namespace std;
typedef pair<llint, llint> P;

llint a, b, c, d;
llint dp[3005][3005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for(int i = a+1; i <= c; i++){
		llint sum = 0;
		for(int j = b; j <= d; j++){
			dp[i][j] = dp[i-1][j] * j % mod;
			dp[i][j] += sum, dp[i][j] %= mod;
			sum += dp[i-1][j], sum %= mod;
			sum *= i-1, sum %= mod;
		}
	}
	
	llint ans = 0;
	for(int i = b; i <= d; i++){
		ans += dp[c][i] * modpow(c, d-i) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 74064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b;
    scanf("%lld%lld",&a,&b);
    if(a > b)
    {
        ll ex;
        ex = a;
        a = b;
        b = ex;
    }
    if(a==1 && b==1)
        printf("1\n");
    else if(a == 1)
        printf("%d\n",b-2);
    else if(a == 2)
        printf("0\n");
    else
        printf("%lld\n",a*b-2*a-2*b+4);
    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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  vi a(n);
  map<int,int> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  int tmp;
  if(n % 2 == 1){ // nが奇数
    tmp = 2;
    for(auto x : mp){
      if(x.fst == 0 and x.snd == 1) continue;
      else if(x.fst == tmp and x.snd == 2){
	tmp += 2;
	continue;
      }else{
	cout << 0 << endl;
	return 0;
      }
    }
  }else{
    tmp = 1;
    for(auto x : mp){
      if(x.fst == tmp and x.snd == 2){
	tmp += 2;
	continue;
      }else{
	cout << 0 << endl;
	return 0;
      }
    }
  }

  //cout << tmp << endl;
  if(tmp != n + 1){
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = 1;
  rep(i,n/2){
    ans *= 2;
    ans %= 1000000007;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3584
k, n = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.append(k+a[0])

max_value = -1
ans = 0
for i in range(1, n+1):
    tmp_d = a[i] - a[i-1]
    ans += tmp_d
    max_value = max(max_value, tmp_d)
ans -= max_value
print(ans)

Measured memory_bytes: 26444
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A
// Tree - Rooted Trees

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int NIL = -1;
const int MAX_T = 100000;

struct node { int parent, left, right; };
struct node T[MAX_T];
int depth[MAX_T];

void print_node(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << depth[u] << ", ";

    if (T[u].parent == NIL) cout << "root, ";
    else if (T[u].left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    auto c = T[u].left;
    while (c != NIL) {
        cout << c;
        c = T[c].right;
        if (c != NIL) cout << ", ";
    }
    cout << "]" << endl;
}

void set_depth(int u, int d) {
    depth[u] = d;
    if (T[u].right != NIL) set_depth(T[u].right, d);
    if (T[u].left != NIL) set_depth(T[u].left, d + 1);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) T[i].parent = NIL, T[i].left = NIL, T[i].right = NIL;

    int id, degree, child;
    for (int i = 0; i < n; ++i) {
        cin >> id >> degree;

        int prev_child = NIL;
        for (int j = 0; j < degree; ++j) {
            cin >> child;
            if (j == 0) T[id].left = child;
            else T[prev_child].right = child;

            T[child].parent = id;
            prev_child = child;
        }
    }

    int root = NIL;
    for (int i = 0; i < n; ++i) {
        if (T[i].parent == NIL) root = i;
    }

    set_depth(root, 0);
    for (int i = 0; i < n; ++i) {
        print_node(i);
    }

    return 0;
}


Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(i, n) for(int i = n-1; i >= 0; i--)
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define rloop(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, val) memset(a, val, sizeof a);
#define test int t; cin>> t; while(t--)
#define all(v) v.begin(),v.end()
#define ll long long
#define ld long double
#define mp_ make_pair
#define pb push_back
#define sz(s) (int)s.size()
const int MAX = 1e5 + 5;
const int inf = 1e9+1;
const ll OO = 1e18;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
int n, a[MAX], dp[MAX];
int solve(int i = 0){
    if(i == n - 1) return 0;

    if(dp[i] < 1e9) return dp[i];

    int choice1 = inf, choice2 = inf;

    if(i + 1 < n)
        choice1 = solve(i + 1) + abs(a[i + 1] - a[i]); // 20 10 20 // 20 10 0

    if(i + 2 < n)
        choice2 = solve(i + 2) + abs(a[i + 2] - a[i]); // 30 20

    return dp[i] = min(choice1, choice2);
}
int main()
{
    cin>> n;
    lp(i, n)
        cin>> a[i];

    mem(dp, 63);
    cout<< solve() <<"\n";

    return 0;
}


Measured memory_bytes: 8956
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int N;
int P[100001];

void solve()
{
    int cnt = 0;

    FOR(i, 1, N+1) {
        int p = P[i];
        if(p == i) {
            if(i != N) {
                ++cnt;
                swap(P[i], P[i+1]);
            }
            else {
                ++cnt;
                swap(P[i-1], P[i]);
            }
        }
    }

#ifdef DEBUG
    PRINT_RANGE(P+1, P+N+1);
#endif
    cout << cnt << "\n";
}

int main()
{
    cin >> N;
    FOR(i, 1, N+1) {
        cin >> P[i];
    }

    solve();

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int BIT_MAX = 200010;

template <class T> class BIT{
	T x[BIT_MAX + 1];
	
public:
	
	BIT(){
		fill(x,x+BIT_MAX+1,0);
	}
	
	void add(int a , T b){
		++a;
		for(; a <= BIT_MAX ; a += a & -a) x[a] += b;
	}
	
	T get(int a){
		++a;
		T b = 0;
		for(; a > 0 ; a -= a & -a) b += x[a];
		return b;
	}
};

string S;
vector<int> c[26];
vector<P2> V;
BIT<int> bit;

int main(){
	cin >> S;
	int n = S.size();
	repp(i,0,n){
		c[S[i]-'a'].PB(i);
	}
	int z = 0;
	repp(i,0,26){
		repp(j,0,c[i].size()){
			if(2*j >= c[i].size()) break;
			if(2*j+1 == c[i].size()){
				++z;
				V.PB(MP(c[i][j],c[i][j]));
			} else {
				V.PB(MP(c[i][c[i].size()-1-j],c[i][j]));
			}
		}
	}
	if(z>1) return cout << -1 << endl , 0;
	LL ans = 0;
	sort(V.begin(),V.end());
	for(auto u : V){
		ans += bit.get(u.second-1) / (u.first == u.second ? 2 : 1);
		bit.add(u.first,1);
		if(u.first != u.second) bit.add(u.second,1);
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string ans;
    n %= 10;

    if (n == 0 || n == 1 || n == 6 || n == 8)
        ans = "pon";
    else if (n == 3)
        ans = "bon";
    else
        ans = "hon";
    cout << ans << endl;

    return 0;
}

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

using namespace std;
int n,k,i,a[200005],inc,max1;
int main()
{cin>>k>>n;
for(i=1;i<=n;i++)
{
      cin>>a[i];
      if(a[i]-a[i-1]>max1&&i>1)
      {
          max1=a[i]-a[i-1];
          inc=i;
      }
}
if(k-a[n]+a[1]>max1)
   {

cout<<a[n]-a[1];
   }
   else
  cout<<k-a[inc]+a[inc-1];

       return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{

	int x;
	
    public void AtCoder(){
        string[] input;
		input = Console.ReadLine().Split(' ');
		x = int.Parse(input[0]);
		int a = 0;
		int ans = 0;
		while(true) {
			ans++;
			a += x;
			a %= 360;
			if (a == 0) {
				Console.WriteLine(ans);
				return;
			}
		}
		
		//Console.WriteLine();
    }
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 27392
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
    public int h { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new List<P>();
        var ps0 = new List<P>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]);
            var y = int.Parse(line[1]);
            var h = int.Parse(line[2]);
            if (h > 0) ps.Add(new P { x = x, y = y, h = h });
            else ps0.Add(new P { x = x, y = y, h = h });
        }
        for (int i = 0; i <= 100; i++)
            for (int j = 0; j <= 100; j++)
            {
                var t = ps[0].h + Math.Abs(ps[0].x - i) + Math.Abs(ps[0].y - j);
                if (!check(ps, i, j, t)) goto next;
                else if (check2(ps0, i, j, t))
                {
                    Console.WriteLine("{0} {1} {2}", i, j, t);
                    goto end;
                }
                next:;
            }
        end:;
    }
    public static bool check2(List<P> ps, int cx, int cy, int t)
    {
        foreach (var x in ps)
            if (t > Math.Abs(x.x - cx) + Math.Abs(x.y - cy)) return false;
        return true;
    }
    public static bool check(List<P> ps, int cx, int cy, int t)
    {
        for (int i = 1; i < ps.Count(); i++)
        {
            var t2 = ps[i].h + Math.Abs(ps[i].x - cx) + Math.Abs(ps[i].y - cy);
            if (t != t2) return false;
        }
        return true;
    }
}


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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

int n, m, k, x, y, x2, y2, ans = INT_MAX;
vector<vector<char>> a;
vector<vector<float>> cost;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int bfs()
{
    queue<pii> q;
    q.push({x, y});
    int r, c;
    cost[x][y] = 0;
    while (!q.empty())
    {
        r = q.front().first, c = q.front().second;
        q.pop();
        if (r == x2 && c == y2)
            return cost[r][c];
        forn(dir, 0, 4)
        {
            forn(i, 1, k + 1)
            {
                int nr = r + dx[dir] * i;
                int nc = c + dy[dir] * i;
                if (nr < 0 || nc < 0 || nr >= n || nc >= m)
                    continue;
                if (a[nr][nc] != '.' || cost[nr][nc] <= cost[r][c])
                    break;
                if (cost[nr][nc] > cost[r][c] + 1)
                {
                    cost[nr][nc] = cost[r][c] + 1;
                    q.push({nr, nc});
                }
            }
        }
    }
    return -1;
}

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    cin >> n >> m >> k;
    cin >> x >> y >> x2 >> y2;
    --x, --y, --x2, --y2;
    // cout << x << y << x2 << y2 << endl;
    a.resize(n);
    cost.resize(n);
    char foo;
    forn(i, 0, n)
    {
        forn(j, 0, m)
        {
            cin >> foo;
            a[i].pb(foo);
            cost[i].pb(INT_MAX);
        }
    }
    cout << bfs();
}

Measured memory_bytes: 11020
H, W = map(int,input().split())
s = [list(input().split()) for i in range(H)]
al = [chr(i) for i in range(65,65+26)]
for i in range(H):
    for j in range(W):
        if s[i][j] == 'snuke':
            print(al[j] ,end = '')
            print(i+1)
            exit()


Measured memory_bytes: 3060
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    if(s.charAt(0) =='7' || s.charAt(1) =='7' || s.charAt(2) == '7')
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

int main() {
	// your code goes here
	double d,s,t;
	cin>>d>>s>>t;
	double tot =(d*1.0)/(s*1.0);
	if(t*1.0>=tot){
	    cout<<"Yes";
	}
	else{
	    cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());

		int[] ans = new int[len + 1];

		for (int i = 1; i <= 100; i++) {
			for (int j = 1; j <= 100; j++) {
				for (int k = 1; k <= 100; k++) {
					int let = i*i+j*j+k*k+i*j+j*k+k*i;
					if (let <= len) {
						ans[let]++;
					}
				}
			}
		}

		for (int i = 1; i < ans.length; i++) {
			System.out.println(ans[i]);
		}

	}
}

Measured memory_bytes: 38740
import copy
import sys

s = input()
t = input()
li = list('abcdefghijklmnopqrstuvwxyz')
r = []
for i in range(len(s)-len(t)+1):
    ss = list(s)
#     print(i)
    lo = [1 if ((s[i + j] == t[j]) or (s[i + j] == '?')) else 0 for j in range(len(t))]
#     print(lo)
    if all(lo):
        ss[i:i+ len(t)] = t
        rs = ''.join(ss)
        rs = rs.replace('?','a')
        r += [rs]

if len(r) == 0:
    print('UNRESTORABLE')
    sys.exit()
r = sorted(r)
print(r[0])

Measured memory_bytes: 3444
import itertools
n = int(input())
l = list(range(1,n+1))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
r = list(itertools.permutations(l))
for i in range(len(r)):
  if r[i] == p:
    a = i
  if r[i] == q:
    b = i
print(abs(a-b))

Measured memory_bytes: 8052
N = gets.to_i
w = N.times.map{gets.chomp}

if w.uniq.length != w.length
    puts 'No'
  	exit
end

(0..(N-2)).each do |i|
    if w[i][-1] != w[i+1][0]
        puts 'No'
        exit
    end
end
puts 'Yes'


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

bool sosuu[10000000];

int main() {
	fill(&sosuu[0], &sosuu[0]+10000000, true);

	sosuu[0] = sosuu[1] = false;

	for (int i = 2; i < 10000000; ++i) {
		for (int j = i*2; j < 10000000; j += i) {
			sosuu[j] = false;
		}
	}

	int n;
	while (cin >> n, n) {
		int ans = 0;
		for (int i = n+1; i <= 2*n; ++i) {
			if (sosuu[i]) ++ans;
		}
		cout << ans << endl;
	}
}

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

int main()
{
    int n; cin>>n;
    vector<pair<int, int>> a;
    for(int i=0; i<n; ++i) {
        int x, l; cin>>x>>l;
        a.emplace_back(x+l, -(x-l));
    }
    sort(begin(a), end(a));
    int res=n;
    int R=a[0].first;
    for(int i=1; i<n; ++i) {
        if (-a[i].second<R)
            --res;
        else
            R=a[i].first;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <tgmath.h>
#define MOD 1000000007
using namespace std;
#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
ll N,W;
#define MAXN 40
ll v[MAXN],w[MAXN];
ll INF = 1<<21;
pair<ll,ll> P[1<<(MAXN/2)];
int main(){
    cin >> N >> W;
    rep(i,N)cin >> v[i] >> w[i];
    int half = N/2;
    for(int i=0;i<1<<half;i++){
        ll tmpw = 0;
        ll tmpv = 0;
        for(int j=0;j<half;j++){
            if(i>>j&1){
                tmpw += w[j];
                tmpv += v[j];
            }
        }
        P[i] = make_pair(tmpw,tmpv);
    }
    ll m = 1;
    sort(P,P+(1<<half));
    for(int i=1;i<1<<half;i++){
        if(P[m-1].second<P[i].second){
            P[m++] = P[i];
        }
    }
    ll res = 0;
    for(int i=0;i<1<<(N-half);i++){
        ll tmpw = 0;
        ll tmpv = 0;
        for(int j=0;j<(N-half);j++){
            if(i>>j&1){
                tmpw += w[j+half];
                tmpv += v[j+half];
            }
        }
        if(W>=tmpw){
            ll tv = (lower_bound(P,P+m,make_pair(W-tmpw,INF))-1)->second;
            res = max(res,tv+tmpv);
        }
    }

    cout << res << endl;
    return 0;
}


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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int cnt = 0;
  int b_cnt = 0;
  for (int i = 0; i < n; i++) {
    bool pass = false;
    if (s.at(i) == 'a' && cnt < a + b) {
      pass = true;
    }
    else if (s.at(i) == 'b' && cnt < a + b && b_cnt < b) {
      pass = true;
      b_cnt++;
    }
    if (pass) {
      cout << "Yes" << endl;
      cnt++;
    }
    else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

int main(){
    double pai=3.141592653589;
    int n,a,b;
    char c[1000],rc[1000],s[10];
    scanf("%s",&c);
    scanf("%d",&n);
    string w;
    for(int i=0;i<n;i++){
        scanf("%s",&s);
        w=s;
        if(w=="print"){
            scanf("%d %d",&a,&b);
            for(int i=a;i<=b;i++){
                printf("%c",c[i]);
            }
            printf("\n");
        }else if(w=="replace"){
            scanf("%d %d %s",&a,&b,&rc);
            int j=0;
            for(int i=a;i<=b;i++){
                c[i]=rc[j];
                j++;
            }
        }else{
            scanf("%d %d",&a,&b);
            int j=b;
            strcpy(rc,c);
            for(int i=a;i<=b;i++){
                c[i]=rc[j];
                j--;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3007;
int dp[MAXN][MAXN];
char s[MAXN], t[MAXN];
int main()
{
    scanf(" %s", s + 1); scanf(" %s", t + 1);
    int n = strlen(s + 1), m = strlen(t + 1);
    for (int i = 1; i <= n / 2; i++) swap(s[i], s[n + 1 - i]);
    for (int j = 1; j <= m / 2; j++) swap(t[j], t[m + 1 - j]);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
            dp[i][j] = s[i] == t[j] ? dp[i - 1][j - 1] + 1 : max(dp[i][j - 1], dp[i - 1][j]);
    }
    int i = n, j = m;
    while (i && j)
    {
        if (s[i] == t[j]) putchar(t[j]), i--, j--;
        else dp[i - 1][j] > dp[i][j - 1] ? i-- : j--;
    }
    puts("");
    return 0;
}

Measured memory_bytes: 35456
// luogu-judger-enable-o2
#include <cstdio>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
char s[110];
int n,pos,maxn;
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;++i)
    {
        if(s[i]=='I') ++pos;
        else --pos;
        maxn=max(maxn,pos);
    }
    printf("%d\n",maxn);
    return 0;
}

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

using namespace std;

int main()
{
int N;
cin >> N;
int A[N];

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

sort(A,A+N);
int it = 1;


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

cout << it << "\n";

return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
long long int f(long long int x)
{
    long long int count = 0;
    while(x > 0)
    {
        x = x / 10;
        count++;
    }
    return count;
}
int main(void)
{
    long long int n,i,j,mod = 1000000000 + 7,sum = 0,x[200001],y[200001],d,count = 1,k,a,nana = 7;
    
    scanf("%lld",&k);
    if(k % 2 == 0 || k % 5 == 0)
    {
        printf("-1\n");
        return 0;
    }
    if(k == 1)
    {
        printf("1\n");
        return 0;
    }

        while(1)
        {
            
            if(nana % k == 0)
            {
                printf("%lld\n",count);
                return 0;
            }
            else
            {
                j = nana % k;
                nana = j * 10 + 7;
                count++;
            }
        }
    
    
    return 0;
}

Measured memory_bytes: 1708
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let nk=readInts()
let n=nk[0]
var flag=0
for i in 1...9{
  for j in 1...9{if i*j==n{flag=1
                          break}}
}

if flag==1{print("Yes")}else{print("No")}

Measured memory_bytes: 13656