akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <cstdio>
using namespace std;

struct FenwickTree {
	typedef int T;
	vector<T> v;
	void init(int n) { v.assign(n, 0); }
	void add(int i, T x) {
		for(; i < (int)v.size(); i |= i + 1) v[i] += x;
	}
	T sum(int i) const { //[0, i)
		T r = 0;
		for(-- i; i >= 0; i = (i & (i + 1)) - 1) r += v[i];
		return r;
	}
	T sum(int left, int right) const { //[left, right)
		return sum(right) - sum(left);
	}
};

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> p(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &p[i]), -- p[i];
		int BlockSize = 250, NumBlocks = N / BlockSize + 1;
		vector<vector<long long> > memo(NumBlocks, vector<long long>(N));
		FenwickTree ft;
		for(int bi = 0; bi < NumBlocks; ++ bi) {
			vector<long long> &v = memo[bi];
			int i = bi * BlockSize;
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i; j < N; ++ j) {
					sum += (j - i) - ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i - 1; j >= 0; -- j) {
					sum += ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
		}
		ft.init(N);
		int Q;
		scanf("%d", &Q);
		for(int ii = 0; ii < Q; ++ ii) {
			int l; int r;
			scanf("%d%d", &l, &r), -- l, -- r;
			int bl = (l + BlockSize - 1) / BlockSize, br = (r - 1) / BlockSize;
			long long ans = 0;
			if(bl > br) {
				for(int i = r; i >= l; -- i) {
					ans += ft.sum(p[i]);
					ft.add(p[i], 1);
				}
				for(int i = l; i <= r; ++ i)
					ft.add(p[i], -1);
			} else {
				int L = bl * BlockSize, R = br * BlockSize;
				ans += memo[bl][r];
				ans += memo[br][l];
				if(bl < br)
					ans -= memo[bl][R - 1];
				for(int i = R; i <= r; ++ i)
					ft.add(p[i], 1);
				for(int i = l; i < L; ++ i)
					ans += ft.sum(p[i]);
				for(int i = R; i <= r; ++ i)
					ft.add(p[i], -1);
			}
			printf("%lld\n", ans);
		}
	}
	return 0;
}

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

int main(){
  int x;
  cin>>x;
  cout<<(x>=30 ? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3592
using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

partial class Solver {
    public void Run() {
        var N = ni();
        var X = ni();
        var m = ni(N);
        var minDonut = m.Min();
        X -= m.Sum();
        cout.WriteLine(m.Count() + X / minDonut);
    }
}

// PREWRITEN CODE BEGINS FROM HERE
partial class Solver : Scanner {
    public static void Main(string[] args) {
        new Solver(Console.In, Console.Out).Run();
    }

    TextReader cin;
    TextWriter cout;

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        this.cin = reader;
        this.cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

    public int ni() { return NextInt(); }
    public int[] ni(int n) { return NextIntArray(n); }
    public long nl() { return NextLong(); }
    public long[] nl(int n) { return NextLongArray(n); }
    public double nd() { return NextDouble(); }
    public string ns() { return Next(); }
}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private CultureInfo ci = CultureInfo.InvariantCulture;

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public int NextInt() { return Int32.Parse(Next(), ci); }
    public long NextLong() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt();
        return array;
    }

    public long[] NextLongArray(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextLong();
        return array;
    }

    public String Next() {
        if (TokenQueue.Count == 0) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int a,b;
  cin >> a >> b;
  int ans = a+b;
  if(ans < a-b) ans = a-b;
  if(ans < a*b) ans = a*b;
  cout << ans << endl;
}


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

int y[10005];

int main(){
while(1){	
	
	int n, a, b, c, x;
	cin >> n >> a >> b >> c >> x;
	if(n == 0 and a == 0 and c == 0 and x == 0) break;
	for(int i=0; i<n; i++) cin >> y[i];
	int ans = 0;
	
	int i = 0;
	while(1){
		if(x == y[i]) i += 1;
		x = (a * x + b) % c;
		if(i == n) break;
		ans += 1;
		if(ans == 10001) break;
	}
	
	if(ans > 10000) cout << -1 << endl;
	else cout << ans << endl;

	
}//end
	return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans;
    string s,t;
    cin>>n>>s>>t;
    ans=n;
    for(int i=0;i<n;i++){
        if(s.substr(i)==t.substr(0,n-i))break;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for i in range(q)]
arr = [0]

for i in range(1, n):
    tmp = 0
    if s[i-1:i+1] == 'AC':
        tmp = 1
    arr.append(arr[i-1] + tmp)

for i in range(q):
    l, r = lr[i]
    ans = arr[r-1] - arr[l-1]
    print(ans)

Measured memory_bytes: 21444
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1005;
int N,M,vis[MAXN],F[MAXN];
vector<int>P[MAXN];
queue<int>Q;
int Ans[MAXN],Len;
int rt,ans=0x3f3f3f3f,tmp[MAXN+5],dep[MAXN+5];
void Print(int x){
	if(vis[x]){
		printf("%d\n",Len);
		for(int i=1;i<=Len;i++)
			printf("%d\n",Ans[i]);
		return ;
	}
	vis[x]=1;Ans[++Len]=x;Print(tmp[x]);
}
void BFS(int u,int Pt){
	memset(vis,0,sizeof(vis));
	memset(dep,0,sizeof(dep));
	while(!Q.empty())Q.pop();
	Q.push(u);dep[u]=1,vis[u]=1;
	while(!Q.empty()){
		u=Q.front();Q.pop();
		int size=P[u].size();
		int Ok=0,flag=0;
		for(int i=0;i<size;i++){
			int v=P[u][i];
			if(v==Pt){
				if(ans>dep[u])
					rt=u,ans=dep[u],memcpy(tmp,F,sizeof(F)),tmp[Pt]=u;
				continue;
			}
			if(vis[v])
				continue;
			vis[v]=1;F[v]=u,dep[v]=dep[u]+1;
			Q.push(v);
		}
	}
	return ;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1,x,y;i<=M;i++){
		scanf("%d%d",&x,&y);
		P[x].push_back(y);
	}
	for(int i=1;i<=N;i++)
		BFS(i,i);
	memset(vis,0,sizeof(vis));
	if(ans==0X3F3F3F3F)
		printf("-1\n");
	else Print(rt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Y;
  cin >> N >> Y;
  
  // x + y + z = N
  // 10000x + 5000y + 1000z = Y
  int a = -1, b = -1, c = -1;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; x + y <= N; y++) {
      	int z = N - x - y;
        if (Y == 10000*x + 5000*y + 1000*z) {
          a = x; b = y; c = z;
        }
    }
  }
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	char a, b;
	cin >> a >> b;
	int x = a - 'A';
	int y = b - 'A';
	if (x > y) {
		cout << ">" << endl;
	}
	else if (x < y) {
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[10];
int flag;

void dfs(int b_top,int c_top,int num) {

  if(num==10) {

    flag=1;
    return;

  }

  if(b_top<a[num]) dfs(a[num],c_top,num+1);

  if(c_top<a[num]) dfs(b_top,a[num],num+1);

  return;

}

int main(void) {

  int n;

  int i;


  scanf("%d",&n);

  for(i=0;i<n;i++) {

    scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);

    flag=0;

    dfs(0,0,0);

    if(flag==1) printf("YES\n");
    else printf("NO\n");

  }

  return 0;

}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();

    if (S.equals("Sunny"))
      System.out.println("Cloudy");
    else if (S.equals("Cloudy"))
      System.out.println("Rainy");
    else
      System.out.println("Sunny");


  }

}


Measured memory_bytes: 21844
# Union-Findデータ構造
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
    def find(self, x):
        if self.pars[x] == x: return x
        else:
            self.pars[x] = self.find(self.pars[x])
            return self.pars[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
        else:
            self.pars[y] = x
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int, input().split())
UF = UnionFind(N+M)
for i in range(N):
    K, *Ls = map(int, input().split())
    for L in Ls:
        UF.union(i, L+N-1)

pars = [UF.find(i) for i in range(N)]
print('YES' if len(set(pars)) == 1 else 'NO')


Measured memory_bytes: 12632
#include <stdio.h>
int main(void)
{
    double f[10];
    while (scanf("%lf", f) != EOF) {
        double res = 0;
        int i;
        for (i=1; i<10; ++i) {
            if (i%2 == 1) f[i] = f[i-1] * 2;
            else f[i] = f[i-1] / 3;
        }
        for (i=0; i<10; ++i) res += f[i];
        printf("%f\n", res);
    }
    return 0;
}

Measured memory_bytes: 0
#19:32
n = int(input())
ans = 0
if n == 1:
  print(0)
else:
  for i in range(1,int(n**.5)+1):
    if n % i == 0:
      x = n // i - 1
      if n // x == n % x == i:
        ans += x
        #print(x)
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

ll n, k, f[1010][1010], g[1010][1010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> k;
    FOR(i,1,k) g[0][i] = 1;
    FOR(i,1,n) {
        ll p = 0;
        FOR(j,1,k) {
            f[i][j] += g[i-1][j];
            p += f[i][j];
        }
        FOR(j,1,k) g[i][j] = p - f[i][j];
    }
    ll res = 0;
    FOR(i,1,k) res += f[n][i];
    cout << res;
    return 0;
}


Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] S = new long[n];

		for(int i = 0; i < n; i++) {
			S[i] = sc.nextLong();
		}

		int q = sc.nextInt();
		int count = 0;

		for(int j = 0; j < q; j++) {
			long T = sc.nextLong();
			for(int i = 0; i < n; i++) {
				if(T == S[i]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 40448
#include<stdio.h>

int main (void){
  int num[10];
  int tmp,i,p,q;

  //printf("10????????°????????\???\n");                                               
  for(i = 0; i < 10; i++){
    scanf("%d",&num[i]);
  }

  for(p = 0; p < 9; p++){
    for(q = p + 1; q < 10; q++){
      if(num[p] < num[q]){
        tmp = num[p];
        num[p] = num[q];
        num[q] = tmp;
      }
    }
  }  
//printf("???????????????\n");                                                     
  for(i = 0; i < 3; i++){
    printf("%d\n",num[i]);
  }

  return 0;
}

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

int n;
int a,x,y;
int p[15][15];
int ans = 0;
int anst;
bool f;

int main()
{
    cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a;
		for (size_t j = 0; j < a; j++)
		{
			cin >> x >> y;
			p[i][x - 1] = y + 1;
		}
	}
	for (size_t i = 0; i < (1 << n); i++)
	{
		f = true;
		for (size_t j = 0; j < n; j++)
		{
			if ((i >> j) & 1)
			{
				for (size_t k = 0; k < n; k++)
				{
					if (p[j][k])
					{
						if ((p[j][k] - 1) != ((i >> k) & 1))
						{
							f = false;
						}
					}
					if (not f)break;
				}
				if (not f)break;
			}
		}
		if (f)
		{
			anst = 0;
			for (size_t j = i; j > 0; j >>= 1)
			{
				anst += (j & 1);
			}
			if (anst>ans)
			{
				ans = anst;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  
 int A, B;
  cin >> A >> B;
   
  if ( A <= 9 && 1 <= A && B <= 9 && 1 <= B  ) {
    cout << A * B << endl;
  }
  else {
    cout << -1 << endl;
  }

   
} 
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> v;

int nibun(int l, int r, int t);

int main() {
	int n;
	cin >> n;
	int tmp;
	for (int i = 0;i < n;i++) {
		cin >> tmp;
		if (i == 0) {
			v.push_back(tmp);
		}
		else {
			int index = nibun(0, v.size() - 1, tmp);
			if (index == v.size())v.push_back(tmp);
			else v[index] = tmp;
		}
	}
	cout << v.size() << endl;
}

int nibun(int l, int r, int t) {
	if (t <= v[r])return r + 1;
	if (t > v[l])return l;
	if (r - l <= 1)return r;
	int mid = (r + l) / 2;
	if (v[mid] >= t) {
		return nibun(mid, r, t);
	}
	else {
		return nibun(l, mid, t);
	}
}

Measured memory_bytes: 3452
#include <iostream>

using namespace std;

int main()
{
  int N;
  cin >> N;
  if( N == 1)
    {
      cout << "Hello World" << endl;
      return 0;
    }
  int A, B;
  cin >> A >> B;
  cout << A+B << endl;
  return 0;
}


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

int main()
{
string s ;
cin >> s ;
vector<ll> v(s.size()+1);
rep(i,s.size()){
  if(s[i]=='<')v[i+1]=v[i]+1;
}
rep(i,s.size()){
  if(s[s.size()-i-1]=='>')v[s.size()-i-1]=max(v[s.size()-i]+1,v[s.size()-i-1]);
}

auto ans=accumulate(v.begin(),v.end(),0LL);
cout << ans << endl;
return 0;
}

Measured memory_bytes: 4740
s = input()

if s[0] == s[1] and s[1] == s[2]:
    print('No')
    exit()
if s[0] == s[1] and s[2] == s[3]:
    print('Yes')
    exit()
if s[0] == s[2] and s[1] == s[3]:
    print('Yes')
    exit()
if s[0] == s[3] and s[1] == s[2]:
    print('Yes')
    exit()

print('No')

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int A,B; cin >> A>>B;
    
    string ans = A==B?"Draw":(A==1||(B!=1&&A-B>0)?"Alice":"Bob");

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[3005];
long long dp[3005][3005];
long long cdp[3005][3005];
int main()
{
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int n,s;
    cin>>n>>s;
    for (int i = 1; i <= n; i++) 
    cin >> arr[i];
    long long ans=0;
    for (int i = 1; i <= n; i++)
    {
        dp[i][arr[i]] = i;
        for (int j = arr[i] + 1; j < 3005; j++)
        dp[i][j] = dp[i - 1][j - arr[i]];
        ans += (dp[i][s] * (n - i + 1))%998244353;
        ans%=998244353;
        for (int j = 0; j < 3005; j++) 
        dp[i][j] = (dp[i - 1][j] + dp[i][j])%998244353;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 71680
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int A[200010] ={};
int B[200010] ={};
int main(){
    int N;
    cin >> N;
    rep(i,N){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B, B+N);
    rep(i,N){
        int j = 0;
        if(A[i] == B[N-1-j]){
            j++;
        }
        cout << B[N-1-j] <<endl;
    }

}

Measured memory_bytes: 3200
from collections import Counter
import math
def comb(n, r):
    # print(n, r)
    return (n * (n-1))//2
    # return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

# All combination
total = 0
for (key, val) in c.items():
    # print('\n', key, val)
    if val > 1:
        total += comb(val, 2)

# print('all:', total)

for i in range(n):
    num = a[i]
    org = c[num]
    # print(org)
    # total - orgC2 + (org-1)C2
    if org > 2:
        ans = total - comb(org, 2) + comb(org-1, 2)
    elif org == 1 or org == 0:
        ans = total
    else:
        ans = total - comb(org, 2)
    print(ans)



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

int n;
int p[20000];		//0-indexedにする

int a[20000];
int b[20000];
int pos[20000];		//pos[i] = {p[id] = iとなるid} p = {2, 0, 4, 5, 3}ならpos = {1, 0, 4, 2, 3}になる。

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> p[i]; p[i]--; pos[p[i]] = i; }
	
	a[0] = 500000000;
	b[0] = 500000000;
	for (i = 1; i < n; i++) {
		int mini = 0;
		int maxi = 1000000000;
		for (j = 0; j < i; j++) {
			if (pos[j] < pos[i]) {
				//a_j < a_i
				//b_j > b_i
				//a_j + b_j <= a_i + b_i - pos[i] + pos[j]
				//を満たすように, a_i, b_iを決める。a_iを最小化。b_iを最大化。
				mini = max(mini, a[j] + 1 - pos[j] + pos[i]);
				maxi = min(maxi, b[j] - i + j);
			}
			else {
				//a_j < a_i
				//b_j > b_i
				//a_j + b_j >= a_i + b_i - pos[i] + pos[j]
				//を満たすように, a_i, b_iを決める。a_iを最小化。b_iを最大化。
				mini = max(mini, a[j] + i - j);
				maxi = min(maxi, b[j] - (1 + pos[j] - pos[i]));
			}
		}
		a[i] = mini;
		b[i] = maxi;
	}
	
	cout << a[0];
	for (i = 1; i < n; i++) { cout << " " << a[i]; }
	cout << endl;
	
	cout << b[0];
	for (i = 1; i < n; i++) { cout << " " << b[i]; }
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int x1 = fs.nextInt();
        final int y1 = fs.nextInt();
        final int x2 = fs.nextInt();
        final int y2 = fs.nextInt();
        final int x = x2 - x1;
        final int y = y2 - y1;
        System.out.println((x2 - y) + " " + (y2 + x) + ' ' + (x1 - y) + ' ' + (y1 + x));
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


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

int main(){
  int n, id, k, pk, lk, i;
  int *H;

  scanf("%d", &n);

  H = malloc(sizeof(int) * (n+1));

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

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ", i, H[i]);
    if(i/2 > 0){
      printf("parent key = %d, ", H[i/2]);
    }
    if(i*2 <= n){
      printf("left key = %d, ", H[i*2]);
    } 
    if(i*2+1 <= n){
      printf("right key = %d, ",H[i*2+1]);
    }
    printf("\n");
  } 

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val S = sc.next
    println("abcdefghijklmnopqrstuvwxyz".filter(c => !S.exists(c == _)).headOption.getOrElse("None"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int>a(n);for(int i = 0;i<n;i++)cin>>a[i];sort(a.begin(),a.end());
    vector<int>b(n);for(int i = 0;i<n;i++)cin >> b[i];
    vector<int>c(n);for(int i = 0;i<n;i++)cin >> c[i];sort(c.begin(),c.end());
    long long sum = 0;
    for(int i = 0;i<n;i++){
        long long j,k;
        j = lower_bound(a.begin(),a.end(), b[i]) - a.begin();
        k = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        sum += j*k;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int D[n];
    REP(i,n) cin >> D[i];
    if(n > 23){
        cout << 0 << endl;
        return 0;
    }


    int ju = 1;
    REP(i,n){
        ju *= 2;
    }
    int mask = 0;
    int ans = 0;
    bool jikoku[25];
    jikoku[0] = true;
    jikoku[24] = true;
    while(mask < ju){
        FOR(i,1,24) jikoku[i] = false;
        bool flag = false;
        int tmp = 1;
        REP(i,n){
            if( (mask& tmp) ){
                if(jikoku[D[i]]){
                    flag = true;
                    break;
                }
                else jikoku[D[i]] = true;
            }
            else{
                if(jikoku[24 - D[i]]){
                    flag = true;
                    break;
                }
                else jikoku[24 - D[i]] = true;
            }
            tmp *= 2;
            
        }
        if(flag){
            mask ++;
            continue;
        }
        int hoge = 25;
        int bef  = 0;
        FOR(i,1,25){
            if(jikoku[i]){
                chmin(hoge,i - bef);
                bef = i;
            }
        }
        chmax(ans,hoge);
        mask ++;
    }
    cout << ans % 24<< endl;

}

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

int H,W;
bool flag = 0;
int bn = 0;
char s[10][10];

void dfs(int x,int y,int cost){
	if(x==H-1&&y==W-1&&cost==bn)flag = 1;
	if(s[x][y+1]=='#')dfs(x,y+1,cost+1);
	if(s[x+1][y]=='#')dfs(x+1,y,cost+1);
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		cin >> s[i][j];
		if(s[i][j]=='#')bn++;
	}
	dfs(0,0,1);
	if(flag)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import java.io.*; 
public class Main{
  public static void main(String[] args) throws java.io.IOException{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br= new BufferedReader(isr);
    String buf =br.readLine();
    int x= Integer.parseInt(buf);
    x=(int)Math.pow(x,3);
    System.out.println(x);
  }
}

Measured memory_bytes: 24120
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int s[10],c[10];
int ask(int x,int y){
	y--;
	while(y--){
		x/=10;
	}
	x%=10;
	return x;
}
int main(void){
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	scanf("%d%d",&s[i],&c[i]);
	int st,ed;
	if(n==1)
	st=0;
	else
	st=pow(10,n-1);
	ed=pow(10,n)-1;
	int num=0;
	int flag=0;
	for(i=st;i<=ed;i++){
		int p=1;
		for(j=1;j<=m;j++){
			if(ask(i,n-s[j]+1)!=c[j]){
				p=0;
				break;
			}
		}
		if(p){
			num=i;
			flag=1;
			break;
		}
	}
	if(flag)
	printf("%d\n",num);
	else
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 384
fun main(args:Array<String>) {
    val blueCardCount = readLine()!!.toInt()
    val blueCards = (1..blueCardCount).map { readLine()!! }
    val redCardCount = readLine()!!.toInt()
    val redCards = (1..redCardCount).map { readLine()!! }
    val count = blueCards.union(redCards).map { word-> Pair(word, blueCards.count { it == word } - redCards.count { it == word }) }.toMap()
    val ans = Math.max(count.maxBy { it.value }!!.value, 0)
    println(ans)
}


Measured memory_bytes: 33728
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
//Union-Find
class UnionFind {
private:
	vector<int> parent;
	vector<int> height;
	vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 0);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};

int p[200000];
int x[200000];
int y[200000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  int n,m;cin>>n>>m;
  UnionFind uf(n);
  REP(i,n){
    cin>>p[i];
    p[i]--;
  }
  REP(i,m){
    cin>>x[i]>>y[i];
    x[i]--;
    y[i]--;
    uf.unite(x[i],y[i]);
  }
  int cnt=0;
  REP(i,n){
    if(uf.same(p[i], i))cnt++;
  }
  P(cnt);
  return 0;
}


Measured memory_bytes: 2560
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        max = A[i]
    else:
        if max > A[i]:
            ans += max - A[i]
        else:
            max = A[i]
print(ans)

Measured memory_bytes: 33116
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="SRR"||s=="RRS")
        cout<<2<<endl;
    else if(s=="SRS"||s=="RSS"||s=="SSR"||s=="RSR")
        cout<<1<<endl;
    else if(s=="RRR")
        cout<<3<<endl;
    else
        cout<<0<<endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
const int MOD=1000000007;

queue<LL> Q;
int main(){
	int K=0;
	cin>>K;
	for(int i=1;i<=9;i++)Q.push(i);
	for(int i=1;i<=K;i++)
	{
		LL num=Q.front();
		Q.pop();
		int matsubi=num%10;
		
		if(matsubi!=0)Q.push(num*10+matsubi-1);
		Q.push(num*10+matsubi);
		if(matsubi!=9)Q.push(num*10+matsubi+1);
		
		if(i==K)cout<<num<<endl;
	}
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a1,a2,a3;

int main(){
	cin>>a1>>a2>>a3;
	if(a1+a2+a3>=22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

// https://atcoder.jp/contests/abc137/tasks/abc137_d
int summer_vacation(int n, int m, int a[], int b[]) {
  typedef pair<int, int> day;
  priority_queue<int>  que;
  vector<day> day_vec;
  for(int i=0;i<n;i++) {
    day_vec.push_back(day(a[i], i));
  }
  sort(day_vec.begin(), day_vec.end());
  int pointer = 0;
  int ans = 0;
  for(int i=m-1; i>=0; i--) {
    int rest_day = m - i;
    while(pointer < day_vec.size() && day_vec.at(pointer).first <= rest_day) {
      int index = day_vec.at(pointer).second;
      que.push(b[index]);
      pointer++;
    }
    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  return ans;
}

int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int b[n];
  for(int i= 0; i< n;i++) {
    cin >> a[i] >> b[i];
  }
  cout << summer_vacation(n, m, a, b);
}

Measured memory_bytes: 5612
def main():
    from collections import deque

    N = int(input())

    dq = deque([0])
    cnt = 0
    while dq:
        x = dq.popleft()
        if all(c in str(x) for c in '357'):
            cnt += 1
        for k in (3, 5, 7):
            nx = x * 10 + k
            if nx <= N:
                dq.append(nx)
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int a, b;
  int sum_a, sum_b;
  int min = 100000000000;
  for (int i = 1; i < n; i++) {
    a = i;
    b = n-a;
    //cout << a << endl;
    while(a>0) {
      sum_a += a % 10;
      a /= 10;
    }
    while(b>0) {
      sum_b += b % 10;
      b /= 10;
    }
    //cout << sum_a << " " << sum_b << endl;
    if (min > sum_a+sum_b) {
      min = sum_a + sum_b;
    }
    sum_a = 0;
    sum_b = 0;
  }
  cout << min << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int N, M, Q;
struct cua{
    int a, b, c, d;
};
 
int A[15];
ll sol = 0;
vector<cua>v;
 
void comb(int pos){
 
    if(pos == N){
 
        ll acc =0;
        for(int j = 0; j < Q; j++)
          if((A[v[j].b] - A[v[j].a]) ==  v[j].c)
            acc += v[j].d;
         sol = max(sol, acc);
        return ;
    }
 
    for(int i = A[pos]; i <= M; i++)
    {
        A[pos+1]=i;
        comb(pos+1);
    }
}
 
int main()
{ 
    cin >> N >> M >> Q;
 
    int a, b, c, d;
    for(int i = 1; i <= Q; i++){
 
        cin >> a >> b >> c >> d;
        v.push_back(cua{a, b, c, d});
    }
 
    A[0]=1;
    comb(0);
 
     cout << sol;
      return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,s,q;
long long a[2005];
long long x[2005];
long long g[2005];
long long ans=9999999999;
int main(){
    cin>>n>>s>>q;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    memset(x,0x7f,sizeof(x));
    for(int i=1;i<=n;i++){
        long long y=a[i],l=1,r=1;
        int e=0;
        for(int j=1;j<=n;j++){
            l=j,r=j;
            while(a[l]<y&&l<=n&&r<=n){
                l++;
                r++;
            }
            while(a[r]>=y&&r<=n){
                r++;
            }
            r--;
            int tot=0;
            for(int k=l;k<=r;k++){
                tot++;
                g[tot]=a[k];
            }
            sort(g+1,g+1+tot);
            if(tot>=s){
                for(int k=1;k<=tot-s+1;k++){
                    e++;
                    x[e]=g[k];
                    //cout<<x[e]<<" ";
                }
            }
            j=r;
            //cout<<tot<<"\n";
            //cout<<l<<" "<<r<<"\n";
        }
        if(e>=q){
            sort(x+1,x+1+e);
            //cout<<x[q]<<" ";
            ans=min(ans,x[q]-y);
        }
    }
    cout<<ans;
    return 0;
}
/*
5 3 2
4 3 1 5 2
11 7 5
24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784
*/

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
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)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
const string df = "UNRESTORABLE";

string s, t;
bool check(int i){
    for(int j=0; j<t.size(); j++){
        //cout << i << " " << j <<  " " << s[i+j] << " " << t[j] << endl;
        if(s[i+j]==t[j] or s[i+j]=='?') continue;
        else return false;
    }
    return true;
}

int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    cin >> s >> t;
    int N = s.size();
    int M = t.size();
    bool ok = false;
    string res = string(N, 'z');
    for(int i=N-M; i>=0; i--){
        string tmp = s;
        ok |= check(i);
        if(!check(i)) continue;
        for(int j=0; j<i; j++){
            if(s[j]=='?') tmp[j] = 'a';
        }
        for(int j=0; j<t.size(); j++){
            if(s[i+j]=='?') tmp[i+j] = t[j];
        }
        for(int j=i+M; j<N; j++){
            if(s[j]=='?') tmp[j] = 'a';
        }
        res = min(res, tmp);
        //cout << i << " " << tmp << endl;
        //cout << res << endl;
    }
    if(ok) cout << res << endl;
    else cout << df << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    ll N;cin>>N;
    vector<ll> A(N);
    For(i,0,N) cin>>A[i];
    ll cnt=0;
    sort(A.begin(),A.end());
    For(i,1,N) if(A[i]==A[i-1]) cnt++;
    cnt+=(cnt%2);
    cout<<N-cnt<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void solve(int a, int b, int c, int k) {
    int cnt = 0;
    while (b <= a) {
        b *= 2;
        cnt ++;
    }
    while (c <= b) {
        c *= 2;
        cnt ++;
    }
    if (cnt <= k) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

Measured memory_bytes: 3668
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize
    };

    let mut res = 0_u64;
    let mut v = vec![0_u64; n + 1];
    for a in 1..=n {
        let mut b = a;
        while b <= n {
            v[b] += 1;
            b += a;
        }
        res += a as u64 * v[a];
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 79268
#include<stdio.h>
 
int main(void)
{
    int a, b;
    int c, d;
 
 
    scanf("%d %d", &a, &b);
 
    c= a * b;
    d= 2 * a + 2 * b;
 
    printf("%d %d\n", c, d);
 
    return 0;
}

Measured memory_bytes: 2744
#include<stdio.h>
int n,s[101],x,m,h,i,j;
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
		if((h==0)&&(s[i]%10)>=1){
			h=1;
		}
		m+=s[i];
	}
	
	if(h==0){
		puts("0");
		return 0;
	}
	
	do{x=0;
		for(i=0;i<n;i++){
			if(s[i]<s[i+1]){
				s[i]^=s[i+1];
				s[i+1]^=s[i];
				s[i]^=s[i+1];
				x=1;
			}
		}
	}while(x!=0);
	
	//for(i=0;i<n;i++)printf("%d\n",s[i]);
	
	if((m%10)==0){
		for(i=n;i>=0;i--){
			if((s[i]%10)>=1){
				m-=s[i];
				break;
			}
		}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 128
<?php
fscanf(STDIN,'%d',$N);
$H=explode(" ",trim(fgets(STDIN)));
$judge=1;
for ($i=1; $i <$N ; $i++) {
  // code...
  $j=0;
  while($j <$i) {
    // code...
    if ($H[$j]>$H[$i]) {
      // code...
      break;
    }
    if ($j==$i-1 and $H[$j]<=$H[$i]) {
      // code...
      $judge++;
      break;
    }
     $j++;
  }
}
echo $judge;
echo "\n";

 ?>


Measured memory_bytes: 3956
n,k = map(int, input().split())
a = list(map(int, input().split()))

tele = [1]
went = set(tele)
now = 1
cnt = 0
flag = True

for i in range(k):
  now = a[now-1]
  if i != k-1 and now in went:
    tele = tele[tele.index(now):]
    cnt = i+1
    flag = False
    break
  tele.append(now)
  went.add(now)

if flag == True:
  print(tele[-1])

else:
  k -= cnt
  cnt = k % len(tele)
  print(tele[cnt])

Measured memory_bytes: 32356
import math

N=int(input())

def ff(x):
    L=int(math.sqrt(x))

    FACT=dict()

    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

    return FACT

# 拡張ユークリッドの互除法.ax+by=gcd(a,b)となる(x,y)を一つ求め、(x,y)とgcd(x,y)を返す.
def Ext_Euc(a,b,axy=(1,0),bxy=(0,1)): # axy=a*1+b*0,bxy=a*0+b*1なので,a,bに対応する係数の初期値は(1,0),(0,1)
    # print(a,b,axy,bxy)
    q,r=divmod(a,b)

    if r==0:
        return bxy,b # a*bxy[0]+b*bxy[1]=b
   
    rxy=(axy[0]-bxy[0]*q,axy[1]-bxy[1]*q) # rに対応する係数を求める.
    return Ext_Euc(b,r,bxy,rxy)

FACT=ff(N*2)
LIST=[]
for f in FACT:
    LIST.append(f**FACT[f])
    
L=len(LIST)

LANS=2*N-1

for i in range(1<<L):
    A=1
    B=1
    for j in range(L):
        if i & (1<<j)!=0:
            A*=LIST[j]
        else:
            B*=LIST[j]
    if A==1 or B==1:
        continue

    x,_=Ext_Euc(A,-B)
    x,y=x[0],x[1]

    if x<0:
        x+=(1+abs(x)//B)*B

    LANS=min(LANS,x*A)

print(LANS)
    


Measured memory_bytes: 70908
s, t = [input() for i in range(2)]
ans = float("inf")
for i in range(len(s) - len(t)+1):
        cnt = 0
        for j in range(len(t)):
                if s[i + j] != t[j]:
                        cnt += 1
        if ans  > cnt:
                ans = cnt
print(ans)       

Measured memory_bytes: 8844
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#

n = int(input())
h = list(map(int, input().split()))
INF = float("inf")
dp = [INF]*n
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i, hh in enumerate(h):
    if i >= 2:
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))


print(dp[-1])


Measured memory_bytes: 52208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back

bool is_palindrome(string s) {
    for(int i = 0 ; i < (int)s.length() / 2 ; i++)
        if(s[i] != s[(int)s.length() - i - 1])
            return false;
    return true;
}

string s;

void solve() {
    cin >> s;
    int n = (int)s.length();
    if(is_palindrome(s)) {
        int x = (n - 1) / 2;
        int y = (n + 3) / 2;
        if(is_palindrome(s.substr(0, x)) && is_palindrome(s.substr(y - 1, n))) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else {
        cout << "No\n";
    }
}

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	s := readLine()

	d1 := 0
	d2 := 0

	for i, c := range strings.Split(s, "") {
		if strconv.Itoa(i%2) == c {
			d1 += 1
		} else {
			d2 += 1
		}
	}

	if d1 > d2 {
		fmt.Printf("%d", d2)
	} else {
		fmt.Printf("%d", d1)
	}
}



Measured memory_bytes: 2688
use std::io::Read;

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

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", x + y / 2);
}


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

int main() {
	string s;
	cin >> s;
	int S = 0, T = 0, count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S') S++;
		else T++;
		if (S < T) count += 2, T--;
	}
	cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  pair<int,int> a[100000];
  rep(i,n){
    int x,y;
    cin>>x>>y;
    a[i]=make_pair(x,y);
  }
  sort(a,a+n);
  int now=0;
  int ans=0;
  while(m>0){
    if(m>=a[now].scd){
      ans+=a[now].fst*a[now].scd;
      m-=a[now].scd;
      now++;
    }else{
      ans+=m*a[now].fst;
      m=0;
    }
  }
  cout<<ans<<endl;
    

  return 0;
}


Measured memory_bytes: 1792
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
char c;
cin>>c;
c++;
cout<<c<<endl;
return 0;
}







Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String,Integer> hash = new HashMap<>();
        int n = sc.nextInt();
        int m = sc.nextInt();
        long work = 0;
        for (int i=0;i<m;i++)work+=sc.nextInt();
        if (n<work)System.out.println(-1);
        else System.out.println(n-work);
    }
}


Measured memory_bytes: 46288