akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

vector<ll> d(1001, LLONG_MAX);

bool bellman_ford(int start, int n, vector<edge> edges){
    d[start] = 0LL;
    bool updated;
    rep(n){
        updated = false;
        for(edge e: edges){
            if(d[e.from] != LLONG_MAX && d[e.from] + e.cost < d[e.to]){
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }
        if(!updated) return true;
    }
    return false;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,m,r;
    cin >> n >> m >> r;
    vector<edge> edges(m);
    int from,to; ll cost;
    rep(m){
        cin >> from >> to >> cost;
        edges[i].from = from;
        edges[i].to = to;
        edges[i].cost = cost;
    }
    if(bellman_ford(r, n, edges)){
        rep(n){
            if(d[i] == LLONG_MAX){
                cout << "INF" << endl;
            }else{
                cout << d[i] << endl;
            }
        }
    }else{
        cout << "NEGATIVE CYCLE" << endl;
    }
    return 0;
}


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

int main(){
	int r,c;
	while(1){
		cin>>r>>c;
		if(r==0&&c==0) break;
		if(r%2==0||c%2==0) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


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

typedef long long lint;

vector< lint > alls;

void makeAll(int i, lint cur) {
  alls.push_back(cur);
  if (i == 17) return;

  makeAll(i + 1, cur * 10 + 2);
  makeAll(i + 1, cur * 10 + 8);
}
int ans = -1;
void rec(int i, lint cur, int dep) {
  if (i == (int)alls.size()) return;
  if (cur == 1) { ans = max(ans, dep); return; }
  if (cur & 1) return;
  if (cur < alls[i]) return;

  if (cur % alls[i] == 0) rec(i, cur / alls[i], dep + 1);
  rec(i + 1, cur, dep);
}

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

  if (n == 1) {
    cout << -1 << endl;
    return 0;
  }
  
  alls.clear();
  makeAll(1,2);
  makeAll(1,8);

  sort(alls.begin(), alls.end());

  rec(0, n, 0);
  cout << ans << endl;
}

Measured memory_bytes: 3368
#include <iostream>
#include <vector>
using namespace std;
struct Tree {
  vector<int> children;
  int parent = -1;
  int depth = 0;
  string type = "";
};
#define MAX 100100
Tree tree[MAX];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int id, k;
    cin >> id >> k;
    if (k > 0) {
      tree[id].type = "internal node";
    } else {
      tree[id].type = "leaf";
    }
    tree[id].children.assign(k, 0);
    for (int j = 0; j < k; j++) {
      cin >> tree[id].children[j];
      tree[tree[id].children[j]].parent = id;
    }
  }
  
  for (int i = 0; i < MAX; i++) {
    if (tree[i].type == "") continue;
    if (tree[i].parent == -1) tree[i].type = "root";
    for (int j = i; tree[j].parent != -1; j = tree[j].parent) {
      tree[i].depth++;
    }

    cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth << ", " << tree[i].type << ", [";
    for (int j = 0; j < tree[i].children.size(); j++) {
      cout << tree[i].children[j];
      if (j+1 != tree[i].children.size()) {
        cout << ", ";
      }
    }
    cout << "]" << endl;
  }
}




Measured memory_bytes: 12204
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, N + 1):
    for k in [-2, -1]:
        if i + k not in a:
            dp[i] += dp[i+k]
            dp[i] %= 1000000007

print(dp[N])


Measured memory_bytes: 58200
import Control.Applicative
import Data.Tuple

--          ([前, 後], [左, 右], [上, 下])
type Dice = [(String, String)]

makeDice :: [String] -> Dice
makeDice ls = map (\(x, y) -> (ls' !! x, ls' !! y)) di
  where
    ls' = "_" : ls
    di = [(2, 5), (4, 3), (1, 6)]

rotate :: Dice -> Char -> Dice
rotate [xs, ys, zs] s
  | s == 'S' = [zs, ys, swap xs]
  | s == 'N' = [swap zs, ys, xs]
  | s == 'E' = [xs, swap zs, ys]
  | s == 'W' = [xs, zs, swap ys]

solve :: Dice -> String -> String
solve ds cmds = fst $ (foldl rotate ds cmds) !! 2


main :: IO ()
main = do
  labels <- words <$> getLine
  cmds   <- getLine
  putStrLn $ solve (makeDice labels) cmds



Measured memory_bytes: 3548
#include <stdio.h>
#include <stdbool.h>

int Mayor(int A, int B){
	return A>B? A: B;
};
bool Equal(int A, int B){
  	if(A == 5)
		return A == B;
 	return false;
};

int main(){

  	int A, B, C, Aux;

  	scanf("%d%d%d", &A, &B, &C);
	Aux = Mayor(C, Mayor(A, B));
  	if(Aux == 7 && (Equal(A, B) || Equal(B, C) || Equal (C, A)))
      printf("YES\n");
  	else
      printf("NO\n");

	return 0;
}


Measured memory_bytes: 1612
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a)
	fmt.Scan(&b)

	if a[0] == b[2] && a[1] == b[1] && a[2] == b[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int count = scanner.nextInt();

        for(int i=0; i<count; i++){
        	int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();

            a*=a;
            b*=b;
            c*=c;

            if(a+b==c || b+c==a || c+a==b){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }
    }
}

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

/*
int linearSearch(vector<int> S, int key){
  for(int i = 0; i < S.size(); i++){
    if(S[i] == key) return i;
  }
  return -1;
}
*/

int linearSearch(vector<int> S, int key){
  int i = 0;
  while(S[i] != key) i++;
  if(i == S.size() - 1) return -1;
  else return i;
}

int main(void){
  vector<int> S;
  int n, q, cnt = 0;

  cin >> n;
  for(int i = 0; i < n; i++){
    int num;
    cin >> num;
    S.push_back(num);
  }

  cin >> q;
  for(int i = 0; i < q; i++){
    int key;
    cin >> key;
    S.push_back(key);
    if(linearSearch(S, key) >= 0) cnt++;
    S.erase(S.begin() + S.size() - 1);
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int t; cin >> t;
		if (t >= k) ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_right

n, m = li()
lrc = [list(li()) for _ in range(m)]

# n = 10**5
# m = 10**5
# lrc = [[1, n, 5] for _ in range(m)]

# l -> r の降順にソート
lrc = sorted(lrc, key=lambda x: x[2])
lrc = sorted(lrc, key=lambda x: x[1])
lrc = sorted(lrc, key=lambda x: x[0])
#lrc = sorted((sorted(lrc, key=lambda x: x[1])), key=lambda x: x[0])

# 二分探索で距離更新
INF = float('inf')
dist = [INF]*n
dist[0] = 0

for left_idx, right_idx, ci in lrc:
    left_idx -= 1
    newleft_idx = bisect_right(dist, dist[left_idx] + ci)
    for idx in range(newleft_idx, right_idx):
        dist[idx] = dist[left_idx] + ci

if dist[-1] == INF:
    print(-1)
else:
    print(dist[-1])


Measured memory_bytes: 105052
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 105
int a[N];
int sol(int x,int n)
{
	if(x==n) return 0;
	int ans=0;
	for(int i=x+1;i<n;i++) ans+=9*(n-i)*9;
	ans+=(a[x]-1)*9*(n-x);
	int cur=x+1;
	while(cur<=n&&a[cur]==0) cur++;
	if(cur!=n+1)
	{
		ans+=(n-cur)*9;
		ans+=a[cur];
	}
	return ans;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	string s;
	cin>>s;
	int n=s.length();
	for(int i=1;i<=n;i++) a[i]=s[i-1]-'0';
	int k=read();
	if(k==1)
	{
		int ans=9*(n-1);
		ans+=a[1];
		cout<<ans<<endl;
	}
	if(k==2)
	{
		int ans=0;
		if(n==1)
		{
			cout<<"0\n";
			return 0;
		}
		for(int i=2;i<n;i++) ans+=9*(i-1)*9;
		ans+=(a[1]-1)*9*(n-1);
		int cur=2;
		while(cur<=n&&a[cur]==0) cur++;
		if(cur!=n+1)
		{
			ans+=(n-cur)*9;
			ans+=a[cur];
		}
		cout<<ans<<endl;
	}
	if(k==3)
	{
		if(n<=2)
		{
			cout<<"0\n";
			return 0;
		}
		int ans=0;
		for(int i=3;i<n;i++) ans+=9*9*9*(i-1)*(i-2)/2;
		ans+=(a[1]-1)*9*9*(n-1)*(n-2)/2;
		int cur=2;
		while(cur<=n&&a[cur]==0) cur++;
		if(cur!=n+1)
		{
			ans+=sol(cur,n);
		}
		cout<<ans<<endl;
	}
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



int N;
int a[202020];
int pos[202020];

signed main()
{
    cin >> N;

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

    set<int> s;
    s.insert(-1);
    s.insert(N);
    int ans = 0;

    for (int i=1; i<=N; i++) {
        s.insert(pos[i]);
        auto it = s.find(pos[i]);
        --it;
        int left = *it;
        ++it;
        ++it;
        int right = *it;
        ans += i * (pos[i] - left) * (right - pos[i]);
    }

    cout << ans << endl;
}


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

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

    int result = 0;
    if (X < 600)
    {
        result = 8;
    }
    else if (X < 800)
    {
        result = 7;
    }
    else if (X < 1000)
    {
        result = 6;
    }
    else if (X < 1200)
    {
        result = 5;
    }
    else if (X < 1400)
    {
        result = 4;
    }
    else if (X < 1600)
    {
        result = 3;
    }
    else if (X < 1800)
    {
        result = 2;
    }
    else
    {
        result = 1;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <vector>

using namespace std;

class c_recursion
{
private:
    int a[2000];

    
public:
    c_recursion();
    void f_input();
    int f_do(int n1, int m1, int i, int s);
};

c_recursion::c_recursion()
{

}

void c_recursion::f_input()
{
    int n,q;
    int i;
    int temp1;
    
    int m[2000];
   
 
    
    cin >> n;
    for ( i = 0; i < n; ++i){
        cin >> a[i];
    }
    cin >> q;
    for ( i = 0; i < q; ++i){
        cin >> m[i];
    }
  
    
    for ( i = 0; i < q; ++i){
        temp1 = c_recursion::f_do(n,m[i],0,0);
        //temp1 = c_recursion::f_do(n,100,0,0);
        //cout << temp1<< endl;
        if (temp1 == 1){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;        
        }
    }
    
}

int c_recursion::f_do(int n1, int m1, int i, int s)
{
 
    int j;
    int res;
    
    res = 0;
    
    for ( j = i; j <= n1;++j ){
        
        //cout << "s: " << s << endl;
        
        if (m1 == s){
            //cout << "return: " << s << " "<< m1 << endl;
            res = 1;
            break;
        }else{
            res = 0;
            if (c_recursion::f_do(n1, m1, j + 1,s + a[j])){
                res =1;
                break;
            }
        } 
    }
    
    if (res == 1){
        //cout << "return 1: " << res << " "<< endl;
        return 1;
    }else{
        //cout << "return 0: " << res << " "<< endl;
        return 0;
    }
}

int main(){
    
    c_recursion recursion01;
    recursion01.f_input();
    
    return 0;
}

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

int main(){

	int n, alu, aluno[101010];

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> alu;
		aluno[alu-1] = i+1; 
	}

	for (int i = 0; i < n; ++i)
	{
		cout << aluno[i] << " ";
	}
	cout << endl;

}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

long long P[200001];
long long Q[200001];

int main(){
  int i,N;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> P[i];
    Q[P[i]]=i;
  }
  int A=0,Amax=0,B=-1,C=0;
  for (i=2;i<=N;++i) {
    A++;
    if (Q[i]<Q[i-1]) {
      if (Amax<A) {
        Amax=A;
      }
      A=0;
      if (B==-1) {
        B=i;
      }
      C=i;
    }
  }
  if (B==-1) {
    B=0;
    C=1;
  }
  int D;
  if (N-B+1 > C-1) {
    D=C-1;
  } else {
    D=N-B+1;
  }
  if (N-Amax > D) {
    cout << D << endl;
  } else {
    cout << N-Amax << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
//push_back make_pair emplace vector double float _unordered_map unodered_set queue stack sort begin end clear
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() { fastIO
	int l, r;l = 0; 
	string str;
	cin >> str;
	r = str.size() - 1;int ans = 0;
	if (str.size()%2 == 0){
		while (r - l >= 1){
			if (str[l] != str[r])++ans;
			++l;--r;
		}
	}
	else while (r != l){
		if (str[l]!=str[r])++ans;
		++l;--r;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3556
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

d = make_divisors(n)
ans = 10**18
for a in d:
    ans = min(ans, n//a-1+a-1)
print(ans)


Measured memory_bytes: 68308
#include<bits/stdc++.h>
using namespace std;
long long find(vector<long long>&a,vector<long long>&b,int i,int j,int n,int m,vector<vector<long long>>&dp,long long k)
{
    if(i>=n || j>=m)
      return 0;
    if(k<0)
      return 0;
     
    if(dp[i][j]!=-1)
      return dp[i][j];
      
    long long ans1=0,ans2=0;
    
    if((k-a[i])>=0)
      ans1=1+find(a,b,i+1,j,n,m,dp,k-a[i]);
    if((k-b[j])>=0)
      ans2=1+find(a,b,i,j+1,n,m,dp,k-b[j]);
      
    dp[i][j]=max(ans1,ans2);
    
    return dp[i][j];
}

int main()
{
    long long n;
    cin>>n;
    long long res=0;
    vector<long long>ans(n+1,1);
    for(int i=2;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            ans[j]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        res+=ans[i]*i;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 81372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s,s1;
	cin>>s>>s1;
	int ans = 0;
	for(int i=0;i<3;i++)
	{
		if(s[i]==s1[i])ans++;
	}
	cout<<ans<<endl;
} 

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

int main(){
  int a,b;
  cin >> a >> b;
  
  int m;
  m = a * b;
  
  if(m % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 1000
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,num1,num2,num;long long K;
char st[MN+5][MN+5];
int pow(int x,long long k)
{
	int sum=1;
	for(;k;k>>=1,x=1LL*x*x%mod)
		if(k&1) sum=1LL*sum*x%mod;
	return sum;
}
struct Matrix
{
	int s[2][2];
	Matrix(){memset(s,0,sizeof(s));}
	Matrix operator * (const Matrix&y)
	{
		Matrix c;
		for(int i=0;i<2;++i)for(int j=0;j<2;++j)for(int k=0;k<2;++k)
			c.s[i][j]=(c.s[i][j]+1LL*s[i][k]*y.s[k][j])%mod;
		return c;	
	}
	void Mul(int&x,int&y)
	{
		int z=x;
		x=(1LL*s[0][0]*x+1LL*s[0][1]*y)%mod;
		y=(1LL*s[1][0]*z+1LL*s[1][1]*y)%mod;
	}
}B;
int main()
{
	n=read();m=read();cin>>K;
	for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j) num+=st[i][j]=='#';
	for(int i=1;i<=n;++i) if(st[i][1]=='#'&&st[i][m]=='#') ++num1;
	for(int i=1;i<=m;++i) if(st[1][i]=='#'&&st[n][i]=='#') ++num2;
	if(num1&&num2) return 0*puts("1");
	if(!num1&&!num2) return 0*printf("%d\n",pow(num,K-1));
	else 
	{
		int res=0;
		if(num2) for(int i=1;i<n;++i)for(int j=1;j<=m;++j) res+=(st[i][j]=='#'&&st[i+1][j]=='#');
		else     for(int i=1;i<=n;++i)for(int j=1;j<m;++j) res+=(st[i][j]=='#'&&st[i][j+1]=='#');
		num1=max(num1,num2);
		int a=1,b=0;
		B.s[0][0]=num;B.s[1][0]=res;B.s[1][1]=num1;
		for(--K;K;K>>=1,B=B*B) if(K&1) B.Mul(a,b);
		printf("%d\n",(a-b+mod)%mod);
	}
	return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int n;
  cin >> n;
  string s;
  cin >> s;
  long int r = 0;
  long int g = 0;
  long int b = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  long int sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = 1; i+j+j < n; j++){
      if((s[i]^s[i+j]^s[i+j+j])==('R'^'G'^'B'))sum++;
    }
  }
  long int ans = r*g*b - sum;
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000000007

#define MAX 		200005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int dp[MAX];

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

	REP(i,N)cin>>dp[i];
	if(dp[0]!=0){
		cout << -1 << endl;
		return 0;
	}
	ull cnt = 0;
	REPS(i,1,N){
		ll diff = dp[i] - dp[i-1];
		if(diff==1)
			cnt++;
		else if(diff < 1)
			cnt += dp[i];
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,a,b;

void go()
{
	cin >> a >> b;

	fo(i,1,20001)
	{
		ld xx = 0.08*i;
		ld yy = 0.10*i;
		int aa = xx;
		int bb = yy;

		if( (aa == a) and (bb == b)) 
		{
			cout << i << endl;
			return;
		}
	}

	cout << -1 << endl;
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    int dis=x/d;
    if (dis>k) cout<<x-k*d;
    else
    {
        k-=dis;
        if (k%2==0) cout<<x-dis*d;
        else cout<<abs(x-(dis+1)*d);
    }
}


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

#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)

using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}

const int MAXN =2e5+3,MAXM=18 +3;
int n,P[MAXN];
class ST_Table{
	public:
		int data[MAXM][MAXN],pos[MAXM][MAXN];
		void buld(bool type){
			up(1,n,i) data[0][i]=INF;
			up(1,n/2,i) data[0][(i<<1)-type]=P[(i<<1)-type],
						pos[0][(i<<1)-type]=(i<<1)-type;
			up(1,18,i) up(1,n,j){
				if(j+(1<<i)-1>n) break;
				pos[i][j]=data[i-1][j]<data[i-1][j+(1<<i-1)]?
				pos[i-1][j]:pos[i-1][j+(1<<i-1)];
				data[i][j]=min(data[i-1][j],data[i-1][j+(1<<i-1)]);
			}
		}
		void gtmn(int L,int R,int &mn,int &ps){
			int delta=R-L+1,cnt=0;
			while((1<<cnt)<=delta) cnt++; cnt--;
			ps=(data[cnt][L]<data[cnt][R-(1<<cnt)+1]?
				pos[cnt][L]:pos[cnt][R-(1<<cnt)+1]);
			mn=min(data[cnt][L],data[cnt][R-(1<<cnt)+1]);
		}
}ST[2];
class Node{
	public:
		int L,R,t1,t2,p1,p2;
		Node(int _L,int _R){
			bool type=!(_L&1); L=_L,R=_R;
			ST[ type].gtmn(L,R,t1,p1);
			ST[!type].gtmn(p1+1,R,t2,p2);
		}
		bool operator <(const Node t)const{
			return t1==t.t1?t2<t.t2:t1<t.t1;
		}
		bool operator >(const Node t)const{
			return t1==t.t1?t2>t.t2:t1>t.t1;
		}
};
priority_queue <Node,vector<Node>,greater<Node> >pq;
void calc(){
	pq.push(Node(1,n));
	while(!pq.empty()){
		Node t=pq.top(); pq.pop();
		printf("%d %d ",t.t1,t.t2);
		if(t.L!=t.p1) 	pq.push(Node(t.L,t.p1-1));
		if(t.p1+1!=t.p2)pq.push(Node(t.p1+1,t.p2-1));
		if(t.R!=t.p2)	pq.push(Node(t.p2+1,t.R));
	}
}
int main(){
	n=qread();
	up(1,n,i) P[i]=qread();
	ST[0].buld(1),ST[1].buld(0);
	calc();
	return 0;
}


Measured memory_bytes: 60660
N, M = map(int, input().split())
ans = 0
if N == 2 or M == 2:
  ans = 0
elif N == 1 and M == 1:
  ans = 1
elif N == 1 or M == 1:
  ans = max(N, M) - 2
else:
  ans = (N-2) * (M-2)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>

int main(){
 int upper=1000000+1;
 int ans=0;

 int N;
 std::cin>>N;
 std::map<int,int> map;
 std::vector<int> B(upper,0);
 int a;
 for(int i=0;i<N;i++){
  std::cin>>a;
  map[a]++;
 }

 if(map[1]==1){
  std::cout<<1<<std::endl;
  return 0;
 }else if(map[1]>1){
  std::cout<<0<<std::endl;
  return 0;
 }

 for(auto p:map){
  if(p.second!=0){
   int j=2;
   while(p.first*j<upper){
    B[p.first*j]++;
    j++;
   }
  }
 }

 for(auto p:map){
  if(B[p.first]==0 && p.second==1){
   ans++;
  }
 }

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

Measured memory_bytes: 16392
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n;
	int[] xs, ys;

	void run(){
		n=sc.nextInt();
		xs=new int[n];
		ys=new int[n];
		for(int i=0; i<n; i++){
			xs[i]=sc.nextInt();
			ys[i]=sc.nextInt();
		}
		solve();
	}

	void solve(){
		int[][] dp1=new int[n+1][n+1];
		int[][] dp2=new int[n+1][n+1];
		int[][] dp=new int[n+1][n+1];
		int[][] k=new int[n+1][n+1];
		for(int i=0; i<=n; i++){
			fill(dp1[i], INF);
			fill(dp2[i], INF);
			fill(dp[i], INF);
			dp1[i][i]=0;
			dp2[i][i]=0;
			if(i<n){
				dp1[i][i+1]=0;
				dp2[i][i+1]=0;
			}
			k[i][i]=i;
		}
		// dp1テ」ツ?ッテッツシツ古ァツクツヲテ」ツつ津・ツ青ォテ」ツ?セテ」ツ?ェテ」ツ??
		if(false)
			for(int w=1; w<=n; w++){
				for(int i=0; i+w<=n; i++){
					int j=i+w;
					for(int s=i; s<=j; s++){
						dp1[i][j]=min(dp1[i][j], dp1[i][s]+dp2[s][j]+xs[j-1]
								-xs[i]);
						dp2[i][j]=min(dp2[i][j], dp1[i][s]+dp2[s][j]+ys[i]
								-ys[j-1]);
						dp[i][j]=min(dp[i][j], dp1[i][s]+dp2[s][j]+xs[j-1]
								-xs[i]+ys[i]-ys[j-1]);
					}
				}
			}

		for(int w=1; w<=n; w++){
			for(int i=0, j=w; j<=n; i++, j++){
				int min=INF;
				for(int r=k[i][j-1]; r<=k[i+1][j]; r++){
					int v=dp1[i][r]+dp2[r][j];
					if(v<min){
						min=v;
						k[i][j]=r;
						dp1[i][j]=v+xs[j-1]-xs[i];
						dp2[i][j]=v+ys[i]-ys[j-1];
						dp[i][j]=v+xs[j-1]-xs[i]+ys[i]-ys[j-1];
					}
				}
			}
		}
		for(int i=0; i<=n; i++){
//			debug(i, dp[i]);
		}
		println(dp[0][n]+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 28000
main(){double a,l,x,s,t;
for(;~scanf("%lf%lf%lf",&a,&l,&x);)
s=(l+l+a)/2,printf("%lf\n",sqrt((a/2)*(a/2)*(s-a)*s)+2*sqrt((l/2)*(l/2)*(x/2)*((l+x+l)/2)));exit(0);}

Measured memory_bytes: 652
N,M=map(int,input().split())
L=[]
for i in range(N) :
  A=list(map(int,input().split()))
  L.append(A)
L.sort()
P=0
for j,k in L :
  P+=j*min(k,M)
  M-=k
  if M<=0 :
    break
print(P)

Measured memory_bytes: 27760
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
using namespace std;

int gcd(int a, int b){
    int g = max(a,b);
    int l = min(a,b);
    int r = g % l;
    if(r == 0){
        return l;
    }else{
        return gcd(l, r);
    }

}

int main(){
    int N;
    int A[100000];
    int M[100000];
    int L[100000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int mini = 1000000000;
    int maxi = 0;
    int gc = A[0];
    for(int i=0;i<N;i++){
        gc = gcd(gc, A[i]);
        M[i] = gc;
    }
    gc = A[N-1];
    for(int i=0;i<N;i++){
        gc = gcd(gc, A[N-1-i]);
        L[N-1-i] = gc;
    }
    for(int i=1;i<N-1;i++){
        maxi = max(maxi, gcd(M[i-1], L[i+1]));
    }
    maxi = max(maxi,L[1]);
    maxi = max(maxi,M[N-2]);   

    cout << maxi << endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;

int main() {
    string s;
    int K;
    cin >> s >> K;

    int slen = s.length();
    set<string> st;
    for(int i = 0; i < slen; ++i) {
        string tmp;
        for(int j = 0; i + j < slen; ++j) {
            tmp += s[i + j];
            st.insert(tmp);
            if(st.size() > K) {
                auto itr = st.end();
                itr--;
                st.erase(itr);
            }
        }
    }
    auto itr = st.end();
    itr--;
    cout << *itr << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

    int n;
    cin>>n;
    vector<string> vs;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        vs.push_back(s);
    }

    map<string,int> mp;
    for(int i=0;i<vs.size();i++){
        mp[vs[i]]++;
    }
    for(auto x:mp){
         if(x.first=="AC"){
            cout<<x.first<<" x "<<x.second<<endl;
         }
          if(mp.find("AC")==mp.end()){
            cout<<"AC x "<<0<<endl;
            break;
        }
        
         
    }
     for(auto x:mp){
        if(x.first=="WA"){
            cout<<x.first<<" x "<<x.second<<endl;
        }

        if(mp.find("WA")==mp.end()){
            cout<<"WA x "<<0<<endl;
            break;
        }
        
    }
     for(auto x:mp){
        if(x.first=="TLE"){
            cout<<x.first<<" x "<<x.second<<endl;
        }
         if(mp.find("TLE")==mp.end()){
            cout<<"TLE x "<<0<<endl;
            break;
        }
        
        
    }
     for(auto x:mp){
        if(x.first=="RE"){
            cout<<x.first<<" x "<<x.second<<endl;
        }
         if(mp.find("RE")==mp.end()){
            cout<<"RE x "<<0<<endl;
            break;
        }
        
    }

   
    // for(auto x:mp){
    //     if(x.first=="")
    // }
    
  
}

Measured memory_bytes: 7436
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long[] div(long h, long w) {
    if(h * w % 2 == 0) {
        return [h*w/2, h*w/2];
    }
    if(h > w) {
        swap(h, w);
    }
    return [h*(w/2), h*((w+1)/2)];
}

void main(){
    long h, w;
    readlnTo(h, w);
    auto ans = long.max / 4;
    foreach(h0; iota(h+1)) {
        auto s0 = h0 * w;
        auto s12 = div(h - h0, w);
        ans = min(ans, max(s0, s12[0], s12[1]) - min(s0, s12[0], s12[1]));
    }
    swap(h, w);
    foreach(h0; iota(h+1)) {
        auto s0 = h0 * w;
        auto s12 = div(h - h0, w);
        ans = min(ans, max(s0, s12[0], s12[1]) - min(s0, s12[0], s12[1]));
    }
    writeln(ans);
}



Measured memory_bytes: 1276
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut d: Vec<usize> = read_as_vec();

    d.sort();

    let mid = n/2;
    println!("{}", d[mid] - d[mid-1]);
}


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

string tmp[71 * 8] = {"\0"};
int p = 0;

void sort(string s[]) {
  for (int i = 0; i < p; i++) {
    for (int j = i; j > 0; j--) {
      if (tmp[j - 1] > tmp[j]) {
	string a = tmp[j - 1];
	tmp[j- 1] = tmp[j];
	tmp[j] = a;
      }
    }
  }
}

string reverse(string s) {
  for (int i = 0; i < s.size() / 2; i++) {
    char t;
    t = s[i];
    s[i] = s[s.size() - i - 1];
    s[s.size() - i - 1] = t;
  }
  return s;
}

void search(string a, string b, int occ) {
  if (occ % 4 == 0 || occ % 4 == 3) a = reverse(a);
  if (occ % 2 == 0) b = reverse(b);

  if (occ <= 4) tmp[p++] = a + b;
  else tmp[p++] = b + a;
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    p = 0;
    for (int i = 0; i < 71 * 8; i++)
      tmp[i] = "\0";
    
    string s, s1, s2;
    cin >> s;
    int len = s.size();
    for (int i = 1; i < len; i++) {
      s1 = s.substr(0, i);
      s2 = s.substr(i);
      for (int j = 1; j < 9; j++)
	search(s1, s2, j);
    }

    sort(tmp);

    int count = 1;
    for (int i = 1; i < p; i++) {
      if (tmp[i - 1] == tmp[i]) continue;
      count++;
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;



int main(){

    long long int a, b, n;

    cin >> a >> b >> n;

    long long int x = min(b-1, n);

    cout << a*x/b << endl;
}   


Measured memory_bytes: 3560
"use strict";
//const p = s => console.log(s);
let inp = require("fs").readFileSync("/dev/stdin", "utf8").trim();
let max = Number(inp.split('\n')[0]);
let nums = inp.split('\n')[1].split(' ').map(Number);
let formed_nums = (new Array(max)).fill(0);
//p(formed_nums)
for (let i = 0; i < max; i++) {
    formed_nums[nums[i] - 1]++
}
//p(formed_nums);
let sum = 0;
formed_nums.forEach(elm => {
    if (elm >= 2) {
        sum += elm * (elm - 1) / 2
    }
});
//p(nums)
nums.forEach(elm => {
    console.log(sum - formed_nums[elm - 1] + 1)
})

Measured memory_bytes: 39212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
	ll n;
   cin >> n;
   vector<ll> a(n);
   REP(i,0,n) cin >> a[i];

   ll extra = 0;
   for(int i = 0; i < n-1; i++) {
      if(a[i] > a[i+1]) {
         extra += a[i]-a[i+1];
         a[i+1] = a[i];
      }
   }
   cout << extra;
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}


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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	int N, Q;
	cin >> N >> Q;
	dsu d(N);
	for (int i=0;i<Q;i++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
			d.merge(u, v);
		} else { // t == 1
			cout << d.same(u, v) << endl;
		}
	}
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>

int main() {
    std::ios::sync_with_stdio(false);
  
    int N, Q;
    std::string S;
    std::cin >> N >> Q >> S;

    std::vector<int> cnt(N + 1, 0);
    for (int i = 2; i <= N; ++i) {
        cnt[i] = cnt[i - 1];
        if (S.substr(i - 2, 2) == "AC") ++cnt[i];
    }

    for (int q = 0; q < Q; ++q) {
        int l, r;
        std::cin >> l >> r;
        std::cout << cnt[r] - cnt[l] << '\n';
    }
    return 0;
}


Measured memory_bytes: 1488
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long

LL a, b, c;
int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> a >> b >> c; 
  if(a + b < c && (4 * a * b < (c - a - b) * (c - a - b))) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()
T = input()

flag = True
ds = defaultdict(chr)
dt = defaultdict(chr)
for i in range(len(S)):
    if S[i] in ds.keys():
        if ds[S[i]] != T[i]:
            flag = False
    else:
        ds[S[i]] = T[i]

    if T[i] in dt.keys():
        if dt[T[i]] != S[i]:
            flag = False
    else:
        dt[T[i]] = S[i]

if flag:
    print('Yes')
else:
    print('No')


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a + b) < (c + d))
        cout << "Right" << endl;
    else if ((a + b) == (c + d))
        cout << "Balanced" << endl;
    else 
        cout << "Left" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e3+5;
int ans[maxn];
int main()
{
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {
            int dis=0;
            dis=min(j-i,abs(x-i)+abs(y-j)+1);
            ans[dis]++;
        }
    for(int i=1;i<n;i++) printf("%d\n",ans[i]);
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

ll get(ll a, ll b) {
  ll res = 1LL;
  while(b) {
    if(b & 1) res = (res * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return res;
}

long long int sumXOR(long long arr[], int n) 
{ 
    long long int sum = 0; 
    for (int i = 0; i <= 60; i++)  
    { 
        //  Count of zeros and ones 
        ll zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        long long int idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2LL == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2LL; 
        } 
          
        // calculating individual bit sum  
        idsum = (oc * zc) % mod;  
        idsum = (idsum * get(2LL, i)) % mod;
        // final sum     
        sum = (sum + idsum) % mod;
    } 
    return sum; 
} 

int main() {
  int n; cin >> n;
  long long a[n + 1];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << sumXOR(a, n) << '\n';
}



Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int a, b, c;
  int x = 0;
  int y = 0;
  while(scanf("%d,%d,%d", &a, &b, &c)!=EOF){
    if( a == 0 ) break;
    if( a*a + b*b == c*c ) x++;
    if( a == b ) y++;
  }
  cout << x << endl;
  cout << y << endl;


  return 0;
}


// EOF

Measured memory_bytes: 3068
#include <iostream>
using namespace std;
void insertionSort(int *arr,int n)
{
	void printTrace(int *arr,int n);
	int v;
	int i,j;
	for(i=1; i<n; i++)
	{
		v = arr[i];
		j = i-1;
		while(j>=0&&arr[j]>v)
		{
			arr[j+1] = arr[j];
			j--;
		}
		arr[j+1] = v;
		printTrace(arr,n);
	}
}
void printTrace(int *arr,int n)
{
	for(int i=0; i<n; i++)
	{
		if(i>0) cout << " ";
		cout << arr[i];
	}
	cout << "\n" ;
}
int main()
{
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	printTrace(arr,n);
	insertionSort(arr,n);
	return 0;
}

Measured memory_bytes: 3096
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
sys.setrecursionlimit(10**5)
def solve():
    N, M, K = map(int, readline().split())
    G = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, readline().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    *D, = map(len, G)
    *I, = range(N)
    I.sort(key = D.__getitem__, reverse = 1)
    INF = 10**9
    def dfs(i, state, c):
        if i == N:
            return c

        v = I[i]
        res = INF

        e1 = []
        for w in G[v]:
            if state[w]:
                continue
            e1.append(w)

        if c + len(e1) <= K:
            for w in e1:
                state[w] = 1
            k = i+1
            while k < N and state[I[k]]:
                k += 1
            res = min(res, dfs(k, state, c+len(e1)))
            for w in e1:
                state[w] = 0

        if len(e1) > 1 and c+1 <= K:
            state[v] = 1
            k = i
            while k < N and state[I[k]]:
                k += 1
            res = min(res, dfs(k, state, c+1))
            state[v] = 0
        return res

    res = dfs(0, [0]*N, 0)
    if res < INF:
        write("%d\n" % res)
    else:
        write("Impossible\n")
solve()


Measured memory_bytes: 13064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;



int main(){
  string S;
  int A[4];
  char op[3];
  cin >> S;

  for(int i=0; i < 4; i++)
    A[i] = S[i]-'0';


  for(int i = 0; i < 2; i++){
    if(i)
      op[0]='+';
    else
      op[0]='-';
    for(int j = 0; j < 2; j++){
      if(j)
        op[1]='+';
      else
        op[1]='-';
      for(int l =0; l < 2; l++){
        if(l)
          op[2]='+';
        else
          op[2]='-';
        int sum=A[0];
        for(int k = 0; k < 3; k++){
          if(op[k]=='+')
            sum+=A[k+1];
          else
            sum-=A[k+1];
        }
        if(sum==7){
          for(int k = 0; k < 3; k++)
            cout << A[k]<<op[k];
          cout << A[3] << "=7"<< endl;
          return 0;
        }
      }
    }
  }
  

  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for (int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    int N;

    while (cin >> N, N)
    {
        int dp[300][300][4];

        rep(i, N) rep(j, N) rep(k, 4) dp[i][j][k] = 0;

        vector<string> grid(N);

        rep(i, N) cin >> grid[i];

        int ans = 0;

        rep(i, N)
        {
            rep(j, N)
            {
                if (grid[i][j] != '1')
                    continue;

                dp[i][j][0] = (j != 0) * dp[i][j - 1][0] + 1;
                dp[i][j][1] = (i != 0) * dp[i - 1][j][1] + 1;
                dp[i][j][2] = (i != 0 && j != 0) * dp[i - 1][j - 1][2] + 1;
                dp[i][j][3] = (i != 0 && j != N - 1) * dp[i - 1][j + 1][3] + 1;

                rep(k, 4) ans = max(ans, dp[i][j][k]);
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4444
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int N;
	int p[200000 + 100];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> p[i];

	int ans = 1, m = p[0];
	for (int i = 1; i < N; i++) {
		if (m >= p[i]) {
			ans++;
		}
		m = min(m, p[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	String s;
	String[] d = { "maerd", "remaerd", "esare", "resare" };

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		s = sc.next();
	}

	void solve() {
		StringBuffer sb = new StringBuffer(s);
		sb.reverse();
		first: while (sb.length() >= 5) {
			for (int i = 0; i < 4; i++) {
				if (d[i].length() <= sb.length()) {
					if (d[i].equals(sb.substring(0, d[i].length()))) {
						sb.delete(0, d[i].length());
						break;
					}
				}
				if (i == 3) {
					break first;
				}
			}
		}
		if (sb.length() == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 28896
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		mins = 0
		for j,vol in enumerate(val):
			if tmp == vol:
				mins = j+1
				break
		if i < D//2:
			ans.append(mins)
		else:
			ans.append(minCn+1)

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

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78532
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>


#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

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

    rep(i,n){
        cin >> tmp;
        if(tmp % 2 == 0){
            if(!(tmp % 3 == 0 || tmp % 5 == 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;


    return 0;
}

Measured memory_bytes: 256