akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

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);

    ll n; cin>>n;
    vl as(n); cin>>as;

    ll sum = 0;
    rep(i, n) sum ^= as[i];
    rep(i, n) {
        ll ans = sum ^ as[i];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4780
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		String strA = next();
		String strB = next();

		if (strA.equals("H")) {
			System.out.println(strB.equals("H") ? "H" : "D");
		} else {
			System.out.println(strB.equals("H") ? "D" : "H");
		}

	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {
	ll N, K;
	cin >> N >> K;

	cout << min(N % K, K - N % K);

	system("PAUSE");
}


Measured memory_bytes: 504
N,K=map(int,input().split())
X=list(map(int,input().split()))
for i in range(N):
    if X[i]<0:
        continue
    elif X[i]==0:
        K-=1
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i+1:i+1+K]
        break
    else:
        if i<K:
            mX=[0]+[-x for x in X[:i]][::-1]
        else:
            mX=[0]+[-x for x in X[i-K:i]][::-1]
        pX=[0]+X[i:i+K]
        break
else:
    mX=[0]+[-x for x in X[::-1]]
    pX=[0]
ans=10**9
l=K-(len(pX)-1)
n=len(mX)
for i in range(len(pX)-1,-1,-1):
    if l<n:
        ans=min(ans,pX[i]+mX[l]*2,pX[i]*2+mX[l])
    else:
        break
    l+=1
print(ans)

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

h,w,k = inpm()
c=inplL(h)
ans=0
for i in range(2**h):
    for j in range(2**w):
        cnt=0
        for hh in range(h):
            for ww in range(w):
                if (i>>hh)&1 != 1 and (j>>ww)&1 != 1 and c[hh][ww]=='#':
                    cnt+=1
        if cnt==k:
            ans+=1
                
print(ans)

Measured memory_bytes: 30824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int dis[305][2];
vector<P> vs;

int main(){
	int n,p,q;
	int i,j,k;
	int a,b,c,d;
	cin>>n>>p>>q;
	cout<<"? "<<p<<" "<<q<<endl;
	cout.flush();
	cin>>a;
	p--,q--;
	dis[q][0]=a,dis[p][1]=a;
	vs.push_back(make_pair(0,p)),vs.push_back(make_pair(a,q));
	for(i=0;i<n;i++){
		if(i==p || i==q)continue;
		cout<<"? "<<i+1<<" "<<p+1<<endl;
		cout.flush();
		cin>>dis[i][0];
		cout<<"? "<<i+1<<" "<<q+1<<endl;
		cout.flush();
		cin>>dis[i][1];
		if(dis[i][0]+dis[i][1]==a)vs.push_back(make_pair(dis[i][0],i));
	}
	sort(vs.begin(),vs.end());
	a=p;
	for(i=1;i<vs.size();){
		b=vs[i].second;
		cout<<"? "<<a+1<<" "<<b+1<<endl;
		cout.flush();
		cin>>c;
		if(c!=dis[b][0]-dis[a][0]){
			vs.erase(vs.begin()+i);
		}else{
			a=b,i++;
		}
	}
	cout<<"!";
	for(i=0;i<vs.size();i++){
		cout<<" "<<vs[i].second+1;
	}
	cout<<endl;
		
}



Measured memory_bytes: 4664
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int r,g,b; cin>>r>>g>>b;
    int a=100*r+10*g+b;
    if(a%4==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

constexpr int nax = 1e5;

int n, ilo[nax + 1];

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

    cin >> n;

    int mi = nax + 1, ma = -1;
    for (int i = 0; i < n; ++i)
    {
        int v; cin >> v;
        ++ilo[v];
        mi = min(mi, v);
        ma = max(ma, v);
    }

    if (mi == ma)
    {
        if (mi == n - 1 or 2 * mi <= n)
            return cout << "Yes" << '\n', 0;
        else
            return cout << "No" << '\n', 0;
    }
    else if (mi + 1 == ma)
    {
        int x = ilo[mi]; int y = ilo[ma];
        if (x + 1 <= ma and ma <= x + y / 2)
            return cout << "Yes" << '\n', 0;
        else
            return cout << "No" << '\n', 0;
    }
    cout << "No" << '\n';
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
int int_comp(const void*a,const void*b){return *(int*)a-*(int*)b;}
using namespace std;
int main()
{
    int n;
    int l[2000];
    int ans=0,flg=0;
    int j,k;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    qsort(l,n,sizeof(int),int_comp);
    for(int i=0;i<n;i++){
        flg=0;
        for(j=i+1;j<n;j++){
            flg=0;
            for(k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k]&&l[j]<l[i]+l[k]&&l[k]<l[i]+l[j]){
                    ans++;
                }
                else{
                    flg=1;
                }
                if(flg==1)break;
            }
            //if(flg==1)break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	static long changecount = 0;
   public static void main(String args[]) throws IOException{


	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	   int n = Integer.parseInt( br.readLine()  );
       Heap[] heaps = new Heap[n];

	   String[] string =  br.readLine().split(" ");

       for(int i = 0 ; i < n ; i++){
    	   heaps[i] = new Heap(i+1,  Integer.parseInt(string[i] ) );
       }


       for(int i = 0 ; i < n ; i++){
            heaps[i].print();
            int I = heaps[i].index/2;
            int Left = 2*heaps[i].index;
            int Right = 2*heaps[i].index + 1;

            if( 1 <= I ){
            	System.out.print( "parent key = "+heaps[I-1].key+ ", ");
            }
            if( Left <= n ){
            	System.out.print( "left key = "+heaps[Left-1].key+ ", ");
            }
            if( Right <= n ){
            	System.out.print( "right key = "+heaps[Right-1].key+ ", ");
            }
            System.out.println();
       }




   }


}



class Heap{

	int  key;
    int index;
    Heap(int i,  int x) {
        key = x;
        index = i;
    }

    void print(){

    	System.out.print("node "+index+": key = " +key+ ", ");
    }


}

Measured memory_bytes: 25076
<?php
function isUniqueArray ($a) {
  $unique_array = array_unique($a);
  if (count($unique_array) === count($a)) {
    return true;
  }
  else {
    return false;
  }
}
fscanf(STDIN,"%d",$n);
$a = explode(" ",trim(fgets(STDIN)));

if(isUniqueArray($a)){
	echo "YES";  
}else{
  	echo "NO";
}
?>

Measured memory_bytes: 61284
#include<bits/stdc++.h>
using namespace std;
long long int a[4],uc;
int main(){
    cin>>a[0]>>a[1]>>a[2];
    
    while(a[0]!=a[1]||a[0]!=a[2]){
        sort(a,a+3);
        if(a[0]<a[2]-1){a[0]+=2;}
        else if(a[1]==a[2]){a[1]++;a[2]++;}
        else if(a[0]==a[1]){a[0]++;a[1]++;}
        uc++;
    }
    cout<<uc;

}


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

ll k,a,b;

int main(){

    cin >> k >> a >>b;

    ll yen=0;
    ll n=1;

    if(b<=a+2){
        cout << k+1 << endl;
        return 0;
    }

    for(;k>0;k--){
        if(n<a||k==1){
            n++;
        }else{
            k--;
            n=n-a+b;
        }
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
def a():
    N, K = [int(n) for n in input().split()]
    h = [int(n) for n in input().split()]
    # dp[i]はi番目までたどり着くのに必要な最小コスト
    # dp[0] = 0
    # dp[1] = |h[1] - h[0]|
    # dp[i] = min(dp[0]+h[i]-h[0], dp[1]+h[i]-h[1], ...)
    dp = [0] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([dp[k] + abs(h[k] - h[i]) for k in range(max(i - K, 0), i)])
    print(dp[N-1])

if __name__ == "__main__":
    a()

Measured memory_bytes: 13980
#include <iostream>

using namespace std;

int main()
{
  int A, B, K, aux, cont = 0, num;

  cin >> A >> B >> K;

  if(A > B){
    aux = B;
  }else{
    aux = A;
  }

  int i;
  
  for(i=aux;i>0;i--){
    
    if(A%i == 0 & B%i == 0){
      cont += 1;

    }
    if(cont == K){
      num = i;
      break; 
    }
  }

  cout << num <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,P;
	while(cin>>N>>P,N||P){
		int wan,cnt[50]={};
		wan = P;
		for(int i=0;;i=(i+1)%N){
			if(wan==0){
				wan += cnt[i]; cnt[i] = 0;
			}
			else{
				cnt[i]++; wan--;
				if(cnt[i]==P){
					printf("%d\n",i); break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a[2];
	int k;
	cin >> a[0] >> a[1] >> k;
	sort(a, a+2);
	int i = a[0];
	int ans;
	while (k){
		if (a[0] % i == 0 and a[1] % i == 0){
			k--;
			ans = i;
		}
		i--;
	}

	cout << ans << endl;







}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;

inline int POS(int k,int value);

const int MAXN = 2e5+10;

struct P {
    int x,y;
} H[MAXN];

vector<int> G[MAXN];

set<int> s;
set<int>::iterator it;

int main()
{
    int N,M;
	cin>>N>>M;
	
    for(int i=1; i<=M; i++) {
        int x,y;
		cin>>x>>y;
		
        H[i].x = x;
		H[i].y = y;
		
        s.insert(x);
		G[x].push_back(y);
    }
    
    for(int i=1; i<=N; i++) {
        sort(G[i].begin(), G[i].end());
    }
    
    for(int i=1; i<=M; i++) {
        cout<<setw(6)<<setfill('0')<<H[i].x
			<<setw(6)<<setfill('0')<<POS(H[i].x, H[i].y)+1<<endl;
    }
    
    return 0;
}

inline int POS(int k,int value) {
    for(int left = 0, len = G[k].size(), right = len - 1; left <= right ;) {
        int mid = left + (right - left) / 2;
        if(G[k][mid] == value) {
        	return mid;
		} else if(G[k][mid] > value) {
        	right = mid;
		} else {
        	left = mid + 1;
		}
    }
    return -1;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
int n,m;ll sum=0;
  cin>>n>>m;
  int a[m];for(int i=0;i<m;i++){
    cin>>a[i];
                 sum+=a[i];              
                               }
  if(sum>n)
    cout<<"-1"<<"\n";
  else
    cout<<n-sum<<"\n";
return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    int a, b;
};

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

int main() {
    int h, n;
    cin >> h >> n;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = { a, b };
    }

    vector<int> dp(h + 1, 1 << 30);//体力をj減らせる最小の魔力消費
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int a = p[i].a;
        int b = p[i].b;
        for (int j = 0; j <= min(a, h); j++) {
            chmin(dp[j], b);
        }
        for (int j = a; j <= h; j++) {
            chmin(dp[j], dp[j - a] + b);
        }
    }

    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int time;
	cin >> time;
	int h = (time / 60 / 60);
	int m = (time - (h*60*60)) / 60;
	int s = time % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int n;
ll a,ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std;

const int N = 1e5 + 7;
const long long oo = 1e18L + 5;

int n, a[N][3];

int main() {
    cin >> n;
    vector<vector<ll>> dp(n + 2, vector<ll>(3, -oo));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (k != j) {
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][k]);
                }
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    int h=gi();
	    int w=gi();


	    System.out.print((n-h+1)*(n-w+1));
//	    if (n%10==3) {
//	    	System.out.print("bon");
//	    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
//	    	System.out.print("pon");
//	    } else {
//	    	System.out.print("hon");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> list(N), copied(N);
    for(int i = 0; i < N; i++){
        cin >> list.at(i);
    }
    for(int i = 0; i < N; i++){
        copied.at(i) = list.at(i);
    }
    sort(copied.begin(),copied.end());
    int L = copied.at(N-1);
    int M = copied.at(N-2);
    for(int i = 0; i < N; i++){
        if(L == M && L == list.at(i))
        cout << M << endl;
        if(L != list.at(i))
        cout << L << endl;
        if(L == list.at(i) && L != M)
        cout << M << endl;
    }
}  

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n;
string s;
map<string,int> mp;
int main() {
	ios::sync_with_stdio(false);
	int i,ans=0;
	cin>>n;
	for (i=1;i<=n;i++) {
		cin>>s;
		if (mp[s]==0) ans++,mp[s]=1;
	}
	cout<<ans<<endl;
	return 0;
} 

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

using namespace std;
typedef long long ll;

int upper_bound(vector<ll>& vec, ll key)
{
    int l=-1, r=vec.size(), mid;
    while(l < r - 1){
        mid = (l + r) / 2;
        if(vec[mid] > key){
            r = mid;
        }
        else{
            l = mid;
        }
    }
    return r;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    
    for(int i=0;i<N;++i){
        cin >> A[i];
        A[i] *= -1;
    }
    sort(A.begin(), A.end());
    for(int i=0;i<N;++i){
        cin >> B[i];
    }
    sort(B.begin(), B.end());
    for(int i=0;i<N;++i){
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    ll ans = 0;
    ll l1, l2;
    for(int i=0;i<N;++i){
        l1 = upper_bound(A, -B[i]);
        l2 = upper_bound(C, B[i]);
        ans += (N - l1) * (N - l2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	r := nextInt()
	fmt.Println(r*r)
}

Measured memory_bytes: 640
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0)
    Dim ans=If(a<1000,"ABC","ABD")
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    while(cin>>n>>k){
        if(n%k)cout<<"1"<<endl;
        else cout<<"0"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
struct Point {
	long long x, y;
	inline Point(long long _x = 0, long long _y = 0): x(_x), y(_y) {}
	inline Point operator - (const Point &oth) const { return Point(x - oth.x, y - oth.y); }
	inline double ang() const { return atan2(y, x); }
};
int n;
Point a[105];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i].x, &a[i].y);
	for (int i = 1; i <= n; i++) {
		vector<double> vec;
		for (int j = 1; j <= n; j++) if (i != j) {
			vec.push_back((a[j] - a[i]).ang());
		}
		sort(vec.begin(), vec.end());
		double mx = vec[0] - vec.back() + 2 * PI;
		for (int i = 1; i < (int)vec.size(); i++) {
			mx = max(mx, vec[i] - vec[i - 1]);
		}
		if (mx <= PI) {
			mx = 0;
		} else {
			mx -= PI;
		}
		printf("%.10lf\n", mx / PI / 2);
	}
	return 0;
}

Measured memory_bytes: 4188
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

int n, i, id, flag = 0;
int use[MAX];
typedef struct pp
{
    int num;
    int parent;
    int dph;
    int *ch;
}g;
g Q[MAX];

void dfs(int q, int d)
{
    if(Q[q].dph<d) Q[q].dph=d;
    for(int l=0; l<Q[q].num; l++)
    {

        Q[Q[q].ch[l]].parent = q;
        dfs(Q[q].ch[l], d+1);
    }
}

int main()
{
    for(int j=0; j<MAX; j++)
    {
        use[j] = 0;
        Q[j].parent = -1;
        Q[j].dph = -1;
    }
    //input
    scanf("%d", &n);
    while(1)
    {
        if((scanf("%d", &id)) == EOF) break;
        scanf("%d", &Q[id].num);
        Q[id].ch = (int*)malloc(sizeof(int) * Q[id].num);
        for(int j=0; j<Q[id].num; j++) 
        {
            scanf("%d", &Q[id].ch[j]);
            use[Q[id].ch[j]] = 1;
        }
    }

    for(int j=0; j<MAX; j++)
    {
        if(use[j] == 0) 
        {
            dfs(j, 0);
            flag=1;
        }
        if(flag==1) break;
    }
    //output results
    for(int j=0; j<n; j++)
    {
        printf("node %d: parent = %d, depth = %d, ",j ,Q[j].parent ,Q[j].dph);
        if(Q[j].parent == -1) printf("root, [");
        else if(Q[j].num == 0) printf("leaf, [");
        else 
        {
            printf("internal node, [");
        }
        for(int k=0; k< Q[j].num; k++)
        {
            printf("%d",Q[j].ch[k]);
            if(k<Q[j].num-1) printf(", ");
        }
            printf("]\n");
    }

    return 0;
}


Measured memory_bytes: 7988
#include<iostream>
#include<string>

using namespace std;

int main(void){
  string a;
  int ans=0;
  
  cin>>a;
  if(a[0]==a[1]&&a[1]==a[2])
     ans++;
  if(a[1]==a[2]&&a[2]==a[3])
    ans++;
  cout<<(ans>=1?"Yes":"No")<<endl;
     return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 210
#define INF 10000000

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,H,W;
ll K;

struct edge{int to,cap,rev;};

vector<edge> G[SIZE];
bool used[SIZE];
bool leaves[100][100];

//グラフ追加: from -> to (cap)
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

//パスを一本見つける
int dfs(int v, int t, int f){
	if(v==t)return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){ //v -> G[v][i].toにd流す
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f==0)return flow;
		flow += f;
	}
}


int main()
{
	char c;
	int sh,sw,th,tw;
	scanf("%d %d\n",&H,&W);
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%c",&c);
			if(c=='.'){
				leaves[i][j]=false;
			}
			else{
				leaves[i][j]=true;
				add_edge(i,100+j,1);
				add_edge(100+j,i,1);
			}
			if(c=='S'){
				sh=i,sw=j;
				add_edge(201,i,INF);
				add_edge(i,201,INF);
				add_edge(201,100+j,INF);
				add_edge(100+j,201,INF);
			}
			if(c=='T'){
				th=i,tw=j;
				add_edge(202,i,INF);
				add_edge(i,202,INF);
				add_edge(202,100+j,INF);
				add_edge(100+j,202,INF);
			}
		}
		scanf("%c",&c);
	}
	if(sh==th || sw==tw){
		printf("-1\n");
		return 0;
	}
	/*
	for(int i=0;i<H;i++){
		printf("\n");
		for(int j=0;j<W;j++){
			if(leaves[i][j])printf("T");
			else printf("F");
		}
	}
	*/

	int ans = max_flow(201,202);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int four = 0, two = 0, none = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (a % 4 == 0)
        {
            four++;
        }
        else if (a % 2 == 0)
        {
            two++;
        }
        else
        {
            none++;
        }
    }
    string ans = "Yes";
    if (four < none)
    {
        ans = "No";
    }
    if (four + 1 >= none && two == 0)
    {
        ans = "Yes";
    }
    cout << ans << endl;

    return 0;
}

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

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

	int bad = 0;
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);

		if(x % 2 == 0) {
			if(x % 3 == 0 || x % 5 == 0)
				continue;
			bad = 1;
		}
	}

	if(!bad)
		printf("APPROVED\n");

	else printf("DENIED\n");

	return 0;
}

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

int main(){
    int a,b,c,k,res = 0;

    cin >> a >> b >> c >> k;

    if( a <= k ){
        res += a;
        k -= a;
    }
    else{
        res += k;
        cout << res << "\n";
        return 0;
    }

    if( b <= k  ){
        k -= b;
    }
    else{
        cout << res << "\n";
        return 0;
    }

    if( c <= k  ){
        res -= c;
        k -= c;
    }
    else{
        res -= k;
    }

    cout << res << "\n";

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n+1];
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	for(int i=2;i<n;i++){
	    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4340
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int n, m;
    vector< vector<int> > nodes;

    vector<int> length;
    vector<int> parents;
    scanf("%d%d", &n, &m);

    nodes.resize(n);
    length.resize(n);
    parents.resize(n);

    for (int i = 0; i < n; ++i) {
        length[i] = ((i == 0) ? 0 : 100000000);
    }

    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);

        a -= 1;
        b -= 1;

        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }

    parents[0] = 0;

    queue<int> q;

    q.push(0);

    while(!q.empty()) {
        int p = q.front();
        q.pop();

        for (auto iter = nodes[p].begin(); iter != nodes[p].end(); iter++) {
            if (length[*iter] <= length[p] + 1) continue;
            length[*iter] = length[p] + 1;
            parents[*iter] = p;
            q.push(*iter);
        }
    }

    printf("Yes\n");

    for (int i = 1; i < n; ++i) {
        printf("%d\n", parents[i] + 1);
    }

    return 0;
}

Measured memory_bytes: 10188
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, p, q;
  cin >> n >> p >> q;
  VI c(n);
  REP(i, n) cin >> c[i];

  int ret = 0;
  REP(i, n) ret += c[i];

  VI v;
  int now = q;
  REP(i, n) {
    // cout << p*now-c[i] << endl;
    v.PB(p*now-c[i]);
    now--;
  }
  sort(ALL(v), greater<>());
  // cout << v << endl;

  now = 0;
  int ans = ret;
  // cout << ret << endl;
  REP(i, n) {
    ret += v[i] + now;
    chmax(ans, ret);
    // cout << ret << endl;
    now += 2*p;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 11000
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		@SuppressWarnings({"resource" })
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		int debt = 100000;
		for(int j=0;j<i;j++){
			debt = f_debt(debt);
		}
		System.out.println(debt);
	}

	private static int f_debt(int n){
		n = (int)(n * 1.05);
		if(n % 1000 != 0){
			n = n - (n%1000) + 1000;
		}
		return n;
	}
}

Measured memory_bytes: 17308
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 && b == 0)
				break;
			char[][] map = new char[a][b];
			for (int i = 0; i < a; i++) {
				map[i] = scanner.next().toCharArray();
			}
			int count = 0;
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < b; j++) {
					if (map[i][j] != '-') {
						count++;
						solve(map[i][j], map, i, j);
					}
				}
			}
			System.out.println(count);
		}
	}

	private static void solve(char c, char[][] map, int y, int x) {
		int[] a = { -1, 0, 0, 1 };
		int[] b = { 0, -1, 1, 0 };
		Deque<int[]> deque = new ArrayDeque<int[]>();
		deque.push(new int[] { y, x });
		while (!deque.isEmpty()) {
			int[] p = deque.pop();
			int yp = p[0];
			int xp = p[1];
			map[yp][xp] = '-';
			for (int i = 0; i < a.length; i++) {
				int yn = yp + a[i];
				int xn = xp + b[i];
				if (yn >= 0 && map.length > yn && xn >= 0 && map[0].length > xn
						&& map[yn][xn] == c) {
					boolean flag = true;
					for (int[] t : deque) {
						if (t[0] == yn && t[1] == xn) {
							flag = false;
							break;
						}
					}
					if (flag) {
						deque.push(new int[] { yn, xn });
					}
				}
			}
		}
	}

}

Measured memory_bytes: 25240
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        boolean res = true;
        int n = s.length();
        for (int i = 0; i < (n-1)/2; i++) {
            if (s.charAt(i) != s.charAt(n - i - 1)) res = false;
        }
        for (int i = 0; i < (n-1)/4; i++) {
            if (s.charAt(i) != s.charAt((n - 1) / 2 - 1 - i)) res = false;
            if (s.charAt((n + 1) / 2 + i) != s.charAt(n - 1 - i)) res = false;
        }        

        if (res) System.out.println("Yes");
        else System.out.println("No");

    }
}

Measured memory_bytes: 21844
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long power(long long a,long long now) {
	long long ans = 1;
	while (now != 0) {
		if (now % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		now /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
long long inv(long long a) {
	return power(a, MOD - 2);
}
long long permutation(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MOD;
	}
	return ans;
}
long long combination(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MOD;
		ans *= inv(i + 1);
		ans %= MOD;
	}
	return ans;
}
long long dp[1001][1001];
long long solve(long long a, long long b) {
	if (b == 1) return 1;
	if (a < 0) return 0;
	if (a == 0) return 1;
	if (dp[a][b]) return dp[a][b];
	return dp[a][b] = (solve(a,b-1) + solve(a-b,b)) % MOD;
}
int main() {
	long long n, k;
	cin >> n >> k;
	cout << solve(n, k) << endl;

	return 0;
}



Measured memory_bytes: 10016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


ll solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    for (int i = 2; i < n; i++) {
        sum ^= a[i];
    }
    if (a[0]+a[1] < sum) return -1;
    ll D = (a[0]+a[1] - sum)/2; // A&B
    if (a[0] < D) return -1;
    ll A = D;
    for (int k = 60; k >= 0; k--) {
        if (((A|bit(k)) <= a[0]) && (bit(k)&sum)) {
            A = A | bit(k);
        }
    }
    if (A == 0) return -1;
    ll B = (a[0]-A+a[1]);
    if ((A&B) != D) return -1;
    return a[0]-A;
}

int main(void){
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	vector<vector<bool>> g(4, vector<bool>(4));
	for (int i = 0; i < (int)g.size() - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a][b] = g[b][a] = true;
	}

	for (int i = 0; i < (int)g.size(); i++) {
		int cnt = count(begin(g[i]), end(g[i]), true);
		if (cnt >= 3) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s == "A") Console.WriteLine("T");
            else if (s == "T") Console.WriteLine("A");
            else if (s == "G") Console.WriteLine("C");
            else  Console.WriteLine("G");

        }

    }

}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[212345], sum = 0;
    for (int i = 0; i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = INF;
    ll tmp = 0;
    for (int i = 0; i < n - 1; i++)
    {
        tmp += a[i];
        ll x = abs(sum - 2 * tmp);
        ans = min(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int w[10],k[10];
	int sum_w = 0,sum_k = 0;
	for(int i = 0; i < 10; i++){
        cin >> w[i];
	}
	for(int i = 0; i < 10; i++){
        cin >> k[i];
	}
	sort(w,w+10);
	reverse(w,w+10);
	sort(k,k+10);
	reverse(k,k+10);
	for(int i = 0; i < 3; i++){
        sum_w += w[i];
        sum_k += k[i];
	}
	cout << sum_w << " " << sum_k << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long N, long long D, std::vector<std::vector<long long>> X) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      double dis = 0;
      for (int k = 0; k < D; k++) {
        dis += (double)(X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      dis = sqrt(dis);
      if (abs(dis - (int)dis) < EPS) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      scanf("%lld", &X[i][j]);
    }
  }
  solve(N, D, std::move(X));
  return 0;
}


Measured memory_bytes: 256
/**************** Geometrical Library ****************/

#include<cmath>
#include<vector>
#include<algorithm>

#define	EPS	1e-8

enum {CCW=1,CW=-1,ON=0};

#define	mp	make_pair
#define	pb	push_back

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy):x(xx),y(yy){}
};

class Line:public vector<Point>{
public:
	Line(const Point &a,const Point &b){
		pb(a),pb(b);
	}
};

class Segment:public Line{
public:
	Segment(const Point &a,const Point &b):Line(a,b){}
};

class Polygon:public vector<Point>{};

class Circle{
public:
	Point c;
	double r;
	Circle(const Point &cc,double rr) : c(cc),r(rr){}
};

Point &operator +=(Point &a,const Point &b){
	a.x+=b.x,a.y+=b.y;
	return a;
}

Point &operator -=(Point &a,const Point &b){
	a.x-=b.x,a.y-=b.y;
	return a;
}

Point &operator *=(Point &a,double c){
	a.x*=c,a.y*=c;
	return a;
}

Point &operator /=(Point &a,double c){
	a.x/=c,a.y/=c;
	return a;
}

Point operator +(const Point &a,const Point &b){
	Point c=a;
	return c+=b;
}

Point operator -(const Point &a,const Point &b){
	Point c=a;
	return c-=b;
}

Point operator *(double c,const Point &a){
	Point b=a;
	return b*=c;
}

Point operator /(const Point &a,double c){
	Point b=a;
	return b/=c;
}

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

bool operator >(const Point &a,const Point &b){
	return b<a;
}

double cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}

double area(const Polygon &pl){
	int n=pl.size();
	double a=0;
	for(int i=0;i<n;i++)	a+=cross(pl[i],pl[(i+1)%n]);
	return abs(a)/2;
}

/**************** Library END ****************/

#include<cstdio>

int main(){
	const double R=1000;
	for(int m;scanf("%d",&m),m;){
		Polygon pl1;	pl1.pb(Point(R,0));
		for(int i=1,vsum=0;i<m;i++){
			int v;	scanf("%d",&v);
			vsum+=v;
			pl1.pb(Point(R*cos(M_PI*vsum/180),R*sin(M_PI*vsum/180)));
		}
		int n;	scanf("%d",&n);
		Polygon pl2;	pl2.pb(Point(R,0));
		for(int i=1,vsum=0;i<n;i++){
			int v;	scanf("%d",&v);
			vsum+=v;
			pl2.pb(Point(R*cos(M_PI*vsum/180),R*sin(M_PI*vsum/180)));
		}
		double a1=area(pl1),a2=area(pl2);
		if(a1>a2+EPS)		puts("1");
		else if(a2>a1+EPS)	puts("2");
		else	puts("0");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=3005;
const int Mod=1e9+7;
int dp[MAX_N][MAX_N],sum[MAX_N][MAX_N];
int n;
int main()
{
	string str;
	cin>>n>>str;
	dp[1][1]=sum[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(str[i-2]=='>')dp[i][j]=sum[i-1][j-1];
			else dp[i][j]=(sum[i-1][i-1]-sum[i-1][j-1]+Mod)%Mod;
			sum[i][j]=(sum[i][j-1]+dp[i][j])%Mod;
		}
	}
	cout<<sum[n][n]<<endl;
	return 0;
}

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


int main(){
    string s,t;
    int a,b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u)cout << a-1 << " " << b << endl;
    else cout << a << " "<< b-1 << endl;
}

Measured memory_bytes: 256
A = []
index = {}
for i in range(3):
    lst = list(map(int,input().split()))
    for idx,l in enumerate(lst):
        index[l] = (i,idx)
    A.append(lst)
N = int(input())

for _ in range(N):
    s = int(input())
    if s in index:
        i,j = index[s]
        A[i][j] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print("Yes")
        exit()
for i in range(3):
    su = 0
    for j in range(3):
        su+=A[j][i]
    if su == 0:
        print("Yes")
        exit()
if A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
    exit()
print("No")
    
    
        

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

using namespace std;

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

  int n;
  cin >> n;

  vector<int> x(n);
  vector<int> y(n);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    v[i] = i;
  }

  double ans = 0.0;
  int a = 0;
  do {
    double sum = 0.0;
    for (int i = 0; i < n - 1; ++i) {
      sum += sqrt(pow((x[v[i]] - x[v[i + 1]]), 2) + pow((y[v[i]] - y[v[i + 1]]), 2));
    }
    ++a;
    ans += sum;
  } while (next_permutation(v.begin(), v.end()));

  cout << ans / a << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



signed main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i < 12508; i++) {
		if (i * 8 / 100 == a && i / 10 == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
}


Measured memory_bytes: 256
S_ = input()
T = input()
len_s, len_t = len(S_), len(T)
i = len_s - len_t
ans = "UNRESTORABLE"
while i != -1:
    isAns = True
    for j in range(len_t):
        if S_[i + j] != '?' and S_[i + j] != T[j]:
            isAns = False
            break
    if isAns:
        ans = S_[:i] + T + S_[i + len_t:]
        ans = ''.join([c if c != '?' else 'a' for c in ans])
        break
    i -= 1
print(ans)


Measured memory_bytes: 3064