akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
int main()
{
	int i,j;
    a=read(),b=read(),c=read();
    ll d=(c-a-b),e=4*a*b;
    if(d>0 && d*d>e) printf("Yes");
    else printf("No");
	return 0;
}   

Measured memory_bytes: 256
var objStr={};
var abc="abcdefghijklmnopqrstuvwxyz".split("");
abc.forEach(function(v,i){
   objStr[v]=i;
});
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var str=Arr.shift();
   var AB=[];
   for(var i=0;i<N;i++){
      var ab=(Arr.shift()).split(" ").map(Number);
      AB.push(ab);
   }
   AB.reverse();
   var s=str.split("");
   for(var i=0;i<N;i++){
      var ab=AB[i];
      var a=ab[0]-1;
      var b=ab[1]-1;
      var plus=b-a;
      var A=s[a];
      var B=s[b];
      s[a]=abc[(objStr[B]+plus)%abc.length];
      s[b]=abc[(objStr[A]+plus)%abc.length];
   }
   console.log(s.join(""));
}

Measured memory_bytes: 9452
#include <stdio.h>

const int permutation[24][4]={
	{0,1,2,3},{0,1,3,2},{0,2,1,3},{0,2,3,1},{0,3,1,2},{0,3,2,1},
	{1,0,2,3},{1,0,3,2},{1,2,0,3},{1,2,3,0},{1,3,0,2},{1,3,2,0},
	{2,0,1,3},{2,0,3,1},{2,1,0,3},{2,1,3,0},{2,3,0,1},{2,3,1,0},
	{3,0,1,2},{3,0,2,1},{3,1,0,2},{3,1,2,0},{3,2,0,1},{3,2,1,0}
};

int main(void) {
	int i,j;
	int query1,query2;
	long long now,min;
	int array[4];
	int ii,jj,temp;
	while(1) {
		scanf("%d%d",&query1,&query2);
		if(query1==0 && query2==0)break;
		min=0x1000000000000000LL;
		for(i=1;i*i<=query1;i++) {
			if(query1%i!=0)continue;
			for(j=1;j*j<=query2;j++) {
				if(query2%j!=0)continue;
				array[0]=i;
				array[1]=query1/i;
				array[2]=j;
				array[3]=query2/j;
				for(ii=0;ii<4;ii++) {
					for(jj=ii;jj+1<4;jj++) {
						if(array[jj]<array[jj+1]) {
							temp=array[jj];
							array[jj]=array[jj+1];
							array[jj+1]=temp;
						}
					}
				}
				for(ii=0;ii<24;ii++) {
					now=0;
					for(jj=1;jj<4;jj++) {
						now+=(long long)(array[permutation[ii][jj-1]]-
								array[permutation[ii][jj]])*
							(long long)(array[permutation[ii][jj-1]]-
								array[permutation[ii][jj]]);
					}
					if(now<min)min=now;
				}
			}
		}
		printf("%lld\n",min);
	}
	return 0;
}

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

int main(void){
   int N;
   cin>>N;
   string S;
   cin>>S;
   long long ans=0;
   for(int i=0;i<1000;i++){
      int count=0;
      int num[3]={i/100,(i/10)%10,i%10};
      for(int i=0;i<N;i++){
         if(num[count]==S[i]-'0') count++;
      }
      if(count==3) ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3672
//C - Boxes and Candies: 25Min;
//Assunto: AdHoc;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x, aux;
    ll ans;
    cin >> n >> x;
    vector<int> caixas(n);
    loop(i, 0, n) cin >> caixas[i];
    loop(i, 0, n-1) {
        aux = (caixas[i] + caixas[i+1]) - x;
        if(aux < 0) aux = 0;
        ans += aux;
        caixas[i+1] -= aux;
        if(caixas[i+1] < 0) caixas[i+1] = 0;
    }
    cout << ans << "\n";
}

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

#define int long long

#define MOD 1000000007
#define maxlen 1000005

int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
vector<int> primeFact(int n){vector<int> ans;for(int t=2;t<=sqrt(n);t++){if(n%t==0){ans.push_back(t);while(n%t==0){n=n/t;}}}if(n>2)ans.push_back(n);return ans;}
vector<int> fact(int n){vector<int> ans;for(int i=1;i<=sqrt(n);i++){if(n%i==0){if( i*i == n ){ans.push_back(i);}else{ans.push_back(i);ans.push_back(n/i);}}}return ans;}
int powerr(int base,int exp,int mod) { if(exp==0)return 1;int t = powerr(base,exp/2,mod)%mod;if(exp%2==0){return (t%mod*t%mod)%mod;}else{return (t%mod*t%mod*base%mod)%mod;}} 
void fastio(){ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}

vector< vector<int> > dp(101 , vector<int> (100001 , INT_MAX ));

int doWork( vector<int> &val, vector<int> &wi, int n, int w, int valLim ){

	for(int i=0;i<=100;i++){
		dp[i][0]=0;
	}


	for(int i=1;i<=n;i++){
		for(int j=0;j<=100000;j++){
			//cout << i << " " << j  <<"\n";
			if(val[i-1] > j){
				dp[i][j] = dp[i-1][j];
			}else{
				//cout << dp[i-1][j-val[i-1]] + wi[i-1] << "\n";
				dp[i][j] = min( dp[i-1][j-val[i-1]] + wi[i-1] , dp[i-1][j] );
			}

		}
	}
	int ans = 0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=100000;j++){
			//if( dp[i][j] < INT_MAX )
			//cout << dp[i][j] << " ";
			if( dp[i][j] <= w ){
				ans= max( ans , j );
			}
		}
		//cout << "\n";
	}

	return ans;

}


int32_t main(){
	//fastio();
		


	int n,w;
	cin >> n >> w;

	vector< int > val(n),wi(n);
	int valLim = 0;

	for(int i=0;i<n;i++){
		cin >> wi[i]  >> val[i];
		valLim = max( valLim , val[i] );
	}

	//cout << valLim << "\n";

	cout << doWork(val,wi,n,w,valLim) << "\n";





	return 0;
}






Measured memory_bytes: 80256
import heapq

N = int(input())
a_li = list(map(int,input().split()))

first_q = a_li[0:N] # 前半部分
last_q = []			# 後半部分

first_ans = sum(first_q)
last_ans = 0

for i in range(2*N,3*N):	#最大値を取るために[-x,x]のタプルでlist
	last_q.append([-a_li[i],a_li[i]])
	last_ans += a_li[i]
	
# 優先度付きキューの作成
heapq.heapify(first_q)
heapq.heapify(last_q)
 
first_ans_li = []
last_ans_li = []

first_ans_li.append(first_ans)
last_ans_li.append(last_ans)


for k in range(N,2*N): # k:区切り位置
	pop = heapq.heappushpop(first_q,a_li[k])	# push + 最小値のpop
	push = a_li[k]
	first_ans = first_ans + push - pop
	first_ans_li.append(first_ans)
	

for k in range(2*N-1,N-1,-1): # k:区切り位置
	pop = heapq.heappushpop(last_q,[-a_li[k],a_li[k]])[1] # push + 最大値のpop
	push = a_li[k]
	last_ans = last_ans + push - pop
	last_ans_li.append(last_ans)

ans = -10**20
	
for i in range(0,N+1):
	ans_dush = first_ans_li[i] - last_ans_li[N-i]
	ans = max(ans,ans_dush)

print(ans)

Measured memory_bytes: 37596
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

#define int long long

using namespace std;

class Solver {
};
signed main() {
	int n,t, q;
	cin >> n >> t >> q;

	vector<tuple<int, int>> people;
	vector<tuple<int, int>> people_sub;
	for (int i = 0; i < n; i++) {
		int a,d;
		cin >> a >> d;
		people.emplace_back(make_tuple(a, d));
		people_sub.emplace_back(make_tuple(a, d));
	}
	sort(people.begin(), people.end());

	vector<int> wall;
	for (int i = 1; i < n; i++) {
		int d1 = get<1>(people[i - 1]);
		int d2 = get<1>(people[i]);
		if (d1 == 1 && d2 == 2) {
			int pos = (get<0>(people[i - 1]) + get<0>(people[i])) / 2;
			wall.emplace_back(pos);
		}
	}

	for (int i = 0; i < q; i++) {
		int index;
		cin >> index;
		index--;
		int pos = get<0>(people_sub[index]);
		int dire = get<1>(people_sub[index]);

		if (dire == 1) {
			int wall_pos = 3e18;
			for (int j = 0; j < wall.size(); j++) {
				if (pos <= wall[j]) {
					wall_pos = wall[j];
					break;
				}
			}
			cout << min(pos + t, wall_pos) << endl;
		}
		else {
			int wall_pos = -3e18;
			int size = wall.size();
			for (int j = size - 1; j >= 0; j--) {
				if (wall[j] <= pos) {
					wall_pos = wall[j];
					break;
				}
			}
			cout << max(pos - t, wall_pos) << endl;
		}
	}
}


Measured memory_bytes: 6460
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) (a > b ? a : b)

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  double p[n];
  for (int i = 0; i < n; i++)
    scanf("%lf", p + i);
  double sumk[n - k + 1];
  sumk[0] = 0;
  for (int i = 0; i < k; i++)
  {
    sumk[0] += p[i];
  }
  for (int i = 1; i < n - k + 1; i++)
  {
    sumk[i] = sumk[i - 1] - p[i - 1] + p[i + k - 1];
  }
  double max = 0;
  for (int i=0; i<n-k+1; i++) max = Max(sumk[i], max);
  printf("%lf\n", (max+k)/2);
  return 0;
}


Measured memory_bytes: 3328
n, d = gets.chomp.split(" ").map(&:to_i)
x = []
n.times do
    x << gets.chomp.split(" ").map(&:to_i)
end

ans = 0

n.times do |i|
    (i+1).upto(n-1) do |j|
        sum = 0
        d.times do |k|
            tmp = (x[i][k] - x[j][k]).abs
            sum += tmp*tmp
        end
        flag = false
        (sum+1).times do |k|
            flag = true if k*k == sum
        end
        ans += 1 if flag
    end
end

puts ans

Measured memory_bytes: 14364
S = input()
ls = len(S)
c = [0]*ls

for i in range(ls):
  if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
    for j in range(i,ls):
      if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
        c[i] += 1
      else:
        break
      
print(max(c))

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

const int mod = 1000000007;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, const mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll X, Y;
    cin >> X >> Y;

    if((X+Y) % 3 != 0 || X > 2*Y || Y > 2*X)
    {
        cout << "0\n";
        return 0;
    }

    int n = (2*X - Y) / 3;
    int m = (2*Y - X) / 3;

    if(n == 0 || m == 0)
    {
        cout << "1\n";
        return 0;
    }

    mint ans = 1;
    for(int i=n+1; i<=(n+m); i++)
    {
        ans *= i;
    }
    mint waru = 1;
    for(int i=1; i<=m; i++)
    {
        waru *= i;
    }
    cout << ans * waru.inv() << '\n';

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <utility>
#define N 120
using namespace std;

pair<int, int> a[N];

int main(void)
{
    int n;
    int i, k, x, y;
    long long o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d", &a[i].first, &a[i].second);

    for(k = o = 0; k < 100000; k ++)
    {
        random_shuffle(a, a + n);
        for(i = x = y = 0; i < n; i ++) {
            if((long long)(x + a[i].first) * (x + a[i].first) + (long long)(y + a[i].second) * (y + a[i].second) > (long long)x * x + (long long)y * y)
            {
                x += a[i].first ;
                y += a[i].second;
            }
        }
        o = max(o, (long long)x * x + (long long)y * y);
    }
    printf("%.15Lf\n", sqrt((long double)o));

    return 0;
}


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

namespace AtCoderBC137
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var matches = Regex.Matches(input, "-?[0-9]+");
            var A = int.Parse(matches[0].Value);
            var B = int.Parse(matches[1].Value);
            var res = Math.Max(A + B, Math.Max(A - B, A * B));
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 15960
import sys
sys.setrecursionlimit(200000)

N=int(input())
edges = [0 for i in range(N)]
edge_l = [[] for i in range(N)]
cols = [0 for i in range(N)]
out = 0
seen = [False for i in range(N)]
seen2 = [False for i in range(N)]

def paint(cur, parC):
  if seen[cur]:
    return
  curC = 1
  seen[cur] = True
  for e in edge_l[cur]:
    if not seen2[e[1]]:
      seen2[e[1]] = True
      if curC == parC:
        curC+=1
      cols[e[1]] = curC
      paint(e[0], curC)
      curC+=1
  return

for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edges[a]+=1
  edges[b]+=1
  edge_l[a].append([b,i])
  edge_l[b].append([a,i])
  out = max(out,edges[a],edges[b])
print(out)
paint(0,0)
for i in range(N-1):
  print(cols[i])

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

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

    string s;
    cin >> s;
    char ch;
    for (int i = 0; i < s.size(); i++) {
        if (i == 0) ch = s[i];
        else
            if (s[i] == ch) {
                cout << "Bad" << endl;
                return 0;
            }
            ch = s[i];
    }
    cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
def resolve():
    N = int(input())
    A = list(input().split())
    
    A_all = np.zeros(10**5 + 1, dtype=int)
    A_calc = range(10**5 + 1)
    for i in range(N):
        A_all[int(A[i])] += 1
    ans = sum(A_all * A_calc)
    
    Q = int(input())
    for i in range(Q):
        B,C = map(int,input().split())
        ans = ans + C * A_all[B] - B * A_all[B]
        print(ans)
        A_all[C] += A_all[B]
        A_all[B] = 0
resolve()

Measured memory_bytes: 39876
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    A = i2nn()
    BC = ii2nnn(M)
    A.sort()
    BC.sort(key=lambda x: x[1])
    BC.reverse()
    #print(A)
    #print(BC)
    i = 0
    for b, c in BC:
        for _ in range(b):
            if i >= len(A) or A[i] >= c:
                break
            A[i] = c
            i += 1
    #print(A)
    print(sum(A))

main()


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

int main(void) {
  int a,N,j,v;
  cin >> N;

  int A[N];

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

  for (int i=1;i<N;i++){
    for (int l=0; l<N-1; l++){
      cout << A[l] << " ";
    }
    cout << A[N-1] <<endl;
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
  for (int l=0; l<N-1; l++){
    cout << A[l] << " ";
  }
  cout << A[N-1] <<endl;
  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define MAX 100000 + 5 
using namespace std;
int main(void){
    int N,c[MAX],color[MAX],d[MAX],count=0;
    vector<int> tree[MAX];
    queue<int> ver;
    cin >> N;
    for(int i=1;i<N;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    for(int i=0;i<N;i++){
        color[i] = 0;
        cin >> c[i];
    }
    sort(c,c+N, greater<int>());
    int max_v = 0;
    for(int i=0;i<N;i++){
        if(i!=0){
            count += c[i];
        }
        if(max_v < tree[i].size()){
            max_v = i;
        }
    }
    ver.push(max_v);
    color[max_v] = 1;
    d[max_v] = c[0]; 
    int u = 1;
    while(!ver.empty()){
        //cout << count << endl;
        int v = ver.front();
        ver.pop();
        for(int i=0;i<tree[v].size();i++){
            int next_v = tree[v][i];
            if(color[next_v]==0){
                d[next_v] = c[u];
                ver.push(next_v);
                color[next_v] = 1;
                u++;
            }
        }
    }
    cout << count << endl;
    for(int i=0;i<N;i++){
        if(i>0){
            cout << ' ';
        }
        cout << d[i];
    }
    cout << endl;
    return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n/i) ret.push_back(i);
        }
    }
    return ret;
}

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

    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        auto tmp = divisor(i);
        if (tmp.size() == 8) {
            ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3632
N, P = map(int, input().split())

from collections import defaultdict
d = defaultdict(int)
i = 2
while P >= i*i:
    if P%i==0:
        P //= i
        d[i] += 1
    elif i == 2:
        i += 1
    else:
        i += 2
if P != 1:
    d[P] += 1

ans = 1
for k, v in d.items():
    # print(k, v)
    if v >= N:
        ans *= k**(v//N)
    # z = v // N
    # ans *= k**z
print(ans)


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long A, long long B)
{
    for (int i = 1; i <= 1350; i++)
    {
        ll a = i * 0.08;
        ll b = i * 0.1;
        if (a == A && b == B)
        {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    func(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int n;
	int ab=min(a,2*c),bb=min(b,2*c),cc=min(a+b,2*c),h=min(x,y);
	n=cc*h;
	if(x>y)
	n+=ab*(x-y);
	if(x<y)
	n+=bb*(y-x);
	cout<<n;
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

bool sig[111111];
int A[111111];

int dp[111111];

int S[111111];
signed main(){
    cin>>N;
    cin>>dp[0];

    N--;
    rep(i,N){
        char c;
        int a;
        cin>>c>>a;
        sig[i]=c!='+';
        A[i]=a;
        S[i+1]=a;
    }


    rep(i,N)S[i+1]+=S[i];

    int pre=-1,latte=-1001001001001001001ll;
    rep(i,N){
        if(sig[i]&&pre!=-1){
            chmax(latte,dp[pre]-(S[i]-S[pre])-S[i]);
        }
        if(!sig[i]){
            dp[i+1]=max(dp[i],latte+S[i])+A[i];
        }
        else{
            dp[i+1]=max(dp[i]-A[i],latte+S[i]+A[i]);
            pre=i;
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}



Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int A[200010],B[200010],num[200010];
int N,M,W,C,E,G,K;
int ans=0,ans2,Max=0,Min=INF,Max2=0;
string S,T;
vector<int> V;
set<int> U;
map<int,int> H;
bool F,Q[200010];

signed main(){
	cin>>N;
	int cnt=0,sum=0;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		if(A[i]%2==1){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
	return 0;
}


Measured memory_bytes: 2304
import java.math.BigInteger;
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();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int max = a[0];
		int gcd = a[0];
		for (int i = 1; i < n; i++) {
			max = Math.max(max, a[i]);
			gcd = BigInteger.valueOf(gcd).gcd(BigInteger.valueOf(a[i])).intValue();
		}

		if (k % gcd == 0 && k <= max) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 62036
# (c) midandfeed
while(True):
	h, w = [int(x) for x in input().split()]
	
	if (h == 0) and (w==0):
		break
		
	col = "#."*w
	for i in range(1, h+1):
		if (i&1):
			print(col[0:w])
		else:
			print(col[1:w+1])
	print()		
	

Measured memory_bytes: 7764
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int a[N];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int n,x;
        cin>>n;

        for(int i=1;i<=n;++i)cin>>a[i];
        sort(a+1,a+n+1);

        int mi=a[1],ma=a[n],res=INT_MAX;

        for(int i=mi;i<=ma;++i){
            int sum=0;
            for(int j=1;j<=n;++j){
                sum+=((a[j]-i)*(a[j]-i));
            }
            res=min(res,sum);
        }

        printf("%d\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class BIT{
public:
  int n,bit[500010];
  BIT(){fill(bit,bit+500010,0);}
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};
int n,c=1;
BIT b=BIT();
int calc(int x){
  int res=0;
  if(c+x>n) {
    res=b.sum(n)-b.sum(c)+b.sum((c+x)-n);
  }else{
    res=b.sum(c+x)-b.sum(c);
  }
  return res;
}
int calc2(int x){
  int res=0;
  if(c-x<=0){
    res=b.sum(n)-b.sum(c-x+n-1)+b.sum(c-1);
  }else{
    res=b.sum(c-1)-b.sum(c-x-1);
  }
  return res;
}

int next(){
  int l=0,r=n,mid;
  while(l+1<r){
    mid=(l+r)/2;
    if(calc(mid)<1) l=mid;
    else r=mid;
  }
  //cout << l << endl;
  if(c+l+1>n) c-=n;
  return c+l+1;
}
int main(){
  int m,Q,a,q,i,j,x,l,r,mid;
  cin>>n>>m>>Q,x=n;
  bool f[n+1],s;
  memset(f,0,sizeof(f));
  b.n=n;
  for(i=0;i<n;i++) b.add(i+1,1);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    s=a%2;a%=x;
    if(a){
      if(!s){
        l=0;r=n;
        while(l+1<r){
          mid=(l+r)/2;
          if(calc(mid)<a) l=mid;
          else r=mid;
        }
        //cout << a << l << calc(l) << calc(l+1) << endl;
        c=c+l+1;
        if(c>n) c-=n;
      }else{
        l=0;r=n;
        while(l+1<r){
          mid=(l+r)/2;
          if(calc2(mid)<a) l=mid;
          else r=mid;
        }
        //cout << a << l << calc2(l) << calc2(l+1) << endl;
        c=c-l-1;
        if(c<=0) c+=n;
      }
    }
    //cout << c << " ";
    f[c]=1;
    b.add(c,-1);
    //for(j=0;j<n;j++) cout<<f[j+1];cout<<endl;
    //for(j=0;j<n;j++) cout<<b.sum(j+1)-b.sum(j);cout<<endl;
    c=next();
    //cout << c << endl;
    x--;
  }
  
  while(Q--) cin>>q,cout<<!f[q+1]<<endl;
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    string s,t;cin>>s>>t;
    int n=s.size();
    set<char> sfac;
    set<char> tfac;
    rep(i,n){
        sfac.insert(s[i]);
        tfac.insert(t[i]);
    }
    if(sfac.size()!=tfac.size()){
        cout<<"No"<<endl;
        return 0;
    }
    map<char,char> judge;
    bool can=true;
    rep(i,n){
        if(judge.count(s[i])){
            if(judge[s[i]]!=t[i]){
                can=false;
                break;
            }
        }
        else judge[s[i]]=t[i];
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

struct Point{
    int x,y;
    Point(int _x, int _y) : x(_x),y(_y) {}
    bool operator < (const Point &a) const {
        return x==a.x ? y<a.y : x<a.x;
    }
};

int H,W,K;
char A[1000][1000];

int sx,sy;
bool used[1000][1000];
int cnt[1000][1000];

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

void bfs() {
    queue< pair<Point,int> > que;
    que.push(make_pair(Point(sx,sy),K));
    while(que.size() > 0) {
        Point p = que.front().first;
        int dep = que.front().second;
        que.pop();
        if(p.x<0 || p.y<0 || p.x>=W || p.y>=H) continue;
        if(used[p.y][p.x]) continue;
        if(dep < 0) continue;
        if(A[p.y][p.x] == '#') continue;
        used[p.y][p.x] = true;
        cnt[p.y][p.x] = dep;
        REP(i,4) {
            que.push(make_pair(Point(dx[i]+p.x,dy[i]+p.y),dep-1));
        }
    }
}

int main() {
    
    cin >> H >> W >> K;
    REP(i,H) scanf("%s",A[i]);
    
    sx = sy = -1;
    REP(i,H)REP(j,W) {
        if(A[i][j] == 'S') {
            sy = i;
            sx = j;
        }
    }
    
    REP(i,1000)REP(j,1000) used[i][j] = false;
    REP(i,1000)REP(j,1000) cnt[i][j] = 1e9;
    bfs();
    
    REP(i,H) {
        if(cnt[i][W-1] == K || cnt[i][0] == K) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    REP(i,W) {
        if(cnt[H-1][i] == K || cnt[0][i] == K) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    /*REP(i,H){
        REP(j,W) cout << cnt[i][j] << " ";
        cout << endl;
    }*/
    
    int ans = 1e9;
    REP(i,H)REP(j,W) {
        if(cnt[i][j] <= K) {
            ans = min(ans,(i));
            ans = min(ans,(j));
            ans = min(ans,(H-i-1));
            ans = min(ans,(W-j-1));
        }
    }
    
    if(ans%K == 0)  ans = ans/K + 1;
    else ans = ans/K + 2;
    
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  ll x, y = 0, m = 100;
  cin >> x;
  while(true) {
    y += 1;
    m = m * 1.01;
    if (m >= x) {
      cout << y <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let S = read_line().chars().rev().collect::<Vec<char>>();

    let words = vec!["dream", "dreamer", "erase", "eraser"]
        .into_iter()
        .map(|s| s.chars().rev().collect::<Vec<char>>())
        .collect::<Vec<_>>();

    let mut i = 0;

    let mut ok = true;
    loop {
        if i >= S.len() {
            break;
        }

        let next = words
            .iter()
            .filter_map(|word| {
                if S[i..].starts_with(word) {
                    Some(i + word.len())
                } else {
                    None
                }
            })
            .next();

        if let Some(j) = next {
            i = j;
            continue;
        } else {
            ok = false;
            break;
        }
    }

    println!("{}", if ok { "YES" } else { "NO" });

    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (100006)
ll n, A[MAXN], cnt[MAXN];
set<int> s[MAXN];
set<int> av;
int main()
{
	FAST
	cin>>n;
	FOR(i,1,n)cin>>A[i], ++cnt[A[i]];
	if(n==2) {
		cout<<"-1\n";
		return 0;
	}
	FOR(i,1,n)s[cnt[i]].ins(i), av.ins(i);
	vector<ll> v;
	while(n-siz(v) > 3) {
		ll V = n-siz(v);
		ll tp = -1;
		assert(siz(s[V])==0);
		if(siz(s[V-1])) {
			tp = *s[V-1].begin();
		} else {
			if(v.empty() || A[v.back()] != *av.begin()) {
				tp = *av.begin();
			} else {
				tp = *++av.begin();
			}
		}
		assert(~tp);
		v.pb(tp);
		av.erase(tp);
		s[cnt[tp]].erase(tp);
		if(av.find(A[tp]) != av.end()) {
			s[cnt[A[tp]]].erase(A[tp]);
			-- cnt[A[tp]];
			s[cnt[A[tp]]].ins(A[tp]);
		}
	}
	assert(n-siz(v)==3);
	/* next permutation here */
	vector<ll> hey = {*av.begin(), *++av.begin(), *++++av.begin()};
	sort(all(hey));
	do {
		v.pb(hey[0]), v.pb(hey[1]), v.pb(hey[2]);
		bool fk=1;
		FOR(i,max(0ll,n-4),n-2) if(A[v[i]] == v[i+1]) {
			fk=0;
		}
		if(fk) break;
		v.pop_back(), v.pop_back(), v.pop_back();
	} while(next_permutation(all(hey)));
	/* */
	assert(v.size()==n); for(auto i:v) cout<<i<<' '; cout<<'\n'; 
}


Measured memory_bytes: 16512
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
    string s,t;
    cin>>s>>t;
    int x=s.length(),y=t.length();
    int dp[x+1][y+1];
    for(int i=0;i<=x;i++)
    dp[i][0]=0;
    for(int i=0;i<=y;i++)
    dp[0][i]=0;
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            if(s[i-1]==t[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }    
        
    }
    vector<char> v;
    int i=x,j=y;
    while(i>=1 && j>=1){
        if(dp[i-1][j-1]<dp[i][j] && (dp[i-1][j]==dp[i][j-1]) &&(dp[i-1][j]<dp[i][j])){
            v.push_back(s[i-1]);
            i--;j--;
        }else{
            if(dp[i-1][j]<dp[i][j-1])
            j--;
            else
            i--;
        }
    }
    for(int i=dp[x][y]-1;i>=0;i--)
    cout<<v[i];
    //cout<<dp[x][y];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 38792
n=int(input())
M=10**9+7
X=list(map(int, input().split()))

tot = 0
s_tot=0

def modpow( a , n , m):
    ans=1
    n_bit = bin(n)[2:]
    l=len(n_bit)
    for i in list(range(l))[::-1]:
        if n_bit[i]=="1":
            ans = (ans * a) % m
        #print(i , n_bit[i] , a , ans)
        a=(a*a) %m
        #print(a,ans)
    return ans
inv_2 = modpow( 2 , M-2 , M)
for i in range(n):
    y=X[i]
    
    tot = (tot + y) % M
    s_tot = (s_tot + y**2%M ) % M

ans= ((tot ** 2 - s_tot )* inv_2 ) % M
print(ans)

Measured memory_bytes: 104456
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	long long maxn;
	cin>>a>>b>>c>>d;
	maxn=max(a*d,a*c);
	maxn=max(maxn,b*c);
	maxn=max(maxn,b*d);
	cout<<maxn<<endl;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


string s;
int main(){
    cin >> s;
    if((s[0] == s[(int)s.size()-1]) ^ (s.size() % 2 == 1)){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<sstream>
typedef long long LL;
using namespace std;
 
LL a[3010];
int main()
{
    int n;
    scanf("%d",&n);
    int s=0;
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]),s+=a[i]-1;
 
    printf("%d\n",s);
    return 0;
}


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

int main(){
  int n; cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=a[0];
  for(int i=1;i<n;i++){
    ans=__gcd(ans,a[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(X: int, A: int):
    print(0 if X < A else 10)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(X, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int A, B;
  cin >> A >> B;
  rep(i,1e9){
    int a = abs(A - i);
    int b = abs(B - i);
    if(a == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] T, int[] A)
        {
            int[] mins = Enumerable.Repeat(int.MinValue, N).ToArray();
            int[] maxs = Enumerable.Repeat(int.MaxValue, N).ToArray();

            mins[0] = Math.Max(T[0], mins[0]);
            maxs[0] = Math.Min(T[0], maxs[0]);
            for (int i = 1; i < N; ++i)
            {
                if (T[i] > T[i - 1])
                {
                    mins[i] = Math.Max(T[i], mins[i]);
                    maxs[i] = Math.Min(T[i], maxs[i]);
                }
                else if (T[i] == T[i - 1])
                {
                    mins[i] = Math.Max(1, mins[i]);
                    maxs[i] = Math.Min(T[i], maxs[i]);
                }
                else
                {
                    return 0;
                }
            }

            mins[N - 1] = Math.Max(A[N - 1], mins[N - 1]);
            maxs[N - 1] = Math.Min(A[N - 1], maxs[N - 1]);
            for (int i = N - 2; i >= 0; --i)
            {
                if (A[i] > A[i + 1])
                {
                    mins[i] = Math.Max(A[i], mins[i]);
                    maxs[i] = Math.Min(A[i], maxs[i]);
                }
                else if (A[i] == A[i + 1])
                {
                    mins[i] = Math.Max(1, mins[i]);
                    maxs[i] = Math.Min(A[i], maxs[i]);
                }
                else
                {
                    return 0;
                }
            }

            long prod = 1;
            for (int i = 0; i < N; ++i)
            {
                if (mins[i] <= maxs[i])
                {
                    prod *= maxs[i] - mins[i] + 1;
                    prod %= 1000000007;
                }
                else
                {
                    return 0;
                }
            }
            return (int)prod;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] T = ReadInts();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, T, A));
        }
    }
}


Measured memory_bytes: 36060
N,T=input().split()
N=int(N)
T=int(T)
ans=None

while(N):
    c,t=input().split()
    c=int(c)
    t=int(t)
    if(t<=T):
        if(ans==None):
            ans=c
        else:
            ans=min(ans,c)
    N-=1

if(ans==None):
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
// AOJ ITP2_1_A: Vector
// 2018.6.24 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char Q[200005][13];
int end;
char a[30];

int main()
{
	int q;
	
	fgets(a, 30, stdin), q = atoi(a);
	while (q--) {
		fgets(a, 30, stdin);
		if (a[0] == '0') strcpy(Q[end++], a+2); // pushBack
		else if (a[0] == '1') printf(Q[atoi(a+2)]); // randomAccess
		else --end; // popBack
	}
	return 0;
}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  long answer = 0;
  int tmp,div;
  int count;
  for(int i=1;i<n+1;i++){
    count = 0;
    div = 10000;
    tmp = i;
    while(tmp > 0){
      count += tmp / div;
      tmp = tmp % div;
      div /= 10;
    }
    if(count >= a && count <= b){
      answer += i;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    S = input()
    if S == 'AC':
        ac += 1
    if S == 'WA':
        wa += 1
    if S == 'TLE':
        tle += 1
    if S == 'RE':
        re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)


Measured memory_bytes: 69884
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
int main(){
	string s;
	cin >> s;
	if(s=="zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl;return 0;
	}else{
		if(s.size()<26){
			bool b[26];
			memset(b,0,sizeof(b));
			for(int i=0;i<s.size();i++)
				b[(int)((int)s[i]-(int)'a')]=1;
			for(int i=0;i<26;i++)
				if(!b[i]){
					cout << s << (char)(i+(int)'a') << endl;
					return 0;
				}
		}else{
			string cs = s;
			next_permutation(cs.begin(),cs.end());
			for(int i = 0; i < s.size(); ++i)
				if(cs[i]==s[i])
					cout << cs[i];
				else{
					cout << cs[i];
					break;
				}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
	int T;
	cin>>T;
	for(int i=0,H,W,N;i<T;++i){
		if(i!=0)cout<<endl;
		char field[21][21];
		int x,y,a;
		cin>>H>>W;
		for(int j=0;j<H;++j){
			string line;
			cin>>line;
			for(int k=0;k<=W;++k) field[j][k]=line[k];
			//scanf("%s",field[j]);
			for(int k=0;k<W;++k)
				if(field[j][k]=='^'||field[j][k]=='v'||field[j][k]=='<'||field[j][k]=='>')
					{
						x=k;y=j;
						if(field[j][k]=='^') a=0;
						else if(field[j][k]=='v') a=1;
						else if(field[j][k]=='<') a=2;
						else if(field[j][k]=='>') a=3;
					}
		}
		string s;cin>>N;
		cin>>s;
		for(int j=0;j<s.size();++j){
			int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//UDLR
			char pos[]={'^','v','<','>'};
			if(s[j]=='U'||s[j]=='D'||s[j]=='L'||s[j]=='R'){
				if(s[j]=='U') a=0;
				else if(s[j]=='D') a=1;
				else if(s[j]=='L') a=2;
				else if(s[j]=='R') a=3;
				field[y][x]=pos[a];
				if(0<=x+dx[a] && x+dx[a]<W && 0<=y+dy[a] && y+dy[a]<H){
					if(field[y+dy[a]][x+dx[a]]=='.'){
						field[y][x]='.';
						x+=dx[a];y+=dy[a];
						field[y][x]=pos[a];
					}
				}
			}else if(s[j]=='S'){
				int sx=x+dx[a],sy=y+dy[a];
				while(0<=sx && 0<=sy && sx<W && sy<H){
					if(field[sy][sx]=='#') break;
					if(field[sy][sx]=='*'){
						field[sy][sx]='.';
						break;
					}
					sx+=dx[a];sy+=dy[a];
				}
			}
		}
		for(int j=0;j<H;++j) printf("%s\n",field[j]);
	}
	return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
using namespace std;
int n;
int main(){
    scanf("%d",&n);
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9) printf("hon");
    if(n==0||n==1||n==6||n==8) printf("pon");
    if(n==3) printf("bon");
    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
int n,a[110],S,T,ne[110],dl[110];
bool vis[110];
ll ans=0;
struct edge
{
	int t;
	ll c,f;
	edge *next,*rev;
}*con[110];
void ins(int x,int y,ll c)
{
	edge *p=new edge;
	p->t=y;
	p->c=c;
	p->f=0;
	p->next=con[x];
	con[x]=p;
	p=new edge;
	p->t=x;
	p->c=0;
	p->f=0;
	p->next=con[y];
	con[y]=p;
	con[x]->rev=con[y];
	con[y]->rev=con[x];
}
bool bfs()
{
	int head,tail;bool re=0;
	memset(ne,0,sizeof(ne));
	dl[1]=S;ne[S]=1;
	for(head=tail=1;head<=tail;head++)
	{	
		int v=dl[head];
		if(v==T) re=1;
		for(edge *p=con[v];p;p=p->next)
			if(!ne[p->t]&&p->c>p->f)
				ne[p->t]=ne[v]+1,dl[++tail]=p->t;	
	}
	return re;
}
ll dinic(int v,ll flow)
{
	if(v==T) return flow;
	if(vis[v]) return 0;
	ll re=0;
	for(edge *p=con[v];flow&&p;p=p->next)
		if(ne[p->t]==ne[v]+1&&p->c>p->f)
		{
			ll o=dinic(p->t,min(flow,p->c-p->f));
			p->f+=o;p->rev->f-=o;
			re+=o;flow-=o; 
		}
	if(re==0) vis[v]=1;
	return re;		
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	S=0;T=n+1;
	for(int i=1;i<=n;i++)
		if(a[i]>0) ins(S,i,a[i]),ans+=a[i];
		else 
		{
			ins(i,T,-a[i]);
			for(int j=2;i*j<=n;j++)
				if(a[i*j]>0) {ins(i*j,i,1e15);}
		}
	while(bfs())
	{
		memset(vis,0,sizeof(vis));
		ans-=dinic(S,1e15);
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a > b) swap(a,b);
  if(b > c) swap(b,c);
  if(a > b) swap(a,b);
  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}

Measured memory_bytes: 1164
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    a = inpl()
    dic = defaultdict(int)
    for i in range(n):
        dic[a[i]] += 1
    ans = 0
    for e in dic:
        num = dic[e]
        ans += (num*(num-1))//2
    for i in range(n):
        print(ans-(dic[a[i]]*(dic[a[i]]-1))//2+((dic[a[i]]-1)*(dic[a[i]]-2))//2)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 111172