akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,c;
	edge(){}
	edge(int tt,int cc){
		to=tt;
		c=cc;
	}
};

struct data{
	int vg,vb,bit,c;
	data(){}
	data(int v1,int v2,int bb,int cc){
		vb=v1;
		vg=v2;
		bit=bb;
		c=cc;
	}
	bool operator<(const data &d)const{
		return c>d.c;
	}
};

int n,m;
int dp[51][51][1<<10];
vector<edge> G[51];
vector<edge> G2[51];
int d[51],e[51];
int siz[1001];
int id[1001];

void solve(){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<(1<<10);k++){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[0][0][0]=0;
	priority_queue<data> que;
	que.push(data(0,0,0,0));
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.vb][q.vg][q.bit]<q.c)continue;
		//printf("%d %d %d %d %d\n",q.vb,q.vg,q.bit,q.c,dp[q.vb][q.vg][q.bit]);
		for(int i=0;i<G[q.vb].size();i++){
			edge ed=G[q.vb][i];
			int nv=dp[q.vb][q.vg][q.bit]+ed.c+d[ed.to];
			int nbit=(e[q.vb]==e[ed.to])?q.bit:0;
			nbit|=1<<id[ed.to];
			if(nv<dp[ed.to][q.vg][nbit]){
				dp[ed.to][q.vg][nbit]=nv;
				//printf("%d %d %d %d\n",ed.to,q.vg,nbit,dp[ed.to][q.vg][nbit]);
				que.push(data(ed.to,q.vg,nbit,nv));
			}
		}
		for(int i=0;i<G2[q.vg].size();i++){
			edge ed=G2[q.vg][i];
			int nv=dp[q.vb][q.vg][q.bit]+ed.c;
			if(e[q.vb]==e[ed.to] && (q.bit>>id[ed.to] & 1));
			else nv+=d[ed.to];
			if(nv<dp[q.vb][ed.to][q.bit]){
				dp[q.vb][ed.to][q.bit]=nv;
				que.push(data(q.vb,ed.to,q.bit,nv));
			}
		}
	}
	if(dp[n-1][n-1][1]==INF)printf("-1\n");
	else printf("%d\n",dp[n-1][n-1][1]);
}

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		memset(d,0,sizeof(d));
		memset(e,0,sizeof(e));
		memset(id,0,sizeof(id));
		memset(siz,0,sizeof(siz));
		e[n-1]=1000;
		for(int i=1;i<n-1;i++){
			scanf("%d%d",&d[i],&e[i]);
			id[i]=siz[e[i]]++;
		}
		for(int i=0;i<n;i++){
			G[i].clear();
			G2[i].clear();
		}
		for(int i=0;i<m;i++){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			a--;
			b--;
			if(e[a]<=e[b]){
				G[a].push_back(edge(b,c));
			}
			if(e[a]>=e[b]){
				G2[b].push_back(edge(a,c));
			}
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 46076
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll power(ll x, ll n, ll m)
{
    if(n==0)
        return 1;
    if(n==1)
        return x;
    x%=m;
    if(n%2)
        return (x*(power((x*x)%m, n/2, m)%m))%m;
    return power((x*x)%m, n/2, m)%m;
}

int main(){
  
    FAST;
    ll n,W, ans=0;
    cin>>n>>W;

    ll v[n+1],w[n+1], V=0;
    for(int i=1; i<=n; i++){
        cin>>w[i]>>v[i];
        V += v[i];
    } 

    ll dp[n+1][V+1];

    dp[0][0] = 0;
    for(int i=1; i<=V; i++)
      dp[0][i] = 1e17;

    for(ll i=1; i<=n; i++){
      for(ll j=0; j<=V; j++){
        if( v[i] <= j )
          dp[i][j] = min( dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
        else
          dp[i][j] = dp[i-1][j];

        if( dp[i][j] <= W )
          ans = max(ans, j );
      }
    }

    // for(int i=0; i<=n; i++){
    //   for(int j=0; j<=V; j++)
    //       cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }

    cout<<ans;

}

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

long long int gcd(long long int a, long long int b)
{
  return b ? gcd(b, a%b) : a;
}

long long int lcm(long long int a, long long int b)
{
  return a * b / gcd(a, b);
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> div(N);

  for(int i=1; i<=N; ++i)
  {
    int n = 0;
    for(int score=i; score<K; score=score*2)
    {
      ++n;
    }
    div[i] = N * pow(2,n);
  }

  long long int c_div = div[1];
  for(int i=1; i<=N; ++i)
  {
    c_div = lcm(c_div, div[i]);
  }

  int num = 0;
  for(int i=1; i<=N; ++i)
  {
    num += c_div/div[i];
  }
  printf("%.12f\n", (double)num/(double)c_div);
  return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)

cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                atk += H[i]
                cnt += 1

    if cnt == N:
        break

print(atk)

Measured memory_bytes: 26180
import sys

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

a = Y - 1000 * N

for x in range(2000 + 1):
    for y in range(2000 - x + 1):
        if 9000 * x + 4000 * y == a:
            z = N - x - y
            if x + y + z == N and z >= 0:
                print("{} {} {}".format(x, y, z))
                sys.exit(0)

print("-1 -1 -1")


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b&&a>=c){
        printf("%d\n",b*c/2);
    }
    else if(b>=c&&b>=a){
        printf("%d\n",a*c/2);
    }
    else{
        printf("%d\n",a*b/2);
    }
    return 0;
}


Measured memory_bytes: 128
/*
20/7/15

*/
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> xy(N);
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        xy.at(i)=make_pair(x,y);
    }
    sort(xy.begin(),xy.end());
    double sum=0;
    do{
        for(int i=1;i<N;i++){
            sum+=sqrt((xy[i].first-xy[i-1].first)*(xy[i].first-xy[i-1].first)+(xy[i].second-xy[i-1].second)*(xy[i].second-xy[i-1].second));
        }
    }while(next_permutation(xy.begin(),xy.end()));
    double d=1;
    for(int i=1;i<=N;i++){
        d*=i;
    }
    printf("%.9lf\n",sum/d);
}


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

using namespace std;

vector<int> prefix_function(const string& s) {
    int n = s.size();
    vector<int> pi(n);
    for (int i = 1; i < n; ++i) {
        pi[i] = pi[i - 1];
        while (pi[i] and s[i] != s[pi[i]]) {
            pi[i] = pi[pi[i] - 1];
        }
        pi[i] += s[i] == s[pi[i]];
    }
    return pi;
}

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

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        auto pi = prefix_function(s.substr(i));
        for (int j = 0; j < n - i; ++j) {
            ans = max(ans, min(j + 1 >> 1, pi[j]));
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n) cin >> m[i];
  int sum = 0;
  rep(i, n) sum += m[i]; 
  int y = x - sum;
  int minv = 1000000000;
  rep(i, n) {
    minv = min(minv, m[i]);
  }

  cout << n+(y/minv) << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var W, H, x, y float64
	fmt.Scan(&W)
	fmt.Scan(&H)
	fmt.Scan(&x)
	fmt.Scan(&y)

	s := W * H * (1.0 / 2.0)
	var f int
	
	if x == W/2 && y == H/2 {
		f = 1
	}
	fmt.Println(s, f)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
vector<int> arr;
int main () {
    int N;
    scanf("%d", &N);
    arr.resize(N+1);
    for(int i=1;i<=N;i++) {
        scanf("%d", &arr[i]);
    }
    
    if(N==1) {
        printf("%d", arr[1]);
    } else if(N==2) {
        printf("%d %d", arr[2], arr[1]);
    } else {
        int step = (N+1)/2;
        
        int idx = N;
        for(int i=1;i<=step-1;i++) {
            printf("%d ", arr[idx]);
            idx -=2;
        }
        
        if(N%2) {
            printf("%d %d ", arr[1], arr[2]);
        } else {
            printf("%d %d ", arr[2], arr[1]);
        }
        
        idx = 3+N%2;
        for(int i=1;i<=step-1-N%2;i++) {
            printf("%d ", arr[idx]);
            idx += 2;
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}

const int MAX1 = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    ll l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answer(ll arr[], ll n, Query queries[], ll q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX1]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
  

int main()
{
    boost
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif
ll n,q;
cin>>n>>q;
   ll a[n];
   ll i;
   REP(i,n)
   {
   cin>>a[i]; 
}
    Query queries[q];
    REP(i,q)
    {
    ll x,y;
    cin>>x>>y; 
    queries[i].l = x-1; 
    queries[i].r = y-1; 
    queries[i].idx = i; 
   }
    sort(queries, queries+q, cmp); 
    answer(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 27176
import java.util.*;
public class Main {
	
	static int N, R;
	static int dist[][];
	static int [] needtovis;
	static boolean [] visited;


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		int M = sc.nextInt();
		R = sc.nextInt();
		
		dist = new int[N+1][N+1];
		needtovis = new int[R+1];
		visited = new boolean[R+1];
		for(int i = 1 ;i<=R; i++) needtovis[i] = sc.nextInt();
		
		for(int i = 1; i<=N; i++) {
			for(int j = 1; j<=N; j++) {
				dist[i][j] = Integer.MAX_VALUE;
			}
			dist[i][i] = 0;
		}
		
		for(int i = 1; i<=M; i++) {
			int a = sc.nextInt(),  b = sc.nextInt(), w = sc.nextInt();
			dist[a][b] = dist[b][a] = w;
		}
				
		
		
		for(int k = 1; k<=N; k++) {
			for(int i = 1; i<=N; i++) {
				for(int j = 1; j<=N; j++) {
					if(dist[i][k] != Integer.MAX_VALUE && dist[k][j] != Integer.MAX_VALUE)
					dist[j][i] = dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
		
		for(int i = 1; i<=N; i++) dist[i][0] = dist[0][i] = 0;
		
		System.out.println(permgenerator(0, 0, 0));
	}
	
	public static int permgenerator(int length, int crntcity, int numCity){
			
		if(numCity == R) return length;
		
//		System.out.println(length);
		
		int min = Integer.MAX_VALUE;
		for(int i = 1; i<=R; i++) {
			if(!visited[i]) {
				visited[i] = true;
				min = Math.min(permgenerator(length + dist[crntcity][needtovis[i]], needtovis[i], numCity+1), min);
				visited[i] = false;
			}
		}
		
		return min;		
		
	}
	
}


Measured memory_bytes: 48256
#include<stdio.h>
long long ans(long long h,long long mul){
	if(h==1) return mul;
	return mul+ans(h/2,mul*2);
}
int main(){
	long long h,a=0;
	scanf("%lld",&h);
	a=ans(h,1);
	printf("%lld",a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

string s;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    if(s.back() != 's')
        cout << s << "s\n";
    else
        cout << s << "es\n";
    return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAX = 2000;
const  long long INF= 1e18;
const long long mod= 1e9+7;

ll arr[MAX+5][MAX+5];

void ncr(){
    arr[0][0] = 1;

    for(int i = 1; i <= MAX; i++){
        arr[i][0] = 1;
        for(int j = 1; j <= i; j++){
            arr[i][j] = (arr[i-1][j-1] + arr[i-1][j])%mod;
        }
    }
}



int main(){
        ll n,k;
        cin>>n>>k;
        ncr();
        for(int i=1;i<=k;i++){  
			ll ans= ((arr[n-k+1][i])*(arr[k-1][i-1]))%mod;
			//cout<<solve(3,1,mod)<<endl;
			cout<<ans<<endl;
			
    }

}


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

int main() {
  int n; cin >> n;
  vector<vector<int>> M(n, vector<int>(n));
  rep(i, n) {
    int u, k; cin >> u >> k;
    rep(z, k) {
      int num; cin >> num;
      M.at(i).at(num - 1) = 1;
    }
  }
  rep(i, n){
    rep(j, n-1)cout << M.at(i).at(j) << " ";
    cout << M.at(i).at(n-1) << endl;
  }
}



Measured memory_bytes: 3208
#include <iostream>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;

const int N = 2010;
int cou[2*N + 1][2];
ll dp[2*N + 1][2*N + 1];

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

	string str;
	cin >> str;
	int n = str.size();

	// Snuke always picks some ball, at most from layer L, where L is the current turn.
	// After L is large enough, he can pick any ball

	// so we have N conditions, saying
	// "no more than I blue balls can be picked in the first K rounds" or same for red

	// DP[N][K]: How many sequences exist where N balls have been picked, K of which
	// have been blue

	for (int i = 0; i < n; ++i) {
		int v = (str[i] - '0');
		cou[i+1][0] = cou[i][0] + (2-v);
		cou[i+1][1] = cou[i][1] + v;
	}
	for (int i = n; i < 2*n; ++i) {
		cou[i+1][0] = cou[i][0];
		cou[i+1][1] = cou[i][1];
	}

	dp[0][0] = 1;
	for (int i = 1; i <= 2*n; ++i) {
		for (int j = 0; j <= min(i, cou[i][1]); ++j) {
			int r = i - j;
			if (r > cou[i][0]) continue;

			if (j == 0) {
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % MOD;
			}
		}
		// cout << i << ' ' << cou[i][0] << ' ' << cou[i][1] << '\n';
		// cout << dp[i][0] << ' ' << dp[i][1] << ' ' << dp[i][2] << ' ' << dp[i][3] << '\n';
	}

	ll res = 0;
	for (int i = 0; i <= 2*n; ++i) res += dp[2*n][i];
	res %= MOD;

	cout << res << '\n';
}


Measured memory_bytes: 123520
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] str = line.split(" ");
        double a = Double.parseDouble(str[0]);
        double b = Double.parseDouble(str[1]);
        double c = Double.parseDouble(str[2]);
        
        double S = a * b * Math.sin(Math.toRadians(c)) / 2;
        double L = a + b + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(c)));
        double h = b * Math.sin(Math.toRadians(c));
        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
    }
 }


Measured memory_bytes: 26104
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        long n = Integer.parseInt(sc.next());
        System.out.println(factorialPower(n));
    }

    public static long factorialPower(long a){
        final int big = 1000000000 + 7;
        long power = 1;
        while(a>0){
            power = (power*(a%big))%big;
            a--;
        }
        return power;
    }
}

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

vector<long long> v ;

int main() {

    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; ++i) {

        int tmp ;
        cin >> tmp;
        v.push_back(tmp) ;

    }
    for(int l = 0; l <= k; ++l) {

        for(int r = 0; r <= k-l; ++r) {

            if(l+r > n)
                continue;
            int d = k - l - r;
            int now = 0;
            vector<int> h;
            for(int i = 0; i < l; ++i) {

                now += v[i];
                h.push_back(v[i]);

            }
            for(int i = n-r; i < n; ++i) {

                now += v[i];
                h.push_back(v[i]);

            }
            sort(h.begin(), h.end());
            for(int i = 0; i < d; ++i) {

                if(i >= h.size()) break;
                if(h[i] >= 0) break;
                now -= h[i];

            }
            ans = max(ans, now);

        }

    }
    cout << ans ;

}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	long double L;
	cin >> L;

	long double ans = (L / 3) * (L / 3) * (L / 3);
	cout << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3][3],b,c;
	for (int i=0;i<3;i++)
		for (int n=0;n<3;n++)
			cin>>a[i][n];
	cin>>b;
	for (int i=0;i<b;i++){
		cin>>c;
		for (int n=0;n<3;n++)
			for (int m=0;m<3;m++)
				if (a[n][m]==c)
					a[n][m]=1000;
	}
	for (int i=0;i<3;i++)
		if (a[i][0]==1000&&a[i][1]==1000&&a[i][2]==1000){
			cout<<"Yes"<<endl;
			return 0;
		}
		else if (a[0][i]==1000&&a[1][i]==1000&&a[2][i]==1000){
			cout<<"Yes"<<endl;
			return 0;
		}
		else;
	if (a[0][0]==1000&&a[1][1]==1000&&a[2][2]==1000||a[2][0]==1000&&a[1][1]==1000&&a[0][2]==1000)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		return 0;		
}

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

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int count = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == '1' && (i + 1) % 2 == 1){
			 ++count;
		}
		else if(s[i] == '0' && (i + 1) % 2 == 0){
			++count;
		}
	}

	cout << min(count, n - count) << endl;
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var NK = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        //すぬけ君の数
        var N = NK[0];
        //お菓子の種類
        var K = NK[1];
        var candyFlgs = new bool[N + 1];
        //K種のお菓子分入力を受ける
        for(var n = 0;n < K; n++)
        {
            //お菓子を持っている人数分ループを実施する
            var loop = int.Parse(Console.ReadLine());
            //お菓子を持っている個人の配列を保持する
            var people = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
            for( var l = 0; l < loop; l++)
            {
                //お菓子を持っているすぬけ君をtrueとする
                candyFlgs[people[l]] = true;
            }
        }
        var ans =0;
        //お菓子を持っていないすぬけ君の数を数える
        for(var indx = 1;indx < candyFlgs.Length;indx++)
        {
            if(candyFlgs[indx] == false)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}



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



int main (){
    int N;
    cin>>N;
    vector<long long> A(N), B(N);
    long long Sum=0;
    for(int i=0 ;i<N; i++){
        cin>>A.at(i);
        Sum+=A.at(i);
    }
        long long Ao=0;
        for(int j=0; j<N/2; j++){
            Ao+=A.at((1+2*j)%N);
        }
        
        B.at(0)=Sum-2*Ao;
        cout<<B.at(0);
        for(int j=1; j<N; j++){
            cout<<' ';
            B.at(j)=2*A.at(j-1)-B.at(j-1);
            cout<<B.at(j);
        }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int i;
    for(i=0;i<s.length();i++){
        if(s[3]=='7'){
            s[3]='8';
        }
        cout<<s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<time.h>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
#define INF 10000000
typedef long long ll;
int n[101];
int main(){
	int a,b,flg;
	while(1){
		flg=0;
		for(int i=0;i<101;i++)n[i]=0;
		while(1){
			if(!(cin>>a>>b))return 0;
			if(a+b==0)break;
			n[a]++;n[b]++;
		}
		if(n[1]%2!=1||n[2]%2!=1)flg=1;
		for(int i=3;i<=100&&flg!=1;i++){
			if(n[i]%2==1)flg=1;
		}
		if(flg==1){
			cout<<"NG"<<endl;
		}else{
			cout<<"OK"<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1156
K, N = map(int, input().split())
A = list(map(int, input().split()))

L = [] #各家の間の距離

for n in range(1, N):
  L.append(A[n]-A[n-1])

L.append(A[0]+K-A[N-1]) #最初の家と最後の家の距離（起点から最初の家の距離に、最後の家から起点までの距離を足す）

ans = K - max(L)

print(ans)

Measured memory_bytes: 32320
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
ll h[200009];
ll a[200009];
ll bit[200009];
void upd(ll idx, ll val){
    ++idx;
    while(idx <= n+1){
        bit[idx] = max(bit[idx], val);
        idx += idx&(-idx);
    }
}
ll get(ll idx){
    ++idx;
    ll ret = 0;
    while(idx > 0){
        ret = max(bit[idx], ret);
        idx -= idx&(-idx);
    }
    return ret;
}
int main() {
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;
    for(ll i = 0; i < n; ++i)
        cin >> h[i];
    for(ll i = 0; i < n; ++i)
        cin >> a[i];
    for(ll i = 0; i < n; ++i){
        upd(h[i], a[i] + get(h[i]-1));        
    }
    cout << get(n) << "\n";
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int i,n,t=0,p=0,m,l,q=0;
    string s;
    cin>>n>>m;
   int ara[n+1]={0},b[n+1]={0},a[n+1]={0};

    for(i=0;i<m;i++){
        cin>>l>>s;
        if(s[0]=='A' && ara[l]!=-1){
            a[l]+=1;
           ara[l]=-1;
        }
        if(s[0]=='W' && ara[l]!=-1){
            b[l]+=1;
            //cout<<b[l]<<endl;

        }
    }
    for(i=1;i<=n;i++){
        q+=a[i];
      //  cout<<a[i]<<endl;
      if(a[i]>0)
        t+=b[i];
    }
    cout<<q<<" "<<t<<endl;


}



Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int N, W;
int w[110], v[110];
int dp[110][110][310];

signed main() {
    cin >> N >> W;
    repq(i,1,N) cin >> w[i] >> v[i];
    int flr = w[1];
    int sum = 0;
    repq(i,1,N) {
        w[i] -= flr;
        sum += w[i];
    }
    dp[0][0][0] = 0;
    int ans = 0;
    repq(i,1,N) repq(j,1,i) repq(k,0,sum) {
        dp[i][j][k] = dp[i-1][j][k];
        // printf("i = %lld, j = %lld, k = %lld, flr = %lld\n", i, j, k, flr);
        if(k-w[i] >= 0 && k + j * flr <= W)
            dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w[i]] + v[i]);
        if(i == N) ans = max(ans, dp[i][j][k]);
    }
    cout << ans << endl;
    return 0;
}

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

#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
}

const int N = 1e3 + 10;
int X[N], Y[N], n;

inline void fuck(int x, int y) {
	Forr(i, 30, 0) {
		int d = 1 << i;
		if(abs(x) > abs(y)) 
			putchar(x < 0 ? (x += d, 'L') : (x -= d, 'R'));
		else 
			putchar(y < 0 ? (y += d, 'D') : (y -= d, 'U'));
	}
}

int main() {

	n = read();
	For(i, 1, n) X[i] = read(), Y[i] = read();

	int flag = X[1] + Y[1] & 1;

	For(i, 2, n) if ((X[i] + Y[i] & 1) != flag) return puts("-1"), 0;

	For(i, 1, n) Y[i] += (!flag); printf("%d\n", 32 - flag);

	Forr(i, 30, 0) printf("%d ", 1 << i); puts(!flag ? "1" : "");

	For(i, 1, n) fuck(X[i], Y[i]), puts(!flag ? "D" : "");

	return 0;
}


Measured memory_bytes: 256
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

MOD=1000000007

def lcm(a,b):
  return a/gcd(a,b)*b

def read_int():
  return int(raw_input())
# N = read_int()

def read_ints():
  return map(int,raw_input().split())
# a,b,c,d=read_ints()

def read_field():
  return raw_input()

def read_fields():
  return raw_input().split()

def print_array(ar):
  n = len(ar)
  for i in range(n-1):
    print ar[i],
  print ar[-1]

def say_bool(val, strs=['Yes','No']):
  print strs[int(val)]

def solve(N):
   return True

a,b,c=read_ints()
if a==b==c:
  print 'Yes'
else:
  print 'No'

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

using namespace std;
#define int long long
const double PI=acos(-1.0);
#define N 666666
#define inf 99999999999999999
vector<int> G[N];
int dis[N];
int f[N];
int n,m;
map<int,int> vis;
int getf(int v){
  if(v==f[v]) return f[v];
  else{
    f[v]=getf(f[v]);
    return f[v];
  }
}
void merge(int u,int v){
  int t1=getf(u);
  int t2=getf(v);
  if(t1!=t2) f[t2]=t1;
}

void spfa(int start){
  vis.clear();
  for(int i=0;i<n+5;i++) dis[i]=inf;
  queue<int> q;
  dis[start]=0;
  q.push(start);
  vis[start]=1;
  while(!q.empty()){
    int temp=q.front();
    q.pop();
    vis[temp]=0;
    for(int i=0;i<G[temp].size();i++){
      int to=G[temp][i];
      if(dis[to]>dis[temp]+1){
        dis[to]=dis[temp]+1;
        if(!vis[to]){vis[to]=1;q.push(to);}
      }
    }
  }
}
signed main(){
  
  cin>>n>>m;
  for(int i=0;i<=n;i++) f[i]=i;
  for(int i=1;i<=m;i++){
    int u,v;
    cin>>u>>v;
    G[u].push_back(v);
    G[v].push_back(u);
    merge(u,v);
  }
  int sum=0;
  for(int i=1;i<=n;i++) if(i==f[i]) sum++;
  if(sum!=1){
    printf("No");
  }else{
    printf("Yes\n");
    spfa(1);
    for(int i=2;i<=n;i++){
      int ans=inf,node=0;
      for(int j=0;j<G[i].size();j++){
            if(ans>dis[G[i][j]]){
              ans=dis[G[i][j]];
              node=G[i][j];
            }
      }
      printf("%lld\n",node);
    }
  }
  return 0;
}

Measured memory_bytes: 33168
A, B, M = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
aB = [int(_) for _ in input().split()]
XYC = [[int(_) for _ in input().split()] for _ in range(M)]
ans = min(aA) + min(aB)
for x, y, c in XYC:
    ans = min(ans, aA[x - 1] + aB[y - 1] - c)
print(ans)


Measured memory_bytes: 32224
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,ans=0;

int t[100];



int calc(){
  int L[100],R[100];
  int res=0;
  L[0]=t[0];
  R[W-1]=t[W-1];

  for(int i=1;i<W;i++){
    L[i]=L[i-1]+(1-t[i]);
  }
  for(int i=W-2;i>=0;i--){
    R[i]=R[i+1]+(1-t[i]);
  }
  res=max(R[0],L[W-1]);

  for(int i=1;i<W-1;i++){
    if(t[i]==1){
      res=max(res,L[i-1]+R[i+1]+1);
    }else{
      res=max(res,L[i-1]+R[i+1]);
    }
  }
  return res;
}

int main(){
  cin>>H>>W;
  ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>t[j];
      if(i>0)t[j]=1-t[j];
    }
    ans+=calc();
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1164
/*

*/
#include <cstdio>
#include <cctype>
#include <algorithm>
#define gc() getchar()
#define mod 1000000007
#define Add(x,v) (x+=v)>=mod&&(x-=mod)
typedef long long LL;
const int N=2e6;

int fac[N+3],ifac[N+3];

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now;
}
inline int FP(int x,int k)
{
	int t=1;
	for(; k; k>>=1,x=1ll*x*x%mod)
		if(k&1) t=1ll*t*x%mod;
	return t;
}
#define C(n,m) (1ll*fac[n+m]*ifac[n]%mod*ifac[m]%mod)//C(n+m,n)
int Calc(int x1,int y1,int sign1,int x2,int y2,int sign2,int X3,int X4,int Y3,int Y4)
{//(x1,y1)->(x2,y2)
	LL res=0;
	for(int x=X3; x<=X4; ++x)
		Add(res,1ll*(x+Y4+1)*C(x-x1,Y4-y1)%mod*C(x2-x,y2-Y4-1/*强制下一步离开y=Y4*/)%mod),
		Add(res,mod-1ll*(x+Y3)*C(x-x1,Y3-y1-1/*强制最后一步是到达y=Y3*/)%mod*C(x2-x,y2-Y3)%mod);
//		Add(res,1ll*(x-x1+Y4-y1+1)*C(x-x1,Y4-y1)%mod*C(x2-x,y2-Y4-1/*强制下一步离开y=Y4*/)%mod),
//		Add(res,mod-1ll*(x-x1+Y3-y1)*C(x-x1,Y3-y1-1/*强制最后一步是到达y=Y3*/)%mod*C(x2-x,y2-Y3)%mod);
	for(int y=Y3; y<=Y4; ++y)
		Add(res,1ll*(y+X4+1)*C(y-y1,X4-x1)%mod*C(y2-y,x2-X4-1)%mod),
		Add(res,mod-1ll*(y+X3)*C(y-y1,X3-x1-1)%mod*C(y2-y,x2-X3)%mod);
//		Add(res,1ll*(y-y1+X4-x1+1)*C(y-y1,X4-x1)%mod*C(y2-y,x2-X4-1)%mod),
//		Add(res,mod-1ll*(y-y1+X3-x1)*C(y-y1,X3-x1-1)%mod*C(y2-y,x2-X3)%mod);

	res%=mod;
	return sign1*sign2*res;
}

int main()
{
	fac[0]=fac[1]=1, ifac[N]=407182070;
	for(int i=2; i<=N; ++i) fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=N; i; --i) ifac[i-1]=1ll*ifac[i]*i%mod;

	static int f[4][3],g[4][3];

	int x1=read(),x2=read(),x3=read(),x4=read(),x5=read(),x6=read(),
		y1=read(),y2=read(),y3=read(),y4=read(),y5=read(),y6=read();

	f[0][0]=x1-1, f[0][1]=y1-1, f[0][2]=1;
	f[1][0]=x2, f[1][1]=y1-1, f[1][2]=-1;
	f[2][0]=x1-1, f[2][1]=y2, f[2][2]=-1;
	f[3][0]=x2, f[3][1]=y2, f[3][2]=1;

	g[0][0]=x5, g[0][1]=y5, g[0][2]=1;
	g[1][0]=x6+1, g[1][1]=y5, g[1][2]=-1;
	g[2][0]=x5, g[2][1]=y6+1, g[2][2]=-1;
	g[3][0]=x6+1, g[3][1]=y6+1, g[3][2]=1;

	LL ans=0;
	for(int i=0; i<4; ++i)
		for(int j=0; j<4; ++j)
			ans+=Calc(f[i][0],f[i][1],f[i][2],g[j][0],g[j][1],g[j][2],x3,x4,y3,y4);
	printf("%lld\n",(ans%mod+mod)%mod);

	return 0;
}

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

int n;
vector<int> a;
vector<int> b;

int main()
{
	cin >> n;
	a.reserve(n);
	b.resize(n - 1);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> b[i];
	}
	a.push_back(b[0]);
	for (int i = 0; i < n - 1; i++)
	{
	    a.push_back(b[i]);
	}
// 	for (int i : a)
// 	    cout << i << ' ';
// 	cout << endl;
    for (int i = 0; i < n - 1; i++)
    {
        a[i] = min(a[i], a[i + 1]);
    }
    int ans = 0;
	for (int i : a)
	    ans += i;
	cout << ans;
	return 0;
}

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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)
#define EREP(t,i,a,b) for(t i = a; i <= b; ++i)
#define REPR(t,i,a,b) for(t i = a; i > b; --i)
#define EREPR(t,i,a,b) for(t i = a; i >= b; --i)

typedef long long ll;

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

int main (void) {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;

    if (s=="Sunny") cout << "Cloudy" << endl;
    else if (s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define int int64_t

int64_t get_ans(string s) {
    int ans = 0;

    int len = 0;
    for (int i = 0; i < SZ(s); ++i)
        if (len != 0 and s[i] == s[i - 1])
            ++len;
        else {
            ans += len / 2;
            len = 1;
        }

    ans += len / 2;

    return ans;
}

int32_t main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    string s = input<string>();
    int k = input<int>();

    if (std::is_sorted(ALL(s)) and std::is_sorted(RALL(s))) {
        cout << (SZ(s) * int64_t(k)) / 2 << "\n";
    } else if (k == 1 or s[0] != s.back()) {
        cout << get_ans(s) * int64_t(k) << "\n";
    } else {
        int p = 0;
        int q = SZ(s) - 1;
        int cnt = 0;
        
        while (s[p] == s[0])
            ++p, ++cnt;

        while (s[q] == s[0])
            --q, ++cnt;

        int64_t ans = (cnt / 2) * int64_t(k - 1);

        int base_ans = get_ans(s.substr(p, q - p + 1));
        ans += int64_t(k) * base_ans;
        
        ans += p / 2;
        ans += (SZ(s) - q - 1) / 2;

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

    return 0;
}


Measured memory_bytes: 256
#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 <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B) { cout << C << endl; }
    else if (B == C) { cout << A << endl; }
    else if (C == A) { cout << B << endl; }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

struct point{
	double x,y;
}; 

void koch(int n,struct point a,struct point b)
{
	struct point s,t,u;
	double th=M_PI*60.0/180.0;
	if(n==0)
	{
		return;
	}
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	t.x=(1.0*a.x+2.0*b.x)/3.0;
	t.y=(1.0*a.y+2.0*b.y)/3.0;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y); 
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y); 
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y); 
	koch(n-1,t,b);
}

int main()
{
	struct point a,b;
	int n;
	scanf("%d",&n);
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}


Measured memory_bytes: 1948
#include<iostream>

using namespace std;

int n, p, stone_left, P[50], winner;

int main(){
    while(cin >> n >> p && n*p!=0){
        stone_left = p;
        winner = n;
        for (int i = 0; i < n; i++) {
            P[i] = 0;
        }
        while(1){
            for(int i = 0; i < n; i++){
                if(stone_left != 0){
                    P[i] += 1;
                    stone_left -= 1;
                    if(P[i] == p) {
                        winner = i;
                        cout << winner << endl;
                        break;
                    }
                    if(winner != n) break;
                } else {
                    stone_left = P[i];
                    P[i] = 0;
                }
            }
            if(winner != n) break;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define P           pair<int, int>
#define dint        long double

const int mod = 998244353;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

int modpow(int a, int b) {
    if(a == 0 || a == 1 || b == 1) return a;
    int ans = 1;
    while(b) {
        if(b%2) ans = mul(ans, a);    
        b /= 2; a = mul(a, a);
    }   return ans;
}

const int N = 2003;
int n;
int a[N];
int dp[N][N];
P b[N];

int go(int pos, int L, int R) {
    if(pos > n) return 0;
    int &ans = dp[L][R];
    if(ans != -1) return ans;
    int op1 = abs(L - b[pos].second) * b[pos].first + go(pos+1, L+1, R);
    int op2 = abs(R - b[pos].second) * b[pos].first + go(pos+1, L, R-1);
    ans = max(op1, op2);
    return ans;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    memset(dp, -1, sizeof dp);

    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
        b[i].first = a[i];
        b[i].second = i;
    }
    sort(b+1, b+n+1); reverse(b+1, b+n+1);
    int ans = go(1, 1, n);
    cout << ans << endl;



    return 0;

}



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

using namespace std;

typedef long long ll;

const int mx = 100050;
int arr[mx];
int dp[mx];
int n;


int main()
{
    scanf("%d",&n);

    int i, j , k , p , q;

    for(i = 0 ; i < n ; i++)scanf("%d",arr+i);

    dp[0] = 0;

    for(i = 1 ; i < n ; i++)
    {
        dp[i] = dp[i-1] + abs(arr[i]-arr[i-1]);
        if(i > 1)
        dp[i] = min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
    }

    printf("%d\n",dp[n-1]);

    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N, A, B;

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

  std::cin >> N >> A >> B;

  ll res = 0;

  if(A > B){
      std::swap(A, B);
  }

  if(A % 2 == B % 2){
      res = (B - A) / 2;
  }else{
      res = std::min((A - 1) + 1 + ((B - A) - 1) / 2,
                     (N - B) + 1 + ((B - A) - 1) / 2);
  }

  std::cout << res << std::endl;
}


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

using namespace std;

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

  int n;
  string name;
  cin >> n;
  map<char, long long> hash;
  vector<char> letters;
  for (int i = 0; i < n; ++i) {
    cin >> name;
    if (name[0] == 'M' || name[0] == 'A' || name[0] == 'R' || name[0] == 'C' || name[0] == 'H') {
      if (hash.find(name[0]) == hash.end()) 
        letters.push_back(name[0]);
      hash[name[0]]++;
    }
  }
  int m = letters.size();
  long long res = 0;
  for (int i = 0; i < m; ++i) 
    for (int j = i+1; j < m; ++j) 
      for (int k = j+1; k < m; ++k) {
        res += hash[letters[i]] * hash[letters[j]] * hash[letters[k]];
      }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    vi ss(n);
    cin>>ss;
    sort(rng(ss));
    int ans = 0;
    rep(i, n) ans += ss[i];
    if (ans % 10 != 0) {
        cout<<ans<<endl;
        return 0;
    }
    rep(i, n) {
        if ((ans - ss[i]) % 10 != 0) {
            cout<<ans - ss[i]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    return 0;
}


Measured memory_bytes: 3112
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val (n,a,b) = readlongs()
    val ans = n / (a + b) * a + Math.min(n % (a + b), a)
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	int n = b - a - 1;
	int h = n * (n + 1) / 2;
	
	cout << h - a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int calc(int a){
  int sum=0;
  int temp=a;
  while(temp>0){
    sum+=temp%10;
    temp/=10;
  }
  return sum;
}

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

  int ans=INF;
  for(int a=1;a<N;a++){
    int b=N-a;
    ans=min(calc(a)+calc(b),ans);
  }

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


Measured memory_bytes: 256