akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int a, b, c, k;

int main() {
	fastio; cin >> a >> b >> c >> k;
	while (b <= a) {
		b *= 2;
		k--;
	}
	while (c <= b) {
		c *= 2;
		k--;
	}
	cout << (k >= 0 ? "Yes" : "No");
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long pa(long long n){
long long s=0;
  while(n>0){
  s++;
    n/=10;
  }
  return s;
}
int main(){
long long n,re,ans=1001001001;
cin>>n;
for(long long a=1;a*a<=n;a++){
  long long b=n/a;
  if(a*b==n){
    re=max(pa(a),pa(b));
    ans=min(ans,re);
  }
}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, m, res; cin >> n >> m; cout << res << endl){
        res = 0;

        vi once(n + 1, true);
        rep(i, m){
            int c, d; cin >> c >> d;

            range(i, c, d){
                once[i] = false;
            }
        }

        res = n + 1 + 2 * count(all(once), false);
    }

	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <iostream>
using namespace std;

char s[200005];
int num[30];

int main()
{
    long long ans=1;
    scanf ("%s",s+1);
    num[s[1]-'a']=1;
    for (int i=2;s[i]!='\0';i++)
        {
        ans+=(long long)(i-1)-(long long)num[s[i]-'a'];
        num[s[i]-'a']++;
        }
    cout << ans;
}


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

int main()
{
    int n,i,j;
    cin>>n;
    int a[n+1][4];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=3;j++) cin>>a[i][j];
    }
    int dp[n+1][4];
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    dp[1][3]=a[1][3];

    for(i=2;i<=n;i++)
    {
       dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
       dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
       dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}


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

int main(){
  int N,M,X;
  cin >>N>>M>>X;
  int a=0;
  int b=0;
  int A;
  for (int i=0;i<M;i++){
    cin>>A;
    if(A<X){
      a++;
    }
    if(A>X){
      b++;
    }
  } 
  cout<<min(a,b)<<endl;
  return 0;
}

    
    
      

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int value,cost;
};

int main(){

	int N,T,S;
	scanf("%d %d %d",&N,&T,&S);

	int dp[T+1];
	for(int i = 0; i <= T; i++)dp[i] = 0;

	Info info[N];

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].value,&info[i].cost);

		for(int time = T; time-info[i].cost >= 0; time--){
			if(time-info[i].cost < S && S < time){
				//Do nothing
			}else{
				dp[time] = max(dp[time],dp[time-info[i].cost]+info[i].value);
			}
		}

		for(int time = 1; time <= T; time++){
			dp[time] = max(dp[time],dp[time-1]);
		}
	}

	printf("%d\n",dp[T]);

	return 0;
}

Measured memory_bytes: 3232
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    s = list(input().rstrip())
    ans = []
    i = 0
    for char in s:
        if char=='0' or char=='1':
            ans.append(char)
        elif char=='B' and len(ans) > 0:
            ans.pop()
    
    print(''.join(ans))    
   
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<vector>
using namespace std;
//上下右左を差すための配列
int keep_nx[4] = {1 , 0 , -1 , 0};
int keep_ny[4] = {0 , 1 , 0 , -1};
vector< vector<bool> > can_Go (20 , vector<bool> (20));   //フィールドで行ける場所

//深さ優先探索
void dfs(int x, int y, int height, int width, int *cnt){
  can_Go[y][x] = false;   *cnt += 1;
  for(int i = 0 ; i < 4 ; i++){
      int nx = x + keep_nx[i], ny = y + keep_ny[i];
      if(0 <= nx && nx < width && 0 <= ny && ny < height && can_Go[ny][nx] == true)
        dfs(nx, ny, height, width, cnt);
  }
}


int main(void){

while(true){
  int width, height, start_x, start_y;    cin >> width >> height;
  if(width == 0 && height == 0)   break;

  for(int i = 0 ; i < height ; i++){
    for(int j = 0 ; j < width ; j++){
      char input;   cin >> input;
      if(input == '.')  can_Go[i][j] = true;
      if(input == '#')  can_Go[i][j] = false;
      if(input == '@'){
        start_x = j;  start_y = i;
      }
    }
  }

  int ans = 0;
  dfs(start_x, start_y, height, width, &ans);

  cout << ans << endl;
}

  return 0;
}


Measured memory_bytes: 3116
import java.io.*;

public class Main {

    public static void main(String... args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            StringBuilder sb = new StringBuilder();
            char[] b = line.toCharArray();
            int p = 0;
            while (p < b.length) {
                switch (b[p]) {
                    case '@':
                        int n = (int) (b[p + 1] - '0');
                        for (int i = 0; i < n; i++)
                            sb.append(b[p + 2]);
                        p += 2;
                        break;
                    default:
                        sb.append(b[p]);
                }
                p++;
            }
            System.out.println(sb.toString());
        }
        br.close();
    }
}

Measured memory_bytes: 16872
def nasu(s):
  x = s
  ma = MC
  su = 0
  L = []
  for i in range(K):
    x = P[x] - 1
    su += C[x]
    L.append(C[x])
    ma = max(ma, su)
    if x == s:
      break
  else:
    return ma
  if su <= 0:
    return ma
  n = i + 1
  div, mod = divmod(K, n)
  ans = (div - 1) * su + ma
  da = div * su
  for i in range(mod):
    da += L[i]
    ans = max(ans, da)
  return ans

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
C = list(map(int, input().split()))
MC = min(C)

ans = MC
for i in range(N):
  ans = max(ans, nasu(i))
print(ans)

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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<vector <int> > dist(n, vector<int>(n));
    vector<int> A, B, C;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            dist[i][j] = i == j ? 0 : 9999;
        }
    }

    for(int i = 0; i < m; i++) {
        int l, r, c;
        cin >> l >> r >> c;
        A.push_back(l-1);
        B.push_back(r-1);
        C.push_back(c);
        dist[A[i]][B[i]] = dist[B[i]][A[i]] = C[i];
    }

    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++) { 
        if(dist[A[i]][B[i]] != C[i]) ans++;
    }

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

Measured memory_bytes: 256
D,G = map(int,input().split())
P = [0]*D
C = [0]*D
for i in range(D):
    P[i], C[i] = map(int,input().split())
s = sum(P)

#dp[i][j] = i問目まででj枚使った時の点数のmax#
dp = [[0 for i in range(s+1)] for j in range(D+1)]
for i in range(D):
    p = P[i]
    c = C[i]
    t = 100*(i+1)
    for j in range(s+1):
        for k in range(p+1):
            if k == p:
                if j >= k:
                    dp[i+1][j] = max(dp[i+1][j],dp[i][j-k]+c+t*k)
            else:
                if j >= k:
                    dp[i+1][j] = max(dp[i][j-k]+t*k,dp[i+1][j])
                else:
                    break
for i in range(s+1):
    if dp[D][i] >= G:
        ans = i
        break
print(ans)

Measured memory_bytes: 3316
n, y = (int(x) for x in input().split())
a = 0
b = 0
c = 0
flag = 0


for s in range(n+1):
    if y-s*10000 == 0 and s == n and flag == 0:
        a = s
        print(a, b, c)
        flag = 1
    else:
        for t in range(n-s+1):
            if y-s*10000-t*5000-(n-s-t)*1000 == 0 and n-s-t >= 0 and flag == 0:
                a = s
                b = t
                c = n-s-t
                print(a, b, c)
                flag = 1
if flag == 0:
    print(-1, -1, -1)


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

using namespace std;
using ll = long long;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> twos(19);
  twos[0] = 1;
  rep(i, 18) { twos[i + 1] = twos[i] * 2; }
  double ans = 0.0;
  if (k <= n) {
    ans += (double)(n - k + 1) / (double)n;
  }
  int m = k - 1 <= n ? k - 1 : n;
  for (int i = 1; i <= m; i++) {
    rep(j, 19) {
      if (k <= i * twos[j]) {
        ans += 1.0 / (double)twos[j] / (double)n;
        break;
      }
    }
  }
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}


Measured memory_bytes: 3768
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut it = buf.split_whitespace().map(|x| x.parse::<i64>().unwrap());
    let n = it.next().unwrap();
    let a = it.next().unwrap();
    let b = it.next().unwrap();

    let num = n / (a + b);
    let res = n % (a + b);

    println!("{}", a * num + std::cmp::min(a, res));
}


Measured memory_bytes: 4352
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    println!("{}", std::cmp::max(0, b - (a - c)));
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll Q;
    cin >> Q;
    while (Q --) {
        ll A, B;
        cin >> A >> B;
        if (A == B) {
            cout << 2 * A - 2 << endl;
        } else {
            if (A > B) {
                swap(A, B);
            }
            if (A + 1 == B) {
                cout << 2 * A - 2 << endl;
            } else {
                ll C = sqrt(A * B);
                if (C * C == A * B) --C;
                if (C * (C + 1) >= A * B) {
                    cout << 2 * C - 2 << endl;
                } else {
                    cout << 2 * C - 1 << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char inputs[6], tmp[51];
  int inputs_shuffle[51][2], inputs_nr[2], stack[52];
  int loop1, loop2, loop3;

  while(1){
    inputs_nr[0] = '\0';
    inputs_nr[1] = '\0';
    
    for(loop1 = 0; loop1 < 51; loop1++){
      inputs_shuffle[loop1][0] = '\0';
      inputs_shuffle[loop1][1] = '\0';
    }
    for(loop1 = 0; loop1 < 52; loop1++){
      stack[loop1] = '\0';
    }


    while((inputs_nr[0] == '\0') || (inputs_nr[1] == '\0')){ // get <n r>
      //      printf("input 'n r'\n");
      scanf("%d %d", &loop1, &loop2);
      
      inputs_nr[0] = loop1;
      inputs_nr[1] = loop2;
      
    if((inputs_nr[0] == 0) && (inputs_nr[1] == 0)) break;    
      
      if((inputs_nr[0] < 1) || (inputs_nr[0] > 50)){
	//	printf("<n> must be more than 1 and less than 50.\n");
	inputs_nr[0] = '\0';      // 1 <= n <= 50
	inputs_nr[1] = '\0';
      }
      
      if((inputs_nr[1] < 1) || (inputs_nr[1] > 50)){
	//	printf("<r> must be more than 1 and less than 50.\n");
	inputs_nr[1] = '\0';      // 1 <= r <= 50
	inputs_nr[0] = '\0';
      }


    }
    
    if((inputs_nr[0] == 0) && (inputs_nr[1] == 0)) break;    
    
    
    for(loop1 = 0; loop1 < inputs_nr[1]; loop1++){  // get <p c>
      
      //      printf("input 'p c'[%d]\n", loop1 + 1);
      scanf("%d %d", &loop2, &loop3);
      
      inputs_shuffle[loop1][0] = loop2;
      inputs_shuffle[loop1][1] = loop3;
      
      
      if((inputs_shuffle[loop1][0] + inputs_shuffle[loop1][1]) > (inputs_nr[0] + 1)){
	//	printf("(p + c) must be less than (%d + 1)\n", inputs_nr[0]);
	loop1--;   //  (p + c) must be less than (n + 1).
      }
      else if((inputs_shuffle[loop1][0] == 0) && (inputs_shuffle[loop1][1] == 0)){
	break;     //  if ((p == 0) && (c == 0)), escape this loop.
      }
    }
    loop1--;
    if((inputs_shuffle[loop1][0] == 0) && (inputs_shuffle[loop1][1] == 0)){
      break;     //  if ((p == 0) && (c == 0)), escape this loop.
    }

    for(loop1 = 0; loop1 < 52; loop1++){  // make the stack
      if(inputs_nr[0] != 0){
	stack[loop1] = inputs_nr[0];
	inputs_nr[0]--;
      }
      else       stack[loop1] = '\0';
    }
    // stack[0], stack[1], stack[2], .......
    //       n ,      n-1,      n-2, .......
    
    loop1 = 0;
    
    while(((inputs_shuffle[loop1][0] != 0) && (inputs_shuffle[loop1][1] != 0)) && loop1 != 51){
      
      for(loop2 = 0; loop2 < (inputs_shuffle[loop1][0] - 1); loop2++){ //
	tmp[loop2] = stack[loop2];
      }
      
      for(loop3 = 0; loop3 < inputs_shuffle[loop1][1]; loop3++, loop2++){
	stack[loop3] = stack[loop2];
      }
      
      for(loop2 = 0; loop2 < (inputs_shuffle[loop1][0] - 1); loop2++, loop3++){
	stack[loop3] = tmp[loop2];
      }
      
      for(loop2 = 0; loop2 < 52; loop2++){
	tmp[loop2] = '\0';
      }
      
      loop1++;
    }
    
    printf("%d\n", stack[0]);
    
  }
  return 0;
  
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int a, b;

int main() {
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATenki solver = new ATenki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATenki {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            String str = s.nextString();
            String str1 = s.nextString();
            int count = 0;

            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == str1.charAt(i)) {
                    count++;
                }
            }

            out.println(count);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRollerCoaster solver = new BRollerCoaster();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRollerCoaster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] h = in.readIntArray(n);

            int answer = 0;
            for (int x : h) {
                if (x >= k)
                    answer++;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



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

int p[7][7] = {
		{0,		300,	500,	600,	700,	1350,	1650},
		{300,	0,		350,	450,	600,	1150,	1500},
		{500,	350,	0,		250,	400,	1000,	1350},
		{600,	450,	250,	0,		250,	850,	1300},
		{700,	600,	400,	250,	0,		600,	1150},
		{1350,	1150,	1000,	850,	600,	0,		500},
		{1650,	1500,	1350,	1300,	1150,	500,	0}
};
int d[7][7] = {
		{0,	6,	13,	18,	23,	43,	58},
		{6,	0,	7,	12,	17,	37,	52},
		{13,7,	0,	5,	10,	30,	45},
		{18,12,	5,	0,	5,	25,	40},
		{23,17,	10,	5,	0,	20,	35},
		{43,37,	30,	25,	20,	0,	15},
		{58,52,	45,	40,	35,	15,	0}
};

int main () {
	int a, b;
	while (cin >> a, a) {
		int h, m;
		bool half = false;
		cin >> h >> m;
		int s = h * 60 + m;
		if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
		cin >> b;
		cin >> h >> m;
		s = h * 60 + m;
		if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
		a--, b--;
		int price = p[a][b];
		int dist = d[a][b];
		if (dist <= 40 && half) price /= 2;
		cout << price + (price % 50) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 998244353

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n,k ;
int arr[500005] ;
string str ;
int bits[500005] ;
int segTree[1000005] ;
int query(int pos,int low,int high,int qlow,int qhigh)
{
    if(low > high)
        return 0 ;

    if(qlow <= low && qhigh >= high)
        return segTree[pos] ;
    if(qlow > high || qhigh < low)
        return 0 ;
    int mid = (low+high)/2 ;
    int a = query(2*pos+1,low,mid,qlow,qhigh) ;
    int b = query(2*pos+2,mid+1,high,qlow,qhigh) ;
    return a+b ;
}
void update(int pos,int low,int high,int ind,int val)
{
    if(low>high)
    {
        return ;
    }
    if(low == high)
    {
        segTree[pos] += val ;
        return ;
    }
    int mid = (low+high)/2 ;
    if(ind<=mid)
    {
        update(2*pos+1,low,mid,ind,val) ;
    }
    else
    {
        update(2*pos+2,mid+1,high,ind,val) ;
    }
    segTree[pos] = (segTree[2*pos+1]+segTree[2*pos+2]) ;
}
void solve()
{
    cin >> n >> k ;
    vector<pii> v ;
    for(int i=0 ; i<k ; i++)
    {
        int l,r ;
        cin >> l >> r ;
        v.pb({l,r}) ;
    }
    update(0,0,n+1,n,1) ;
    int ans = 0 ;
    for(int i=n-1 ; i>=1 ; i--)
    {
        int temp = 0 ;
        for(int j=0 ; j<k ; j++)
        {
            int l = v[j].fi ;
            int r = v[j].se ;
            if(i+l>n)
                continue ;
            int t = query(0,0,n+1,min(i+l,n),min(i+r,n)) ;
            temp += t ;
            temp %= mod ;
        }
        //suf[i] += suf[i+1] ;
        //cout << i << " " << temp << "\n"  ;
        update(0,0,n+1,i,temp) ;
    }
    cout << query(0,0,n+1,1,1) << "\n" ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 7712
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if ( a > b ){
        cout << "a > b"<< endl;
    } else if ( a == b ) {
        cout << "a == b"<< endl;
    } else {
        cout << "a < b"<< endl;
    }
    return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(2, vector<ll>(N));
    for ( int i = 0; i < 2; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            cin >> A[i][j];
        }
    }
    vector<ll> AL(N), AR(N);
    for ( int i = 0; i < N; i++ ) {
        if ( i > 0 ) AL[i] = AL[i-1];
        AL[i] += A[0][i];
    }
    for ( int i = N-1; i >= 0; i-- ) {
        if ( i < N-1 ) AR[i] = AR[i+1];
        AR[i] += A[1][i];
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ll x = AL[i] + AR[i];
        if ( ans < x ) ans = x;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
	string str;
	cin >> str;
	int c[26] = {0};
	for (int it = 0; it < str.length(); ++it) {
		c[str[it] - 'a']++;
	}
	bool is_even = true;
	for (int it = 0; it < 26; ++it) {
		if (c[it] % 2)
			is_even = false;
	}
	puts(is_even ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
struct Segtree{
    int siz=1;
    vector<int>dat,laz;
    Segtree(int n){
        while(siz<n)siz*=2;
        dat.resize(siz*2-1,0);
        laz.resize(siz*2-1,0);
    }
    void eval(int k,int l,int r){
        if(laz[k]!=0){
            dat[k]+=laz[k];
            if(r-l>1){
                laz[2*k+1]+=laz[k]/2;
                laz[2*k+2]+=laz[k]/2;
            }
            laz[k]=0;
        }
    }
    void update(int a,int b,int x,int k=0,int l=0,int r=-1){
        if(r==-1)r=siz;
        eval(k,l,r);
        if(b<=l||r<=a)return;
        if(a<=l&&r<=b){
            laz[k]+=(r-l)*x;
            eval(k,l,r);
            return;
        }
        update(a,b,x,2*k+1,l,(l+r)/2);
        update(a,b,x,2*k+2,(l+r)/2,r);
        dat[k]=dat[2*k+1]+dat[2*k+2];
    }
    int query(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=siz;
        if(b<=l||r<=a)return 0;
        eval(k,l,r);
        if(a<=l&&r<=b)return dat[k];
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};
int n,q;
signed main(){
    cin>>n>>q;
    Segtree seg(n);
while(q--){
    int typ;
    cin>>typ;
    if(typ==0){
        int s,t,x;
        cin>>s>>t>>x;
        s--,t--;
        seg.update(s,t+1,x);
    }
    else{
        int s,t;
        cin>>s>>t;
        s--,t--;
        cout<<seg.query(s,t+1)<<endl;
    }
}
    return 0;
}


Measured memory_bytes: 7080
#include <stdio.h>


// input 
// n m		<-- n-cup(1<=n<=15)/m-times)1<=m<=15000000)
// n0 a_1,...,a_n0
// n1 b_1,...,b_n1
// n2 c_1,...,c_n2
//
//
//

int DECODE_3Gray2int(int n,int POS[]);

int main(){

	int n,m;
	int n0,a;
	int i;
	int SerialNo;
	int max;
	int POS[16];
	int ans;

	while(scanf("%d %d",&n,&m)!=EOF){
		if(!n&&!m) break;

		for(i=0;i<16;i++)POS[i]=0;

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

//dbg for(i=0;i<n;i++)printf("%d ",POS[i]);puts("");

		SerialNo=DECODE_3Gray2int(n,POS);	//sol. determined from 3-adic/n-bit GrayCode

		max=1;
		for(i=0;i<n;i++)max*=3;
		max=max-1;

		ans=SerialNo;
		if(SerialNo>max-SerialNo)ans=max-SerialNo;

		printf("%d\n",m>=ans?ans:-1);

	}


	return 0;
}


int DECODE_3Gray2int(int n,int POS[]){

	int SDEC[16];
	int k,l;
	int jdg,keta;
	int ret;
	
	for(k=0;k<16;k++)SDEC[k]=0;
	for(k=n-1;k>=0;k--){
		jdg=0;
		keta=1;
		for(l=1;k+l<=n;l++){
			jdg=jdg+keta*SDEC[k+l];
			keta*=3;
		}
		SDEC[k]=jdg%2?(2-POS[k]):POS[k];
	}
//dbg for(k=0;k<n;k++)printf("%d ",SDEC[k]);puts("");

	keta=1;ret=0;
	for(k=0;k<16;k++){
		ret+=SDEC[k]*keta;
		keta*=3;
	}
	
	return ret;
}

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

using namespace std;

int main()
{
    unsigned long long int n;
    scanf("%llu", &n);

    int name[15], i;
    for (i = 0; n; i++)
    {
        n--;
        name[i] = n % 26;
        n /= 26;
    }
    for (int j = i - 1; j >= 0; j--)
        printf("%c", name[j] + 'a');

    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size()-1; i<=N; i++) if(i!=N) cout << v[i] << ' '; else cout << v[i] << endl; }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll M_MAX = 100000;
constexpr ll A_I_MAX = 1000000000;

ll N, M;
ll A[M_MAX];

void input() {
	scanf("%lld%lld", &N, &M);
	rep(i, N) scanf("%lld", A + i);
}

void solve() {


	priority_queue<ll, vector<ll>, function<bool(ll,ll)>>que(
		[](const ll &x, const ll &y){
			return x < y;
		}//xの優先度が低いときに対してtrueを返すこと この場合昇順優先
	);

	rep(i,N){
		que.push(A[i]);
	}

	rep(i,M){
		ll X=que.top();
		que.pop();
		que.push(X/2);
	}



	ll ans = 0;
	while(!que.empty()){
		ll X=que.top();
		que.pop();
		ans+=X;
	}
	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


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

namespace ABC079C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var A = input[0] - '0';
            var B = input[1] - '0';
            var C = input[2] - '0';
            var D = input[3] - '0';

            var op = new[] { '+', '-' };
            var answer = (
                from op1 in op
                from op2 in op
                from op3 in op
                let AB = op1 == '+' ? A + B : A - B
                let ABC = op2 == '+' ? AB + C : AB - C
                let ABCD = op3 == '+' ? ABC + D : ABC - D
                where ABCD == 7
                select $"{A}{op1}{B}{op2}{C}{op3}{D}=7"
            ).FirstOrDefault();

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 26660
#include <iostream>
using namespace std;
int main(){
int a[101][101],n = 0,r,c;
cin >> r >> c;
	for (int i = 0 ; i < 101 ; i++ ){
		for (int j = 0 ; j < 101 ; j++){
			a[i][j] = 0;
		}
	}

	for (int i = 0; i < r ; i++){
		for (int j = 0 ; j < c ; j++){
			cin >> a[i][j];
		}
	}
	
	for (int i = 0 ; i < r ; i ++){
		for (int j = 0 ;j < c ; j++){
			a[i][c] += a[i][j];
		}
	}
	for (int j = 0 ;j < c + 1 ; j++){
		for (int i = 0 ; i < r ; i++ ){
			a[r][j] += a[i][j];
		}
	}
	
	for (int i = 0 ;i <= r ; i++){
		for (int j = 0 ;j <= c ;j++){
			cout << a[i][j];
			if(j!= c)cout << " ";

		}
 cout << endl;
	}
	
	


    return 0 ;


} 

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
struct Vertex {int s, c;};
struct Edge {Vertex to; int w;};
bool operator<(Vertex l, Vertex r) {return l.s!=r.s ? l.s<r.s : l.c<r.c;}
using Graph = map<Vertex, vector<Edge>>;
const int INF = 1e9;
int main() {
  int N, M;
  cin >> N >> M;
  Graph G;
  for(auto i=0; i<M; ++i) {
    int p, q, c;
    cin >> p >> q >> c;
    --p; --q; --c;
    Vertex u{p, c}, v{q, c};
    Vertex a{p, -1}, b{q, -1};
    G[u].push_back({v, 0});
    G[v].push_back({u, 0});
    G[u].push_back({a, 0});
    G[v].push_back({b, 0});
    G[a].push_back({u, 1});
    G[b].push_back({v, 1});
  }
  map<Vertex, int> d;
  deque<Vertex> q;
  q.push_front({0, -1});
  d[{0, -1}] = 0;
  while(!q.empty()) {
    auto v = q.front();
    q.pop_front();
    for(auto e: G[v]) {
      if(!d.count(e.to)) d[e.to] = INF;
      if(d[e.to] <= d[v] + e.w) continue;
      d[e.to] = d[v] + e.w;
      if(e.w) q.emplace_back(e.to);
      else    q.emplace_front(e.to);
    }
  }
  if(d.count({N-1, -1})) cout << d[{N-1, -1}] << endl;
  else                   cout << -1 << endl;
}


Measured memory_bytes: 90624
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll l,r,d,i,c=0;
	cin>>l>>r>>d;
	for(i=l;i<=r;i++){
		if(i%d==0){
			c++;
		}
	}
	cout<<c;
	return 0;	
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
int a[20],n;
bool solve(int i,int m){
  int res;
  if(m==0){
    return true;
  }
  if(i>=n){
    return false;
  }
  return solve(i+1,m) || solve(i+1,m-a[i]);
}
int main(){
  int q;
  int m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m;
    if(solve(0,m)==1){
      cout<<"yes\n";
    }else{
      cout<<"no\n";
    }
  }
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>

void output(std::vector<std::vector<int>>& v)
{
	size_t size = v.size();
	for (auto num : v)
	{
		std::cout << num[0] << " " << num[1] << std::endl;
	}
}

int main()
{
	std::vector<std::vector<int>> numbers;
	std::vector<int> num(2);
	std::cin >> num[0] >> num[1];

	while (num[0] != 0 || num[1] != 0)
	{
		std::sort(num.begin(), num.end());
		numbers.push_back(num);
		std::cin >> num[0] >> num[1];
	}
	
	output(numbers);
	return 0;
}


Measured memory_bytes: 3120
from collections import deque

S = input()
Q = int(input())
q = deque(list(S))
rev = 0
for _ in range(Q):
    s, *x = input().split()
    if s == "1":
        rev += 1
    else:
        if ((x[0] == "1" and rev % 2 == 0)
                or (x[0] == "2" and rev % 2 == 1)):
            q.appendleft(x[1])
        else:
            q.append(x[1])

if rev % 2 == 0:
    print("".join(q))
else:
    print("".join(q)[::-1])


Measured memory_bytes: 103688
main :: IO ()
main = do
  [r,g,b,n] <- map read . words <$> getLine
  print $ solve r g b n

solve :: Int -> Int -> Int -> Int -> Int
solve r g b n = go 0 0 0
  where go x 0 a
          | n - r * x < 0 = a
          | n - r * x >= 0 && (n - r * x) `mod` b == 0 = go x 1 (a + 1)
          | otherwise = go x 1 a
        go x y a
          | n - r * x - g * y < 0 = go (x + 1) 0 a
          | n - r * x - g * y >= 0 && (n - r * x - g * y) `mod` b == 0 = go x (y + 1) (a + 1)
          | otherwise = go x (y + 1) a


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

vector<mint> fact,ifact;

mint comb(int64 n, int64 r){
  return fact[n] * ifact[r] * ifact[n-r];
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m,k;
  cin >> n >> m >> k;
  fact.resize(n*m+1,1);
  ifact.resize(n*m+1,1);
  REP(i,n*m)fact[i+1] = fact[i] * (i+1);
  ifact[n*m] = fact[n*m].inv();
  FORR(i,n*m,1)ifact[i-1] = ifact[i] * i;
  mint ans = 0;
  REP(d,n){
    ans += (mint)d * (n - d) * m * m;
  }
  REP(d,m){
    ans += (mint)d * (m - d) * n * n;
  }
  ans *= comb(n*m-2,k-2);
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
ll a[100005], sum[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	map<ll, int> mp;
	FOR(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	
	sort(a, a+n);
	a[n] = -1;
	ll last = 0;
	FOR(i, n) {
		sum[i] = a[i] + last;
		last = sum[i];
	}
	int cnt = 0;
	for (int i = n-1; i >= 0; i--) {
		if (2*sum[i] < a[i+1]) break;
		else if (mp.find(a[i]) != mp.end()){
			cnt += mp[a[i]];
			mp.erase(a[i]);
			// cout << a[i] << endl;
		}
	}
	
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 8064
#include<iostream>

using namespace std;
int main(){
	int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k];
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int main(){
	int m=-INF;
	cint2(a,b);
	m=max(a+b,m);
	m=max(a-b,m);
	m=max(a*b,m);
	cout<<m<<endl;
	return 0;
}


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

void solve(int test){
	int l, r, d;
	cin>>l>>r>>d;
	int res = r/d - (l-1)/d;
	cout<<res<<endl;
}

int main(){
	int t; t=1;
	// cin>>t;
	for(int tt=1;tt<=t;tt++)solve(tt);
}

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

int main(){
    int N;
    cin >> N;
    long long A[N], B[N+1];

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

    B[0] = 0;

    for(int i = 0; i < N; i++){
        B[i+1] = 2*A[i] - B[i];
    }

    long long x = B[N]/2;

    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            B[i] += x;
        }
        else{
            B[i] -= x;
        }
    }

    for(int i = 0; i < N; i++){
        cout << B[i] << endl;
    }
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("869121");
            //2511445
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int N = int.Parse(InputList[0]);

        const long Hou = 1000000000 + 7;

        long Answer = DeriveModPow(10, N, Hou);
        Answer -= 2 * DeriveModPow(9, N, Hou);
        Answer %= Hou;
        if (Answer < 0) Answer += Hou;

        Answer += DeriveModPow(8, N, Hou);
        Answer %= Hou;

        Console.WriteLine(Answer);
    }

    //繰り返し2乗法で、(NのP乗) Mod Mを求める
    static long DeriveModPow(long pN, long pP, long pM)
    {
        long CurrJyousuu = pN % pM;
        long CurrShisuu = 1;
        long WillReturn = 1;

        while (true) {
            //対象ビットが立っている場合
            if ((pP & CurrShisuu) > 0) {
                WillReturn = (WillReturn * CurrJyousuu) % pM;
            }

            CurrShisuu *= 2;
            if (CurrShisuu > pP) return WillReturn;
            CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
        }
    }
}


Measured memory_bytes: 27792
use std::io;
use std::str::FromStr;

fn main(){
    let mut buf = String::new();
    let _ = io::stdin().read_line(&mut buf);

    let vec : Vec<i64> = buf.split_whitespace().map(|x| i64::from_str(x).unwrap()).collect();
    let (a, b, c) = (vec[0], vec[1], vec[2]);

    println!("{}", if a < b && b < c { "Yes" } else { "No" });
}



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

int main() {

	int n; cin >> n;
	vector<ll> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[i] == l[j] || l[j] == l[k]) continue;
				if (l[i] + l[j] <= l[k]) continue;
				ans++;
			}
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600