akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
   int D[10], d[10], i, n, sum, j;
   char s[100];
   scanf("%d", &n);
   while ( n ) {
       sum = 1;
       for ( i = 1; i <= 6; i++ ) {
           D[i] = i;
           d[i] = i;
           /*printf("%d ", D[i]);*/
       }
       /*printf("a\n");*/
       for ( i = 1; i <= n; i++ ) {
           scanf("%s", s);
           if ( s[0] == 'N') {
               d[1] = D[2];
               d[2] = D[6];
               d[5] = D[1];
               d[6] = D[5];
           } else if ( s[0] == 'E') {
               d[1] = D[4];
               d[3] = D[1];
               d[4] = D[6];
               d[6] = D[3];
           } else if ( s[0] == 'W') {
               d[1] = D[3];
               d[3] = D[6];
               d[4] = D[1];
               d[6] = D[4];
           } else if ( s[0] == 'S') {
               d[1] = D[5];
               d[2] = D[1];
               d[5] = D[6];
               d[6] = D[2];
           } else if ( s[0] == 'R') {
               d[2] = D[3];
               d[3] = D[5];
               d[4] = D[2];
               d[5] = D[4];
           } else if ( s[0] == 'L') {
               d[2] = D[4];
               d[3] = D[2];
               d[4] = D[5];
               d[5] = D[3];
           }
           for ( j = 1; j<= 6; j++ ) {
               D[j] = d[j];
               /*printf("%d ", D[j]);*/
           }
           sum += D[1];
           /*printf("\nD[1]:%d\n", D[1]);*/
       }
       printf("%d\n", sum);
       scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1812
// https://atcoder.jp/contests/abc148/tasks/abc148_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &x : v)
        cin >> x;
    int a = 1;
    for (auto &x : v) {
        if (x == a) {
            a++;
        }
    }
    if (a == 1) {
        cout << "-1\n";
    } else {
        cout << N - a + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define N 100000
#define MOD 1000000007
using namespace std;


vector <ll> fact(N+1);
vector <ll> rever_fact(N+1);

ll modulo (ll a, ll b){
  ll x = 1 , y = a;
  while(b>0){
    if(b%2 == 1)x=(x*y)%MOD;
    y = (y*y)%MOD;
    b /= 2;
  }
  if(x<0) return (MOD+x) % MOD;
  return x % MOD ;
}


// in range 0 <= x <= N
// 1. x!
// 2. (x!)^{-1}
//   2-1. (N!)^{-1}
//   2-2. (N-1!)^{-1} = { (N!)^{-1} }* N
//   2-3. *****
void setfact(ll n){
  ll inp=1;
  ll a,b;
  
  //****************************1.x!************************
  fact[0]=1; //0!  
  for (ll i = 1;i <= n;i++){
    inp*=i;
    inp%=MOD;
    fact[i]=inp; 
  }

  //***********************2.(x!)^{-1}********************
  //***********2-1.(N!)^{-1}= (N!)^{MOD-2}****************
  rever_fact[n] = modulo(fact[n],MOD-2);
  //***********2-2 
  for(ll i = n-1;i>=0;i--) rever_fact[i]=(rever_fact[i+1]*(i+1))%MOD;
}


//  aCb = a! / {b!*(a-b)!}
//      = a! * b!^{-1} * (a-b)!^{-1}
ll aCb(ll a , ll b){
  if(a<b || b<0) return 0;
  //cout << fact[a] << rever_fact[b]<<rever_fact[a-b] << endl;
  return (( (fact[a]*rever_fact[b])%MOD)*rever_fact[a-b])%MOD;
}



int main(){
  ll n;
  vector <ll> a ;
  ll check[100005]={0};
  ll a1,a2;
  ll inp;
  ll same;
  ll result;
  vector <ll> dis;
   
  cin >> n;
  setfact(n+1);
  
  for(ll i =0;i<n+1;i++){
    cin >> inp;
    
    if(check[inp]==0) check[inp]= 1;
    else same = inp;
    a.push_back(inp);  
  }

  for(ll i = 0; i < n+1;i++){
    if(a[i]==same) dis.push_back(i);
  }
  a1 = dis[0];
  a2 = n-dis[1];

  
  for (int i =1;i<=n+1;i++){
    result = aCb(n+1,i) - aCb(a1+a2 , i-1);
    if(result< 0) result += MOD;
    cout << result << endl;
  }
}


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

int main() {
    ll N, a, b, c, p, q, r,t0,t1,t2;
    cin >> N;
    vector<ll> dp(3,0);
    cin >> a >> b >> c;
    dp[0] = a; dp[1] = b; dp[2] = c;
    REP(i,N-1){
        cin >> a >> b >> c;
        t1 = max(dp[0]+b,dp[2]+b);
        t2 = max(dp[1]+c,dp[0]+c);
        t0 = max(dp[1]+a,dp[2]+a);
        dp[0] = t0; dp[1] = t1; dp[2] = t2;
    }
    cout << *max_element(dp.begin(), dp.end())<< endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String... args){
       Scanner scan = new Scanner(System.in);
       long x = scan.nextLong();
       long y = scan.nextLong();

       long res = 0;

       if(x < 0 && y < 0){
           if(y < x){
               res+=2;
           }
           x*=(-1);
           y*=(-1);
       }else if(y < 0){
           y*=(-1);
           res++;
       }else if(x < 0){
           x*=(-1);
           res++;
       }else if(y < x){
           res+=2;
       }

       if(x>0 && y == 0){
           res--;
       }else if(x<0 && y==0){
           res--;
       }

       res+= Math.max(x,y)-Math.min(x,y);

       System.out.println(res);
    }
}


Measured memory_bytes: 10320
import sys
import math

N = int(sys.stdin.readline().strip())

ratios = []
for _ in range(N):
    t, a = map(int, sys.stdin.readline().strip().split())
    ratios.append((t, a))

ans = 0
for i in range(N-1):
    t1, a1 = ratios[i]
    t2, a2 = ratios[i+1]

    # math.ceilが直球だが、精度が悪い？
    # rate = max(math.ceil(t1 / t2), math.ceil(a1 / a2))
    rate = max((t1 - 1) // t2, (a1 - 1) // a2) + 1
    ratios[i+1] = (t2 * rate, a2 * rate)

print(sum(ratios[N-1]))

Measured memory_bytes: 38256
#!/usr/bin/env python3


def main():
    Sd = input()
    N = len(Sd)
    T  = input()
    ans = []
    for i in range(N-len(T)+1):
        flag = True
        tmp = list(Sd)
        for j in range(len(T)):
            if Sd[i+j] == '?':
                tmp[i+j] = T[j]
            elif Sd[i+j] != T[j]:
                flag = False
                break
        if flag:
            ans.append(''.join(tmp).replace('?','a'))
    if ans == []:
        print('UNRESTORABLE')
    else:
        print(sorted(ans)[0])


if __name__ == "__main__":
    main()


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

if n % 2 == 0:
	b = a[1::2]
	c = a[0::2]
	b.reverse()
	b.extend(c)
else:
	b = a[0::2]
	c = a[1::2]
	b.reverse()
	b.extend(c)

b = [str(i) for i in b]
b = ' '.join(b)
print(b)


Measured memory_bytes: 31300
#include<stdio.h>

int i,j,n,a[5],b[5];

int main(){
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("\n%d %d %d",&a[0],&a[1],&a[2]);
        for(j=0;j<3;j++)b[j]=a[j]*a[j];
        if(b[0]==b[1]+b[2])printf("YES\n");
        else if(b[1]==b[2]+b[0])printf("YES\n");
        else if(b[2]==b[0]+b[1])printf("YES\n");
        else printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if(b/a>=c) {
    cout << c << endl;
  }
  else if(b/a<c){
  cout << b/a << endl;
  }
  else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N , Y = map(int,input().split())
K = 0
for i in range(N+1):
    for j in range(N - i+1):
        k = N - (i + j)
        if 0 < i + j + k <= N:
            if 10000 * i + 5000 * j + 1000 * k ==Y:
                print("{} {} {}".format(i,j,k))
                exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





ll n;
ll dp[105][5][5][5][5];

const ll A = 0, C = 1, G = 2, T = 3;

ll f(ll cur, ll s1, ll s2, ll s3, ll s4){
    if(~dp[cur][s1][s2][s3][s4]) return dp[cur][s1][s2][s3][s4];
    if(s1 == A && s3 == G && s4 == C) return 0;
    if(s2 == A && s3 == C && s4 == G) return 0;
    if(s2 == G && s3 == A && s4 == C) return 0;
    if(s1 == A && s2 == G && s4 == C) return 0;
    if(s2 == A && s3 == G && s4 == C) return 0;
    if(cur == n) return 1;
    ll res = 0;
    REP(i, 4){
        res += f(cur + 1, s2, s3, s4, i);
        res %= MOD;
    }
    return dp[cur][s1][s2][s3][s4] = res;
}

int main() {
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << f(0, 4, 4, 4, 4) << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(0<=x&&0<=y&&0<=x+r&&0<=y+r&&W>=x+r&&H>=y+r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2684
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
B = []
for i, a in enumerate(A):
    B.append((a, i+1))

A = sorted(B)
i, j = 0, 0
C = [[0]*W for _ in range(H)]
flag = True
for k in range(N):
    num, color = A[k]
    while num:
        C[i][j] = color
        if flag:
            if j < W-1:
                j += 1
            else:
                i += 1
                flag = False
        else:
            if j > 0:
                j -= 1
            else:
                i += 1
                flag = True
        num -= 1

for k in range(H):
    print(*C[k])



Measured memory_bytes: 42992
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bit(i) (1<<(i))
#define set(mask,i) (mask |= (1<<(i)))
#define get(mask,i) (mask & (1<<(i)))
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
const ll INF64 = (ll)1e15;
const int INF32 = (int)1e9;
const int64_t md = (int64_t)((int64_t)1e9 + 7);
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int& el : arr) cin >> el;
	int dp[n];
	for(int& el : dp) el = INF32;
	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		for(int kk = 1; kk <= k; kk++) {
			if(i-kk >= 0) dp[i] = min(dp[i], dp[i-kk]+abs(arr[i]-arr[i-kk]));
		}
	}
	cout << dp[n-1];

	return 0;
}

Measured memory_bytes: 4356
#include<iostream>
#include<list>
#include<cstring>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>
#include <vector>
#include <queue>

using namespace std;

int main(void){
    int N,M,r,q;
    int t[1000][4];
    int ts,te;
    int i,j,k,l,m,n;
    while(1){
        cin >> N >> M;
        if(!N) break;
        cin >> r;
        for(i = 0;i < r;i++){
            cin >> t[i][0] >> t[i][1] >> t[i][2] >> t[i][3];
        }
        cin >> q;
        for(i = 0;i < q;i++){
            cin >> ts >> te >> m;
            n = 0;
            l = 0;
            for(j = 0;j < r;j++){
                if(t[j][2] == m){
                    if(n == 0) k = t[j][0];
                    if(t[j][3]){
                        n++;
                    }
                    else{
                        n--;
                    }
                    if(n == 0){
                        if(k < ts) k = ts;
                        if(t[j][0] > te) k = te-k;
                        else k = t[j][0]-k;
                        if(k > 0) l += k;
                    }
                }
            }
            cout << l << endl;
        }
    }
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;
void solve(){
    int n,m;
    cin>>n>>m;
    int tn = min(m,n);
    int tm = max(m,n);
    int re = 0;
    for(int i=0;i<tm;i++){
        re = 10 * re+tn;
    }
    cout<<re<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

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

void call(int n) {
	for (int i = 1;i <= n;++i) {
		int x = i;
		if (x%3 == 0) {
			cout << " " << i;
			continue;
		}
		do {
			if (x%10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		} while (x);
	}
	cout << endl;
}

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

Measured memory_bytes: 3084
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long[]a=new long[n];
		Arrays.setAll(a,i->s.nextInt());
		long sum=Arrays.stream(a).sum();
		if(sum%(n*(n+1L)/2)!=0) {
			System.out.println("NO");
			return;
		}
		long k=sum*2/n/(n+1);
		{
			long t=a[0]-a[n-1];
			for(int i=n-1;i>0;--i)
				a[i]-=a[i-1];
			a[0]=t;
		}
		for(int i=0;i<n;++i)
			a[i]=k-a[i];
		System.out.println(
				Arrays.stream(a).allMatch(i->i>=0&&i%n==0)&&
				Arrays.stream(a).sum()/n==k?"YES":"NO");
	}
}

Measured memory_bytes: 61068
#include<iostream>
#include<cstdio>

using namespace std;

int main(int argc, char *argv[])
{
  int l[10];
  int v1,v2;
  int L;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2) !=EOF){
    L =0;
  for(int i = 0;i < 10;i++){
    L += l[i];
  }
  double d;
  d =(double)L*v1/(v1+v2);
  L =0;
  for(int i = 0;i < 10;i++){
    L += l[i];
    if(d <=L){
      printf("%d\n",i+1);
      break;
    }
  }
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
 
using namespace std;
 
 
//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
 
#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
 
//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;
 
 
int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}
 
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};
 
 
 
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
 
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}
 
 
 
 
int main(){
 
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;

    ll cnt[100001] = {0};
    rep(i, n){
        int A, B;
        cin >> A >> B;
        cnt[A] += B;
    }

    FOR(i, 1, 100001){
        if(k <= cnt[i]){
            ppp(i);
            break;
        }
        k -= cnt[i];
    }


    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int n[5],i,m;
	for(i=0;i<5;i++)scanf("%d",&n[i]);
	if(n[0]<0){
		n[0]-=(n[0]+n[0]);
		m=n[2]*n[0]+n[3]+n[4]*n[1];
	}
	else m=n[4]*(n[1]-n[0]);
	printf("%d\n",m);
	return 0;
}


Measured memory_bytes: 2068
// B.

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cmath>

using namespace std;

struct Point {
	long double x;
	long double y;
	int i;
	bool operator < (const Point &p) const {
		return x < p.x || (x == p.x && y < p.y);
	}
};

long double cross(const Point &O, const Point &A, const Point &B) {
	return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

vector<Point> convex_hull(vector<Point> &P)
{
	int n = (int)P.size(), k = 0;
	if (n <= 2) {
		return P;
	}
	vector<Point> H(2 * n);
	sort(P.begin(), P.end());
	for (int i = 0; i < n; ++i) {
		while (k >= 2 && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	for (int i = n - 2, t = k + 1; i >= 0; i--) {
		while (k >= t && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--;
		H[k++] = P[i];
	}
	return vector<Point>(H.begin(), H.begin() + k - 1);
}

long double rad(const Point &a, const Point &b, const Point &c) {
	long double a1 = a.x - b.x, a2 = a.y - b.y;
	long double b1 = c.x - b.x, b2 = c.y - b.y;
	long double cos = (a1 * b1 + a2 * b2) / (sqrt(a1 * a1 + a2 * a2) * sqrt(b1 * b1 + b2 * b2));
	return acos(cos);
}

int main(int argc, char *argv[])
{
	cout.precision(10);
	int n;
	cin >> n;
	vector<Point> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i].x;
		cin >> p[i].y;
		p[i].i = i;
	}
	vector<long double> res(n);
	vector<Point> ch = convex_hull(p);
	if (ch.size() <= 2) {
		for (int i = 0; i != ch.size(); ++i) {
			res[ch[i].i] = 1.0 / ch.size();
		}
	} else {
		for (int i = 0; i != ch.size(); ++i) {
			int prev = (i - 1 + ch.size()) % ch.size();
			int next = (i + 1) % ch.size();
			long double r = rad(ch[prev], ch[i], ch[next]);
			res[ch[i].i] = (M_PI - r) / (2 * M_PI);
		}
	}
	for (int i = 0; i < n; ++i) {
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define isNum(a) (a>='0'&&a<='9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define inf 2147483647
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int main () {
    int d;
    read(d);
    cout<<"Christmas";
    for (int i=d; i<=24; ++i) {
        cout<<" Eve";
    }
    EL;
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch)) {
        if (ch=='-') {
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch)) {
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    r_e_a_d = flag*k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e<0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e<10) {
            putchar(w_r_i_t_e+'0');
        }else {
            write(w_r_i_t_e/10);
            putchar((w_r_i_t_e%10)+'0');
        }
    }
}


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

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


int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	int s[100];
	int ans=0;
	rep(i, N) {
		cin >> s[i];
		ans += s[i];
	}
	if (ans % 10 != 0) {
		cout << ans << endl;
		return 0;
	}
	sort(s, s + N);
	bool flag = false;
	rep(i, N) {
		if ((ans - s[i]) % 10 != 0) {
			cout << ans - s[i] << endl;
			flag = true;
			break;
		}
	}
	if (flag == false) {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
ans = N - K + 1
print(ans)
for i in range(1, K):
    ans = ans*(N-K+1-i)%MOD*(K-i)%MOD*pow(i*(i+1),MOD-2,MOD)%MOD
    print(ans)


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

using namespace std;

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

  int idx = 0;
  vector<int> X(N), Y(N), H(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> H[i];
    if (H[i] > 0) idx = i;
  }

  for (int x = 0; x <= 100; x++) {
    for (int y = 0; y <= 100; y++) {
      int h = H[idx] + abs(x - X[idx]) + abs(y - Y[idx]);
      for (int i = 0; i < N; i++) {
        if (max(h - abs(x - X[i]) - abs(y - Y[i]), 0) != H[i]) break;
        if (i == N - 1) {
          cout << x << " " << y << " " << h << '\n';
          return 0;
        }
      }
    }
  }
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = new Point[N];

            for (int i = 0; i < N; i++)
            {
                array[i] = new Point(Console.ReadLine().Split().Select(int.Parse).ToArray());
            }

            double sum = 0;
            var count = 0;
            foreach (var item in Enumerate(array))
            {
                for (int i = 0; i < N - 1; i++)
                {
                    var j = i + 1;
                    sum += Math.Sqrt(Math.Pow(item[i].X - item[j].X, 2) + Math.Pow(item[i].Y - item[j].Y, 2));
                }
                count++;
            }

            Console.WriteLine(sum / count);
        }

        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
        {
            if (items.Count() == 1)
            {
                yield return new T[] { items.First() };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };
                var unused = items.Except(leftside);
                foreach (var rightside in Enumerate(unused))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }

        struct Point
        {
            public int X { get; set; }
            public int Y { get; set; }

            public Point(int[] array)
            {
                X = array[0];
                Y = array[1];
            }

        }
    }
}


Measured memory_bytes: 19756
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int n; cin >> n;
  string s, t; cin >> s >> t;
  for (int i = 0; i < n; ++i) {
    cout << s[i] << t[i];
  }
  cout << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int total = 0;
    for(int i = 0;i<m;i++){
      int a = sc.nextInt();
      total+= a;
    }
    if(total > n){
      System.out.println(-1);
    }else{
      System.out.println(n - total);
    }
  }
}


Measured memory_bytes: 46308
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,fac[500010],revfac[500010],mod=1000000007;
ll pow(ll x,ll y)
{
    if(!y)
    {
        return 1;
    }
    ll ret=1;
    if(y%2)
    {
        ret=x;
    }
    ll tem=pow(x,y/2);
    ret*=tem;
    ret%=mod;
    ret*=tem;
    ret%=mod;
    return ret;
}
ll p(ll x,ll y)
{
    ll ret=fac[x]*revfac[x-y];
    ret%=mod;
    return ret;
}
ll c(ll x,ll y)
{
    ll ret=fac[x]*revfac[y];
    ret%=mod;
    ret*=revfac[x-y];
    ret%=mod;
    return ret;
}
int main()
{
    fac[0]=revfac[0]=1;
    for(ll i=1;i<=500000;i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=mod;
        revfac[i]=pow(fac[i],mod-2);
    }
    scanf("%lld%lld",&n,&m);
    ans=p(m,n);
    for(ll i=1;i<=n;i++)
    {
        if(i%2)
        {
            ans+=mod*mod;
            ans-=c(n,i)*p(m-i,n-i);
        }
        else
        {
            ans+=c(n,i)*p(m-i,n-i);
        }
        ans%=mod;
    }
    ans*=p(m,n);
    ans%=mod;
    printf("%lld",ans);
}


Measured memory_bytes: 11604
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	ll  n, m, ans = 0;

	cin >> n >> m;



	if (n == 1 && m == 1) {
		cout << 1 << endl;
		return 0;
	}

	if (n == 1 && m >= 2) {
		cout << m - 2 << endl; return 0;
	}


	if (n >= 2 && m == 1) {
		cout << n - 2 << endl; return 0;
	}

	if (n == 2) {
		cout << 0 << endl; return 0;
	}

	if (m == 2) {
		cout << 0 << endl; return 0;

	}
	cout << (n - 2) * (m - 2) << endl;

}

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

using namespace std;

int main()

{
    long long int n,sum=0,a;
    cin>>n;
    while(n--)
    {
        cin>>a;
        sum=sum^a;
}
    if(sum==0)
    cout<<"Yes"<<endl;
    else
cout<<"No"<<endl;
    
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  int i,c=0;
  cin>>s>>t;
  for(i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
      	c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3924
import math
while True:
    q=int(input())
    
    if q==-1:
        break
    
    x=q/2
    while True:
        a=x**3-q
        if math.fabs(a)<(0.00001*q):
            break
        x=x-(x**3-q)/(3*(x**2))
        
    print(x)


Measured memory_bytes: 5724
def can_solve(i, m, n, A):
    if m == 0:
        can = True
        return can
    if i >= n:  # 全部探索おわの条件
        can = False
        return can
    if m < 0:  # 足しすぎて負になった時の終了条件
        can = False
        return can
    if sum(A[i:]) < m:  # 全部足しても足りないようなときの終了条件
        can = False
        return can

    can = can_solve(i+1, m, n, A) or can_solve(i+1, m-A[i], n, A)
    return can




if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    m = list(map(int, input().split()))

    for mi in m:
        if can_solve(i=0,m=mi,n=n,A=A):
            print("yes")
        else:
            print("no")






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

int main(){
    int n, x;
    int min = 1000000;
    int max = - 1000000;
    long long sum = 0;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x;
        sum += x;
        if (x < min){
            min = x;
        }
        if (x > max){
            max = x;
        }
    }

    cout << min << " " << max << " " << sum << endl;

    return 0;
}



Measured memory_bytes: 3104
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Restaurant[] r = new Restaurant[n];
        for(int i = 0; i < n; i++) {
            String name = sc.next();
            int rank = sc.nextInt();
            r[i] = new Restaurant(name, rank, i);
        }
        Arrays.sort(r, new Comparator<Restaurant>() {
            @Override
            public int compare(Restaurant o1, Restaurant o2) {
                if(o1.name.compareTo(o2.name) != 0) {
                    return o1.name.compareTo(o2.name);
                } else {
                    return o2.rank - o1.rank;
                }
            }
        });
        for(int i = 0; i < n; i++) {
            System.out.println(r[i].index + 1);
        }
    }
}


class Restaurant {
    String name;
    int rank;
    int index;
    Restaurant(String name, int rank, int index) {
        this.name = name;
        this.rank = rank;
        this.index = index;
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y,ans=0;
  cin >>x>>y;
  ans+=abs(abs(y)-abs(x));
  if(x>0 && y>0){
    if(x>y) ans+=2;
  }
  if(x<0 && y<0){
    if(x>y) ans+=2;
  }
  if(x<0 && y>0) ans++;
  if(x>=0 && y<=0){
    if(x!=0 || y!=0) ans++;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
# C - Green Bin
# https://atcoder.jp/contests/abc137/tasks/abc137_c

from collections import Counter

n = int(input())
S = []
for _ in range(n):
  s = "".join(sorted(input()))
  S.append(s)

C = Counter(S)

ans = 0
for i in C.values():
  ans += (i * (i - 1)) // 2 

print(ans)

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

int main() {
    int x,y; cin >> x >> y;
    vector<vector<int>> a(3);
    a[0] = {1,3,5,7,8,10,12};
    a[1] = {4,6,9,11};
    a[2] = {2};
    for(int i= 0; i < 3; i ++) {
        auto itr1 = find(a[i].begin(), a[i].end(), x);
        auto itr2 = find(a[i].begin(), a[i].end(), y);
        if(itr1!=a[i].end() && itr2!=a[i].end()) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> edges(N, vector<bool>(N, false));
  for (int i{}; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edges[a][b] = edges[b][a] = true;
  }

  vector<int> route(N);
  iota(route.begin(), route.end(), 0);
  int ans{};
  do {
    bool ok{true};
    for (int i{}; i < N - 1; ++i) {
      if (!edges[route[i]][route[i + 1]]) {
        ok = false;
        break;
      }
    }
    if (ok)
      ++ans;
  } while (next_permutation(route.begin() + 1, route.end()));

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


Measured memory_bytes: 3576
while True:
    n = input()
    if (n == 0):
        break
    state = []
    schedule = []
    ok = True
    for i in range(n):
        temp = map(int, raw_input().split())
        if temp[0] != 0:
            schedule.append(set(temp[1:]))
        else:
            ok = False
        state.append(set([i]))
    if (ok == False):
        print -1
        continue
    for day in range(1, 31):
        temp = []
        Maps = set()
        for i in range(len(schedule)):
            if day in schedule[i]:
                temp.append(i)
                Maps |= state[i]
        for c in temp:
            state[c] = Maps
        if len(Maps) == n:
            print day
            break
    else:
        print -1
            

Measured memory_bytes: 4372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N;cin>>N;
  float ans=(double)(N+1)/(2*N);
  if(N%2==0){
    cout<<0.5<<endl;
    return 0;
  }
  else{
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    int n;
    cin >> n;
    double ans = ((n + 1) / 2) / (double)n;
    printf("%.10f\n", ans);
}

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

using namespace std;

bool check(char c)
{
	char list[] = "ACGT";

	for (int i = 0; i < 4; i++)
	{
		if (c == list[i])
		{
			return true;
		}
	}

	return false;
}

int main()
{
	string S;
	cin >> S;

	int count = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (check(S[i]))
		{
			count++;
		}
		else
		{
			ans = max(ans, count);
			count = 0;
		}
	}

	ans = max(ans, count);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    string s;
    cin>>s;
    char a;
    bool is=false;
    REP(i,SIZE(s)){
        a=s[i];
        if(a=='9')is=true;
    }
    string ans;
    if(is){
        ans="Yes";
    }else{
        ans="No";
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <map>

int main()
{
        std::string S, T;
        std::map<char, char> m, mr;
        std::cin >> S >> T;

        for (int i = 0; i < T.size(); ++i) {
                auto t = T[i];
                auto s = S[i];
                auto it = m.find(t);
                if (it != m.end() && it->second != s) {
                        std::cout << "No\n";
                        exit(0);
                }
                it = mr.find(s);
                if (it != mr.end() && it->second != t) {
                        std::cout << "No\n";
                        exit(0);
                }
                m[t] = s;
                mr[s] = t;
        }
        S.clear();
        T.clear();
        for (auto it = m.begin(), end = m.end(); it != end; ++it) {
                S.append(1, it->first);
                T.append(1, it->second);
        }

        for (int i = 0; i < S.size(); ++i) {
                if (S[i] == T[i])
                        continue;
                auto s = S[i];
                auto t = T[i];
                for (auto it = S.begin(), end = S.end(); it != end; ++it) {
                        if (*it == s)
                                *it = t;
                        else if (*it == t)
                                *it = s;
                }
        }
        if (S == T)
                std::cout << "Yes\n";
        else
                std::cout << "No\n";
}

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

void Main() {
  long int n, y;
  cin >> n >> y;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
        cout << i << " " << j << " " << n - i - j << endl;
        return;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int ba = 0, a = 0, b = 0;
  rep(i, n) {
    string s;
    cin >> s;

    rep(j, sz(s) - 1) if (s[j] == 'A' && s[j + 1] == 'B') ans++;

    if (s[0] == 'B' && s[sz(s) - 1] == 'A')
      ba++;
    else if (s[0] == 'B')
      b++;
    else if (s[sz(s) - 1] == 'A')
      a++;
  }
  if (ba > 0) {
    ans += ba - 1;
    if (a > 0) {
      ans++;
      a--;
    }
    if (b > 0) {
      ans++;
      b--;
    }
  }
  ans += min(a, b);
  cout << ans << endl;
}


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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  Dijkstra<int> D(N);
  for (int i = 0; i + 1 < N; i++) {
    D.add(i, i + 1, 1);
  }
  D.add(--X, --Y, 1);
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    Dijkstra<int> D2 = D;
    D2.solve(i);
    for (int j = 0; j < N; j++) ans.at(D2.dist.at(j))++;
  }
  for (int i = 1; i < N; i++) cout << ans.at(i) / 2 << "\n";
}

Measured memory_bytes: 512
import collections

N = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
values, counts = zip(*c.most_common())

ans = 0

for cc in c.values():
    ans += (cc * (cc - 1)) / 2

for i in a:
    print(int(ans - ((c[i] * (c[i] - 1)) / 2) + ((c[i] - 1) * (c[i] - 2) / 2)))



Measured memory_bytes: 36536
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  int n,m;
  long long ans=0;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  vector<int> x(n,0);
  x.at(0)=1;
  vector<pair<int,int>> pairs(m);
  if(m == 0){
    if(n == 1){cout << 0 << endl;}
    else{
      cout << 1;
      if(n==3){
        cout << 0;
      }
      cout << 0 << endl;
    }
  }
  else{
      for(int i = 0; i < m; i++){
    cin >> s.at(i) >> c.at(i);
    pairs.at(i)=make_pair(s.at(i),c.at(i));
  }
  sort(pairs.begin(),pairs.end());
  for(int i = 0; i < m-1; i++){
    if(pairs.at(i).first==pairs.at(i+1).first){
      if(pairs.at(i).second!=pairs.at(i+1).second){
        ans =  1;
      }
    }
    else if(pairs.at(i).first==1){
      if(pairs.at(i).second==0 && n != 1){
        ans = 1;
      }
    }
  }
  if(pairs.at(m-1).first==1){
    if(pairs.at(m-1).second==0 && n != 1){
        ans = 1;
    }
  }
  if(ans!=1){
    for(int i = 0; i < m; i++){
      x.at(pairs.at(i).first-1)=pairs.at(i).second;
    }
    for(int i = 0; i < n-1; i++){
    cout << x.at(i);
  }
  cout << x.at(n-1) << endl;
  }
  if(ans==1){
    cout << -1 << endl;
  }
  }
}

Measured memory_bytes: 256
x_1,y_1,x_2,y_2 = map(int,input().split())
x_3 = x_2-(y_2-y_1)
y_3 = y_2+(x_2-x_1)
x_4 = x_1-(y_2-y_1)
y_4 = y_1+(x_2-x_1)
print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 2940
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
if m==0
  if n==1
    putsend 0
  else
    putsend "1"+"0"*(n-1)
  end
end

sc=m.times.map{gsmi}

idx = sc.index([1,0])
if idx
  if n==1 && sc.uniq.size==1
    putsend 0
  else
    putsend -1
  end
end

sc.uniq!
ar=sc.map{|i|i[0]}
if ar.size==ar.uniq.size
  ans=""
  1.upto n do |i|
    c=nil
    sc.each do |j|
      if j[0]==i
        c=j[1].to_s
        break
      end
    end
    if c.nil?
      if i==1
        c="1"
      else
        c="0"
      end
    end
    ans<<c
  end
  puts ans
else
  puts -1
end

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////


int main() {
  
  int Tc; cin >> Tc;
  while(Tc --) {
    list<char> lst;
    
    string s; cin >> s;
    int const N = s.size();
    
    lst.push_back(s[0]);
    for(int i=3; i<N; i+=3) {
      if(s[i-1] == '>') {
	list<char>::iterator it = find(ALL(lst), s[i-3]);
	advance(it, 1);
	if(s[i] != *it) lst.insert(it, s[i]);
      }
      else {
	list<char>::iterator it = find(ALL(lst), s[i-3]);
	if(it != lst.begin()) advance(it, -1);
	if(s[i] != *it) lst.insert(it, s[i]);
      }
    }

    EACH(it, lst) {cout << *it;}cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
n=gets.chomp.to_i
t = gets.chomp.split(" ").map{|u|u.to_i}
t.sort!
gets
b = gets.chomp.split(" ").map{|u|u.to_i}
ans = 0
b.each do |d|
  r = n
  l = 0
  mid = 999999999
  while(true)
    mid = l + (r-l)/2
    if (t[mid] == d)
      ans += 1
      break
    elsif(t[mid] > d)
      r = mid
    else
      l = mid + 1
    end
    break if r == l
  end
end
p ans

Measured memory_bytes: 18168
from collections import Counter

N = int(input())
numbers = [int(x) for x in input().split()]

odds = numbers[::2]
evens = numbers[1::2]

c1 = Counter(odds).most_common(2)
c2 = Counter(evens).most_common(2)

if c1[0][0] == c2[0][0]:
  print(min(
    N - c1[0][1] - (c2[1][1] if len(c2) > 1 else 0),
    N - c2[0][1] - (c1[1][1] if len(c1) > 1 else 0)
  ))    
else:  
  print(N - c1[0][1] - c2[0][1])



Measured memory_bytes: 63212
#include <iostream>
#include <vector>

using namespace std;

#define MAX 3000

typedef long long ll;

ll mod = 1e9+7;
vector<ll> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 1; i < MAX-1; i++) {
        fac[i+1] = fac[i] * (i+1) % mod;
        inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod;
        finv[i+1] = finv[i]*inv[i+1] % mod;
    }
}

ll COM(ll n, ll k) {
    if (k < 0 || n < k)
        return 0;
    
    ll res = 1;
    res *= fac[n]*finv[k]%mod*finv[n-k]%mod;
    return res;
}

int main() {
    ll n, k;    cin >> n >> k;

    COMinit();

    for (int i = 1; i <= k; i++) {
        cout << COM(n-k+1, i)*COM(k-1, i-1) % mod << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int n, m, p, MOD;
lint pow2[2505], ans;
inline int ask(int x1, int y1, int x2, int y2) {
	cout << "? " << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	int ret = 0; cin >> ret; return ret;
}
inline int siz(int x1, int y1, int x2, int y2) {
	return (x2 - x1 + 1) * (y2 - y1 + 1);
}
inline void search(int x1, int y1, int x2, int y2, int las) {
	if (x1 == x2 && y1 == y2) {
		ans = (ans + pow2[x1 * m + y1]) % MOD;
	} else if (x2 - x1 < y2 - y1) {
		int mid = (y1 + y2) >> 1;
		int a1 = ask(x1, y1, x2, mid);
		int a2 = las - a1;
		if (a1) {
			if (a1 == siz(x1, y1, x2, mid)) {
				rep (i, x1, x2) {
					rep (j, y1, mid) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, y1, x2, mid, a1);
			}
		}
		if (a2) {
			if (a2 == siz(x1, mid + 1, x2, y2)) {
				rep (i, x1, x2) {
					rep (j, mid + 1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, mid + 1, x2, y2, a2);
			}
		}
	} else {
		int mid = (x1 + x2) >> 1;
		int a1 = ask(x1, y1, mid, y2);
		int a2 = las - a1;
		if (a1) {
			if (a1 == siz(x1, y1, mid, y2)) {
				rep (i, x1, mid) {
					rep (j, y1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(x1, y1, mid, y2, a1);
			}
		}
		if (a2) {
			if (a2 == siz(mid + 1, y1, x2, y2)) {
				rep (i, mid + 1, x2) {
					rep (j, y1, y2) {
						search(i, j, i, j, 1);
					}
				}
			} else {
				search(mid + 1, y1, x2, y2, a2);
			}
		}
	}
}
int main() {
	cin >> n >> m >> p >> MOD;
	pow2[0] = 1;
	rep (i, 1, 2500) {
		pow2[i] = pow2[i - 1] * 2ll % MOD;
	}
	search(0, 0, n - 1, m - 1, p);
	/*lint poww = 1;
	rep (i, 0, n - 1) {
		rep (j, 0, m - 1) {
			(ans += ask(i, j, i, j) * poww) %= MOD;
			poww = poww * 2 % MOD;
		}
	}*/
	cout << "! " <<  ans << endl;
	return 0;
}

Measured memory_bytes: 724