akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll a,b;
        cin>>a>>b;
        if(a>=b*2)cout<<a-b*2<<endl;
        else cout<<0<<endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,a,b;
	int as,bs;
	cin>>x>>a>>b;
	as=x-a;
	bs=x-b;
	if(as<0){
		as=fabs(as);
	}if(bs<0){
		bs=fabs(bs);
	}if(as>bs){
		cout<<"B"<<endl;
	}if(bs>as){
		cout<<"A"<<endl;
	} 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String line1 = in.next();
            String line2 = in.next();
            String line3 = in.next();
            StringBuilder res = new StringBuilder();
            res.append(line1.charAt(0));
            res.append(line2.charAt(1));
            res.append(line3.charAt(2));
            System.out.println(res.toString());
        }
    }
}


Measured memory_bytes: 26920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) { cin >> h.at(i);  }
  
  int tmp, ans = 0;
  for(int i = 1; i < n; i++) {
    int t = i - 1;
    if(h.at(t) >= h.at(i)) {
      tmp++;
    }else if(h.at(t) < h.at(i)) {
      tmp = 0;
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
}


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

int dig(int n){
    int ans[10],i = 0;
    while(n > 0){
        ans[i] = n % 10;
        i++;
        n /= 10;
    }
}

int main(void){
    int n,ans[3], i = 0;
    cin >> n;
    if(n <= 111){
        cout << 111 <<endl;
        return 0;
    }else if(n > 111 && n <= 222){
        cout << 222 << endl;
        return 0;
    }else if(n > 222 && n <= 333){
        cout << 333 << endl;
        return 0;
    }else if(n > 333 && n <= 444){
        cout << 444 << endl;
        return 0;
    }else if(n > 444 && n <= 555){
        cout << 555 << endl;
        return 0;
    }else if(n > 555 && n <= 666){
        cout << 666 << endl;
        return 0;
    }else if(n > 666 && n <= 777){
        cout << 777 << endl;
        return 0;
    }else if(n > 777 && n <= 888){
        cout << 888 << endl;
        return 0;
    }else if(n > 888 && n <= 999){
        cout << 999 << endl;
        return 0;
    }
}


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

int main(){
    int N;cin>>N;
    set<int> s;
    for(int i=0;i<N;++i){
        int a; cin >> a;
        s.insert(a);
    }
    int p=s.size();
    cout <<(p%2?p:p-1) <<"\n";
}

Measured memory_bytes: 4992
n, x, y = map(int, input().split())
kyori = []

def clc(i1, i2):
    if (i1 < x and i2 <= x) or (y <= i1 and y < i2):
        return i2 - i1
    else:
        return min(1 + abs(i2 - y) + abs(i1 - x), i2 - i1)

for k in range(1, n+1):
    for l in range(k+1, n+1):
        tmp = clc(k, l)
        kyori.append(tmp)
outs = [0 for _ in range(n-1)]
for k in kyori:
    outs[k-1] += 1
for i in range(n-1):
    print(outs[i])

Measured memory_bytes: 67372
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	set<int> tes;
	for(int i=0;i<N;i++){
		int d;
		cin>>d;
		tes.insert(d);
	}
	cout<<tes.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

flag = 0
for i, s in enumerate(S):
    if i % 2 == 1:
        if s == 'L' or s== 'U' or s=='D':
            continue
        else:
            flag = 1
            break
    else:
        if s == 'R' or s== 'U' or s=='D':
            continue
        else:
            flag = 1
            break

if flag == 1:
    print('No')
else:
    print('Yes')

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

int main(void){
  long i;
  long N;
  int K;
  long ans=0;
  int h;
  scanf("%ld %d",&N,&K);
  // int h[N];

  for(i=0; i<N; i++){
    scanf("%d",&h);
    if(h>=K){
      ans++;
    }
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll A, B, C;
string s;
ll t;
ll ret = 0;

void input() {
  IN(s);
}

void solve() {
  if (s == "SUN") {
    ret = 7;
  }
  if (s == "MON") {
    ret = 6;
  }
  if (s == "TUE") {
    ret = 5;
  }
  if (s == "WED") {
    ret = 4;
  }
  if (s == "THU") {
    ret = 3;
  }
  if (s == "FRI") {
    ret = 2;
  }
  if (s == "SAT") {
    ret = 1;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
  }
  
  sort(m.begin(), m.end());
  
  int sum = 0;
  
  for (int j = 0; j < N; j++) {
    sum += m.at(j);
  }
  
  int a = X - sum;
  
  cout << a / m.at(0) + N << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Nmax = 100;
const ll P = 1000000007;
int N,K;
int A[Nmax];
ll dp[Nmax+1][Nmax+1][256];

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			for(int k=0; k<256; k++){
				dp[i+1][j+1][k] = (dp[i][j][k^A[i]] + dp[i][j+1][k])%P;
			}
		}
		dp[i+1][1][A[i]] += 1;
	}

	/*
	for(int i=0; i<=N; i++){
		for(int j=0; j<=N; j++){
			for(int k=0; k<256; k++){
				if(dp[i][j][k]>0){
					cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
				}
			}
		}
	}
	*/

	ll ans = 0;
	ll fact = 1;
	for(int i=1; i<=N; i++){
		ans = (ans + fact*dp[N][i][K])%P;
		fact = (fact * (i+1))%P;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

	vector< vector<int> > freq;
	for(int j = 0; j < n; j++) {
		vector<int> tmp;
		for(int i = 0; i < 26; i++) {
			tmp.push_back(0);
		}
		freq.push_back(tmp);
	}

	vector<string> in;
	for(int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		in.push_back(tmp);
	}

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < in[i].size(); j++) {
			freq[i][in[i][j] - 'a']++;
		}
	}

	vector<int> mins;
	for(int i = 0; i < 26; i++) {
		mins.push_back(1000000);
		for(int j = 0; j < n; j++) {
			if(freq[j][i] < mins[i]) {
				mins[i] = freq[j][i];
			}
		}
	}
	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < mins[i]; j++) {
			cout << (char) ('a' + i);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int N, L[200], result;
	int i, j, max, add, buf;

	scanf("%d", &N);
	N *= 2;
	for (i = 0; i < N; i++) scanf("%d", &L[i]);

	for (i = 0; i < N; i++) {
		max = L[0];
		add = 0;
		for (j = 1; j < N - i; j++) {
			if (max < L[j]) {
				max = L[j];
				add = j;
			}
		}
		j--;
		buf = L[j];
		L[j] = max;
		L[add] = buf;
	}

	result = 0;
	for (i = 0; i < N; i += 2) {
		result += L[i];
	}
	printf("%d\n", result);

	return 0;
}

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


int gcd(int a, int b);
int A[100001];

int main() {

    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int g = A[0];
    int R[100001], L[100001];
    for (int i = 0; i < N; i++) {
        g =  gcd(g, A[i]);
        R[i] = g;
    }

    g = A[N-1];
    for (int i = N-1; i >= 0; i--) {
        g = gcd(g, A[i]);
        L[i] = g;
    }
/*
    for (int i = 0; i < N; i++) {
        cout << R[i] << ' ';
    }
    cout << '\n';
    for (int i = 0; i < N; i++) {
        cout << L[i] << ' ';
    }
    */

    int ans = 1;

    if ( N > 2) {
        for (int i = 0; i < N-2; i++) {
            int t = gcd(R[i], L[i+2]);
            ans = max(ans, t);
        }
    }
    ans = max(ans, R[N-2]);
    ans = max(ans, L[1]);

    cout << ans << '\n';

}


int gcd(int a, int b) {

  while (b) {
      int temp = a;
    a = b;
    b = temp % b;
  }
  return a;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
    int a,b,c,i,x;
    x=0;
    cin >> a >> b >> c;
    for(i=a;i<=b;i++){
        if(c%i==0){
            x++;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int N, bt, bx, by, t, x, y;
    bool ok = true;
    cin >> N;

    bt = bx = by = 0;
    REP(i, N) {
        cin >> t >> x >> y;
        if (!ok) continue;

        int dist = abs(x - bx) + abs(y - by);
        ok = dist <= (t - bt) && dist % 2 == (t - bt) % 2;
        bt = t, bx = x, by = y;
    }

    if (ok) cout << "Yes" << endl;
    else    cout << "No"  << endl;
    return 0;
}

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

const int MAX = 101000;


int main() {
    int N;
    cin >> N;
    vector<int> dp(MAX,N);
    dp[0]=0;
    for(int i=0;i<N;++i) {
        for(int j=1;i+j<=N;j*=6) dp[i+j] = min(dp[i+j], dp[i]+1);
        for(int j=9;i+j<=N;j*=9) dp[i+j] = min(dp[i+j], dp[i]+1);
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000



int main(){
	
	int R,C,K;
	cin>>R>>C>>K;
	
	vector<vector<long long>> V(R,vector<long long>(C,0LL));
	
	for(int i=0;i<K;i++){
		int r,c,v;
		cin>>r>>c>>v;
		r--;c--;
		V[r][c] = v;
	}
	
	vector<vector<vector<long long>>> dp(R,vector<vector<long long>> (C,vector<long long>(4,0LL)));
	
	for(int i=0;i<R;i++){
		for(int j=0;j<C;j++){
			for(int k=3;k>=1;k--){
				dp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1] + V[i][j]);
			}
			for(int k=0;k<4;k++){
				if(i!=R-1){
					dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
				}
				if(j!=C-1){
					dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
				}
			}
		}
	}
	
	long long ans = 0LL;
	for(int i=0;i<4;i++){
		ans = max(ans,dp.back().back()[i]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 706120
s = input()

if s[0] == 'R':
    if s[1] == 'R':
        if s[2] == 'R':
            print(3)
        else:
            print(2)
    else:
        if s[2]:
            print(1)
        else:
            print(0)
else:
    if s[1] == 'R':
        if s[2] == 'R':
            print(2)
        else:
            print(1)
    else:
        if s[2] == 'R':
            print(1)
        else:
            print(0)


Measured memory_bytes: 8992
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int a = 0;
		int b = N;
		int s = 0;
		
		while(true){
			a = b % 10;
			b = b / 10;
			s += a;
			if(b == 0) break;
		}
		
		System.out.println((N % s == 0) ? "Yes" : "No");
	}
}

Measured memory_bytes: 23636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
    sc.Scan()
    s := sc.Text()
    return strconv.Atoi(s)
}

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

    rs, _ := nextInt()

    s := rs % 60
    rm := rs / 60
    m := rm % 60
    h := rm / 60

    fmt.Printf("%d:%d:%d\n", h, m, s)
}


Measured memory_bytes: 1112
#include<stdio.h>

typedef struct{

  char alf;
  int num;
  int beforei;
  
}key;

int partition(key *,int,int);

void quicksort(key *,int,int);


int main(){

  int i,n,j,point=0;
  key A[100000];

  scanf("%d%*c",&n);

  for(i=0;i<n;i++){

    scanf("%c%d%*c",&A[i].alf,&A[i].num);
    A[i].beforei=i;

  }

  quicksort(A,0,n-1);


  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
    
      if(A[i].num==A[j].num&&A[i].beforei>A[j].beforei){
	printf("Not stable\n");
	point++;
	break;
      }
      if(point==1)break;
    }
    if(point==1)break;
  }

  if(point==0) printf("Stable\n");
  

  for(i=0;i<n;i++){

    printf("%c %d\n",A[i].alf,A[i].num);

  }

  return 0;

}

int partition(key *A,int p,int r){

  int i,j,x;
  key kari;
  
  x=A[r].num;
  i=p-1;

  for(j=p;j<r;j++){

    if(A[j].num<=x){
      i++;
      kari=A[i];
      A[i]=A[j];
      A[j]=kari;
      
    }
  }

  kari=A[i+1];
  A[i+1]=A[r];
  A[r]=kari;
  
    
  return i+1;
}



void quicksort(key *A,int p,int r){

  int q;

  if(p<r){

    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);

  }



  
}

Measured memory_bytes: 1780
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]

E = [[] for _ in [0]*N]
for i,ab in enumerate(AB):
    a,b = ab
    a -= 1
    b -= 1
    E[a].append((b,i))
    E[b].append((a,i))

done = [False]*N
done[0] = True
ans = [0]*(N-1)
q = [(0,0)]
while q:
    i,c0 = q.pop()
    c = 1
    for j,ei in E[i]:
        if done[j]:continue
        done[j] = True
        if c==c0: c+=1
        q.append((j,c))
        ans[ei] = c
        c += 1

print(max(ans))
for out in ans:
    print(out)

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	ll n;
	cin>>n;
	vec<ll> a(n);
	REP(i,n){
		cin>>a[i];
		a[i]-=i+1;
	}

	sort(all(a));

	ll b=a[n/2];
	ll ans=0;
	REP(i,n) ans+=abs(a[i]-b);
	cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.close();
		if(H == 1 || W == 1) {
			System.out.println(1);
			return;
		}
		long h = H % 2 == 0 ? H / 2 : (H / 2) + 1;
		long w = W % 2 == 0 ? W / 2 : (W / 2) + 1;
		long h2 = W / 2; 
		long w2 = H / 2;
		System.out.println((long)(h * w) + (long)(h2 * w2));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N, a[100002], od, ev;
int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", a + i);
		if(a[i] & 1)	od++;
		else ev++;
	}
	if(od & 1)	puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n;
ll a[1 << 17], b[1 << 17];
priority_queue<LP> q;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i] >> b[i];
		q.push({ a[i] + b[i],i });
	}
	int x = 0;
	ll ans = 0;
	while (!q.empty()) {
		LP p = q.top(); q.pop();
		if (x) {
			ans -= b[p.second];
		}
		else {
			ans += a[p.second];
		}
		x ^= 1;
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 998244353
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    int n;
    string str;
    cin>>n;
    cin>>str;
    int num_one = 0;
    for(int i=0;i<n;i++){
        if(str[i] == '1')num_one++;
    }

    if(num_one == 0){
        for(int i=0;i<n;i++){
            cout<<1<<endl;
        }
    }
    else if(num_one == 1){
        ll ans_pos = 0 ,tmp2=1;
        ll arr_pos[n];

        for(int i=n-1;i>=0;i--){
            if(str[i]=='1'){
                ans_pos = tmp2%(num_one+1);
            } 
            arr_pos[i] = tmp2;
            tmp2 = (tmp2*2)%(num_one+1);
        }
        int count =0;
        for(int i=0;i<n;i++){
            count = 0;
            if(str[i]=='0'){
                ll val = (ans_pos + arr_pos[i])%(num_one+1);
                count = 1;
                while(val!=0){
                    val = val%(__builtin_popcount(val));
                    count++;
                }
                cout<<count<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
    }
    else{
        ll ans_neg=0, ans_pos = 0 ,tmp1=1,tmp2=1;
        ll arr_neg[n], arr_pos[n];

        for(int i=n-1;i>=0;i--){
            if(str[i]=='1'){
                ans_neg = ans_neg%(num_one-1) + tmp1%(num_one-1);
                ans_pos = ans_pos%(num_one+1) + tmp2%(num_one+1);
            } 
            arr_neg[i] = tmp1;
            arr_pos[i] = tmp2;
            tmp1 = (tmp1*2)%(num_one-1);
            tmp2 = (tmp2*2)%(num_one+1);
        }
        int count =0;
        for(int i=0;i<n;i++){
            count = 0;
            if(str[i]=='0'){
                ll val = (ans_pos + arr_pos[i])%(num_one+1);
                count = 1;
                while(val!=0){
                    val = val%(__builtin_popcount(val));
                    count++;
                }
                cout<<count<<endl;
            }
            else{
                ll val = (ans_neg - arr_neg[i] + (num_one-1))%(num_one-1);
                count = 1;
                while(val!=0){
                    val = val%(__builtin_popcount(val));
                    count++;
                }
                cout<<count<<endl;
            }
        }
    }
    
    
}

Measured memory_bytes: 6388
#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>;

int main()
{
    int n;
    cin >> n;
    rep(i, 3) {
        if (n % 10 == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

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

Measured memory_bytes: 580
import sys
from math import sqrt


def rec(state, v):
    if state == (1 << N) - 1:
        return cakes[v]
    if dp[state][v] != -1:
        return dp[state][v]

    ret = INF
    for u in range(N):
        if state == 0:
            ret = min(ret, rec(1 << u, u) + cakes[u])
        elif not (state >> u & 1):
            ret = min(ret, rec(state | 1 << u, u) + sqrt(pow(cakes[u] + cakes[v], 2) - pow(cakes[u] - cakes[v], 2)))
    dp[state][v] = ret
    return ret


testcases = [[int(x) for x in line.split()] for line in sys.stdin.readlines()]

for testcase in testcases:
    box, *cakes = testcase
    N = len(cakes)
    INF = box + 1
    dp = [[-1] * N for _ in range(1 << N)]
    print('OK' if rec(0, 0) <= box else 'NA')

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
 
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    set<ll> st;
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    int count=1;
    rep(i,n){
        if(a[i]==a[i+1])count+=1;
        if(a[i]!=a[i+1]) {
            if(count%2==1){ans+=1;}
            count=1;
            }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main(void){
    int n;
    cin >> n;

    v_ll h(n+1);
    
    irep2(i, 1, n) {
        cin >> h[i];    
    }

    v_ll cost(n+5, INF);
    cost[1] = 0;

    irep2(i, 1, n) {
        cost[i+1] = min(cost[i+1], cost[i] + abs(h[i] - h[i+1]));
        cost[i+2] = min(cost[i+2], cost[i] + abs(h[i] - h[i+2]));
    }
    //for(auto c : cost) { cout << c << " "; } cout << endl;
    cout << cost[n] << endl;

	return 0;
}


Measured memory_bytes: 1792
import math

k = int(input().rstrip())


ans = 0
for a in range(1, k + 1):
    if a == 1:
        ans += k * k
    else:
       for b in range(1, k + 1):
            if b == 1:
               ans += k
            else:
                if a == b:
                    tmp = a
                    if tmp == 1:
                        ans += k
                    else:
                        for c in range(1, k + 1):
                            if c == 1:
                                ans += 1
                            else:
                                ans += math.gcd(tmp, c)
                else:
                    tmp = math.gcd(a, b)
                    if tmp == 1:
                        ans += k
                    else:
                        for c in range(1, k + 1):
                            if c == 1:
                                ans += 1
                            else:
                                ans += math.gcd(tmp, c)

print(ans)

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    if (N == M) print("Yes");
    else print("No");
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int main(){
    
    ll X,Y;
    cin >> X >> Y;
    
    ll ans = 0;
    
    while (X <= Y) {
        ans += 1;
        X = 2*X;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[200],p[200];
    unsigned char ss[500];
    
    scanf("%s",s);
    
    strcpy(ss,s);
    strcat(ss,s);
    
    scanf("%s",p);
    
    if(strstr(ss,p)==NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int h=in(),w=in(),n=in(),i,j,k,a[10000],c[100][100],x;
	rep(i,n)a[i]=in();
	i=j=k=0;
	rep(i,n){
		x=0;
		while(x<a[i]){
			c[j][k]=i+1;
			if(j%2==0){
				if(k<w-1)k++;
				else j++;
			}
			else{
				if(k>0)k--;
				else j++;
			}
			x++;
		}
	}
	rep(i,h){
		rep(j,w-1)printf("%d ",c[i][j]);
		print(c[i][j]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAXN = 105;
int main()
{
    double t=100,x;
    int res=0;
    scanf("%lf",&x);
    while(t<x){
        t=t+(ll)(t*0.01);
        res++;
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;
int n,deg[lim],vis[2][lim];
vector<int> adj[2][lim];
void dfs(int x,int s,vector<int>& l,vector<int>& r) {
	if(vis[s][x]==1)
		return;
	vis[s][x] = 1;
	if(s==0)
		l.push_back(x);
	else
		r.push_back(x);
	for(auto y:adj[s][x])
		dfs(y,s^1,l,r);
}

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

    cin>>n;
    for(int i=0;i<n;i++) {
    	int x,y;
    	cin>>x>>y;
    	adj[0][x].push_back(y);
    	adj[1][y].push_back(x);
    	deg[x]++;
    }

    ll ans = 0;
    for(int i=1;i<=100000;i++) {
    	vector<int> l,r;
    	dfs(i,0,l,r);
    	int sum = 0;
    	for(auto x:l)
    		sum += deg[x];
    	ans += l.size()*1LL*r.size() - sum;
    }
    cout<<ans;

	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;
 
struct UF{
    vector<int> par;
    vector<int> sz;
    UF(){}
    UF(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};
 
 
signed main(){
    int n, k, l;
    cin >> n >> k >> l;
    UF u(n), s(n);
    rep(i, 0, k){
        int p, q;
        cin >> p >> q;
        p--; q--;
        u.unite(p, q);
    }
    rep(i, 0, l){
        int p, q;
        cin >> p >> q;
        p--; q--;
        s.unite(p, q);
    }
    map<P, int> mp;
    rep(i, 0, n){
        mp[P(u.find(i), s.find(i))]++;
    }
    rep(i, 0, n){
        cout << mp[P(u.find(i), s.find(i))] << endl;
    }
}

Measured memory_bytes: 18048
import math
N=int(input())

a=N//1.08
b=N//1.08+1

a_=math.floor(a*1.08)
b_=math.floor(b*1.08)

if a_==N:
    print(math.floor(a))
elif b_==N:
    print(math.floor(b))
else:
    print(':(')

Measured memory_bytes: 3060
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P_ = [0]*a
Q_ = [0]*b
for i in range(a):
    P_[i] = P[i]*(-1)

for i in range(b):
    Q_[i] = Q[i]*(-1)

import heapq
heapq.heapify(P_)
heapq.heapify(Q_)

R.sort(reverse=True)

P.sort(reverse=True)
Q.sort(reverse=True)

P_ = P[0:x]
Q_ = Q[0:y]
import heapq
heapq.heapify(P_)
heapq.heapify(Q_)
for i in range(c):
    r = R[i]
    p = heapq.heappop(P_)
    q = heapq.heappop(Q_)
    if p <= r and r <= q:
        heapq.heappush(P_, r)
        heapq.heappush(Q_, q)
    elif q <= r and r <= p:
        heapq.heappush(P_, p)
        heapq.heappush(Q_, r)
    elif p <= q <= r:
        heapq.heappush(P_, r)
        heapq.heappush(Q_, q)
    elif q <= p <= r:
        heapq.heappush(P_, p)
        heapq.heappush(Q_, r)
    else:
        heapq.heappush(P_, p)
        heapq.heappush(Q_, q)
#print(P_)
#print(Q_)
print(sum(P_)+sum(Q_))

Measured memory_bytes: 122920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
using namespace std;
typedef long long ll;
void inputVector(vector<int> * p, int a){ REP(i, a){ int input; cin >> input; p -> push_back(input); }}

int main(int argc, const char * argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> h, d;
  inputVector(&h, n);
  sort(h.begin(), h.end());
  REP(i, n - (k - 1)) {
    d.push_back(h[i + k - 1] - h[i]);
  }
  int D = *min_element(d.begin(), d.end());
  cout << D << endl;
  return 0;
}

Measured memory_bytes: 1400
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		out.println(inint()*inint()%2==0 ? "Even" : "Odd");

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

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

int i,j,r,n,m,s,t,d,q;
int inf=1000000000;

vector<vector<pair<int,int> > > L(1000,vector<pair<int,int> >(0));
vector<int> x(1000,0),y(1000,inf),p(1000,-1);
queue<int> Q;


void scan(int v){
	
	if(y[v]==inf) return;
	for(j=0; j<L[v].size(); j++){
		if(y[v]+L[v][j].second<y[L[v][j].first]){
			p[L[v][j].first]=v;
			y[L[v][j].first]=y[v]+L[v][j].second;
			if(x[L[v][j].first]==0){
				Q.push(L[v][j].first);
				x[L[v][j].first]=1;
			}
		}
	}
	return ;
	
}
int main() {
	
	cin >> n >> m >> r;
	
	y[r]=0;
	for(j=0; j<m; j++){
		cin >> s >> t >> d;
		L[s].push_back({t,d});
	}
	
	Q.push(r);
	Q.push(-1);
	x[r]=1;
	
	i=0;
	while(i<n){
		q=Q.front();
		Q.pop();
		if(q==-1){
			i++;
			Q.push(-1);
		}else{
			x[q]=0;
			scan(q);
		}
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<L[i].size(); j++){
			if(y[i]<inf && y[i]+L[i][j].second<y[L[i][j].first]){
				cout << "NEGATIVE CYCLE" << endl;
				return 0;
			}
		}
	}
	
	for(j=0; j<n; j++){
		if(y[j]==inf){
			cout << "INF" << endl;
		}else{
			cout << y[j] << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    vector<pii> A(N);
    for(int i=0;i<N;i++){
        int n;
        cin>>n;
        A.at(i)=make_pair(n,i+1);
    }
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        cout<<A.at(i).second;
        if(i==N-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
}

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

 const int N = 1000;

int lcs(string X,string Y){
    int C[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m ; ++i) {
        C[i][0] = 0;
    }
    for (int j = 1; j <= n ; ++j) {
        C[0][j] = 0;
    }

    for (int i = 1; i <= m ; ++i) {
        for (int j = 1; j <= n ; ++j) {
         if (X[i] == Y[j]){
             C[i][j] = C[i-1][j-1] + 1;
         }else{
             C[i][j] = max(C[i-1][j],C[i][j-1]);
         }
            maxl = max(maxl,C[i][j]);
        }
    }
    return maxl;
}


int main(){
    string s1,s2;
    int n;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}

Measured memory_bytes: 5128
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin >> h >> w;
	vector<string> mas(h);
	rep(i,h){
		cin >> mas[i];
	}
	vector<vector<int> > dp(h+1,vector<int>(w+1));
	dp[1][1] = 1;
	reps(i,h){
		reps(j,w){
			if(mas[i-1][j-1] == '#') continue;
			(dp[i][j] += dp[i-1][j] + dp[i][j-1]) %= mod;
		}
	}
	cout << dp[h][w] << '\n';
	return 0;	
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    deque<int>q;
    rep(i,n){
        int a; cin>>a;
        if(i%2==0)q.push_back(a);
        else q.push_front(a);
    }
    if(n%2==0){
        rep(i,n){
            if(i!=n-1){cout<<q.front()<<" "; q.pop_front();}
            else cout<<q.front()<<endl;
        }
    }
    else{
        rep(i,n){
            if(i!=n-1){cout<<q.back()<<" "; q.pop_back();}
            else cout<<q.back()<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2944
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    F = [LI() for _ in range(N)]
    P = [LI() for _ in range(N)]

    ans = -INF
    for i in range(1, 2 ** 10):
        tmp = 0
        for j in range(N):
            cnt = 0
            for k in range(10):
                if i >> k & 1:
                    cnt += F[j][k]
            tmp += P[j][cnt]
        ans = max(tmp, ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10084
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  long A=0, B=0;
  cin >> A >> B;
  long C;
  if(B > A){
  	C = B;
  	for(int i; i < B; i++){
  	  if(C % A == 0) break;
  	  C += B;
 	 }
  } else {
    cin >> A >> B;
    C = A;
    for(int i; i < A; i++){
	 if(C % B == 0) break;
  	 C += A;
 	 }
  }
  cout << C;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/15/2018
 
 17:20-17:34 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL K;
LL A[MAX_N],B[MAX_N];
void solve() {
  LL res=0;
  REP(i,N) if((A[i]|K)==K) res+=B[i];
  REPE(i,30) if((K>>i)&1) {
    LL mask=K-(1LL<<i);
    mask|=(1LL<<i)-1LL;
    LL x=0;
    REP(i,N) if((A[i]|mask)==mask) x+=B[i];
    SMAX(res,x);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>K;
  REP(i,N) cin>>A[i]>>B[i];
  solve();
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

bool is_unbalanced(string s)
{
    map<char, int> mp;
    int sz = s.size();
    if (sz < 2)
        return false;
    for (int i = 0; i < sz; i++)
    {
        mp[s[i]]++;
    }

    for (auto &c : mp)
    {
        if (2 * c.second > sz)
            return true;
    }
    return false;
}

string s;

int main()
{
    cin >> s;
    int N = s.size();
    for (int i = 0; i + 1 < N; i++)
    {
        string t = s.substr(i, 2);
        if (is_unbalanced(t))
        {
            cout << i + 1 << " " << i + 2 << "\n";
            return 0;
        }
    }
    if (N == 2)
    {
        cout << -1 << " " << -1 << endl;
        return 0;
    }

    for (int i = 0; i + 2 < N; i++)
    {
        string t = s.substr(i, 3);
        if (is_unbalanced(t))
        {
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    ll *x = new ll[n];
    ll *y = new ll[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x, x+n);

    ll a = x[n/2-1], b = x[n/2];
    
    for (int i = 0; i < n; i++) {
        if (y[i] <= a)
            cout << b << endl;
        else
            cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		x: isize,
		a: isize,
		b: isize,
	}

	if (x-a).abs() < (x-b).abs() {
		println!("A");
	}
	else {
		println!("B");
	}
}



Measured memory_bytes: 2144
import sys
input = sys.stdin.readline
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
def div_game(n):
    zs = []
    li = list(set( prime_factorize(n)))
    #print(li)
    for p in li:
        a = 1
        z = 1        
        while n > 1 and n >= z:
            z = p ** a
            if n % z == 0 and z not in zs:
                n = n/z
                zs.append(z)
                #print(p**a,n,z)
            a += 1
    #print(zs)
    return len(zs)

if __name__ == "__main__":
    n = int(input())
    print(div_game(n))


Measured memory_bytes: 9240
from collections import Counter
s=[1 if i=="R" else -1 for i in input()]
n=len(s)
k=10**100
a=[i+s[i] for i in range(n)]
while k:
  a=[a[i] for i in a]
  k >>= 1
a=Counter(a)
print(*[a[i] for i in range(n)])

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

int main() {
    int N;
    cin >> N;
    vector<int>H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for(int i = 0; i < N-1; i++) {
        if(H[i+1] > H[i]) {
            H[i+1]-=1;
        }
    }    
    for(int i = 1; i < N; i++) {
        if(H[i] < H[i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640