akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int N;
	int M;
	while (cin >> N && N > 0){
		int x_point = 10;
		int y_point = 10;
		int x[N];
		int y[N];
		int count = 0;
		for (int i = 0; i <= N-1; i++){
			cin >> x[i] >> y[i];
		}

		cin >> M;
		char d[M+1];
		int l[M];
		for (int i = 0; i <= M-1; i++){
			cin >> d[i] >> l[i];
		}

		for (int i = 0; i <= M-1; i++){
			while (l[i] > 0){
				//cout << "x_point:" << x_point << "y_point:" << y_point << endl;
				//cout << "i:" << i << endl;
				//cout << "d[i]:" << d[i] << endl;
				for (int j = 0; j <= N-1; j++){
					if ((x_point == x[j])&&(y_point == y[j])){
						count++;
						x[j] = 100;
						y[j] = 100;
					}
				}
				if (d[i] == 'N'){
					y_point++;
					l[i]--;
				}
				else if (d[i] == 'E'){
					x_point++;
					l[i]--;
				}
				else if (d[i] == 'S'){
					y_point--;
					l[i]--;
				}
				else if (d[i] == 'W'){
					x_point--;
					l[i]--;
				}

				if (l[i] == 0){

				//cout << "x_point:" << x_point << "y_point:" << y_point << endl;
				//cout << "i:" << i << endl;
				//cout << "d[i]:" << d[i] << endl;
				for (int j = 0; j <= N-1; j++){
					if ((x_point == x[j])&&(y_point == y[j])){
						count++;
						x[j] = 100;
						y[j] = 100;
					}
				}

			}
			}
		}
		if (count == N){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
		//cout << count << endl;
	}
}

Measured memory_bytes: 1152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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=1e18;
const ll MAX_N=(1<<19);

ll n,N,dat[2*MAX_N-1];//n...segmenttreeの葉の大きさ,N...与えられた数列等の大きさ
ll a[1000000];

ll unit(){
    return 0;//単位元
}

ll calc(ll a,ll b){
    return a+b;//演算
}

//初期化
void init(){
    n=1;
    while(n<N) n*=2;//座標とかであれば n<N ではなく n<(座標の最大値)　下も同様
    //for(int i=0;i<N;i++) dat[i+n-1]=a[i];
    //for(int i=N;i<n;i++) dat[i]=unit();//単位元で埋める
}

void update(ll k,ll s){
    k+=n-1;
    dat[k]=s;//変更する式
    while(k>0){
        k=(k-1)/2;
        dat[k]=calc(dat[2*k+1],dat[2*k+2]);//条件
    }
}

ll query(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||b<=l) return unit();//単位元
    if(a<=l&&r<=b) return dat[k];

    ll m=(l+r)/2;
    ll u=query(a,b,2*k+1,l,m);
    ll v=query(a,b,2*k+2,m,r);
    return calc(u,v);//条件
}
//abc166e

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //ll N;
    cin>>N;
    ll a[N+1];
    for(ll i=1;i<=N;i++) cin>>a[i];
    V<P> d;
    V<ll> dd;
    for(ll i=2;i<=N;i++){
        d.push_back(make_pair(i-a[i],i));
        dd.push_back(i-a[i]);
    } 
    init();
    sort(all(d));
    sort(all(dd));
    for(ll i=0;i<N-1;i++) update(i,1);
    map<ll,ll> mp;
    for(ll i=0;i<N-1;i++){
        mp[d[i].sc]=i;
    }
    ll ans=0;
    for(ll i=1;i<N;i++){
        ll x=lb(all(dd),a[i]+i)-dd.begin();
        ll y=ub(all(dd),a[i]+i)-dd.begin();
        ans+=query(x,y,0,0,n);
        update(mp[i],0);
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 25176
#include<iostream>
#include<array>

using namespace std;

int main(){
    int n,ans=0,time = 0;
    array<int,500>c;
    array<int,500>s;
    array<int,500>f;
    cin>>n;
    for(int i = 0; i<n-1;i++){
        cin>>c.at(i)>>s.at(i)>>f.at(i);
    }

    for(int i = 0; i< n-1; i++){
        ans=s.at(i)+c.at(i);
    for(int j = i+1; j<n-1; j++){
        time = s.at(j);
        while(ans>time){
            time = time + f.at(j);
        }
        ans = time + c.at(j);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;
const int INF=1e9;

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

    vector<int> cost(n,INF);
    vector<int> pare(n,-1);
    pare[0]=0;
    cost[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty())
    {
        int now=que.front();
        que.pop();
        for(auto v:ab[now])
        {
            if(cost[v]==INF || cost[v]>cost[now]+1)
            {
                cost[v]=cost[now]+1;
                pare[v]=now;
                que.push(v);

            }
        }
    }
    bool flag=true;
    for(auto c:pare)
    {
        if(c<0)
        {
            flag=false;
        }
    }
    if(flag)
    {
        sayyes;
        for(int i=1;i<n;i++)
        {
            cout<<pare[i]+1<<endl;
        }
    }
    else
    {
        sayno;
    }
    

}


Measured memory_bytes: 10656
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll r; cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd, log10
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 8)


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


# https://qiita.com/greenteabiscuit/items/31c46ab3ceac07e749d2


n, m = LI()
graph = [[] for _ in range(n)]
v = [False] * n

for i in range(m):
    a, b = LI()
    graph[a - 1].append(b)
    graph[b - 1].append(a)


def dfs(now, depth):
    if v[now - 1]:
        return 0
    if depth == n-1:
        return 1
    ans = 0
    v[now - 1] = True
    for node in graph[now - 1]:
        ans += dfs(node, depth+1)

    v[now - 1] = False
    # ここが大事.上で探索の一つが終わるからリセットしている.

    return ans


print(dfs(1, 0))


Measured memory_bytes: 74724
//কী পেয়েছো তুমি, কী চেয়েছিলে তুমি.? হিসেবটা তোমার বড়ই গড়মিল...!!//
#include <bits/stdc++.h>
#define pi acos(-1)
#define maxn 100001
using namespace std;
typedef long long ll;
const int mx=10000005;
int main()
{
    string s,t="";
    cin>>s;
    int q;
    cin>>q;
    while(q-->0)
    {
        int tc;
        cin>>tc;
        if(tc==1)swap(s,t);
        else
        {
            int l;
            char ch;
            cin>>l>>ch;
            if(l==1)
                t.push_back(ch);
            else
                s.push_back(ch);
        }
    }
    reverse(t.begin(),t.end());
    cout<<t+s<<endl;
}


Measured memory_bytes: 1248
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,m,q;
    cin >>n>>m>>q;
    int l,r;
    vector<vector<int>>map(n+3,vector<int>(n+3,0));
    rep(i,m){
        cin>>l>>r;
        map[l][r]++;
    }

    rep(i,n+1){
        rep(j,n+1){
           
            map[i][j+1]+=map[i][j];
        }
       
    }

    rep(i, n+1)
    {
        rep(j, n + 1)
        {
            map[i+1][j]+=map[i][j];
        //    clog << map[i][j] << " ";
        }
      //  clog << endl;
    }
    rep(i,q){
        cin>>l>>r;
        l--;
        cout<<map[r][r]+map[l][l]-map[r][l]-map[l][r]<<endl;;
    }
    //cout<<ans<<endl;
}

Measured memory_bytes: 1920
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int ans = 0;
    REP(i,n){
        int x;
        cin >> x;
        ans += min(x,k-x)*2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s1;
    while(cin >> s1)
    {
        for(int i=s1.length()-1;i>=0;i--) cout << s1[i];
        cout << "\n";
    }
    return 0 ;
}



Measured memory_bytes: 3232
import java.util.Scanner;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String sentence = "";
		while(sc.hasNext()) {
			sentence += sc.nextLine();
		}

		// アルファベット数格納用
		TreeMap<Character, Integer> countAlph = new TreeMap<>();
		char alphabet = 'a';
		final int ALPHABET_SIZE = 'z' - 'a';
		for(int i=0; i<=ALPHABET_SIZE; i++) {
			countAlph.put(alphabet, 0);
			alphabet++;
		}

		for(int i=0; i<sentence.length(); i++) {
			if(sentence.charAt(i) == ' ') continue;
			String checkChar = String.valueOf(sentence.charAt(i));
			if(Character.isUpperCase(checkChar.charAt(0))) checkChar = checkChar.toLowerCase();
			Pattern p = Pattern.compile("[a-z]");
			Matcher m = p.matcher(checkChar);
			if(m.find()) countAlph.put(checkChar.toCharArray()[0], countAlph.get(checkChar.toCharArray()[0]) + 1);
		}

		// 出力
		alphabet = 'a';
		for(int i=0; i<=ALPHABET_SIZE; i++) {
			System.out.println(String.valueOf(alphabet) + " : " + countAlph.get(alphabet));
			alphabet++;
		}

		sc.close();

	}

}


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

using namespace std;

long long inf=1000000007;

int main(){
	long long n,k;
	cin>>n>>k;
	vector<long long> hoge(n);
	vector<pair<long long,long long>> dis(n,make_pair(-1,-1));

	for(long long i=0;i<n;i++) cin>>hoge.at(i);
	long long now=-1;
	long long cnt=0;
	while(true){
		cnt++;

		if(now==-1){
			now=hoge.at(0);
		}else{
			now=hoge.at(now-1);
		}

		if(dis.at(now-1).first==-1){
			dis.at(now-1).first=cnt;
		}else{
			if(dis.at(now-1).second==-1){
				dis.at(now-1).second=cnt-dis.at(now-1).first;
			}else{
				break;
			}
		}
	}

	for(long long i=0;i<n;i++){
		if(dis.at(i).first==-1) continue;
		long long pre=k;
		pre-=dis.at(i).first;
		if(pre<0) continue;

		if(pre==0){
			cout<<i+1<<endl;
			break;
		}else if(dis.at(i).second!=-1 && pre%dis.at(i).second==0){
			cout<<i+1<<endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 8008
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B = map(int, input().split())
L = [int(v) for v in input().split()]

ans = 0
for i in range(N - 1):
    s = L[i + 1] - L[i]
    ans += min(s * A, B)

print(ans)

Measured memory_bytes: 14172
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
	pw[0]=1;
	for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	pre();
	ll a,b;
	cin>>a>>b;
	if(abs(a-b)>1) cout<<"Alice\n";
	else cout<<"Brown\n";	
	
		
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
int H,W,i,l;
    for(;scanf("%d %d",&H,&W);){
        if(H==0&&W==0){
            break;
        }
        for(i=1;i<=H;i++){
            for(l=1;l<=W;l++){
                printf("#");}
            printf("\n");}
        printf("\n");}
    return 0;
}
 
    
            

Measured memory_bytes: 572
#include <iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

struct ModCalc{
        const long long MOD = 1e9+7;

        long long Permutation(long long n, long long r){
                long long tmp = 1;
                long long i = n;
                while(i!=n-r){
                        tmp *= i;
                        tmp %= MOD;
                        --i;
                }
                return tmp;
        }

        long long Factorial(long long x){
                long long tmp = 1;
                long long i = 1;
                while(i<=x){
                        tmp *= i;
                        tmp %= MOD;
                        ++i;
                }
                return tmp;
        }

        long long FastPow(long long x, long long p){
                if(p==1) return x;
                if(p%2==0){
                        long long sr = FastPow(x, p/2);
                        return (sr*sr)%MOD;
                }else{
                        long long sr = FastPow(x, (p-1)/2);
                        return ((x*sr)%MOD*sr)%MOD;
                }
        }
};

/*long long FastPow(long long x, long long p){
        long long mod = 1e9+7;
        if(p==1) return x;
        if(p%2==0){
                long long sr = FastPow(x, p/2);
                return (sr*sr)%mod;
        }else{
                long long sr = FastPow(x, (p-1)/2);
                return ((x*sr)%mod*sr)%mod;
        }
}

long long Permutation(long long n, long long r, long long cnt=1){
        long long mod = 1e9+7;
        if(cnt==r) return n;
        else return (n*Permutation(n-1, r, cnt+1))%mod;
}

long long Factorial(long long x){
        long long mod = 1e9+7;
        if(x==1) return 1;
        return (x*Factorial(x-1))%mod;
}*/

int main(){
        ll n,a,b,ans;
        cin >> n >> a >> b;
        ModCalc mc;
        ans = mc.FastPow(2, n) - 1;
        ans -= (mc.Permutation(n,a)*mc.FastPow(mc.Factorial(a),MOD-2))%MOD;
        if(ans<0) ans += MOD;
        ans -= (mc.Permutation(n,b)*mc.FastPow(mc.Factorial(b),MOD-2))%MOD;
        if(ans<0) cout << ans+MOD << endl;
        else cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3604
PROGRAM slimes
      IMPLICIT NONE
      INTEGER :: N, ans
      CHARACTER(10**5) :: s
      
      INTEGER :: i
      read*,N
      read*,s
      
      ans = 0
      DO i = 1,N-1
        IF( s(i:i)/=s(i+1:i+1) )THEN
          ans = ans + 1
        END IF
      END DO
      ans = ans + 1
      
      print*,ans
      
      END PROGRAM

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

#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define per(i, a, b) for(int i = a; i >= b; --i)

using namespace std;

#define N 1000005

int n, ans;
char s[N], t[N];
int a[N], sum[N];

int main() {
    scanf ("%d", &n);
    scanf ("%s", s + 1);
    scanf ("%s", t + 1);
    if (s[1] != t[1]) {
        puts("-1");
        return 0;
    }
    int flag = 0;
    rep (i, 1, n) {
        if (s[i] != t[i]) { flag = 1; break; }
    }
    if (!flag) {
        puts("0");
        return 0;
    }
    int tot = n, f = 0, k = 0;
    per (i, n, 1) {
        f += sum[i + k];
        if (t[i] != s[tot] || tot > i) {
            while ((s[tot] != t[i] || tot > i) && tot >= 1) --tot;
            if (tot == i) continue;
            if (tot == 0) {
                puts("-1");
                return 0;
            }
            ++k, ++f;
            sum[i + k - 1] = 0;
            --sum[tot + k - 1];
        }
        ans = max(ans, f);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int maxP=0;
  for(int i = 0; i < N; i++) cin >> vec.at(i);
  long long ans=0;
  for(int i = 0; i < N; i++) ans+=(vec.at(i)-1)*(vec.at(i)-1);
  for(int i = 2; i <= 100; i++){
    long long tmp=0;
    for(int j = 0; j < N; j++){
      tmp += (vec.at(j)-i)*(vec.at(j)-i);
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int arr[13] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    cout << (arr[x] == arr[y] ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
from collections import Counter, deque

N = int(input())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

ca, cb = Counter(A), Counter(B)

cab = ca+cb

if any(c > N for c in cab.values()):
    print('No')
else:
    print('Yes')
    B.rotate(N//2)
    res = []
    while A:
        if A[0] != B[0]:
            A.popleft()
            res.append(str(B.popleft()))
        else:
            B.rotate()
        
    print(' '.join(res))

Measured memory_bytes: 205876
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int a,b,h; cin >> a >> b >> h;
	cout<<((a+b)*h)/2<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

int main()
{
    string s;
    int n;
    cin >> n;
    cin >> s;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            cnt++;
            i+=2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3572
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function Z_Algorithm(s){
  var l=s.length,a=Array(l);
  a[0]=l;
  for(var i=1,j=0;i<l;){
    while(i+j<l && s[j]===s[i+j])++j;
    a[i]=j;
    if(j === 0){++i; continue;}
    var k=1;
    while(i+k<l && k+a[k]<j)a[i+k]=a[k], ++k;
    i += k; j -= k;
  }
  return a;
}

main();
function main(){
  var n = o.a();
  var a = o.l(), b = o.l();
  var c = Array(n), d = Array(n);
  c[0] = a[n-1]^a[0], d[0] = b[n-1]^b[0];
  for(var i = 1; i < n; i++){
    c[i] = a[i-1]^a[i];
    d[i] = b[i-1]^b[i];
  }
  d = d.concat(c).concat(c);
  var za = Z_Algorithm(d);
  var ans = [];
  for(var i = 0; i < n; i++){
    if(za[n+i] >= n){
      ans.push(i+" "+(a[i]^b[0]));
    }
  }
  if(ans.length)console.log(ans.join("\n"));
}

Measured memory_bytes: 114508
#!/usr/bin/env python3
import sys
import math
from collections import defaultdict, deque
import heapq

INF = float("inf")


class Graph(object):
    """グラフを扱うオブジェクト
    """

    def __init__(self, N):
        self.N = N
        self.edges = defaultdict(list)
        pass

    def add_edge(self, from_, to_, weight=1):
        """必ず0インデックスで入力すること。
        """
        self.edges[from_].append([to_, weight])
        self.edges[to_].append([from_, weight])

    def remove_edge(self, from_, to_):
        for t_, w_ in self.edges[from_]:
            if t_ == to_:
                break
        self.edges[from_].remove([t_, w_])
        self.edges[t_].remove([from_, w_])


def shortestPath(g: Graph, s: int):
    """ グラフgにおいて、始点sから各頂点への最短路を求める
    引数
    g: グラフ, s: 始点
    返り値
    dist: 始点からの距離が格納されたリスト
    prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    """
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.edges[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


class UnionFind(object):
    """UnionFind木
    """

    def __init__(self, N):
        self.tree = list(range(N))

    def root(self, i):
        if self.tree[i] == i:
            return i
        else:
            self.tree[i] = self.root(self.tree[i])
            return self.tree[i]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.tree[x] = y


def solve(N: int, a: "List[int]", b: "List[int]"):
    g = Graph(N)
    for x, y in zip(a, b):
        g.add_edge(x-1, y-1, 1)

    dist, prev = shortestPath(g, 0)

    depth = dist[N-1]
    boundary = N-1
    for _ in range((depth-1) // 2):
        boundary = prev[boundary]
    g.remove_edge(boundary, prev[boundary])
    # print(boundary, prev[boundary])

    visited = [False]*N
    countA = 0
    q = deque()
    q.append(0)
    while len(q) > 0:
        curr = q.popleft()
        visited[curr] = True
        countA += 1
        for t_, w_ in g.edges[curr]:
            if visited[t_] == False:
                q.append(t_)
    countB = N-countA
    if countA > countB:
        print("Fennec")
    else:
        print("Snuke")
    # print(countA, countB)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]"
    b = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 59200
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const char E = 'E';
    const char W = 'W';
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    FOR(i,1,n) if (s[i] == E) cnt++;
    int ans = cnt;
    REP(i,n-1) {
        if (s[i] == W) cnt++;
        if (s[i+1] == E) cnt--;
        //cerr << cnt << endl;
        ans = min(ans,cnt);
    }

    cout << ans << '\n';

    return 0;
}

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

int main(){

    int R;
    cin >> R;

    float ans = 2 * R * M_PI;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = scanner.nextInt();
        }
        int cnt = sort(S);
        for (int i = 0; i < n; i++) {
            System.out.print(S[i]);
            if (i < n - 1) {
                System.out.print(" ");
            } else {
                System.out.println("");
            }
        }
        System.out.println(cnt);
    }

    private static int merge(int[] a1, int[] a2, int[] a) {
        int cnt = 0;
        int i1 = 0;
        int i2 = 0;
        while (i1 < a1.length || i2 < a2.length) {
            cnt++;
            if (i1 < a1.length && (i2 >= a2.length || a1[i1] < a2[i2])) {
                a[i1 + i2] = a1[i1++];
            } else {
                a[i1 + i2] = a2[i2++];
            }
        }
        return cnt;
    }

    private static int sort(int[] a) {
        if (a.length < 2) {
            return 0;
        }
        int n1 = a.length / 2;
        int n2 = a.length - n1;
        int[] a1 = new int[n1];
        int[] a2 = new int[n2];
        for (int i = 0; i < n1; i++) {
            a1[i] = a[i];
        }
        for (int i = 0; i < n2; i++) {
            a2[i] = a[n1 + i];
        }
        int cnt = 0;
        cnt += sort(a1);
        cnt += sort(a2);
        return cnt + merge(a1, a2, a);
    }
}

Measured memory_bytes: 169320
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
inline ll read()
{
	ll x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define MOD 1000000007
ll s[MN+5];
int l[MN+5],f[MN+5][2],S[MN+5];
inline int mod(int x){return x<MOD?x:x-MOD;}
int main()
{
	int n,i,x;ll a,b;
	n=read();a=read();b=read();if(a>b)swap(a,b);
	for(i=1;i<=n;++i)s[i]=read();s[0]=-1e18;s[++n]=2e18;
	for(l[1]=i=1;++i<n;)l[i]=s[i]-s[i-1]<a?i:l[i-1];
	for(f[0][1]=S[0]=i=1;i<=n;++i)
	{
		if(s[i]-s[i-1]>=b)f[i][1]=mod(f[i-1][0]+f[i-1][1]);
		if(i>1)
		{
			x=min(i-2,(int)(upper_bound(s,s+n+1,s[i]-b)-s-1));
			if(l[i-1]-1<=x)f[i][0]=mod(S[x]+MOD-(l[i-1]-1>0?S[l[i-1]-2]:0));
		}
		S[i]=mod(S[i-1]+mod((s[i+1]-s[i-1]>=a?f[i][0]:0)+f[i][1]));
	}
	printf("%d",mod(f[n][0]+f[n][1]));
}

Measured memory_bytes: 2560
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
 

 

int main() 
{ 
    ll h,w,m; cin>>h>>w>>m;
    map <ll,ll> r;
    map <ll,ll> c;
    set <pll> s;
    for(int i=0;i<m;i++){
        ll a,b; cin>>a>>b;
        r[a]++;
        c[b]++;
        s.insert(mp(a,b));
    }
    ll m1=0;
    ll f1=-1;
    ll m2=0;
    ll f2=-1;
    ll ans=0;
    for(auto i:r){
       if(m1<=i.second){
           m1=i.second;
           f1=i.first;
       }
    }
    for(auto i:c){
        if(m2<=i.second){
           m2=i.second;
           f2=i.first;
       }
    }
    //cout<<m1<<" "<<m2<<endl;
    for(auto i:c){
        if(s.find(mp(f1,i.first))!=s.end()){
            ans=max(m1+i.second-1,ans);
        }else{
            ans=max(ans,m1+i.second);
        }
    }
    for(auto i:r){
        if(s.find(mp(i.first,f2))!=s.end()){
            ans=max(m2+i.second-1,ans);
        }else{
            ans=max(ans,m2+i.second);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 59440
n=input()
res=0
for i in range(2**len(n)):
    f=[0]
    for j in range(1,len(n)):
        if (i>>j)&1:
            f.append(j)
    f.append(len(n))
    #print(f)
    pre=0
    for j in range(len(f)-1):
        #print(n[f[j]:f[j+1]])
        pre+=int(n[f[j]:f[j+1]])
    ##print(pre)
    res+=pre
print(res//2)

Measured memory_bytes: 40432
#include <stdio.h>

int main(){
  int n,m,pre=1;
  scanf("%d", &n);
  while(n--){
    scanf("%d", &m);
    if(m < pre){
      printf("No\n");
      return 0;
    }
    if(m>pre) --m;
    pre = m;
  }
  printf("Yes\n");
  return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

// ll ret[1000000000000];

ll dfs(ll n){
    if(n <= 1){
        return 1;
    }

    // if(ret[n])return ret[n];

    return dfs(n/2) + dfs(n/2);
}

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

    ll h;  
    cin >> h;

    ll ans = (ll)log2(h);

    cout << (ll)pow(2,ans)*2-1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int X;
  cin >> X;
  ll a = 0, ans = 0;
  while (true) {
    ans++;
    a += X;
    a %= 360;
    if (a == 0) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long 
 
int main() {
  int N;
  cin >> N;
  
  ll int sum = 0;
  
  for(int i = 1; i <= N; ++i) {
    if(i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
 
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3540
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let _n = input::<usize>();
    let s = input::<String>();
    let k = input::<usize>();

    let sk = s.chars().nth(k - 1).unwrap();
    let ans = s
        .chars()
        .map(|c| if c == sk { c } else { '*' })
        .collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

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


Measured memory_bytes: 3136
#include <cassert>
#include <iostream>
#include <vector>

static const int INF = 1 << 30;

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

class DPsolver {

private:
  const int numNode;
  const std::vector<std::vector<int>> parentList;
  std::vector<int> dp;
  std::vector<bool> finished;

public:
  explicit DPsolver(const int numNode_,
                    std::vector<std::vector<int>> &&parentList_)
      : numNode(numNode_), parentList(std::move(parentList_)) {
    assert(static_cast<int>(parentList.size()) == 1 + numNode);
    dp.assign(1 + numNode, -INF);
    finished.assign(1 + numNode, false);
  }

  // DPsolver(const int n) : numNode{n} {
  //   parentList.assign(1 + numNode, {});
  //   dp.assign(1 + numNode, -INF);
  //   finished.assign(1 + numNode, false);
  // }

  // void setEdge(const int fromNode, const int toNode) {
  //   assert(1 <= fromNode and fromNode <= numNode);
  //   assert(1 <= toNode and toNode <= numNode);
  //   parentList[toNode].push_back(fromNode);
  // }

  void solve() {
    for (int i = 1; i <= numNode; ++i)
      evalDP(i);
  }

  int getMax() {
    int result = -1;
    for (auto v : dp)
      chmax(result, v);
    return result;
  }

private:
  int evalDP(const int i) {
    assert(1 <= i and i <= numNode);
    if (finished[i])
      return dp[i];
    if (parentList[i].empty()) {
      dp[i] = 0;
      finished[i] = true;
      return dp[i];
    }
    for (auto j : parentList[i]) {
      assert(1 <= j and j <= numNode);
      chmax(dp[i], evalDP(j) + 1);
    }
    finished[i] = true;
    return dp[i];
  }
};

int main() {
  int numNode;
  int numEdge;
  std::cin >> numNode >> numEdge;
  assert(2 <= numNode and numNode <= 1.0e+5);
  assert(1 <= numEdge and numEdge <= 1.0e+5);
  std::vector<std::vector<int>> parentList(1 + numNode);
  for (int e = 1; e <= numEdge; ++e) {
    int fromNode;
    int toNode;
    std::cin >> fromNode >> toNode;
    assert(1 <= fromNode and fromNode <= numNode);
    assert(1 <= toNode and toNode <= numNode);
    // solver.setEdge(fromNode, toNode);
    parentList[toNode].push_back(fromNode);
  }
  DPsolver solver(numNode, std::move(parentList));
  solver.solve();
  std::cout << solver.getMax() << std::endl;
  return 0;
}


Measured memory_bytes: 10368
X, K, D = map(int, input().split())

Xa = abs(X)
Xs = Xa // D
Xm = Xa % D

if (K <= Xs):
    print(abs(Xa-D*K))
elif (K-Xs) % 2 == 0:
    print(abs(Xm))
else:
    print(abs(D-Xm))


Measured memory_bytes: 9184
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 100000
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int n,val[MAXN+5],cnt[MAXN+5],ans,st;
int dp[MAXN+5],flag[MAXN+5];

int main(){
	n=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read(),w=read();
		val[u]^=w,val[v]^=w;
	}
	for(int i=0;i<n;i++)cnt[val[i]]++;
	for(int i=1;i<=15;i++)ans+=cnt[i]/2,st|=(cnt[i]&1)*(1<<(i-1));
	dp[0]=-1;
	for(int S=1;S<(1<<15);S++)dp[S]=dp[S>>1]+(S&1);
	dp[0]=0;
	for(int S=1;S<(1<<15);S++)
		for(int i=0;i<15;i++)
		if(S&(1<<i))flag[S]^=(i+1);
	for(int S=1;S<(1<<15);S++)
	if(!flag[S]){
		for(int nS=(S-1)&S;nS;nS=(nS-1)&S)
		if(!flag[nS])dp[S]=min(dp[S],dp[nS]+dp[S^nS]);
	}
	printf("%d",ans+dp[st]);
}

Measured memory_bytes: 4416
using System;

class Program{
    static void Main(){
        int N = int.Parse(Console.ReadLine());
        int L, kL;
        string[] str = Console.ReadLine().Split(' ');
        
        L = 0;
        kL = 0;
        for(int i = 0; i < N-1; i++){
            for(int j = 1; j < N; j++){
                L = System.Math.Abs( int.Parse(str[i]) - int.Parse(str[j]) );
                if(L > kL){
                    kL = L;
                }
            }
        }
        Console.WriteLine("{0}", kL);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;


int main()
{
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			break;
		int sum = 0, max_s = -1, min_s = 1001;
		for (int i = 0; i < n; ++i) {
			int s;
			scanf("%d", &s);
			sum += s;
			max_s = max(max_s, s);
			min_s = min(min_s, s);
		}

		sum = sum - max_s - min_s;
		printf("%d\n", sum/(n-2));
	}

	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m,x; cin>>n>>m>>x;
    vector<ll> c(n);
    vector<vector<ll>> a(n,vector<ll>(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m) cin>>a[i][j];
    }

    ll ans=INF;
    rep(bit,(1<<n)){
        vector<ll> level(m);
        ll tmp=0;
        rep(i,n){
            if(bit & (1<<i)){
                tmp+=c[i];
                rep(j,m) level[j]+=a[i][j];
            }
        }
        bool can=true;
        rep(j,m) if(level[j]<x) can=false;
        if(can) ans=min(ans,tmp);
    }
    if(ans!=INF) cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

//D
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int max = M / N; // 最大値 （切り捨て

		for(int i = max; 1 <= max; i--) {
			if(M % i == 0) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "Yes" : "No")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 

	string s;
	cin >> s;
	int c=0;
	for(int i=0; s[i]; i++){
		c += (s[i]-'0');
		c%=9;
	}
	output(c==0);
 
	return 0;
}  

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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 arr[4];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    REP(i, 0, 3) {
        int a, b;
        cin >> a >> b;
        arr[a - 1]++;
        arr[b - 1]++;
    }
    int cnt = 0;
    REP(i, 0, 4) {
        cnt += (arr[i] % 2);
    }
    cout << (cnt <= 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
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 << "100 100" << endl;
    rep(i, 50) {
        rep(j, 100) {
            if (i % 2 == 1) cout << ".";
            else if (i % 2 == 0 && j % 2 == 1 && B > 1) {
                B--;
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    rep(i, 50) {
        rep(j, 100) {
            if (i % 2 == 0) cout << "#";
            else if (i % 2 == 1 && j % 2 == 1 && A > 1) {
                A--;
                cout << ".";
            } else {
                cout << "#";
            }
        }
        cout << endl;
    }

    return 0;
}
// .#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.
// ...............................
// .#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.
// ...............................
// ###############################
//  #.#.#.#.#.#.#

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
bool ex[10][5];
void print(string s)
{
	for(int i=0;i<5;i++)
	{
		if(s[i]-'0'<=4)cout << '*';
		else cout << ' ';
	}
	cout << endl;
	for(int i=0;i<5;i++)
	{
		if(s[i]-'0'<=4)cout << ' ';
		else cout << '*';
	}
	cout << endl;
	for(int i=0;i<5;i++)cout << '=';
	cout << endl;
	for(int i=0;i<5;i++)
	{
		for(int j=0;j<5;j++)
		{
			int p=s[j]-'0';
			if(ex[p][i])cout << '*';
			else cout << ' ';
		}
		cout << endl;
	}
	return;
}
int main()
{
	memset(ex,true,sizeof(ex));
	int l=0,r=5;
	for(int i=0;i<5;i++)
	{
		ex[l][i]=false;
		ex[r][i]=false;
		l++;r++;
	}
	string s;
	bool fir=true;
	while(cin >> s)
	{
		if(fir)fir=false;
		else cout << endl;
		string base;
		int sz=s.size();
		for(int i=0;i<5-sz;i++)base+='0';
		base+=s;
		print(base);
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m ;
  vector<pair<int,int>> AB(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    AB.at(i) = make_pair(a,b);
  }
  sort(AB.begin(),AB.end());
  priority_queue<int> can;
  int d =1,i =0,ans =0;
  while(d<=m){
    for(int j=i;j<n;j++){
      if(AB.at(j).first==d){
        can.push(AB.at(j).second);
      }else{
        i = j;
        break;
      }
    }
    if(!can.empty()){
      ans += can.top();
      can.pop();
    }
    d++;
  }
  cout << ans << endl;
}
      
        




Measured memory_bytes: 1660