akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        int result = 1;
        long current = x;
        while(current <= y) {
            current = current * 2;
            if(current <= y) {
                result++;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  vector<int> target(N);
  for(int i = 0; i < N; ++i) {
    cin >> target[i];
  }
  int minimum = 1e9;
  vector<int> runlength(M);
  for(int i = 0; i < M; ++i) {
    cin >> runlength[i];
  }
  int length = accumulate(runlength.begin(), runlength.end(), 0);
  {
    vector<int> base(length);
    int idx = 0;
    int num = 1;
    for(int i = 0; i < M; ++i) {
      for(int j = 0; j < runlength[i]; ++j) {
        base[idx++] = num;
      }
      num = 1 - num;
    }
#if 0
    for(int i = 0; i < length; ++i) {
      cerr << base[i] << ' ';
    }
    cerr << endl;
#endif
    int res = 0;
    for(int i = 0; i < length; ++i) {
      for(int j = i; j < length; ++j) {
        if(target[i] == base[j]) {
          for(int k = j - 1; k >= i; --k) {
            swap(base[k], base[k + 1]);
            res++;
          }
          break;
        }
      }
    }
#if 0
    for(int i = 0; i < length; ++i) {
      cerr << base[i] << ' ';
    }
    cerr << endl;
#endif
    if(base == target)
      minimum = min(minimum, res);
  }
  {
    vector<int> base(length);
    int idx = 0;
    int num = 0;
    for(int i = 0; i < M; ++i) {
      for(int j = 0; j < runlength[i]; ++j) {
        base[idx++] = num;
      }
      num = 1 - num;
    }
#if 0
    for(int i = 0; i < length; ++i) {
      cerr << base[i] << ' ';
    }
    cerr << endl;
#endif
    int res = 0;
    for(int i = 0; i < length; ++i) {
      for(int j = i; j < length; ++j) {
        if(target[i] == base[j]) {
          for(int k = j - 1; k >= i; --k) {
            swap(base[k], base[k + 1]);
            res++;
          }
          break;
        }
      }
    }
#if 0
    for(int i = 0; i < length; ++i) {
      cerr << base[i] << ' ';
    }
    cerr << endl;
#endif
    if(base == target)
      minimum = min(minimum, res);
  }
  cout << minimum << endl;
}

Measured memory_bytes: 1200
#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;
int main(){
  long long n,x;
  cin>>n;
  deque<long long>d(n);
  for(int i=0;i<n;i++)
    cin>>d[i];
  sort(d.begin(),d.end());
  x=d[n-1]-d[0];
  cout<<x<<endl;
return 0;
}

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

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    LL a,ans1=0,ans2=0;
    map<LL,int> mp;
    vector<LL> v;
    rep(i,N){
        cin>>a;
        mp[a]++;
    }
    for(auto itr : mp){
        if(itr.second >= 4){
            v.push_back(itr.first);
            v.push_back(itr.first);
        }
        if(itr.second >= 2){
            v.push_back(itr.first);
        }
        // cout<< itr.first << " " << itr.second << endl;
    }
    reverse(v.begin(), v.end());
    if(v.size()){
        cout<<v[0]*v[1]<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 6528
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  int INF = INT_MAX;
  ll mod = 1e9+7;
  // lld PI = 3.141592653;


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     // fstream cin("text.txt");

      int n;
      cin>>n;
      char a[n][n];
      bool ok = false;
      for (int x = 0; x<n;x++){
        for (int y = 0;y<n;y++){
          cin>>a[x][y];
          if (a[x][y]=='#') ok = true;
        }
      }

      if (!ok){
        cout<<"-1\n";
        return 0;
      }
     
      int cost = n;
      vector<bool> row(n);

      for (int y = 0; y<n; y++){
        bool bb = false;
        for (int x =0;x<n;x++){
          if (a[x][y] == '#') bb =true;
        }
        row[y] = bb;
      }

      for (int x = 0; x<n; x++){
        int cnt = 0;
        for (int y =0;y<n;y++){
          if (a[x][y] == '#') cnt++;
        }
        cnt = n- cnt;
        if (a[x][x] != '#' && !row[x]) {cnt++; }
        cost = min(cost, cnt);
      }


      int str = 0;
      for (int y = 0; y<n; y++){
        int cnt = 0;
        for (int x = 0;x<n;x++){
          if (a[x][y] == '.') cnt = 1;
        }
        str += cnt;
      }
      cout<< cost+ str <<"\n";
}
  

Measured memory_bytes: 3396
#include <stdio.h>

#define INIT_LOOP 0
#define SECOND_ELEMENT 1
#define EXIT_SUCCESS 0
#define ELEMENT_MAX_INIT -1000000001

int main( void )
{
	unsigned long usW_Delement_cnt;
	unsigned long usW_Dloop_cnt;
	signed long ulW_Delement;
	signed long ulW_Delement_first;
	signed long ulW_Delement_min;
	signed long slW_Delement_max;

	scanf("%d", &usW_Delement_cnt );									/*????´??????°?????°??????*/
	for( usW_Dloop_cnt = INIT_LOOP; usW_Dloop_cnt < usW_Delement_cnt; usW_Dloop_cnt++){
		scanf("%ld", &ulW_Delement);
		if( usW_Dloop_cnt == INIT_LOOP ){
			ulW_Delement_first = ulW_Delement;
		}
		else{
			/*else???????????????????????§?????\*/
		}

		if( usW_Dloop_cnt == SECOND_ELEMENT ){
			slW_Delement_max = ulW_Delement - ulW_Delement_first;
		}
		else if( slW_Delement_max < ulW_Delement - ulW_Delement_min ){
			slW_Delement_max = ulW_Delement - ulW_Delement_min;
		}
		else{
			/*else?????????????????????????????\*/
		}

		if( usW_Dloop_cnt == INIT_LOOP ){
			ulW_Delement_min = ulW_Delement;
		}
		else if( ulW_Delement_min > ulW_Delement ){
			ulW_Delement_min = ulW_Delement;
		}
		else{
			/*else?????????????????????????????\*/
		}

	}
	printf("%ld\n", slW_Delement_max);
	return EXIT_SUCCESS;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int H, W, N; cin >> H >> W >> N;

cout << (N + max(H, W) - 1)  / max(H, W) << endl;




}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 1048576
#define MOD 1000000007
#define at(i,j) (((i)>>(j))&1)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int limit[25][2], f[MAXN+5], nex[25][MAXN+5], cro[MAXN+5], n, m, k, E, Ans; inline int Add(int &x, int v){x += v, x<MOD?:x-=MOD;}
int main()
{
	n = read()-1, m = read(), k = read(), E = 1<<n, f[0] = 1;
	for(rint i = 0, a, b; i < k; a = read(), b = read()-1, limit[a][0] |= 1<<b, limit[a][1] |= read()<<b, i++);
	for(rint S = 0, j, t; S < E; S++) for(j = 0, t = 0; j < n; t += at(S,j), j&&at(S,j)&&!at(S,~-j) ? nex[t][S] = S^(1<<j)^(1<<~-j) : 0, j++);
	for(rint S = 0, j, t; S < E; S++) for(j = n-1, t = 1; ~j && t; !at(S,j) ? cro[S] = S^(1<<j), t = 0 : 0, j--);
	for(rint i = 1, S, j; i <= m; i++)
	{
		for(S = 0; S < E-1; Add(f[cro[S]],f[S]), S++);
		for(j = 0; j < n; j++) for(S = ~-E; ~S; nex[j][S] ? Add(f[nex[j][S]],f[S]),0 : 0, S--);
		for(S = 0; S < E; S&limit[i][0]^limit[i][1] ? f[S] = 0 : 0, S++);
	}	for(rint S = 0; S < E; Add(Ans,f[S]), S++); printf("%d\n",Ans); return 0;
}

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

int main()
{
    int n,x,y;

    cin>>n>>x>>y;

    int cnt1=0,cnt2=0,cnt3=0;

    map<int,int>mp;

    for(int i=x;i<=y;++i)
    cnt2++;


    for(int i=1;i<x;++i)
    ++cnt1;
    for(int i=y;i<n;++i)
    ++cnt3;

    if(cnt1 && cnt3)
    {
        int cnt=cnt1+cnt3+1;
        for(int i=1;i<=(cnt1+cnt3+1);++i)
        {
        mp[i]+=cnt;--cnt;
        }
        mp[1]--;
    }
    else if(cnt1)
    {
        int cnt=cnt1+1;
        for(int i=1;i<=cnt1+1;++i)
        {
        mp[i]+=cnt;--cnt;
        }
        mp[1]--;
    }
    else if(cnt3)
    {
        int cnt=cnt3+1;
        for(int i=1;i<=cnt3+1;++i)
        {
        mp[i]+=cnt;--cnt;
        }
        mp[1]--;
    }

    for(int i=1;i<=(cnt2/2);++i)
    mp[i]+=cnt2;

    if(cnt2%2==0)
    {
        mp[cnt2/2]-=(cnt2/2);
    }

    for(int i=1,add;i<=(cnt2/2);++i)
    {
        for(int j=1;j<=cnt1;++j)
        {
            add=i+j;
            if(i==1 || ((2*i)==cnt2 && cnt2%2==0))
            mp[add]+=1;
            else mp[add]+=2;
        }
    }

     for(int i=1,add;i<=(cnt2/2);++i)
    {
        for(int j=1;j<=cnt3;++j)
        {
            add=i+j;
            if(i==1 || ((2*i)==cnt2 && cnt2%2==0))
            mp[add]+=1;
            else mp[add]+=2;
        }
    }
/**/
    for(int i=1;i<n;++i)cout<<mp[i]<<endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
       val a = sc.nextInt()
        val b = sc.nextInt()
        println(Math.max(a+b,Math.max(a-b,a*b)))
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

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


Measured memory_bytes: 29356
#include <iostream>
using namespace std;
int main() {
  char a;
  cin >> a;
  if (a== 'A') {
    cout << 'T' <<endl;
  }
  if (a== 'T') {
    cout << 'A' <<endl;
  }
  if (a== 'C') {
    cout << 'G' <<endl;
  }
  if (a== 'G') {
    cout << 'C' <<endl;
  }
  return 0;
}

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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  set<char> s;
  rep(i,3){
    char a;
    cin >> a;
    s.insert(a);
  }
  if(s.size() == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}






Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<(b+1)/2;i++){
		printf("%d %d\n",i+1,a-i);
	}
	int c=a/2+1;
	for(int i=0;i<b/2;i++){
		printf("%d %d\n",c+i+1,c-i-1);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int ufa[252521];
int ufb[252521];
map<int,int> data[252521];
void init(){
  REP(i,252521){
    ufa[i]=ufb[i]=-1;
  }
}
int roota(int x){
  return ufa[x]<0?x:ufa[x]=roota(ufa[x]);
}
int rootb(int x){
  return ufb[x]<0?x:ufb[x]=rootb(ufb[x]);
}
bool unitea(int x,int y){
  x=roota(x);
  y=roota(y);
  if(x!=y){
    if(ufa[x]>ufa[y])swap(x,y);
    ufa[x]+=ufa[y];
    ufa[y]=x;
    return true;
  }
  return false;
}
bool uniteb(int x,int y){
  x=rootb(x);
  y=rootb(y);
  if(x!=y){
    if(ufb[x]>ufb[y])swap(x,y);
    ufb[x]+=ufb[y];
    ufb[y]=x;
    for(auto P:data[y]){
      data[x][P.first] += P.second;
    }
    return true;
  }
  return false;
}

int main(){
  init();
  int n,k,l;
  scanf("%d%d%d",&n,&k,&l);
  REP(i,k){
    int s,t;
    scanf("%d%d",&s,&t);
    --s;--t;
    unitea(s,t);
  }
  REP(i,n){
    data[i][roota(i)] += 1;
  }
  REP(i,l){
    int s,t;
    scanf("%d%d",&s,&t);
    --s;--t;
    uniteb(s,t);
  }
  REP(i,n){
    printf("%d",data[rootb(i)][roota(i)]);
    if(i<n-1)putchar(' ');
    else putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 26112
char t(ulong c) {
	switch(c) {
		case 0: return 'A';
		case 1: return 'C';
		case 2: return 'G';
		case 3: return 'T';
		default: return 'x';
	}
}	

void main() {
	auto N = ri;
	ulong MOD = 1000000007;
	
	auto dp = new long[][][][](N+1, 4, 4, 4);
	dp[0][3][3][3] = 1;
	
	foreach(n; 0..N) foreach(t1; 0..4) foreach(t2; 0..4) foreach(t3; 0..4) {
		if(dp[n][t1][t2][t3] == 0) continue;
		foreach(a; 0..4) {
			char c1 = t1.t, c2 = t2.t, c3 = t3.t, c4 = a.t;
			if([c1, c3, c4] == "AGC") continue;
			if([c1, c2, c4] == "AGC") continue;
			if([c2, c3, c4] == "AGC") continue;
			if([c2, c3, c4] == "GAC") continue;
			if([c2, c3, c4] == "ACG") continue;
			dp[n+1][t2][t3][a] += dp[n][t1][t2][t3];
			dp[n+1][t2][t3][a] %= MOD;
		}
	}
	long res;
	foreach(t1; 0..4) foreach(t2; 0..4) foreach(t3; 0..4) {
		res += dp[N][t1][t2][t3];
		res %= MOD;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

cin>>n>>m;
ll a[n+1][m+1];
char c;
memset(a,0,sizeof a);
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        cin>>c;
        if(c=='.'){
            a[i][j]=0;
        }else{
            a[i][j]=-1;
        }
    }
}
a[1][1]=1;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(a[i][j]!=-1){
            if(a[i][j-1]!=-1){
                a[i][j]+=a[i][j-1];
            }
            if(a[i-1][j]!=-1){
                a[i][j]+=a[i-1][j];
            }
            a[i][j]%=(ll)(1e9+7);
        }
    }
}
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
  //      cout<<a[i][j]<<" ";
    }
//    cout<<endl;
}
cout<<a[n][m]<<endl;
}



Measured memory_bytes: 11412
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N, R, iR;

    cin >> N >> R;

    if(N < 10){
        iR = R + 100*(10-N);
    }
    else{
        iR = R;
    }

    cout << iR << endl;

    return 0;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String[] args) {

        // ??????????????????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);

        // ???????????????????????´??° (??????????????°??¨?¨???°) ???????????????.
        int tate = sc.nextInt();
        int yoko = sc.nextInt();

        // ???????????????????????´??° (?????????????´?) ?????????????????§??¨?????????.
        // ?????????????????¨?????????.
        // ????????????????§???????????¨????????????????.
        int[][] matrix = new int[tate][yoko];
        int sum = 0;
        int kado = 0;
        for (int i = 0; i < tate; i ++) {
            sum = 0;
            for (int j = 0; j < yoko; j ++) {
                matrix[i][j] = sc.nextInt();
                System.out.print(matrix[i][j] + " ");
                sum += matrix[i][j];
            }
            kado += sum;
            System.out.println(sum);
        }

        // ?????????????????¨?????????.
        for (int i = 0; i < yoko; i ++) {
            sum = 0;
            for (int j = 0; j < tate; j ++) { sum += matrix[j][i]; }
            System.out.print(sum + " ");
        }
        System.out.println(kado);
    }
}

Measured memory_bytes: 40456
N,M,X,Y=map(int, input().split())
x=max(map(int, input().split()))
y=min(map(int, input().split()))

c1 = set(range(X+1, Y+1))
c2 = set(range(x+1, y+1))

print("No War" if len(c1&c2) > 0 else "War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int n;
    cin >> n;
    ll a,b;
    cin >> a >> b;

    vector<ll> x;

    rep(i,n){
        ll tmp;
        cin >> tmp;
        x.pback(tmp);
    }

    ll ans = 0;

    rep(i,n - 1){
        if((x[i + 1] - x[i]) * a < b){
            ans += (x[i + 1] - x[i]) * a;
        }else{
            ans += b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d,n; cin>>d>>n;
  int ans=0;
  
  if(d==0){
    if(n==100) ans=101;
    else ans=n;
  }
  else if(d==1){
    if(n==100) ans=10100;
    else ans=n*100;
  }
  else{
    if(n==100) ans=1010000;
    else ans=n*10000;
  }
  cout<<ans<<endl;
}
    
    


Measured memory_bytes: 256
l=[]
t=0
for i in range(5):
  p=int(input())
  t+=p
  l.append(p%10)
l=sorted(l)
b=False
o=0
for i in l:
  if i!=0:
    if b==False:
      o=i
      b=True
    else:
      t+=10-i
  else:
    pass
print(t)

Measured memory_bytes: 3060
#77 C - Attention
N = int(input())
S = input()

# lw[i]: i より左にいる人の中で W を向いている人数をカウント
lw = [0]*N
cntw = 0
# 左に人がいるのは [1,N-1] 
for i in range(1,N):
    if S[i-1] == 'W':
        cntw += 1
    lw[i] = cntw

# re[j]: j より右にいる人の中で E を向いている人数をカウント
re = [0]*N
cnte = 0
# 右に人がいるのは [0,N-2]
for j in range(N-2,-1,-1):
    if S[j+1] == 'E':
        cnte += 1
    re[j] = cnte

ans = 10**10
for i,j in zip(lw,re):
    tot = i+j
    ans = min(tot,ans)
print(ans)

Measured memory_bytes: 23436
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
ll tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K % 2 == 0)
        cout << A - B << endl;
    else
        cout << B - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

int main()
{
	int a, b;
	cin >> a >> b;
	if (a - 2 * b >= 0) {
		cout << a - 2 * b << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

signed main()
{
   int N; cin >> N;
   vec<int> A(N);
   rep(i, 0, N) {
      cin >> A[i];
   }

   SORT(A);

   vec<int> D(N-1);
   rep(i, 0, N-1) {
      D[i] = A[i+1]-A[i];
   }

   int ans = 0;
   rep(i, 0, N-1) {
      ans += 2 * min(i+1, N-1-i) * D[i];
   }
   if ((N-1) % 2 == 1) {
      ans -= D[(N-1)/2];
   } else {
      ans -= min(D[(N-1)/2], D[(N-1)/2-1]);
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  300005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



// class MemoryGame{
// public:
// // vs construct(int n){
void solve(){
	ll n,k;
	cin>>n>>k;
	ll a[n+1]={0};
	rep(i,0,n){
		ll x;
		cin>>x;
		x--;
		a[i]=x;
		// cout<<x<<endl;
	}
	mii m;
	vi v;
	ll x=0,y=1;
	while(!m[x]){
		v.pb(x);
		m[x]=y;
		y++;
		x=a[x];
		// cout<<x<<endl;
	}
	if(k<sz(v)){
		cout<<v[k]+1<<endl;
		return;
	}
	ll z=m[x];
	ll aa=z;
	aa--;
	reverse(all(v));
	while(aa--){
		v.ppb();
		k--;
	}
	// cout<<sz(v)<<k;
	// k--;
	reverse(all(v));
	cout<<v[k%sz(v)]+1;


}
// };
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1,a,b;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}


Measured memory_bytes: 18456
// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)        (abs((a)-(b)) < EPS)
#define CILING(a, b)    (((a)+(b)-1LL)/(b))

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    int n;cin >> n;
    int ans = 1;
    for(;ans <= n;ans*=2){}
    if(ans > n) ans/=2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

 int a,b,c;

 char op;

 while(true){

 cin >> a >> op >> b;

 if (op == '?' ) break;

 if (op == '+') cout<< (a+b) <<endl; 
 else if (op == '-' ) cout << ( a- b) << endl;
 else if (op == '*') cout << (a*b) << endl;
 else cout << (a/b) << endl;

}

}


Measured memory_bytes: 3088
#include<stdio.h>
#define MAX 100
void dfs(int,int);
int adj[MAX][MAX];
int d[MAX];
int f[MAX];
int flg[MAX];
int time=0;

int main(){
  int n,i,j;
  int x,y,z;
	
  scanf("%d",&n);	
  for(i=0;i<n;i++){
    flg[i]=0;
    for(j=0;j<n;j++)
      adj[i][j]=0;
  }
	
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    for(j=0;j<y;j++){
      scanf("%d",&z);
      adj[x-1][z-1]=1;
    }
  }
	
  for(i=0;i<n;i++)
    if(!flg[i])
      dfs(i,n);
  for(i=0;i<n;i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);
  return 0;	
}
void dfs(int u,int n){	
  flg[u]=1;
  d[u]=++time;
  for(int i=0;i<n;i++){
    if(adj[u][i] && !flg[i]){
      dfs(i,n);
    }
  }
  f[u]=++time;
  return;	
}



Measured memory_bytes: 2056
n = int(input())
f = [0]*(n+1)
x = 1
while x*x < n:
    y = 1
    while y*y < n:
        if x*y >= n: break
        z = 1
        while z*z < n:
            k = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= k <= n: f[k] += 1
            z += 1
        y += 1
    x += 1
for i in range(1, n+1): print(f[i])


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solver() {
    int N = input();
    vector< int > cnt(100);

    range(i, 1, N + 1) {
        int d = i;
        for (int j = 2; j * j <= d; ++j) {
            while (d % j == 0) {
                cnt[j]++;
                d /= j;
            }
        }

        if (d != 1) cnt[d]++;
    }

    i64 ans = 0;
    range(i, 2, 100) range(j, 2, 100) range(k, 2, j) {
        if (i == j or j == k or k == i) continue;
        ans += (cnt[i] >= 2 and cnt[j] >= 4 and cnt[k] >= 4 ? 1 : 0);
    }

    range(i, 2, 100) range(j, 2, 100) {
        if (i == j) continue;
        ans += (cnt[i] >= 14 and cnt[j] >= 4 ? 1 : 0);
        ans += (cnt[i] >= 24 and cnt[j] >= 2 ? 1 : 0);
    }

    range(i, 2, 100) {
        ans += (cnt[i] >= 74 ? 1 : 0);
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

const int MAX_V=210;

int M,R;

vi route;

int d[MAX_V][MAX_V];
int V;
int ans=INF;

void warshall_floyd(){
    for(int k=0;k<V;k++)
        for(int i=0;i<V;i++)
            for(int j=0;j<V;j++)
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
}

signed main(){
    io();
    cin>>V>>M>>R;
    route.resize(R);
    rep(i,R){
        in(route[i]);
        route[i]--;
    }

    sort(all(route));

    fill(d[0],d[MAX_V-1],INF);
    rep(i,MAX_V) d[i][i]=0;
    int a,b,c;
    rep(i,M){
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    warshall_floyd();
    rep(i,V){
        rep(j,V) cerr<<d[i][j]<<" ";
        cerr<<endl;
    }

    int res;
    do{
        res=0;
        rep(i,R-1){
            res+=d[route[i]][route[i+1]];
        }
        //show(res);
        ans=min(ans,res);
    }while(next_permutation(all(route)));

    out(ans);

    return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
AC=[0]*(n+1)
WA=[0]*(n+1)

for i in range(m):
    p,s=map(str,input().split())
    if s=="AC":
        AC[int(p)]+=1
    elif s=="WA" and AC[int(p)]==0:
        WA[int(p)]+=1

for i in range(n+1):
    if AC[i]==0:
        WA[i]=0

cnt=AC.count(0)
answer=len(AC)-cnt
ans=sum(WA)
print(answer,ans)

Measured memory_bytes: 10456
import java.util.*;

class Main{
	public static void main(String[] a){
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] hen = new int[3];
		for(int i = 0 ; i < N ; i ++ ){
			for(int x = 0; x < 3 ; x++){
				hen[x] = scanner.nextInt();
			}
			Arrays.sort(hen);
			if(  (hen[2]*hen[2])  == (hen[0]*hen[0]  + hen[1]*hen[1]) ){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
    	}
}

Measured memory_bytes: 33088
#!/usr/bin/env python3
n, m = map(int, input().split())
mod = 10**9 + 7
if -2 < n - m < 2:
    d = 1
    s = 1
    for i in range(1, n + 1):
        d = d * i % mod
    for i in range(1, m + 1):
        s = s * i % mod
    print((d * s * (1 + (n == m))) % mod)
else:
    print(0)


Measured memory_bytes: 9140
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 10001

ll dp[N][101];

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

    string k;
    int d;
    cin>>k>>d;
    ifr(i,0,N) ifr(j,0,d) dp[i][j]=0;
    dp[0][0]=1;
    ifr(i,1,N) {
        ifr(j,0,d) {
            ifr(x,0,10) {
                dp[i][(j+x)%d] = (dp[i][(j+x)%d]+dp[i-1][j])%mod;
            }
        }
    }
    ll ans = 0,sum=0,st=1,n=k.length();
    ifr(i,1,n) {
        ifr(j,1,10)
            ans=(ans+dp[i-1][((d-j)%d +d)%d ])%mod;
    }
    ifr(i,0,n) {
        ifr(j,st,int(k[i]-'0')) {
            sum=(sum+j)%d;
            ans = (ans+dp[n-i-1][(d-sum)%d])%mod;
            sum=(sum-j+d)%d;
        }
        st=0;
        sum=(sum+(k[i]-'0')+d)%d;
    }
    if(sum==0) ans=(ans+1)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int K, S; cin >> K >> S;
    int cnt = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z <= K) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# D - Ki

from collections import deque

n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

cnt = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    cnt[p] += x

done = [-1]*n
done[0] = 1
d = deque()
d.append((0, 0))

while len(d)>0:
    v = d.popleft()
    cnt[v[0]] += v[1]
    done[v[0]] = 1
    for i in graph[v[0]]:
        if done[i]<0:
            d.append((i, cnt[v[0]]))

print(' '.join(map(str, cnt)))


Measured memory_bytes: 67272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

template <class T>
T mult(T n,T m){
	if(m==0) return 1;
	if(m==1){
		return n%mod;
	}else if(m%2==0){
		T t=mult(n,m/2);
		return (t*t)%mod;
	}else{
		T t=mult(n,m-1);
		return (t*n)%mod;
	}
}

vector<ll> d1(200010),d2(200010);
template <class T>
void make_table(T N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			d1[i]=1;
			d2[i]=1;
		}else{
			d1[i]=(i*d1[i-1])%mod;
			d2[i]=mult(d1[i],mod-2);
		}
	}
}

template <class T>
T comb_mod_2(T n,T k){
	if(n<k) return 0;
	return (((d1[n]*d2[n-k])%mod)*d2[k])%mod;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<int> a(n+2);
	map<int,int> cnt;
	int tar;
	FOR(i,1,n+2){
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(auto itr:cnt){
		if(itr.se==2){
			tar=itr.fi;
			break;
		}
	}
	ll l=-1,r;
	FOR(i,1,n+2){
		if(a[i]==tar){
			if(l==-1) l=i;
			else r=i;
		}
	}
	make_table(200010);
	FOR(k,1,n+2){
		ll ans=comb_mod_2(n+1,k)-comb_mod_2(n+l-r,k-1);
		ans=(ans+mod)%mod;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 9472
#include <cstdio>
#include <vector>
#include <string>
#include <cassert>

struct Tree {
  std::string s;
  struct Node {
    Node *left, *right;
    int value;
  } *root;
  
  Tree(const std::string &s): s(s) {
    size_t i=0;
    root = new Node;
    root->left = root->right = nullptr;
    root->value = 114514;
    parse(root, i);
  }

  void parse(Node *root, size_t &i) {
    root->left = parse_node(i);
    root->value = parse_value(i);
    root->right = parse_node(i);
  }

  Node *parse_node(size_t &i) {
    assert(s[i] == '(');
    ++i;

    Node *node;
    if (s[i] == '(') {
      node = new Node;
      parse(node, i);
    } else {
      assert(s[i] == ')');
      node = nullptr;
    }
    ++i;
    return node;
  }

  int parse_value(size_t &i) {
    assert(s[i] == '[');
    ++i;

    int res=0;
    while (s[i] != ']') {
      res = res*10 + s[i]-'0';
      ++i;
    }
    ++i;

    return res;
  }
};

void print_sum(Tree::Node *ra, Tree::Node *rb) {
  if (ra == nullptr || rb == nullptr) {
    return;
  }

  printf("(");
  print_sum(ra->left, rb->left);
  printf(")");

  printf("[%d]", ra->value+rb->value);

  printf("(");
  print_sum(ra->right, rb->right);
  printf(")");
}

int main() {
  char buf[1024];
  scanf("%s", buf);
  std::string A=buf;
  scanf("%s", buf);
  std::string B=buf;

  Tree ta(A), tb(B);
  print_sum(ta.root, tb.root);
  printf("\n");
}



Measured memory_bytes: 2896