akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<complex>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x<<" = "<<x<<endl
using namespace std;

typedef vector<int> vi;
typedef long long ll;

const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;
const int mod = (int)1e9 + 9;

typedef vector<vi> M;
M operator*(const M &a, const M &b){
	M res(a.size(), vi(b[0].size()));
	rep(i,res.size()) rep(j,res[0].size()){
		rep(k,a[0].size()) res[i][j] = (res[i][j] + (ll)a[i][k] * b[k][j]) % mod;
	}
	return res;
}
vi operator*(const M &a, const vi &b){
	vi res(a.size());
	rep(i,res.size()) rep(j,a[0].size()) res[i] = (res[i] + (ll)a[i][j] * b[j]) % mod;
	return res;
}
M pw[70];
ll w, h;
ll x[31], y[31], ys[31];
int n, dp[2][76];

void calc(){
	rep(i,w) if(dp[0][i] >= 0) for(int j = i-1; j < i+2; j++){
		if(j < 0 || j >= w || dp[1][j] < 0) continue;
		(dp[1][j] += dp[0][i]) %= mod;
	}
}

int main(){
	int cs = 0;
  while(cin >> w >> h >> n, w){
  	rep(i,n) cin >> x[i] >> y[i], --x[i], ys[i] = --y[i];
  	ys[n] = h;
  	sort(ys, ys+n);
  	
  	pw[0] = M(w, vi(w));
  	rep(i,w){
  		memset(dp, 0, sizeof(dp));
			dp[0][i] = 1;
			calc();
			rep(j,w) pw[0][i][j] = dp[1][j];
  	}
  	rep(i,63) pw[i+1] = pw[i] * pw[i];
  	vi v(w);
  	v[0] = 1;
  	for(ll i = 0; i < h-1; i++){
  		ll next = *lower_bound(ys, ys+n+1, i);
  		if(next > i+1){
  			int k = 0;
  			for(ll m = next-i-1; m; m /= 2, k++)
  				if(m & 1) v = pw[k] * v;
				i = next-2;
				continue;
  		}
  		memset(dp, 0, sizeof(dp));
  		rep(j,w) dp[0][j] = v[j];
  		rep(j,n) if(i == y[j] || y[j] == i+1) dp[y[j]-i][x[j]] = -1;
  		calc();
  		rep(j,w) v[j] = max(0, dp[1][j]);
  	}
  	printf("Case %d: %d\n", ++cs, v[w-1]);
  }
  return 0;
}

Measured memory_bytes: 2440
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  int n,r;

  while(cin>>n>>r,n||r){
    vector<int> v;
    REP(i,1,n+1) v.push_back(i);
    rep(i,r){
      int p,c;
      cin>>p>>c;

      rep(j,c){
        int tmp = v[n-p-c+1];
        v.erase(v.begin() + (n-p-c+1));
        v.push_back(tmp);
      }
    }

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

Measured memory_bytes: 0
#A-Frog1
N=int(input())
H=list(map(int,input().split()))
H.insert(0,0)#H[i]はiコメの高さ
current=[0,0]#current[x]はx個目まで行く時のコストの最安値
current.append(abs(H[2]-H[1]))
for i in range(3,N+1):#i個目まで行くときのコストの最安値を追加
    one=current[i-1]+abs(H[i]-H[i-1])
    two=current[i-2]+abs(H[i]-H[i-2])
    current.append(min([one,two]))
print(current[-1])

Measured memory_bytes: 13980
import std.stdio; // readln
import std.array; // split
import std.conv; // to
import std.typecons;
import std.range;
import std.algorithm;

void main(){
	string[] s = split(readln());
	int N = to!int(s[0]);
	int K = to!int(s[1]);

	long[] X = new long[](N);
	long[] Y = new long[](N);
	Tuple!(long,long)[] T = new Tuple!(long,long)[](N);
	for(long i = 0; i < N; i++){
		s = split(readln());
		long x = to!long(s[0]);
		long y = to!long(s[1]);
		X[i] = x;
		Y[i] = y;
		T[i] = Tuple!(long,long)(x,y);
	}
	auto sorted_x = X;
	auto sorted_y = Y;
	sort(sorted_x);
	sort(sorted_y);

	long ans = long.max;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			for(int k = 0; k < N; k++){
				for(int l = k + 1; l < N; l++){
					int cnt = 0;
					for(int m = 0; m < N; m++){
						if(T[m][1] >= sorted_y[i] && T[m][1] <= sorted_y[j] && T[m][0] >= sorted_x[k] && T[m][0] <= sorted_x[l]){
							cnt++;
						}
					}
					if(cnt >= K){
						ans = min(ans, (sorted_y[j] - sorted_y[i]) * (sorted_x[l] - sorted_x[k]));
					}
				}
			}
		}
	}
	writeln(ans);
}


Measured memory_bytes: 256
// C - Bugged
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vi S(N+1);
	int MAX = 0;
	rp(i,N){
		cin>>S[i+1];
		MAX += S[i+1];
	}

	sort(all(S));

	int maxi = 0;
	vi dp(MAX+1);

	// rp(i,MAX+1)printf("%2d,",i%10);puts("");///
	// rp(i,MAX+1)printf("---");puts("");///

	for(int i=1; i<=N; ++i){
		int s = S[i];
		for(int j=MAX; j>=s; --j){
			// cout<<dp[j]<<","<<dp[j-s]<<","<<s<<"\n";///
			dp[j] = max(dp[j], dp[j-s] + s);
			int c = dp[j];
			if(c%10==0) c=0;
			maxi = max(maxi, c);
		}

		// for(auto e:dp){printf("%2d,",e);}puts("");//

	}
	cout<< maxi <<endl;
}


Measured memory_bytes: 256
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val a, b, h, m = Scanner.nextDouble

	val angle = Math.abs(30.0 * h + 0.5 * m - 6 * m) * Math.PI / 180.0

	pw.println(Math.sqrt(Math.pow(a, 2.0) + Math.pow(b, 2.0) - 2 * a * b * Math.cos(angle)))
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54632
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer[] a = new Integer[N];
        int i = 0;
        while(i < N){
            a[i] = sc.nextInt();
            i++;
        }
        int alice = 0;
        int bob = 0;
        int j = 0;
        Arrays.sort(a, Comparator.reverseOrder());
        for(int ai: a){
            if(j % 2 == 0){
                alice += ai;
            }else{
                bob += ai;
            }
            j++;
        }
        System.out.println(alice - bob);
    }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec A(N);
  rep(i, N){
    cin >> A[i];
  }
  sort(ALL(A));

  ll ok = A[N-1];
  ll ng = 0;
  while(abs(ok-ng)>1){
    ll m = (ok+ng)/2;
    ll cnt = 0;
    rep(i, N){
      if(A[i]>m){
        cnt+=A[i]/m;
      }
    }
    if(cnt>K){
      ng=m;
    }else{
      ok=m;
    }
    cerr << ok << " " << ng<<endl;
  }

  cout << ok;
  return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int H, W;
    cin >> H >> W;
    vector<vector<int>> s(H, vector<int>(W));
    REP(i, H){
        string tmp;
        cin >> tmp;
        REP(j, W){
            if(tmp[j] == '.'){
                s[i][j] = 0;
            }else{
                s[i][j] = 1;
            }
        }
    }

    string ans = "Yes";
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    REP(i, H){
        REP(j, W){
            if(s[i][j] == 0) continue;
            int sumtmp = 0;
            REP(r, 4){
                if(0 <= j + dx[r] && j + dx[r] < W && 0 <= i + dy[r] && i + dy[r] < H){
                    sumtmp += s[i + dy[r]][j + dx[r]];
                }
            }
            if(sumtmp == 0){
                ans = "No";
                break;
            }
        }
    }

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    string s,t;
    cin >> s;
    t = s;
    reverse(t.begin(),t.end());

    int d(0);
    rep(i,s.size()) if(s[i]!=t[i])  d++;

    cout << d/2 << endl;

    return 0;
}

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

int main() {
	int n, need;
	cin >> n >> need;
	int64_t x[n], y[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	int64_t ans = numeric_limits<int64_t>::max();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					int count = 0;
					for (int m = 0; m < n; m++) {
						if (x[i] <= x[m] && x[m] <= x[j] && y[k] <= y[m] && y[m] <= y[l]) {
							count++;
						}
					}
					if (need <= count) {
						ans = min(ans, (x[j] - x[i]) * (y[l] - y[k]));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	scanf("%d",&k);
	if(k<=500){
		printf("%d\n",k);
		for(int i=1;i<=k;i++,puts(""))
			for(int j=1;j<=k;j++)
				printf("%d ",(i+j)%k+1);
	}else{
		int n=(k+3>>1)&0x3ffffffe;
		printf("%d\n",n);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++){
				int now=(i+j)%n+1;
				if(i%2==0)now+=n;
				if(now>k)now-=n;
				printf("%d ",now);
			}
	}
	return 0;
}

Measured memory_bytes: 1152
# 約数の列挙
#############################################################


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
#############################################################


N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 2 == 1 and len(make_divisors(i)) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 61996
#include <stdio.h>

int
main(void)
{
	int x, y;

	for (;;) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0)
			break;
		if (x <= y)
			printf("%d %d\n", x, y);
		else
			printf("%d %d\n", y, x);
	}

	return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def solve():
    N, q = map(int, input().split())
    root = [-1] * N

    def find(x: int) -> int:
        if root[x] < 0:
            return x
        else:
            while root[x] >= 0:
                x = root[x]
            return x

    def union(x: int, y: int):
        x = find(x)
        y = find(y)
        if x == y:
            return
        if root[x] > root[y]:
            x, y = y, x
        root[x] += root[y]
        root[y] = x

    for _ in range(q):
        t, u, v = map(int, input().split())
        if t:
            print(int(find(u) == find(v)))
        else:
            union(u, v)


solve()


Measured memory_bytes: 75848
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (true) {
            String string = scanner.next();
            if (string.equals("#")) {
                break;
            }
            int counter = 0;
            int previous = 0;
            final Set<Character> left = new HashSet<Character>();
            final Set<Character> right = new HashSet<Character>();
            Collections.addAll(left, 'q', 'w', 'e', 'r', 't',
                                     'a', 's', 'd', 'f', 'g',
                                     'z', 'x', 'c', 'v', 'b');
            for (char c : string.toCharArray()) {
                if (left.contains(c)) {
                    if (previous == -1) {
                        counter++;
                    }
                    previous = 1;
                } else {
                    if (previous == 1) {
                        counter++;
                    }
                    previous = -1;
                }
            }
            System.out.println(counter);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	int n[2000], v[2000];
	
	for(int i = 0; i < N; i++){
		cin >> n[i];
		v[i] = 0;
	}
	
	int m;
	
	for(int i = 0; i < M; i++){
		cin >> m;
		for(int j = 0; j < N; j++){
			if(n[j] <= m){
				v[j]++;
				break;
			}
		}
	}
	
	int ans, max;
	
	max = 0;
	
	for(int i = 0; i < N; i++){
		if(v[i] > max){
			ans = i;
			max = v[i];
		}
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>

int main()
{
	int a,b,i;
  
(void) scanf("%d %d",&a,&b);
  
  if(a<b)
  {
  for(i=1;i<=b;i++)  
  {
    printf("%d",a);
  }
    return 0;
  }
	
  for(i=1;i<=a;i++)  
  {
    printf("%d",b);
  }
  return 0;

}


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

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

    int cnt=0;
    for(int i=0;i<n;i++) {
        if(v[i]!=i+1)
            cnt++;
    }

    if(cnt>2){
        cout<<"NO"<<endl;
    }
    else {
        cout<<"YES"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,k;
    char s[55];
    scanf("%d %d", &n,&k);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(i==k-1){
            printf("%c",s[i]-('A'-'a'));
        }
        else{
            printf("%c",s[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int H,W;
  cin>>H>>W;
  cout << (H+W-1) / W << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define ld long double
#define oo 2e18
#define OS tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;


const int N = 3e2 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, l, e[N][N], ee[N][N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m >> l;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            e[i][j] = (i == j) ? 0 : oo;
            ee[i][j] = (i == j) ? 0 : oo;
        }
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        e[a][b] = c;
        e[b][a] = c;
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (e[i][k] + e[k][j] < e[i][j])
                    e[i][j] = e[i][k] + e[k][j];
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i != j) {
                ee[i][j] = (e[i][j] <= l) ? 1 : oo;
            }
        }
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (ee[i][k] + ee[k][j] < ee[i][j])
                    ee[i][j] = ee[i][k] + ee[k][j];
            }
        }
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (ee[a][b] < oo) {
            cout << ee[a][b] - 1 << "\n";
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5104
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
l=[[0]*26]
for d in range(D):
    x=[]
    for b in range(len(l)):
        x.extend([(S[d][i]-sum([(d+1-l[b][j])*C[j] for j in range(26) if i!=j]),i,b) for i in range(26)])
    x=sorted(x,key=lambda a:a[0])[::-1]
    l2=[]
    for _,i,b in x[:10]:
        l2.append(l[b].copy())
        l2[-1][i]=d+1
    l=l2
    print(x[0][1]+1)

Measured memory_bytes: 9520
#include<iostream>
using namespace std;
int a[35]={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 main()
{
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------
signed main()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> ma;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> a >> b;
    if (a == b)
    {
      count++;
    }
    else
    {
      count = 0;
    }
    if (count >= 3)
    {
      out("Yes");
      return 0;
    }
  }
  if (count >= 3)
  {
    out("Yes");
  }
  else
  {
    out("No");
  }
}

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

int main(){
	// sengen
	int x,y;
	int sum;
	// nyuryoku
	cin >> x >> y;
	// keisan
	for(int t=0;t<=x;t++){
		int k = x-t;
		sum = t*2 + k*4;
		if(sum == y){
			cout << "Yes";
			return 0;
		}
	}
	// syutsuryoku
	cout << "No";
}

Measured memory_bytes: 3672
import bisect

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cum = [0]
B_cum = [0]

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

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
print(ans)

Measured memory_bytes: 47552
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int X, cnt[31], ans;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		X = X ^ a;
		int res = 0;
		res = __builtin_ctz(a);
		cnt[res]++;
	}
	
	for(int i = 30; i >= 0; i--) {
		if((X >> (i)) & 1) {
			if(cnt[i] > 0) {
				X = X ^ ((1LL << (i + 1) )- 1);
				ans++;
			}
			else 
				return cout << -1, 0;
		}
	}
	return cout << ans, 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
	int price,many;
	int p_sum = 0;
	int m_sum = 0;
	int count = 0;
	int a;
	double x,y,iptr;
	double ave;
	while(scanf("%d,",&price) != EOF){
		scanf("%d",&many);
		count++;
		m_sum += many;
		p_sum = p_sum + price * many;
	}
	ave = (double)m_sum / count;
	/*y = modf(ave,&z);
	printf("%f\n",y);
	if(y >= 0.5){
		ave++;
	}*/
	y = modf(ave,&iptr);
	a = (int)ave;
	if(y >= 0.5){
		a++;
	}
	printf("%d\n%d\n",p_sum,a);
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			A();
		}

		public static void A()
		{
			Scanner cin = new Scanner();
			int a = cin.Int();
			int p = cin.Int();
			int ans = ((a * 3) + p) / 2;
			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LIN(N)[::-1] #bisect使いたいので
    LIS = [A[0]] #もとの順序の広義単調減少は反転させた配列の広義単調増加
    for a in A[1:]:
        if LIS[-1] <= a:
            LIS.append(a)
        else:
            update_index = bisect_right(LIS,a)
            LIS[update_index] = a
    print(len(LIS))





if __name__ == '__main__':
    main()

Measured memory_bytes: 51292
#include <iostream>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A == B && B==C){
        cout << "No" << endl;
        return 0;
    }
    else if(A != B && B != C && C != A){
        cout << "No" << endl;
        return 0;
    }
    else{
        cout << "Yes" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <list>
#include <numeric>
#include <string>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int m, n; m = in, n = in;) {
		list<int> p(m);
		iota(begin(p), end(p), 1);
		auto q {begin(p)};
		for (int i: range(1, n + 1)) {
			char c = gcu();
			ungetc(c, stdin);
			if (isdigit(c)) {
				int t = in;
				if (next(begin(p), 1) == end(p))
					continue;
				if (i % 3 && i % 5 && i == t)
					q++;
				else
					q = p.erase(q);
			} else {
				string s = in;
				if (next(begin(p), 1) == end(p))
					continue;
				if ((s.size() > 4 && i % 15 == 0) || (s.size() == 4 && s[0] == 'F' && i % 3 == 0) || (s[0] == 'B' && i % 5 == 0))
					q++;
				else
					q = p.erase(q);
			}
			if (q == end(p))
				q = begin(p);
		}
		int j {};
		for (int &i: p)
			out(j++ ? " ": "", i);
		outl();
	}
}



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

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

    int n; cin >> n;
    int a[n], b[n], c[n], dp[n][3];

    for (int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    
    for (int i=1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> A(2 * n - 1), B(2 * n - 1);
	for (int i = 0; i < 2 * n - 1; ++i) scanf("%d", &A[i]);
	int lo = 1, hi = 2 * n - 1;
	while (lo < hi) {
		int m = (lo + hi + 1) >> 1;
		for (int i = 0; i < 2 * n - 1; ++i) {
			B[i] = A[i] >= m;
		}
		int st = 0;
		vector<int> d(2, INT_MAX);
		for (int i = 0; i < 2 * n - 1; ++i) {
			if (i + 1 == 2 * n - 1 || B[i] != B[i + 1]) {
				if (i - st + 1 >= 2) {
					if (i < n - 1) d[B[i]] = min(d[B[i]], n - 1 - i);
					else if (st > n - 1) d[B[i]] = min(d[B[i]], st - (n - 1));
					else d[B[i]] = 0;
				}
				st = i + 1;
			}
		}
		int col = min_element(d.begin(), d.end()) - d.begin();
		if (d[col] == INT_MAX) col = n % 2 == 0 ? !B[n - 1] : B[n - 1];
		else assert(d[0] != d[1]);
		if (col == 1) lo = m;
		else hi = m - 1;
	}
	printf("%d\n", lo);
}


Measured memory_bytes: 1920
/*Lucky_Glass*/
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=2e5,MOD=1e9+7;

vector<int> lnk[N+3];
int n,X,Y,mn1,mn2,tot;
int col[N+3],val[N+3],cmin[N+3],cnt[N+3],fac[N+3],inv[N+3];
bool vis[N+3];

void AddEdge(int u,int v){
    lnk[u].push_back(v);
    lnk[v].push_back(u);
}
void DFS(int u){
    tot++;
    cnt[col[u]]++;vis[u]=true;
    for(int i=0;i<(int)lnk[u].size();i++){
        int v=lnk[u][i];
        if(vis[v]) continue;
        DFS(v);
    }
}
int QPow(int A,int B){
    int res=1;
    while(B){
        if(B&1) res=int(1ll*res*A%MOD);
        A=int(1ll*A*A%MOD);
        B>>=1;
    }
    return res;
}
int EC(int A,int B){return int(1ll*fac[B]*inv[A]%MOD*inv[B-A]%MOD);}
int main(){
    scanf("%d%d%d",&n,&X,&Y);
    fac[0]=1;for(int i=1;i<=n;i++) fac[i]=int(1ll*fac[i-1]*i%MOD);
    inv[n]=QPow(fac[n],MOD-2);for(int i=n-1;i>=0;i--) inv[i]=int(1ll*inv[i+1]*(i+1)%MOD);
    for(int i=1;i<=n;i++) cmin[i]=0;
    val[0]=MOD;col[0]=-1;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&col[i],&val[i]);
        if(val[cmin[col[i]]]>val[i]) cmin[col[i]]=i;
        if(val[mn1]>val[i]){
            if(col[mn1]!=col[mn2]) mn2=mn1;
            mn1=i;
        }
        else if(val[mn2]>val[i] && col[mn1]!=col[i]) mn2=i;
    }
    for(int i=1;i<=n;i++)
        if(i!=cmin[col[i]] && val[i]+val[cmin[col[i]]]<=X)
            AddEdge(cmin[col[i]],i);
    if(val[mn1]+val[mn2]<=Y) AddEdge(mn1,mn2);
    for(int i=1;i<=n;i++){
        if(col[i]==col[mn1]){
            if(val[i]+val[mn2]<=Y)
                AddEdge(i,mn2);
        }
        else{
            if(val[i]+val[mn1]<=Y)
                AddEdge(i,mn1);
        }
    }
    DFS(mn1);
    int ans=1;
    for(int i=1;i<=n;i++){
        ans=int(1ll*ans*EC(cnt[i],tot)%MOD);
        tot-=cnt[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,cnt=0;
    cin >> n >> m;
    int a[m],b[m];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    for(int i=0;i<m;i++){
       vector<vector<int>> graph(n);
        for(int j=0;j<m;j++){
          if(i==j) continue;
          graph[a[j]].push_back(b[j]);
          graph[b[j]].push_back(a[j]);
        }
    	vector<int> dist(n,-1);
    	queue<int> que;
    	que.push(0);
    	dist[0]=0;
    	while(!que.empty()){
        	int v = que.front();
        	que.pop();
        	for(int j:graph[v]){
            	if(dist[j]!=-1) continue;
            	dist[j] = dist[v] + 1;
            	que.push(j);
       	 	}
    	}
        bool flag = 0;
        for(int k=0;k<n;k++){
          if(dist[k]==-1) flag = 1; 
        }
        if(flag) cnt++;
    }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N, H, W; cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}





Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const int MAX = 505;
int H[MAX][MAX];
int V[MAX][MAX];
int D[MAX][MAX];

signed main(){
  int h,w,r,c;
  while(cin>>h>>w>>r>>c,h){
    memset(H,0,sizeof(H));
    memset(V,0,sizeof(V));
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w+0;j++) cin>>H[i][j];
      for(int j=1;j<=w+1;j++) cin>>V[i][j];
    }
    for(int j=1;j<=w+0;j++) cin>>H[h+1][j];

    memset(D,0,sizeof(D));
    using P = pair<int, int>;
    queue<P> que;
    auto push=
      [&](int i,int j){
        if(D[i][j]) return;
        D[i][j]=1;
        que.emplace(i,j);
      };

    for(int i=1;i<=h;i++) push(i,0);
    for(int i=1;i<=h;i++) push(i,w+1);
    for(int j=1;j<=w;j++) push(0,j);
    for(int j=1;j<=w;j++) push(h+1,j);

    int dy[]={0,0,1,-1};
    int dx[]={1,-1,0,0};
    auto in=[&](int y,int x){return 1<=y&&y<=h&&1<=x&&x<=w;};

    auto check=
      [&](int ny,int nx){
        if(!in(ny,nx)) return;

        int cnt[2]={};
        cnt[H[ny+0][nx]]+=D[ny-1][nx];
        cnt[H[ny+1][nx]]+=D[ny+1][nx];
        cnt[V[ny][nx+0]]+=D[ny][nx-1];
        cnt[V[ny][nx+1]]+=D[ny][nx+1];

        if(cnt[0]&&cnt[1]) push(ny,nx);
      };

    while(!que.empty()){
      auto p=que.front();que.pop();
      int y=p.first,x=p.second;
      for(int k=0;k<4;k++){
        int ny=y+dy[k],nx=x+dx[k];
        check(ny,nx);
      }
    }

    int ans=D[r][c];
    if(r==1) ans|=H[r+0][c]==0;
    if(r==h) ans|=H[r+1][c]==0;
    if(c==1) ans|=V[r][c+0]==0;
    if(c==w) ans|=V[r][c+1]==0;

    cout<<(ans?"Yes":"No")<<endl;
  }
  return 0;
}



Measured memory_bytes: 6156
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    vector<vector<int> > XL(N,vector<int>(2,0));
    for(auto &xl: XL){
        cin >> xl[0] >> xl[1];
    }
    sort(XL.begin(), XL.end());

    int cnt=0;
    int tmp=MOD;
    for(auto xl: XL){
        if(tmp<=xl[0]-xl[1]){
            cnt++;
            tmp=xl[0]+xl[1];
        }else if(tmp>xl[0]+xl[1]){
            tmp=xl[0]+xl[1];
        }
    }
    cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {

    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      int[] ans = new int[37];

      for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
          for (int c = 0; c < 10; c++) {
            for (int d = 0; d < 10; d++) {
                ans[a + b + c + d]++;
            }
          }
        }
      }

      int n;
      String line;
      while(true) {
        line = br.readLine();
        if((line == null) || line.isEmpty()) break;

        n = Integer.parseInt(line);
        System.out.println(n<37 ? ans[n] : 0);
      }
    } catch (IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 24348
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}node;

#define NIL NULL

node *ROOT;

void insert(int);
void inorder(node*);
void preorder(node*);
int find(node*,int);

int N;

int main(){
  int i,x,j,key;
  int a;
  char com[20];
  scanf("%d",&N);

  for ( i = 0; i < N; i++ ){
    scanf("%s", com);

    if(com[0] == 'f'){
      scanf("%d",&key);
      a = find(ROOT,key);
      if(a==NIL){
        printf("no\n");
      }
      else printf("yes\n");
      //else printf("no\n");
    }

    else  if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }


    else if ( com[0] == 'p' ){
      inorder(ROOT);
      printf("\n");
      preorder(ROOT);
      printf("\n");
  }



}
  return 0;
}


void insert(int z){
  node* T;
  node* y;
  node* x;
  T = (node *)malloc(sizeof(node)*1);
  y = NIL;
  x = ROOT;
  T->key = z;
  T->left = NIL;
  T->right = NIL;
  //parent set
  while(x != NIL){
    y = x;
    if(T->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  T->parent = y;

//insert!
  if(y == NIL){
    ROOT = T; // Tree is empty
  }
  else if(T->key < y->key){
    y->left = T;
  }

  else{
    y->right = T;
  }
}

void inorder(node* n){

  if(n != NIL){
    inorder(n->left);
      printf(" %d",n->key);
      inorder(n->right);
  }
}

void preorder(node* n){
  if(n != NIL){
    printf(" %d",n->key);
    preorder(n->left);
    preorder(n->right);
  }
}

int find(node* x,int key){
  if(x==NIL || key == x->key){
    return x;
  }
  if(key < x->key){
    return find(x->left,key);
  }
  else if(key > x->key){
    return find(x->right,key);
  }
}

Measured memory_bytes: 19364
# require 'pp'
# # IS_DEBUG = true
# IS_DEBUG = false
# def dputs str
# 	if(IS_DEBUG)
# 		puts str
# 	end
# end
# def dpp str
# 	if(IS_DEBUG)
# 		pp str
# 	end
# end
def comb(n,a)
	return $fact[n] * $finv[a] % $mod * $finv[n-a] % $mod;
end
def pow(a,n)
	prd = 1;
	exp = a;
	while(n > 0)
		if((n&1)==1)
			prd *= exp;
			prd %= $mod;
		end
		exp *= exp;
		exp %= $mod;
		n >>= 1;
	end
	return prd;
end
# constant
NMAX = 200015;
$mod = 998244353;
# preprocess
$fact = Array.new(NMAX);
$finv = Array.new(NMAX);
$fact[0] = 1;
$finv[0] = 1;
for i in 1..(NMAX)
	$fact[i] = $fact[i-1] * i % $mod;
	$finv[i] = pow($fact[i], $mod-2);
end

N,M,K=gets.chomp.split(' ').map{|n| n.to_i}

sum = 0
for k in 0..(K)
	sum += M * pow(M-1, N-1-k) * comb(N-1, k)
	sum %= $mod
end

puts sum



Measured memory_bytes: 17508
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int rank=1,pass=0;
    vector<bool> check(n,false);
    for(int i=0;i<n;++i){
        if(s[i]=='a'){
            if(pass<a+b){
                check[i]=true;
                pass++;
            }
        }else if(s[i]=='b'){
            if(rank<=b&&pass<a+b){
                pass++;
                rank++;
                check[i]=true;
            }
        }
    }
    for(int i=0;i<n;++i){
        if(check[i]){
            cout << "Yes" <<endl;
        }else{
            cout << "No" <<endl; 
        }
    }
    return 0;
}


Measured memory_bytes: 976
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var k = parseInt(lines[0]);
    var s = parseInt(lines[1]);
    var value =0;
    
    
       for(var x=0; x<=k; x++)
       {
        for(var y=0; y<=k; y++)
            {
                var z = s - x -y;
                
                if(z<=k && z>=0){
                ++value;
                        }else{
                             value =value+0;
                            　}
                
            }
       }
     
        console.log(value);
});

Measured memory_bytes: 7628