akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */

vector<int>color(100000, -1);
vector<vector<P>> G;
void dfs(int i){
    for(pair<int, int> next : G[i]){
        if(color[next.first] == -1){
            if(next.second % 2){
                color[next.first] = !color[i];
            }else{
                color[next.first] = color[i];
            }
            dfs(next.first);
        }
    }
}
int main(){
    int N; cin >> N;
    G.resize(N);
    rep(i, N - 1){
        int u, v, w; cin >> u >> v >> w;
        --u;--v;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    color[0] = 0;
    dfs(0);
    rep(i, N){
        cout << color[i] << endl;
    }
}


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

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  vector<int> b(n + 1);
  while (k--)
  {
    for (int i = 0; i <= n; i++)
    {
      b[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
      int from = max(i - a[i], 0);
      int to = min(i + a[i], n - 1);
      b[from] += 1;
      b[to + 1] -= 1;
    }
    // for (int i = 0; i <= n; i++)
    // {
    //   cout << b[i] << " ";
    // }
    // cout << endl;
    bool changed = false;
    for (int i = 0; i < n; i++)
    {
      if (a[i] != b[i])
        changed = true;
      a[i] = b[i];
      b[i + 1] += b[i];
    }
    if (!changed)
    {
      break;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (i > 0)
    {
      cout << " ";
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;
    if (x == 2 || x == 11 || x == 12){
        cout << "No" << endl;
    }
    else if (x == 4 || x == 6 || x == 9 ){
        if (y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if (y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
    long N;
    cin >> N;
    long count = 0;
    for(int i = 1; i < (N-i)/i; i++){
        if((N-i)%i == 0){
            count += (N-i)/i;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        long[] h = new long[n];
        for(int i = 0;i < n;i++){
            h[i] = stdIn.nextLong();
        }

        long max = 0L;
        long count = 0L;

        for(int i = 0;i < n-1;i++) {
            if(h[i+1] <= h[i]){
                count++;
            }else{
                if(count > max) {
                    max = count;
                }
                count = 0;
            }
        }

        if(count > max){
            max = count;
        }
        
 
        System.out.println(max);

        
    }

}

Measured memory_bytes: 49148
#include<stdio.h>
int ans[8][8]={0};
void printboard(){
  int i,j;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(ans[i][j]==1) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  return;
}
int check(int a,int b){
  int i,j;
  for(i=0;i<8;i++){
    if(i!=b && ans[a][i]==1) return 0;
  }
  for(i=0;i<8;i++){
    if(i!=a && ans[i][b]==1) return 0;
  }
  i=a;
  j=b;
  for(i++,j++;i<8 && j<8;i++,j++){
    if(ans[i][j]==1)return 0;
  }
  i=a;
  j=b;
  for(i--,j--;i>=0 && j>=0;i--,j--){
    if(ans[i][j]==1)return 0;
  }
  i=a;
  j=b;
  for(i++,j--;i<8 && j>=0;i++,j--){
    if(ans[i][j]==1)return 0;
  }
  i=a;
  j=b;
  for(i--,j++;i>=0 && j<8;i--,j++){
    if(ans[i][j]==1)return 0;
  }
  return 1;
}
int putqueen(int m){
  int i;

  for(i=0;i<8;i++){
    if(ans[m][i]==1){
      if(putqueen(m+1)==0)return 0;
    }
  }


  if(m==8){
    printboard();
    return 1;
  }

  else {
    for(i=0;i<8;i++){
      if(ans[m][i]==0 && check(m,i)==1){
        ans[m][i]=1;
        if(putqueen(m+1)==0){
          ans[m][i]=0;
        }
      }
    }
  }


  return 0;

}

int main(){
  int i,j,t,y,n,m=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&t,&y);
    ans[t][y]=1;
  }
  i=putqueen(m);
  return 0;
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

i64 pow(i64 a, i64 n)
{
  i64 ret = 1;
  for (; 0 < n; n >>= 1, a = a * a)
    if (n % 2 == 1)
      ret *= a;
  return ret;
}

int main()
{
  i64 l, n;
  string snake;
  cin >> l >> n >> snake;
  i64 ans = l, t = (1 - pow(2, n)) / -1;
  for (i64 i = 0; i < l - 1; i++)
    if (snake[i] == 'o' && snake[i + 1] == 'o')
      ans += t * 3;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] arr = new int[h*w];
		int counter = 0;
		for(int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			for(int j = 0; j < a; j++) {
				arr[counter++] = i;
			}
		}
		for(int i = 0; i < h; i++) {
			StringBuilder sb = new StringBuilder();
			if(i % 2 == 0) {
				for(int j = 0; j < w; j++) {
					if(j!=0) sb.append(" ");
					sb.append(arr[w*i+j]);
				}
			} else {
				for(int j = 0; j < w; j++) {
					if(j!=0) sb.append(" ");
					sb.append(arr[w*i-j+w-1]);
				}
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 32736
import java.util.*;
import java.io.*;
public class Main{
    static PrintWriter out;
    static Scanner sc;
    public static void main(String[] args){
        sc=new Scanner(System.in);
        out=new PrintWriter(System.out);

        int t=1;
      //  t=sc.nextInt();
        while(t-->0){
            forEachTestcase();
        }

        out.close();
    }

    static void forEachTestcase(){
        int n=sc.nextInt();
        String ans="";
        String s="ACL";
        for(int i=0;i<n;i++){
            ans+=s;
        }
        System.out.println(ans);
    }

    static class modOpeation{
        static long mod;
        modOpeation(long mod){
            this.mod=mod;
        }
        static long mul(long a,long b){
            a%=mod;
            b%=mod;
            return (a*b)%mod;
        }
        static long add(long a,long b){
            a%=mod;
            b%=mod;
            return (a+b)%mod;
        }
        static long sub(long a,long b){
            a%=mod;
            b%=mod;
            return ((a-b)%mod+mod)%mod;
        }
        static long modPow(long a,long b){
            long ans=1;
            while(b>0){
                if(b%2==1)ans=mul(ans,a);
                a=mul(a,a);
                b>>=1;
            }
            return ans;
        }
        static long modInv(long a){
            return modPow(a,mod-2);
        }
        static long ifact[],fact[];
        static long nCr(int n,int r){
            if(r>n)return 0;
            return mul(fact[n],mul(ifact[r],ifact[n-r]));
        }
        static void initFactorial(int max){
            fact=new long[max];
            ifact=new long[max];
            fact[0]=ifact[0]=1;
            for (int i = 1; i <max ; i++) {
                fact[i]=mul(fact[i-1],i);
                ifact[i]=mul(ifact[i-1],modInv(i));
            }
        }
    }

}

Measured memory_bytes: 39396
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++)  cin >> h[i];

    long long dp[100010];
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),sum=0;
    int[] a=new int[n];
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++) {
    	if(a[i]%2==0)a[i]=1;
    	else a[i]=2;
    }
    for(int i=0;i<n;i++) {
    	int count=1;
    	for(int j=0;j<n;j++) {
    		if(j==i) count*=a[j];
    		else if(j>i)count*=3;
    		else count*=3-a[j];
    		//System.out.println(count);
    	}
    	sum+=count;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n+m);
  rep(i, n){
    int k;
    cin >> k;
    rep(j, k){
      int l;
      cin >> l;
      uf.unite(i, l+n-1);
    }
  }

  bool ans = false;
  rep(i, n-1){
    if(uf.same(i, i+1) == false) ans = true;
  }
  if(ans == false) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

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

  return 0;
}

Measured memory_bytes: 8464
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; ll cnt = 0;
  
  for(auto c : s){
    if(c == 'x') cnt++;
  }
  
  if(cnt <= 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <map>
#include <cstring>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000

string S;
int X;
int main(){
    cin >> X;

    int hv = 0;

    hv = (X / 500) * 1000 + (X % 500) / 5 * 5;

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


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    int n;
    unsigned long long int res = 0;
    cin >> n;
    long long int before = 0;

    for(int i = 0; i < n; i++ ){
        long long int a;
        cin >> a;
        res += (a+before)/2;
        before = (a+before)%2;
        if(a == 0)before =  0;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		char[] decode = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
		char[] encode = new char['Z' + 'z'];
		for (int i = 0; i < decode.length; i++) {
			encode[decode[i]] = (char)i;
		}

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] a = sc.nextIntArray(n);
			char[] c = sc.next().toCharArray();
			int m = c.length;

			int id = 0;
			for (int i = 0; i < m; i++) {
				int k = a[id++];
				if (n <= id) id = 0;

				int v = encode[c[i]];
				v = (v - k + decode.length) % decode.length;
				c[i] = decode[v];
			}

			System.out.println(c);
		}
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 17212
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #1_indexed
for i in range(1,N+1):
    w,v = wv[i-1]
    for j in range(W+1):
        if j-w>=0:
            dp[i][j] = max(dp[i][j],dp[i-1][j-w]+v)
        dp[i][j] = max(dp[i][j],dp[i-1][j])
print(dp[-1][-1])


Measured memory_bytes: 120940
n=int(input())
a=list(map(int,input().split()))
ans=[]
b_1=0
for i in range(n):
    if i%2==0:
        b_1+=a[i]
    else:
        b_1-=a[i]
ans.append(str(b_1))
for i in range(1,n):
    ans.append(str(a[i-1]*2-int(ans[-1])))
print(' '.join(ans))
    


Measured memory_bytes: 17228
#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, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> s(n);
    vector<char> ans(n);
    rep(i, n) cin >> s.at(i);

    bool ok = true;

    auto next = [&](int i, int& x, int& y) {
        if(x + y == 0) {
            ok = false;
            return ok;
        }
        if(x == 0) {
            ans.at(i) = s.at(i).at(0);
            x++; y--;
        } else if (y == 0) {
            ans.at(i) = s.at(i).at(1);
            x--; y++;
        } else {
            if(i < n-1 && s.at(i+1).find(s.at(i).at(0)) != string::npos) {
                ans.at(i) = s.at(i).at(0);
                x++; y--;
            } else {
                ans.at(i) = s.at(i).at(1);
                x--; y++;
            }
        }
        return true;
    };

    rep(i, n) {
        if(s.at(i) == "AB") {
            if(!next(i, a, b)) break;
        } else if(s.at(i) == "AC") {
            if(!next(i, a, c)) break;
        } else if(s.at(i) == "BC") {
            if(!next(i, b, c)) break;
        }
    }

    if(ok) {
        cout << "Yes" << endl;
        rep(i, n) cout << ans.at(i) << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 6440
import sys
from collections import deque

readline = sys.stdin.readline

n, m = map(int, input().split())
G = [[]for i in range(n+1)]
for i in range(m):
    a, b = map(int, readline().split())
    G[a].append(b)
    G[b].append(a)

ans = [0]*(n+1)

stk = deque([1])

while stk:
    v = stk.pop()
    for s in G[v]:
        if ans[s] == 0:
            ans[s] = v
            stk.appendleft(s)
ans = ans[2:]

if 0 in ans:
    print("No")
else:
    print("Yes")
    for i in ans:
        print(i)

Measured memory_bytes: 34640
a,b,c,d,e,f = map(int, input().split())

ans_cons = 0
whole_weight = 100 * a
suger_weight = 0

water = []
suger = []

for i in range(f//(100*a)+1):
  for j in range(f//(100*a)+1):
    w = 100 * a * i + 100 * b * j
    if w <= f:
      water.append(w)

for k in range(f-(100*a)+1):
  for l in range(f-(100*a)+1):
    s = c * k + d * l
    if s <= f:
      suger.append(s)
for wa in water:
  for su in suger:
    if (wa + su) == 0:
      continue
    if (wa + su) > f:
      continue
    cons = su * 100 / (wa + su)
    limit = e * 100 / (100 + e)

    if cons > limit:
      continue

    if cons > ans_cons:
      ans_cons = cons
      whole_weight = wa + su
      suger_weight = su

print("{} {}".format(whole_weight, suger_weight))

Measured memory_bytes: 12436
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;
 
int main(){
int a,b;
  cin>>a>>b;
  
 if(a*b == 1){
 cout << "Odd"<<endl;}
  else if((a*b)%2 == 0){
  cout<<"Even"<<endl;
  }else{
  cout<<"Odd"<<endl;}
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,i,x[8];
    char y[100];
    for(i=0;i<7;i++){
        scanf("%d",&x[i+1]);
    }
    gets(y);
    a=strlen(y);
    for(i=0;i<a;i++){
        if(y[i]=='S'){x[0]=x[1];x[1]=x[5];
            x[5]=x[6];x[6]=x[2];x[2]=x[0];}
        else if(y[i]=='N'){x[0]=x[1];x[1]=x[2];
            x[2]=x[6];x[6]=x[5];x[5]=x[0];}
        else if(y[i]=='E'){x[0]=x[1];x[1]=x[4];
            x[4]=x[6];x[6]=x[3];x[3]=x[0];}
        else if(y[i]=='W'){x[0]=x[1];x[1]=x[3];
            x[3]=x[6];x[6]=x[4];x[4]=x[0];}
    }
    printf("%d\n",x[1]);
    return 0;
}

Measured memory_bytes: 600
def merge_sort(A):
    if len(A) <= 1:
        return A, 0
    mid = len(A) // 2
    left, lcount = merge_sort(A[:mid])
    right, rcount = merge_sort(A[mid:])
    merged, count = merge(left, right)
    return merged, lcount + rcount + count

def merge(left, right):
    lpos = 0
    rpos = 0
    #lcount = 0
    #rcount = 0
    merged = []
    while lpos < len(left) and rpos < len(right):
        if left[lpos] <= right[rpos]:
            merged.append(left[lpos])
            lpos += 1
            #lcount += 1
        else:
            merged.append(right[rpos])
            rpos += 1
            #rcount += 1
    
    if left[lpos:]:
        merged.extend(left[lpos:])
        #lcount += len(left[lpos:])
    if right[rpos:]:
        merged.extend(right[rpos:])
        #rcount += len(right[rpos:])
    
    #print merged
    #return merged, lcount + rcount
    return merged, len(merged)

if __name__ == '__main__':
    n = int(raw_input())
    A = map(long, raw_input().split())
    
    sorted, count = merge_sort(A)
    print ' '.join(str(x) for x in sorted)
    print count

Measured memory_bytes: 62932
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
a=lmp()
l=[]
heapq.heapify(l)
for i in a:
    heapq.heappush(l,(-1)*i)
for i in range(m):
    j=heapq.heappop(l)
    heapq.heappush(l,-(-j//2))
print(-sum(l))

Measured memory_bytes: 21980
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 105
using namespace std;
char s1[maxn], s[maxn];
int len;
int ans = 0x3f3f3f3f;
int check(char ch, int len){
	for(int i = 0; i < len; i++){
		if(s[i] != ch) return 0;
	}
	return 1;
}
void work(int x){
	for(int i = 0; i < len; i++) s[i] = s1[i];
	char now = x + 'a';
	int cur_ans = 0;
	int cur_len = len;
	while(!check(now, cur_len)){
		for(int i = 0; i < cur_len; i++){
			if(s[i] == now || s[i+1] == now){
				s[i] = now;
			}
		}
		cur_len--;
		cur_ans++;
	}
	ans = min(ans,cur_ans);
}
int main(){
	//freopen("main.in","r",stdin);
	scanf("%s",s1);
	len = strlen(s1);
	for(int i = 0; i < 26; i++){
		work(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, M, Q;
int L[201010], R[201010];
int ans[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> Q;

    rep(i, 0, N) L[i] = i - 1, R[i] = i + 1;
    L[0] = N - 1;
    R[N - 1] = 0;

    rep(i, 0, N) ans[i] = 1;

    int bat = 0;
    rep(_, 0, M) {
        int a; cin >> a;
        if (a % 2 == 0) {
            rep(i, 0, a) bat = R[bat];
        } else {
            rep(i, 0, a) bat = L[bat];
        }

        ans[bat] = 0;
        int l = L[bat];
        int r = R[bat];
        R[l] = r;
        L[r] = l;
        bat = r;
    }

    rep(_, 0, Q) {
        int q; cin >> q;
        printf("%d\n", ans[q]);
    }
}



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

int main(){
  int A,B;
    cin>>A>>B;
  if(A==B||A==(B+1)||(A+1)==B){
    cout<<A+B;
  }
  else if(A>(B+1)){
    cout<<A+(A-1);
  }
  else if((A+1)<B){
    cout<<B+(B-1);
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

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

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

int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  for(int i = 0; i < n; i++) cin >> t[i];

  ll ans = t[0];
  for(int i = 0; i < n; i++) {
    ans = lcm(ans, t[i]);
  }

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


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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

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

	vector<int> mway(n, -1);
	mway[0] = 0;
	queue<int> q;
	q.push(0);
	vector<int> ans(n, -1);
	ans[0] = 0;
	while (q.size()) {
		int targ = q.front(); q.pop();
		for (auto x : to[targ]) {
			if (ans[x] == -1) {
				ans[x] = targ;
				q.push(x);
				continue;
			}
		}
	}
	cout << "Yes" << endl;
	rep(i, n) {
		if (i == 0) continue;
		cout << ans[i] + 1 << endl;
	}
	return 0;
} 

Measured memory_bytes: 10604
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define all(x) x.begin(),x.end()
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

//ll modexp(ll x, ll y, ll p)
//{
//	ll res = 1;
//	x = x % p;
//	while (y > 0)
//	{
//		if (y & 1)
//			res = (res * x) % p;
//		y = y >> 1;
//		x = (x * x) % p;
//	}
//	return res;
//}

//ll mulmod(ll a, ll b,ll m)
//{
//	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b)
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

// ll modInv(ll a)
// {
//     ll g = gcd(a, mod);
//     if (g != 1)
//         return -1;
//     else
//         return modexp(a, mod-2, mod);
// }
int main()
{
	fastio;
	ll n=0,ans=0;
	cin>>n;
	map<ll,ll>mp;
	ll ar[n];
	for(auto &i:ar){
       cin>>i;
       ans+=mp[i];
       ++mp[i];
	}
	for(auto &i:ar){
        cout<<ans-mp[i]+1<<"\n";
	}

   	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef map<int, int> MII;
typedef map<int, VI> MIVI;
typedef map<LL, LL> MLLLL;
typedef map<LL, VLL> MLLVLL;

template<typename T>
void dbg(T a)
{
      #ifdef LOCAL
            cerr<<a<<"\n";
      #endif
}

template<typename T, typename ...Arg>
void dbg(T a,Arg ...arg)
{
      #ifdef LOCAL
            cerr<<a<<" ";
            dbg(arg...);
      #endif
}

const int maxn = (1e6)+7;
const int inf = (1e9)+7;
const LL LLinf = (1e18)+7;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int suma(int a)
{
      int r = 0;
      while(a > 0)
      {
            r += a % 10;
            a /= 10;
      }
      return r;
}

int main()
{
      _upgrade
      int n;
      cin>>n;
      int res = n;
      for(int i = 1; i < n ;i++)
            res = min(res, suma(i) + suma(n - i));
      cout<<res;
      return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;
VI A;


int solve(){
	VI B;
	rep(i, 0, N) B.pb(abs(N-1-2*i));
	sort(ALL(B));
	if(A != B) return 0;
	int ans = 1;
	rep(i, 0, N/2) ans = MUL(ans, 2);
	return ans;
}


signed main(){
	cin >> N;

	rep(i, 0, N){
		int a;
		cin >> a;
		A.pb(a);
	}

	sort(ALL(A));

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 2548
N=int(input())
a=list(map(int,input().split()))

d={}
for h in range(1,N):
    if a[h] in d:
        d[a[h]]+=1
    else:
        d[a[h]]=1
ans="Yes"
b=[a[0]]

for h in range(1,N):
    t=a[h]^a[0]
    if t in d:
        b.append(a[h])
        d[a[h]]-=1
        if d[a[h]]==0:
            del d[a[h]]
        break
    if h==N-1:
        ans="No"

if ans=="Yes":
    for i in range(1,N+1):
        if i==h:
            continue
        if i==N:
            t=b[-1]^b[-2]
            if t!=b[0]:
                ans="No"
            break
        t=b[-1]^b[-2]
        if t in d:
            b.append(t)
            d[t]-=1
            if d[t]==0:
                del d[t]
        else:
            ans="No"
            break

print(ans)

Measured memory_bytes: 20624
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    println!("{}{}", 2018, s[4..].iter().cloned().collect::<String>());
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  int t=1;
  int cnt=0;
  while(t*2-1<=n){
    cnt++;
    t*=2;
  }

  cout<<cnt<<endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,K,x;
    cin>>N>>K;
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>x;
        sum+=min(x,K-x);
    }
    cout<<2*sum<<endl;
    return 0; 
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String firstLine = sc.nextLine();
		int n = Integer.parseInt(firstLine);
		HashMap<String, Integer> map = new HashMap<>();

		// nの文字列リストを取得
		for (int i = 0; i < n; i++) {
			String line = sc.nextLine();
			if (map.get(line) == null) {
				map.put(line, 1);
			} else {
				map.put(line, map.get(line) + 1);
			}
		}
		String secondLine = sc.nextLine();
		int m = Integer.parseInt(secondLine);
		// mの文字列リストを取得
		for (int i = 0; i < m; i++) {
			String line = sc.nextLine();
			if (map.get(line) == null) {
				map.put(line, -1);
			} else {
				map.put(line, map.get(line) - 1);
			}
		}
		sc.close();

		int max = 0;
		for (String key : map.keySet()) {
			if (max < map.get(key)) {
				max = map.get(key);
			}
		}
		System.out.println(max);
	}

}


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

int main() {
    size_t n;
    cin >> n;
    vector<int> v( n );
    for ( size_t i = 0; i < n; ++i )
        cin >> v.at( i );
    sort( v.begin(), v.end() );
    reverse( v.begin(), v.end() );
    int a = 0;
    for ( size_t i = 0; i < n; ++i ) {
        if ( i % 2 == 0 )
            a += v.at( i );
        else
            a -= v.at( i );
    }
    cout << a;
}


Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

A,B = [0],[0]

for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])

ans,j = 0,m

for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans,i+ j)
print(ans)



Measured memory_bytes: 47512
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
n_list = []
for i in range(26):
  n_list.append(0)
for i in range(len(S)):
  n_list[s_list.index(S[i])] = n_list[s_list.index(S[i])] + 1
num = 1
for i in range(26):
  num = num * (n_list[i]+1)
if num % 2 == 1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <iostream>

int main(){
    int a, b;
    std::cin >> a >> b;

    if (13 <= a)
    {
        std::cout << b << std::endl;
    }
    else if (6 <= a && a <=12)
    {
        std::cout << b / 2 << std::endl;
    }
    else
    {
        std::cout << 0 << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,d,a;
    cin>>n>>d>>a;

    vector<pii> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i].F>>v[i].S;

    sort(all(v));

    vector<int> arr(n,0);
    int ans=0,sum=0,tmp,pos;

    for(int i=0;i<n;++i)
    {
        //cout<<arr[i]<<","<<sum<<"\n";

        sum+=arr[i];

        v[i].S-=sum*a;

        if(v[i].S<=0)
            continue;

        tmp=v[i].S/a+(v[i].S%a!=0);

        //cout<<tmp<<"\n";

        ans+=tmp;

        sum+=tmp;
        pos=upper_bound(all(v),make_pair(v[i].F+2*d,inf))-v.begin();
        if(pos<n)
            arr[pos]-=tmp;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

int main(){
  
  ll n;
  cin>>n;
  int n_ = 0 ;
  string ans;
  while(n_ < n) ans+=')',n_+=ans.size();

  int idx = ans.size()-1;
  ans += string(ans.size(),'(');
  while(n_ !=n){
    int i = idx++;
    while(i>=0&& ans[i]==')' && n_!=n) swap(ans[i],ans[i+1]),i--,n_--;
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll n, m, q;
    cin >> n >> m >> q;

    vvll vec(n, vll(n,0));

    REP(i,m){
        ll l, r;
        cin >> l >> r;
        vec[l-1][r-1]++;
    }

    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            vec[i][j] += vec[i][j-1];
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=n-1;j>0;j--){
            vec[j-1][i] += vec[j][i];
        }
    }

    /*
    REP(i,n){
        REP(j,n){
            cout << vec[i][j] <<" ";
        }
        cout << endl;
    }
    */

    REP(i,q){
        ll s, g;
        cin >> s >> g;
        cout << vec[s-1][g-1] <<endl;
    }

    
    return 0;
}



Measured memory_bytes: 5312
# C - Train Ticket
S = input()
op_cnt = len(S) - 1

for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt-1-j] = '+'
    formula = ''
    for a, b in zip(S, op + ['']):
        formula += a + b
    if eval(formula) == 7:
        print(formula + '=7')
        break

Measured memory_bytes: 3188
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var X = one[2];
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		var tmp = nextIntArray();
		var cost = tmp[0];
		tmp.shift();
		list[i] = {
			cost : cost,
			rikai : tmp
		};
	}
	var max = 1000000000;
	var output = 1000000000;
	for(var i = 0; i < (1 << N); i++){
		var allRikai = new Array(M).fill(0);
		var isOK = true;
		var cost = 0;
		for(var j = 0; j < N; j++){
			if((i & (1 << j)) != 0){
				cost += list[j].cost;
				for(var k = 0; k < M; k++){
					allRikai[k] += list[j].rikai[k];
				}
			//ここにbitが一致したときの処理入れる
			}
		}
		for(var j = 0; j < M; j++){
			if(allRikai[j] < X){
				isOK = false;
			}
		}
		if(isOK){
			output = Math.min(output, cost);
		}
	//ある1つのbit探索を終えたらここに処理を入れる
	}
	if(output == max){
		myout(-1);
	}else{
		myout(output);
	}
}


Measured memory_bytes: 34732
#include <bits/stdc++.h>
using namespace std;
int n;
long long f[20][20][500][500];
struct node {
    int l, r, lc, rc;
    friend inline int operator < (const node &a, const node &b) {
        return a.l == b.l ? a.r == b.r ? a.lc == b.lc ? a.rc < b.rc : a.lc < b.lc : a.r < b.r : a.l < b.l;
    }
};
int a[20];
map < node, long long > mp;
inline long long dp(int l, int r, int lc, int rc) {
    if (l + 1 == r) return 0;
    if (lc < 500 && rc < 500) {
        if (f[l][r][lc][rc]) return f[l][r][lc][rc];
    }
    else if (mp.count({l, r, lc, rc})) return mp[{l, r, lc, rc}];
    long long ans = 1e18;
    for (int i = l + 1; i < r; i++) {
        ans = min(ans, 1ll * (lc + rc) * a[i] + dp(l, i, lc, lc + rc) + dp(i, r, lc + rc, rc));
    }
    if (lc < 500 && rc < 500) f[l][r][lc][rc] = ans;
    else mp[{l, r, lc, rc}] = ans;
    return ans;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    return cout << dp(1, n, 1, 1) + a[1] + a[n] << endl, 0;
}

Measured memory_bytes: 266496
import sys
sys.setrecursionlimit(4100000)
from collections import defaultdict
n = str(input())
seen = defaultdict(int)
for letter in n:
    seen[letter] += 1
res = 0
for key in seen.keys():
    if seen[key] != 2:
        res += 1
if res != 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int img[8][8];

int checker(int i, int j) {
  if (0 <= i && i < 8 && 0 <= j && j < 8) {
    return img[i][j];
  } else {
    return 0;
  }
}

int main() {
  while (!cin.eof()) {
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (cin.eof()) return 0;
        char c;
        cin >> c;
        img[i][j] = c - '0';
      }
    }
    bool flag = false;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (checker(i, j)) {
          if (checker(i,j+1) && checker(i+1,j) && checker(i+1,j+1)) {
            cout << 'A' << endl;
          } else if (checker(i+1,j) && checker(i+2,j) && checker(i+3,j)) {
            cout << 'B' << endl;
          } else if (checker(i,j+1) && checker(i,j+2) && checker(i,j+3)) {
            cout << 'C' << endl;
          } else if (checker(i+1,j) && checker(i+1,j-1) && checker(i+2,j-1)) {
            cout << 'D' << endl;
          } else if (checker(i,j+1) && checker(i+1,j+1) && checker(i+1,j+2)) {
            cout << 'E' << endl;
          } else if (checker(i+1,j) && checker(i+1,j+1) && checker(i+2,j+1)) {
            cout << 'F' << endl;
          } else if (checker(i,j+1) && checker(i+1,j) && checker(i+1,j-1)) {
            cout << 'G' << endl;
          } 
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
  }


  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
  int a,b,c,k;

  scanf("%d%d",&a,&b);

  if(a<b){
    c=a;
    a=b;
    b=c;
  }
  
  while(b>0){
    k=a%b;
    a=b;
    b=k;
    }
  

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

  return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
int main(){
  int n,s,m=0,h=0;
  scanf("%d",&n);
  while(n>=60){
  if(n>=60){
    m=n/60;
    n-=m*60;
  }
  }
  while(m>=60){
    if(m>=60){
    h=m/60;
    m-=h*60;
    }
  }
  printf("%d:%d:%d\n",h,m,n);
  return(0);
}
      

Measured memory_bytes: 1024
"""
- Nを素因数分解する
- N = p[i]^1*p[i]^2...*p[k]^1*p[k]^2...
"""
from collections import Counter
N = int(input())
factors = []
i = 2

while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1
# N == 1
ans = 0
# print(factors)
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)

Measured memory_bytes: 9448