akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, N);
  string M = N;
  reverse(all(N));
  print(N == M ? "Yes" : "No");
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_b
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_ints(): return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


N, M, K = read_ints()
for n, m in product(range(N + 1), range(M + 1)):
    # n行,m列塗りつぶすと？
    if K == (M - m) * n + (N - n) * m:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 73800
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,k,a[1 << 17][3],ans[1 << 17][3];

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		for(int j = 0;j <= 2;j++)
		{
			for(int jj = 0;jj <= 2;jj++)
			{
				if(jj == j) continue;
				ans[i][j] = max(ans[i][j],ans[i - 1][jj] + a[i][j]);
			}
		}
	}
	rc(max({ans[n][0],ans[n][1],ans[n][2]}));
}

Measured memory_bytes: 6400
#include<iostream>
using namespace std;
//Ford-Fulkerson O(FE)
#include<algorithm>
#include<utility>
#include<vector>
#include<limits>
template<typename T>
struct MF{
	vector<vector<pair<pair<int,int>,T> > >G;
	vector<int>used;
	MF(int n_=0):G(n_),used(n_,0){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back(make_pair(
			make_pair(to,G[to].size()),cap
		));
		G[to].push_back(make_pair(
			make_pair(from,G[from].size()-1),0
		));
	}
	T dfs(int u,int t,T f,int dfstime)
	{
		if(u==t)return f;
		used[u]=dfstime;
		for(pair<pair<int,int>,T>&e:G[u])
		{
			if(used[e.first.first]<dfstime&&e.second>0)
			{
				T d=dfs(e.first.first,t,min(f,e.second),dfstime);
				if(d>0)
				{
					e.second-=d;
					G[e.first.first][e.first.second].second+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(int dfstime=1;;dfstime++)
		{
			T f=dfs(s,t,numeric_limits<T>::max(),dfstime);
			if(f>0)ret+=f;
			else break;
		}
		return ret;
	}
};
main()
{
	int N,E;
	cin>>N>>E;
	MF<int>mf(N);
	for(int i=0;i<E;i++)
	{
		int u,v,c;cin>>u>>v>>c;
		mf.add_edge(u,v,c);
	}
	cout<<mf.max_flow(0,N-1)<<endl;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    long int A,B,C,D;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%ld %ld %ld %ld", &A,&B,&C,&D);

    if(A*B == C*D){
        printf("%ld",A*B);
        return 0;
    }

    if(A*B > C*D){
        printf("%ld",A*B);
        return 0;
    }

    else{
        printf("%ld",C*D);
        return 0;
    }

    return 0;

}

Measured memory_bytes: 256
import re
a, b = map(int, input().split())
s = input()
p1 = r"\d{"+ str(a) +"}"
p2 = r"\d{"+ str(b) +"}"
if s[a] == "-" and re.fullmatch(p1, s[0:a]) != None and re.fullmatch(p2, s[a+1:]) != None:
        print("Yes")
else:
        print("No")



Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long min = Long.MAX_VALUE;
		for (long i = 1; i <= Math.sqrt(n); i++) {
	        if (n % i == 0) {
          		min = Math.min(min, i - 1 + n / i - 1);
	        }
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23892
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

int T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
int a[N],b[N];
char c[N];

struct Data{
	int x,y;
}d[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	x=read();	y=read();	z=read();
	if (y*z>=x)	puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
	int k, a, b;
    cin >> k >> a >> b;
    for(int i=a; i<=b; i++){
    	if(i%k == 0){
        	cout<< "OK" <<endl;
            return 0;
        }
    }
    cout<< "NG" <<endl;
}

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

int main() {
	string S;
	
	cin >> S;
	int ans = 700;
	if(S[0] == 'o') ans += 100;
	if(S[1] == 'o') ans += 100;
	if(S[2] == 'o') ans += 100;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
using namespace std;

int n,x[100000],y[100000],xmi = INF,ymi = INF,xma = -INF,yma = -INF;

bool C(int a){
	bool f1 = true,f2 = true;
	for(int i = 0;i < n;i++){
		if(min(max(x[i] - xmi,y[i] - ymi),max(xma - x[i],yma - y[i])) > a) f1 = false;
		if(min(max(x[i] - xmi,yma - y[i]),max(xma - x[i],y[i] - ymi)) > a) f2 = false;
	}
	return (f1 || f2);
}

int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		x[i] = a + b;
		y[i] = a - b;
		xmi = min(xmi,x[i]);
		xma = max(xma,x[i]);
		ymi = min(ymi,y[i]);
		yma = max(yma,y[i]);
	}
	int low = 0,up = 1000010;
	while(up - low > 1){
		int mid = (low + up) / 2;
		if(C(mid)) up = mid;
		else low = mid;
	}
	cout << up << endl;
	return 0;
}

Measured memory_bytes: 3848
#include<stdio.h>
#define NUM 100

int main(){
  int i,j,n,count,minj,hoji;
  int a[NUM];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      hoji=a[i];
      a[i]=a[minj];
      a[minj]=hoji;
      count++;
    }
  }

  for(i=0;i<n;i++){
    if(i!=n && i!=0){
      printf(" ");
    }
    printf("%d",a[i]);
  }

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

  return 0;
}



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

int main(){
  int x, a, b, c;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; ++i)
    for (int j = 0; j <= b; ++j)
      for (int k = 0; k <= c; ++k)
        ans += (500 * i + 100 * j + 50 * k == x);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
     char s[100000] ;
     for(int i=0;i<100000;i++){
          s[i] = '#' ;
     }
     cin >> s ;
     int count = 0 ;
     for(int i=0;i<100000;i++){
          if(s[i]!='#') count++ ;
          else break ;
     }
     int i = 0;
     while(s[i]!='#'){
          if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m') i += 5 ;
          else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]!='r') i += 5 ;
          else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r') i += 6 ;
          else if(s[i-5]=='d'&&s[i-4]=='r'&&s[i-3]=='e'&&s[i-2]=='a'&&s[i-1]=='m'&&s[i]=='e'&&s[i+1]=='r') i += 2 ;
          else break ;
     }
     
     if(i+1==count) cout << "YES" ;
     else cout << "NO" ;
}


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

int H,W,arr[60][60];
char ch;

int main()
{
    cin>>H>>W;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
        {
            cin>>ch;
            if(ch=='#')
            {
                arr[i][j]=-10;
                arr[i-1][j-1]++;
                arr[i-1][j]++;
                arr[i-1][j+1]++;
                arr[i][j-1]++;
                arr[i][j+1]++;
                arr[i+1][j-1]++;
                arr[i+1][j]++;
                arr[i+1][j+1]++;
            }
        }
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
            if(arr[i][j]<0)
			cout<<"#";
            else cout<<arr[i][j];
        cout<<endl;
    }   
}

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


int main() {
	long long a,b;
	cin>>a>>b;
	for(int i=a; i>=2; i--){
		if(a%i==0&&b%i==0){
			a/=i;
			break;
		}
	}
	cout<<a*b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << (A ^ B ^ 1 ^ 2 ^ 3) << endl;

    return 0;
}


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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue<int> q;
	vector<int> dist(n, INF);
	vector<int> pre(n, -1);
	dist[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int u : to[v]) {
			if (dist[u] != INF) continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	rep(i, n) {
		if (i == 0)continue;
		int ans = pre[i];
		++ans;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10732
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define LL long long int
const LL MOD = 1e9+7;

pair<int, int> v[N];
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first + a.second > b.first + b.second;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int n, i, turn = 0;
  cin >> n;
  LL ans = 0;
  for (i=0;i<n;i++) cin >> v[i].first >> v[i].second;
  sort(v, v+n, cmp);
  for (i=0;i<n;i++) {
    if (i&1) ans -= v[i].second;
    else ans += v[i].first;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(0, Math.Max(a[3], a[4]) + 1).Min(i => Math.Max(a[3] - i, 0) * a[0] + Math.Max(a[4] - i, 0) * a[1] + 2 * i * a[2]));
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
int main()
{
  int k;
  string s;
  cin >> k >> s;
  if (s.size() > k)
  {
    s = s.substr(0, k) + "...";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[302];	ll ans[302][302];
int main() {
	ll h,w,k;
	cin>>h>>w>>k;
	char a[302][302]; 
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			char now;
			cin>>now;
			a[i][j]=now;
		}
	//	cout << "k";
		for(ll j=0;j<w;j++){
			//cout << "k";
			if(a[i][j]=='#'){
		    	ch[i]=true;
				break;
			}
		}
	}
	ll now=0;
	ll first=0;
	for(ll i=0;i<h;i++){
		if(ch[i]==false){
			continue;
		}
		now++;
		ll cnt=0;
		for(ll j=0;j<w;j++){
			if(a[i][j]=='#'){
				if(cnt!=0){
					now++;
				}
				cnt++;
			}
			ans[i][j]=now;			
			if(first==0){
				first=i;
			}
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(ans[i][j]==0){
				ans[i][j]=ans[first][j];
				continue;
			}
			else{
				first=i;
			}
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cout << ans[i][j]<<" ";
		}
		cout <<endl;
	}	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1536
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = sorted(il())
    l = D[N // 2 - 1]
    r = D[N // 2]
    print(r - l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19848
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
        const numbers = line.split(' ').map(Number);

        let a = numbers[0];
        let b = numbers[1];

        if (a === 0 && b === 0){break;}

        if(a > b){
            const tmp = a;
            a = b;
            b = tmp;
        }
        
        const output = a + ' ' + b;

        console.log(output);
}


Measured memory_bytes: 18828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=205,inf=1e9;
int col[N],f[N][N],n,ans;
char ch[N];
void GG(){
	puts("-1"); exit(0);
}
void dfs(int p,int x){
	if(col[p]==1-x)GG();
	if(col[p]>=0)return; col[p]=x;
	For(i,1,n)if(f[p][i]==1){
		dfs(i,x^1);
	}
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n){
		scanf("%s",ch+1);
		For(j,1,n)f[i][j]=ch[j]=='1'?1:inf;
	}
	memset(col,-1,sizeof(col));
	dfs(1,0);
	For(k,1,n)For(i,1,n)For(j,1,n)f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	For(i,1,n)For(j,i+1,n)ans=max(ans,f[i][j]);
	cout<<ans+1<<endl;
}


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

int main(){
  int n,x;
  cin>>n;
  x = n%10;
  if(x==2 || x==4 || x==5 || x==7 || x==9) cout<<"hon";
  else if(x==0 || x==1 || x==6 || x==8) cout<<"pon";
  else cout<<"bon";
  return 0;
}


Measured memory_bytes: 3640
N,C = list(map(int,input().split()))

program_list = []

for i in range(N):
    s,t,c = list(map(int,input().split()))
    program_list.append((s-0.5,"s",c-1))
    program_list.append((t,"t",c-1))

program_list.sort(key=lambda x:x[0])

c_list=[0 for i in range(C)]
count_list=[0 for i in range(C)]

max_num=0
for i in range(2*N):
    if program_list[i][1]=="s":
        c = program_list[i][2]
        count_list[c]+=1
        c_list[c] = min(1,count_list[c])
        max_num=max(sum(c_list),max_num)
    else:
        c = program_list[i][2]
        count_list[c]-=1
        c_list[c] = min(1,count_list[c])

print(max_num)

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



using namespace std;

int n, a[10000001], mx, cnt;

int main (){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n - 1; i++){
		if(a[i] >= a[i + 1]){
			cnt++;
		}
		if(a[i] < a[i + 1]){
			if(cnt > mx){
				mx = cnt;
			}
			cnt = 0;
		}
	}
	if(cnt > mx){
		mx = cnt;
	}
	cout << mx;
	return 0;
}


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

max_comb = -1
k = lst[0]
mid = k/2
high = 1
low = N-1
while abs(high - low) > 1:
    if mid - lst[(high+low)//2] ==0:
        high = (high+low) // 2
        low = high
        break
    elif mid - lst[(high+low)//2] > 0:
        low = (high+low)//2
    else:
        high = (high+low)//2
p = lst[high] if abs(mid - lst[high]) < abs(mid - lst[low]) else lst[low]
print(k, p)

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

signed main() {
  int h, w, k;
  cin >> h >> w >> k;

  string s[h];
  rep(i, 0, h) cin >> s[i];

  int ans = 1e9;
  rep(mask, 0, 1<<(h-1)){
    V<int> d(h);
    {
      d[0] = 0;
      int tmp = 0;
      rep(i, 0, h-1){
        if(mask>>i & 1) tmp++;
        d[i+1] = tmp;
      }
    }

    int n = __builtin_popcount(mask);
    V<int> cnt(n+1);
    int prev = 0, tmp = 0;
    bool ok = true;
    rep(i, 0, w){
      bool f = false;
      rep(j, 0, h){
        if(s[j][i] == '1'){
          cnt[d[j]]++;
          if(cnt[d[j]] > k){
            f = true;
          }
        }
      }

      if(f){
        cnt.assign(n+1, 0);
        tmp++;

        f = false;
        rep(j, 0, h){
          if(s[j][i] == '1'){
            cnt[d[j]]++;
            if(cnt[d[j]] > k){
              f = true;
            }
          }
        }

        if(f){
          ok = false;
          break;
        }
      }
    }

    if(ok) chmin(ans, tmp+n);
  }

  cout << ans << endl;

  return 0;
}



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

using namespace std;

int main() {
  long long N, D;
  cin >> N >> D;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= D;
  }
  vector<map<long long, long long>> dp(N + 1);
  dp[0][0] = 1;
  for(int i = 0; i < N; i++) {
    for(auto e : dp[i]) {
      long long j = e.first;
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j + A[i]] += dp[i][j];
    }
  }
  cout << dp[N][0] - 1 << endl;
  return 0;
}


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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<int>> B(3, vector<int>(3));
  
  rep(i, 3) {
    rep(j, 3) {
      cin >> A.at(i).at(j);
    }
  }
  
  int n;
  cin >> n;
  
  vector<int> b(n);
  rep(i, n) {
    cin >> b.at(i);
    rep(j, 3) {
      rep(k, 3) {
        if (b.at(i) == A.at(j).at(k)) { B.at(j).at(k) = 1; }
      }
    }
  }
     
  int sum_r, sum_c, sum_rx;
  rep(i, 3) {
    sum_r=0;
    sum_c=0;
    rep(j, 3) {
      sum_r += B.at(i).at(j);
      sum_c += B.at(j).at(i);
    }
    if (sum_r == 3 or sum_c == 3) { 
      cout << "Yes" << endl;
      exit(0);
    }
  }
  
  if (B.at(1).at(1) == 1) {
    if (B.at(0).at(0) == 1 and 
        B.at(2).at(2) == 1) {   
          cout << "Yes" << endl;
          exit(0);
    }
    if (B.at(0).at(2) == 1 and 
        B.at(2).at(0) == 1) {   
          cout << "Yes" << endl;
          exit(0);
    } 
  }
  cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>                                                                                                   
  
  int main(){
     int N;
     std::string S;
     std::cin >> N >> S;
  
     int count = 0;
     for(int i=1; i<N; ++i){
        if(S[i]=='E') ++count;
     }
     int ans = count;
     for(int i=1; i<N; ++i){
        if(S[i-1]=='W') ++count;
        if(S[i]=='E') --count;
        if(ans>count) ans = count;
     }
     std::cout << ans << std::endl;
     return 0;
  }

Measured memory_bytes: 900
n=int(input())
S=input()
anslist=[]
c=0
#3けたの暗証番号なので000~999までの最大1000通り
for i in range(1000):
    c=0
    if i<10:
        i="00"+str(i)
    elif i<100:
        i="0"+str(i)
    else:
        i=str(i)
    tmp=""
    j=0
    while j<n:
        if S[j]==i[0]:
            tmp+=S[j]
            j+=1
            break
        j+=1
    while j<n:
        if S[j]==i[1]:
            tmp+=S[j]
            j+=1
            break
        j+=1
    while j<n:
        if S[j]==i[2]:
            tmp+=S[j]
            j+=1
            break
        j+=1
    if tmp==i:
        anslist.append(tmp)
                        
#print(anslist)
print(len(anslist))

Measured memory_bytes: 68228
#include<bits/stdc++.h>
using namespace std;
int a[101],n;
int main() 
{
	cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    cout<<(*max_element(a+1,a+1+n))-(*min_element(a+1,a+1+n))<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n;

//vector< vector<int> > ans;
set< vector<int>, greater< vector<int> >  > ans;
int a[15];

void rec() {
  vector<int> v;
  rep (i,n) {
    if (!a[i]) break;
    v.push_back(a[i]);
  }
  //ans.push_back(v);
  if (ans.count(v)) return;
  ans.insert(v);

  //rep (i,n) printf("%3d",a[i]); puts("");
  
  rep (i,n-1) {
    for (int j=i+1;j<n;++j) {
      if (a[i] && a[i] - 1 >= a[j] + 1) {
        //printf("%d vs %d -- %d, %d \n", a[i]-1, a[j]+1, i, j);
        bool ok = true;
        //if (i != j-1 && a[j-1] < a[j]+1) ok = false;
        if (j != i+1) {
          for (int k = j-1; k > i ; --k) {
            //printf("%d:%d ", k, a[k]);
            if (a[k] < a[j]+1) ok = false;
          }
          //puts("");
          for (int k = i+1; k < j; ++k) {
            if (a[k] > a[i] - 1) ok = false;
          }
        }
        if (ok) {
          a[i]--; a[j]++;
          rec();
          a[i]++; a[j]--;
        }
      }
      if (!a[j]) break;
    }
  }
}

void solve() {
  ans.clear();
  memset(a, 0, sizeof a);
  a[0] = n;
  //a[0] = 2, a[1] = a[2] = a[3] = 1;
  //a[0] = a[1] = 2, a[2] = 1;
  rec();
  //cout<<ans.size()<<endl;
  foreach(ans,i) {
    rep(j,i->size()) {
      if (j) putchar(' ');
      printf("%d", i->at(j));
    }
    puts("");
  }
  // rep(i,ans.size()) {
  //   rep(j,ans[i].size()) printf("%3d",ans[i][j]);
  //   puts("");
  // }
  //sort(ans.begin(), ans.end());
  //ans.erase(unique(ans.begin(), ans.end()), ans.end());
}

int main() {
  while (cin >> n, n) solve();
  return 0;
}

Measured memory_bytes: 0
/* Filename: ABC073D.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		final int INF = 1 << 29; 
		
		while(input.hasNext()){
			int N = input.nextInt();
			int M = input.nextInt();
			int R = input.nextInt();
			int[] r = new int[R];
			
			for(int i = 0; i < r.length; ++i){
				r[i] = input.nextInt();
			}
			
			int[][] dist = new int[N + 1][N + 1];
			for(int i = 0; i < dist.length; ++i){
				for(int j = 0; j < dist[i].length; ++j){
					dist[i][j] = INF;
				}
				
				dist[i][i] = 0;
				dist[0][i] = 0;
			}
			
			while(M > 0){
				int A = input.nextInt();
				int B = input.nextInt();
				int C = input.nextInt();
				
				if(C < dist[A][B]){
					dist[A][B] = C;
					dist[B][A] = C;
				}
				
				--M;
			}
			
			floyd_warshall(dist);
			boolean[] isVisited = new boolean[R];
			int ans = findShortest(0, 0, R, 0, Integer.MAX_VALUE, isVisited, r, dist);
			
			System.out.println(ans);
		}
	}
	
	private static int findShortest(int prev, int visitedNum, int total, int currentDist, int currentMin, boolean[] isVisited, int[] r, int[][] dist){
		if(visitedNum == total){
			return Math.min(currentDist, currentMin);
		} else{
			for(int i = 0; i < isVisited.length; ++i){
				if(isVisited[i] == false){
					isVisited[i] = true;
					int min = findShortest(r[i], visitedNum + 1, total, currentDist + dist[prev][r[i]], currentMin, isVisited, r, dist);
					currentMin = Math.min(min, currentMin);
					isVisited[i] = false;
				}
			}
		}
		
		return currentMin;
	}
	
	private static void floyd_warshall(int[][] graph){
		for(int mid = 0; mid < graph.length; ++mid){
			for(int u = 0; u < graph.length; ++u){
				for(int v = 0; v < graph[u].length; ++v){
					graph[u][v] = Math.min(graph[u][v], graph[u][mid] + graph[mid][v]);
				}
			}
		}
		
	}
}


Measured memory_bytes: 44380
from statistics import median

n = input()
a_lst = list(map(int, input().split(" ")))

each_b = []
for (i, a) in enumerate(a_lst):
    each_b.append(a - (i + 1))

good_b = median(each_b)

total = 0
for (i, a) in enumerate(a_lst):
    total += abs(a - (good_b + i + 1))

print(int(total))


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

int main()
{
	string str;
	cin>>str;
	int n=str.size();
	string s=str;
	reverse(s.begin(),s.end());
	if(str!=s) {cout<<"No"<<endl;return 0;}
	int first=(n-1)/2;
	string str2(str.begin(),str.begin()+first);
	string str3=str2;
	reverse(str3.begin(),str3.end());
	if(str3!=str2) {cout<<"No"<<endl;return 0;}
	int last=(n+3)/2;
	string str4(str.begin()+last-1,str.end());

	string str5=str4;
	reverse(str5.begin(),str5.end());
	if(str5!=str4) {cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

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

    bool ans = false;

    for (ll i = 0; i <= n; i++){
        for (ll j = 0; j <= m; j++){
            ll b = m*i + n*j - 2*i*j;
            if (k == b){
                ans = true;
                goto out;
            }
        }
    }
    out:

    YesNo(ans);

}

Measured memory_bytes: 3636
h,w,m=[int(i) for i in raw_input().split()]
r=[0 for i in range(h)]
c=[0 for i in range(w)]
d={}
for i in range(m):
    h1,w1=[int(j)-1 for j in raw_input().split()]
    r[h1]+=1
    c[w1]+=1
    x=str(h1)+'#'+str(w1)
    d[x]=d.get(x,0)+1
maxx=max(r)
r1=[]
for i in range(len(r)):
    if maxx==r[i]:
        r1.append(i)
maxx=max(c)
c1=[]
for i in range(len(c)):
    if maxx==c[i]:
        c1.append(i)
maxx1=0;flag=0
for i in r1:
    for j in c1:
        x=str(i)+'#'+str(j)
        if(d.get(x,0)==0):
            maxx1=max(maxx1,r[i]+c[j])
            flag=1
        else:
            maxx1=max(maxx1,r[i]+c[j]-d[x])
    if flag:
        break
print maxx1
        
    


Measured memory_bytes: 162480
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin>>N;
    long long A=N*(N+1)*(N+2)/6;
    for(int i=0;i<N-1;i++){
        long long S,G;
        cin>>S>>G;
        A-=min(S,G)*(N-max(S,G)+1);
    }
    cout<<A<<endl;
}

Measured memory_bytes: 3640
n, m = map(int, input().split())

dic = dict()
for i in range(m):
    p, y = map(int, input().split())
    if not p in dic:
        dic[p] = []
    dic[p].append((y, i+1))

ans = []
for p, l in dic.items():
    l.sort()
    for i, x in enumerate(l):
        ans.append([x[1], str(p).zfill(6) + str(i + 1).zfill(6)])
ans.sort()

for x in ans:
    print(x[1])

Measured memory_bytes: 118756
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<long double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] = 1.0 / a[i];
    }
    long double ans = accumulate(a.begin(), a.end(), 0.0);

    cout << fixed << setprecision(10) << 1.0 / ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

ll func(ll x, ll c, ll d) {
  return x - x / c - x / d + x / (c / __gcd(c, d) * d);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << func(b, c, d) - func(a - 1, c, d) << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n,m,toi;
  cin>>n>>m>>toi;
  
  vector<ll> p(n+2);
  vector<ll> q(m+2);
  p[0]=-INF,p[n+1]=INF;
  q[0]=-INF,q[m+1]=INF;
  rep(i,n) cin>>p[i+1];
  rep(i,m) cin>>q[i+1];

  rep(to,toi){
    ll x;
    cin>>x;
    int a,b,c,d;
    ll sr,sl,tr,tl;

    a=lb(p,x);
    sr=p[a]-x;
    b=ub(p,x);
    sl=x-p[b-1];
    
    c=lb(q,x);
    tr=q[c]-x;
    d=ub(q,x);
    tl=x-q[d-1];

    ll ans=min({max(sr,tr),max(sl,tl),
      2*sr+tl,2*tl+sr,2*sl+tr,2*tr+sl});
    cout << ans << endl;
  }

}

Measured memory_bytes: 4788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 update : [s,t) に xを加算
 query  : [s,t) の　最大(小)値を出力する
 */

/* [0..N-1] */
const ll INIT = 0; // 問題に合わせる
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, init_v);
    }
    
    void lazy_evaluate(int l, int r,int k){
        node[k] += lazy[k];
        if(r - l > 1){
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    void update(int a, int b, ll x) { update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, ll x) {
        lazy_evaluate(l,r,k);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_evaluate(l,r,k);
        }
        else {
            update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            node[k] = min(node[2 * k + 1],node[2 * k + 2]);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        lazy_evaluate(l, r, k);
        if (r <= a || b <= l) return LLONG_MAX; // min : LLONG_MAX , max : LLONG_MIN
        if (a <= l && r <= b) {
            return node[k];
        }
        else {
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    SegTree ST(n);
    int q; cin >> q;
    while(q--){
        int com; cin >> com;
        if(com == 0){
            int s,t,x; cin >> s >> t >> x;
            ST.update(s-1,t,x);
        }else{
            int i; cin >> i;
            cout << ST.query(i-1,i) << endl;
        }
    }
}



Measured memory_bytes: 7068
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    let ab = a+b;
    let ac = a+c;
    let bc = b+c;
    if ab <= ac && ab <= bc {
        println!("{}", ab);
    } else if ac <= ab && ac <= bc {
        println!("{}", ac);
    } else {
        println!("{}", bc);
    }
}


Measured memory_bytes: 4352
from collections import deque

N = int(input())
edges = [[] for _ in range(N + 1)]
ends = []

for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    ends.append(b)

nodes = deque([1])
count = [0] * (N + 1)

while nodes:
    node = nodes.popleft()
    nodes.extend(edges[node])

    c = 0
    for n in edges[node]:
        c += 1 + (c + 1 == count[node])
        count[n] = c

print(max(count))
for i in ends:
    print(count[i])

Measured memory_bytes: 18676
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b)for(int i=a,E=b;i<=E;i++)
#define abs(x)(x>0?x:-(x))
#define ll long long
#define min(a,b)(a<b?a:b)
#define max(a,b)(a>b?a:b)
using namespace std;
const int N=2e5+5;
int n,a[N];
ll s[N],ans,u[4],ma,mi,w1,w2;
void get(){
	ma=mi=u[0];
	fo(i,1,3)ma=max(ma,u[i]),mi=min(mi,u[i]);
	ans=min(ans,ma-mi);
}
void work(int a,int b,int c){
	u[0]=s[a];u[1]=s[b]-s[a];u[2]=s[c]-s[b];u[3]=s[n]-s[c];get();
}
int main(){
	scanf("%d",&n);ans=1e18;
	fo(i,1,n)scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	fo(i,1,n){
		w1=w2=0;
		for(int l=1,r=i,m;m=l+r>>1,l<=r;)
			if(s[m]>=s[i]-s[m])w1=m,r=m-1;else l=m+1;
		for(int l=i+1,r=n,m;m=l+r>>1,l<=r;)
			if(s[m]-s[i]>=s[n]-s[m])w2=m,r=m-1;else l=m+1;
		if(!w1||!w2)continue;
		if(w1<i&&w2<n)work(w1,i,w2);
		if(w1<i&&w2>i)work(w1,i,w2-1);
		if(w1&&w2<n)work(w1-1,i,w2);
		if(w1&&w2>i)work(w1-1,i,w2-1);
	}
	printf("%lld",ans);
}

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

using namespace std;

typedef long long Int;

char conv(int x)
{
	if (x <= 9) return (x + '0');
	return (x - 10 + 'A');
}

int main()
{
	int N, M, Q;
	Int bits[1024], all;

	while (scanf("%d %d %d", &N, &M, &Q) && N){
		for (int i = 0; i < M; i++){
			bits[i] = (1ll << N) - 1;
		}
		all = (1ll << N) - 1;
		Int mask = 0;

		for (int i = 0; i < Q; i++){
			char S[1024], B[1024];
			scanf("%s %s", S, B);

			Int nxt = 0;
			for (int j = N - 1; j >= 0; j--){
				nxt = (nxt << 1) | (S[j] - '0');
			}
			
			mask ^= nxt;

			for (int j = 0; B[j]; j++){
				if (B[j] - '0') bits[j] &= mask;
				else bits[j] &= (~mask & all);
			}
		}

		for (int i = 0; i < M; i++){
			if (__builtin_popcountll(bits[i]) == 1){
				printf("%c", conv(__builtin_ctzll(bits[i])));
			}
			else {
				printf("?");
			}
		}

		printf("\n");
	}

	return (0);
}

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

using namespace std;

int main(){
    char c;
    cin >> c;
    char s[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for(int i=0;i<26;i++){
        if(c==s[i]){
            cout << s[(i+1)%26] << endl;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int X,Y,A,B,C;
   cin >> X >> Y >> A >> B >> C;
   vector<int> p(A),q(B),r(C);
   f(i,0,A){
      cin >> p[i];
   }
   f(i,0,B){
      cin >> q[i];
   }
   f(i,0,C){
      cin >> r[i];
   }
   sort(all(q),greater<int>());
   sort(all(p),greater<int>());
   sort(all(r),greater<int>());
   multiset<int> s;
   f(i,0,X){
      s.insert(p[i]);
   }
   f(i,0,Y){
      s.insert(q[i]);
   }
   f(i,0,C){
      s.insert(r[i]);
   }
   int ans = 0;
   for(auto &e : s) ans += e;
   int cnt = 0;
   for(auto &e : s){
      if(cnt == (int)s.size()-(X+Y)) break;
      ans -= e;
      cnt++;
   }
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

// Aを変形してBにできるか <=> AとBの標準形が一致するか
struct BinaryBasis{
    vector<ll> basis;
    bool update;
    BinaryBasis():update(false){}
    // 基底に加える
    bool add(ll bit){
        for(auto &p:basis) bit=min(bit,bit^p);
        if(bit){
            basis.push_back(bit);
            return update=true;
        }
        else return false;
    }
    // bitを基底で表現できるか
    bool check(ll bit){
        for(auto &p:basis) bit=min(bit,bit^p);
        return bit==0;
    }
    // 掃き出して標準形に
    void normalize(){
        if(update){
            sort(begin(basis),end(basis));
            update=false;
        }
        for(int i=(int)basis.size()-1;i>=0;i--){
            for(int j=i-1;j>=0;j--) basis[i]=min(basis[i],basis[i]^basis[j]);
        }
    }
    bool operator==(BinaryBasis &a){
        normalize(),a.normalize();
        return basis==a.basis;
    }
    // 0-indexedでk番目を返す
    ll get_kth(ll k){
        if((1ll<<basis.size()<=k)) return -1;
        ll ret=0;
        if(update){
            sort(begin(basis),end(basis));
            update=false;
        }
        for(int i=(int)basis.size()-1;i>=0;i--){
            if(k<(1ll<<i)) ret=min(ret,ret^basis[i]);
            else{
                k-=1ll<<i;
                ret=max(ret,ret^basis[i]);
            }
        }
        return ret;
    }
 
    size_t size() const{
        return basis.size();
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    // 奇数個1な桁は考慮したくないから最初に省く

    int n;cin>>n;
    ll t=0;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
        t^=v[i];
    }
    ll ans=0;
    rep(i,60){
        if((t>>i)&1){
            ans+=1ll<<i;
            rep(j,n){
                if((v[j]>>i)&1)v[j]^=(1ll<<i);
            }
        }
    }

    BinaryBasis bs;
    rep(i,n) bs.add(v[i]);
    bs.normalize();
    ll a=0;
    for(auto b:bs.basis) chmax(a,a^b);
    a<<=1;
    ans+=a;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");


var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  let num = line.split(/\s/).map(i => parseInt(i));

  console.log(num[0] * num[1] / 2);
});


Measured memory_bytes: 7628
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::vector<int>> p(1001, std::vector<int>(1001));
  for (size_t i = 0; i < N; ++i) {
    size_t x1, y1, x2, y2;
    scanf("%zu %zu %zu %zu", &x1, &y1, &x2, &y2);
    ++p[x1][y1];
    --p[x1][y2];
    --p[x2][y1];
    ++p[x2][y2];
  }

  for (size_t i = 1; i <= 1000; ++i)
    for (size_t j = 0; j <= 1000; ++j)
      p[i][j] += p[i-1][j];

  for (size_t i = 0; i <= 1000; ++i)
    for (size_t j = 1; j <= 1000; ++j)
      p[i][j] += p[i][j-1];

  int res = 0;
  for (const auto& pi: p)
    res = std::max(res, *std::max_element(pi.begin(), pi.end()));

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



Measured memory_bytes: 6408