akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct edge {
    int to, cost;
};

int n, m;
int u[110000], v[110000], s[110000];
vector<edge> G[110000];
int potential[110000];
bool even[110000], visited[110000];

void dfs(int s, bool ev, int pot) {
    visited[s] = true;
    even[s] = ev;
    potential[s] = pot;
    for (int i = 0; i < G[s].size(); i++) {
        if (!visited[G[s][i].to]) {
            dfs(G[s][i].to, !ev, G[s][i].cost - pot);
        }
    }
}

signed main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i] >> s[i];
        G[u[i]].push_back({v[i], s[i]});
        G[v[i]].push_back({u[i], s[i]});
    }
    dfs(1, true, 0);
    for (int i = 0; i < m; i++) {
        if (abs(potential[u[i]] + potential[v[i]]) % 2 != s[i] % 2) {
            cout << 0 << endl;
            return 0;
        }
        if (potential[u[i]] + potential[v[i]] != s[i]) {
            fill(visited, visited + 110000, false);
            dfs(u[i], true, potential[u[i]] - (potential[u[i]] + potential[v[i]] - s[i]) / 2);
            for (int i = 0; i < m; i++) {
                if (potential[u[i]] + potential[v[i]] != s[i]) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            for (int i = 1; i <= n; i++) {
                if (potential[i] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << 1 << endl;
            return 0;
        }
    }
    fill(visited, visited + 110000, false);
    dfs(1, true, 1);
    for (int i = 0; i < m; i++) {
        if (abs(potential[u[i]] + potential[v[i]]) % 2 != s[i] % 2) {
            cout << 0 << endl;
            return 0;
        }
        if (potential[u[i]] + potential[v[i]] != s[i]) {
            fill(visited, visited + 110000, false);
            dfs(u[i], true, potential[u[i]] - (potential[u[i]] + potential[v[i]] - s[i]) / 2);
            for (int i = 0; i < m; i++) {
                if (potential[u[i]] + potential[v[i]] != s[i]) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            for (int i = 1; i <= n; i++) {
                if (potential[i] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << 1 << endl;
            return 0;
        }
    }

    int min1 = LLONG_MAX, min2 = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        if (even[i]) {
            min1 = min(min1, potential[i]);
        } else {
            min2 = min(min2, potential[i]);
        }
    }
    if (min1 + min2 <= 0)
        cout << 0 << endl;
    else
        cout << min1 + min2 - 1 << endl;
}

Measured memory_bytes: 16256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int V = 20;
struct edge {
	int a, b, c;
};
int main() {
	int N;
	cin >> N;
	vector<edge> ans;
	for (int i = 0; i < V - 2; ++i) {
		if (N % 2 == 1) {
			ans.push_back(edge{ i, V - 1, N - 1 });
			--N;
		}
		if (N != 0) {
			ans.push_back(edge{ i, i + 1, 0 });
			ans.push_back(edge{ i, i + 1, N / 2 });
			N /= 2;
		}
	}
	for (int i = 0; i < N; ++i) {
		ans.push_back(edge{ V - 2, V - 1, i });
	}
	cout << V << ' ' << ans.size() << endl;
	for (edge e : ans) {
		cout << e.a + 1 << ' ' << e.b + 1 << ' ' << e.c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
	//数列を入力
	//前後の数と比較して2番目に小さい
	//{9, 6, 3, 2, 5, 8, 7, 4, 1}

	const int MAX = 20;
	int a[MAX];

	int n = 0;

	cin >> n;

	int num = 0;

	//整数書き込み
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	for (int i = 1; i < n-1; i++) {

		if ((a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] > a[i + 1])) {
			num++;

		}

	}

	cout << num;


}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

//解説AC
//https://atcoder.jp/contests/agc016/submissions/4398884
//実装力がほしい

map<char, int> mp;
int n;

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string s;
  int ans = 1e9/2;
  string max_s = "";
  cin >> s;
  n = s.size();

  REP(i, 26){
    char word = char('a'+i);
    int num=0;
    string tmp1=s, tmp2;
    while(count(tmp1.begin(), tmp1.end(), word) != tmp1.size()){
      tmp2 = tmp1;
      tmp1 = "";
      REP(i, tmp2.size()-1){
	if(tmp2[i] == word || tmp2[i+1] == word){
	  tmp1 += word;
	}
	else{
	  tmp1 += tmp2[i];
	}
      }
      num++;
    }
    ans = min(ans, num);
  }
  
  cout << ans << endl;

  
  return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<int> ans(N + 1, 0);
    for_(x,1,101) for_(y,1,101) for_(z,1,101) {
        int n = x * x + y * y + z * z + x * y + x * z + y * z;
        if (n <= N) ++ans[n];
    }

    for_(i,1,N+1) cout << ans[i] << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l;
    cin >> l;
    double ans = l*l*l;
    printf("%f\n",ans/27);
}

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

int main(){
	string str;
	int l1, l2, l3;
	int p;
	int t, h;
	
	t = 0; h = 0;
	while(getline(cin, str)){
		l1 = 0; l2 = 0; l3 = 0; p = 0;
		while(p < str.size() && str[p] != ','){
			l1 = l1 * 10 + (str[p] - 48);
			p++;
		}
		p++;
		while(p < str.size() && str[p] != ','){
			l2 = l2 * 10 + (str[p] - 48);
			p++;
		}
		p++;
		while(p < str.size() && str[p] != ','){
			l3 = l3 * 10 + (str[p] - 48);
			p++;
		}
		
		if(l1 * l1 + l2 * l2 == l3 * l3) t++;
		if(l1 == l2) h++;
	}
	
	cout << t << endl << h << endl;
	
	return 0;
}

Measured memory_bytes: 1172
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;
public class Main {
	
	private HashMap<String, Pair> thisM, thatM;
	private class Pair {
		public int a, b;
		public Pair( int a, int b ) {
			this.a = a;
			this.b = b;
		}
	}
	private Scanner sc;
	private void init() {
		thisM = new HashMap<String, Pair> ();
		thatM = new HashMap<String, Pair> ();
		
		for( int a = 0; a < 26; a++ ) {
			if( a % 2 == 0 || a % 13 == 0 ){ continue; }
			for( int b = 0; b < 26; b++ ) {
				String thisT = "", thatT = "";
				Pair p = new Pair( a, b );
				for( int i = 0; i < 4; i++ ) {
					thisT += (char)( 'a' + ( ( "this".charAt(i) - 'a' ) * a + b ) % 26 ) + "";
					thatT += (char)( 'a' + ( ( "that".charAt(i) - 'a' ) * a + b ) % 26 ) + "";
				}
				thisM.put( thisT, p );
				thatM.put( thatT, p );
			}
		}
		
	}
	private void run() {
		init();
		sc = new Scanner( System.in );
		int n = sc.nextInt();
		sc.nextLine(); // pass \n
		
		for( int i = 0; i < n; i++ ) { //<dataset>
			String line = sc.nextLine();
			String[] words = line.split(" ");
			ArrayList<String> fourLengthWords = new ArrayList<String>();
			for( int j = 0; j < words.length; j++ ) {
				if( words[ j ].length() == 4 ) {
					fourLengthWords.add( words[ j ] );
				}
			}

			// aとbを求めたら, 復号
			for( String str : fourLengthWords ) {
				Pair p1 = thisM.get( str );
				Pair p2 = thatM.get( str );
				if( p1 != null ) {
					System.out.println( decode( line, p1 ) );
					break;
				} else if( p2 != null ) {
					System.out.println( decode( line, p2 ) );
					break;
				}
				
			}
			
		} // </dataset> 
	}
	
	private String decode( String line, Pair p ) {
		char[] cstr = line.toCharArray();
		String dest ="";
		for( int i = 0; i < cstr.length; i++ ) {
			if( cstr[ i ] == ' ' ) {
				dest += " ";
				continue;
			}
			for( int j = 0; ; j++ ) {
				int dist = 26 * j - p.b;
				if( ( cstr[ i ] - 'a' + dist ) % p.a == 0 )  {
					dest += (char)( ( cstr[ i ] - 'a' + dist ) / p.a % 26 + 'a' ) + "";
					break;
				}
			}
		}
		return dest;
	}
	
	public static void main( String[] args ) {
		new Main().run();
	}
}

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

int main(){
    int a[11][5];
    int b[11];
    memset(b,0,sizeof(b));
    a[0][0]=4;
    b[4]++;
    for(int i=1;i<11;i++){a[i][0]=(a[i-1][0]+8)%11;b[a[i][0]]++;}
    for(int i=0;i<11;i++){
        for(int j=1;j<5;j++){
            a[i][j]=(a[i][j-1]+9)%11;
            b[a[i][j]]++;
        }
    }
    int n,k;
    cin >> n >>k;
    n=n-2;
    long long ans=0;
    if(n>=11){ans+=b[k]*(n/11);}
    for(int i=0;i<n%11;i++){
        for(int j=0;j<5;j++){
            if (a[i][j]==k){ans++;}
        }
    }
    cout << ans <<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.*
import java.io.PrintWriter

val pw = PrintWriter(System.out)
val MOD = 1000000007L
val INF = 2147483647
val LINF = 9223372036854775807L

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

fun solve(){
    val (n, m) = nextIntList()
    val count = IntArray(n) { 0 }
    var ans = "YES"
    
    repeat(m) { 
        val (a, b) = nextIntList()
        count[a - 1] += 1
        count[b - 1] += 1
    }
    for (i in 0 until n) {
        if(count[i] % 2 != 0){
            ans = "NO"
            break;
        }
    }

    println(ans)

}


// Print
fun println(v: String){
    pw.println(v)
}
fun print(v: String){
    pw.print(v)
}

// Read
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextLongList() = next().split(" ").map{ it.toLong() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextAryln(n: Int) = Array(n){ next() }
fun nextIntAryln(n: Int) = IntArray(n){ nextInt() }
fun nextLongAryln(n: Int) = LongArray(n){ nextLong() }
fun nextDoubleAryln(n: Int) = DoubleArray(n) { nextDouble() }

// Math
fun abs(n: Long) : Long = Math.abs(n)
fun abs(n: Double) : Double = Math.abs(n)
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long = listOf(a, b, c, d, e).max()!!.toLong()
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long = listOf(a, b, c, d, e).min()!!.toLong()
fun prime(from: Long, to: Long = from) : List<Long>{
    return (from..to).filter{ i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all{ j -> i % j != 0L}
    }
}
fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))
fun lcm(a: Long, b: Long) : Long = a / gcd(a, b) * b
fun modpow(a: Long, n: Long, p:Long = MOD) : Long {
    var res = 1L
    var ar = a
    var nr = n
    while(nr > 0){
        if((nr and 1) == 1L) res = res * ar % p
        ar = ar * ar % p
        nr = nr shr 1
    }
    return res
}
fun modinv(a: Long, p: Long = MOD) : Long = modpow(a, p - 2, p)
fun ncr(n: Long, r: Long) : Long {
    var a = 1L
    var b = 1L
    for (i in 1..r) {
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    }
    return modinv(b, MOD) * a % MOD
}

data class Node(val id: Int, var past: Int = -1, var edges: MutableList<Edge> = mutableListOf())
data class Edge(val from: Int, val to: Int, val cost: Long = 1L)

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

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  
  cout << fixed << setprecision(10);
  
  double X, Y;
  X = W/2;
  Y = H/2;
  
  double S;
  
  S = W * H / 2;
  cout << S << ' ';
  
  if (x == X && y == Y) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  
  

 
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int ans = 0, max = 0;
  for(int i = 0; i < S.length(); i++){
    if(S[i] == 'R') max++;
    else if(max > ans){
      ans = max;
      max = 0;
    }
  }
  if(max > ans) ans = max;
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b;
    cin >>k>>a>>b;
    for(int i=a;i<=b;i++){
        if (i%k==0){
            cout << "OK" << endl;
            exit(0);
        }

    }
    cout << "NG" << endl;



    



}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int n5 = 0, n7 = 0;
	for(int i = 0; i < 3; i++) {
		int A;
		cin >> A;
		if(A == 5)
			n5++;
		else if(A == 7)
			n7++;
	}
	if(n5 == 2 && n7 == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> cnt(n, 0);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }
  ll sum = 0;
  rep(i, n) {
    sum += cnt[i] * (cnt[i] - 1) / 2;
  }
  vector<ll> ans(n, sum);
  rep(i, n) {
    ans[i] -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
    ans[i] += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 7124
#include <iostream>
using namespace std;
int a=1,b=0,t,sum=0,n,m,soma1,soma2=0,sum1;

int dig(int l);

int main(){
cin>>n;
b=n-1;
soma2=dig(a)+dig(b);


for(int j=0;j<=(n/2)-2;j++){
    a++;
    b=n-a;
    soma1 = dig(a)+dig(b);
    if (soma1<soma2){soma2=soma1;}
    soma1=0;

}
cout<<soma2<<endl;
return 0;
}

int dig(int l){
while(l>0){
        m=l%10;
        sum=sum+m;
        l=l/10;}
sum1=sum;
sum=0;
return sum1;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int H,W,K;
char c[6][6];

int main(){
    cin>>H>>W>>K;
    rep(i,H) rep(j,W) cin>>c[i][j];

    int ans=0;
    rep(h,1<<H){
        rep(w,1<<W){
            int sum=0;
            rep(i,H){
                if(h>>i&1) continue;
                rep(j,W){
                    if(w>>j&1) continue;
                    if(c[i][j]=='#') sum++;
                }
            }
            if(sum==K) ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int a, b, c, x, y, z;
	scanf("%d" "%d" "%d" , &a, &b, &c);
	if(a>=b)
	{
		x=a;
		y=b;}
		else
		{
			x=b;
			y=a;
		}
	if(y>=c)
	{
		z=c;}
	else
		{if(x>=c)
        {
			z=y;
			y=c;
		}
         else
         {
           x=c;
           y=b;
           z=a;
         }
        }
	
	printf("%d\n", x*10+y+z);
	
	return 0;
}

Measured memory_bytes: 128
main :: IO ()
main = do
  ss <- getLine
  let [a1,m1,a2,m2,a3,m3] = map (read :: String -> Int) . words $  ss
  if [a1,m1,a2,m2,a3,m3] == [0,0,0,0,0,0]
    then return ()
    else do
      let ans = getAns [a1,m1,a2,m2,a3,m3]
      putStrLn $ show ans
      main

getAns :: [Int] -> Int
getAns [a1,m1,a2,m2,a3,m3] = c1 `koubaisuu` c2 `koubaisuu` c3
  where c1 = getCicle 1 a1 m1 0
        c2 = getCicle 1 a2 m2 0
        c3 = getCicle 1 a3 m3 0

getCicle :: Int ->Int -> Int -> Int -> Int
getCicle 1 a m 0 = getCicle (a `mod` m) a m 1
getCicle 1 a m count = count
getCicle x a m count = getCicle (a*x `mod` m) a m (count + 1)

gojohou :: Int -> Int -> Int
gojohou x y
  | x `mod` y == 0 = y
  | otherwise  = gojohou y (x `mod` y)

koubaisuu :: Int -> Int -> Int
koubaisuu x y = (x * y) `div` (gojohou (max x y) (min x y))

Measured memory_bytes: 7504
#include<bits/stdc++.h>
using namespace std;
vector<int>dp(100000001,-1);
int main(){
	int n;
	cin>>n;
	vector<int> h;
	for(int i=0;i<n;i++){
		int h1;
	    cin>>h1;
	    h.push_back(h1);
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
	    if(i==1)
			dp[i]=abs(h[i-1]-h[i]);
		else		
		dp[i]=min(abs(h[i-2]-h[i])+dp[i-2],abs(h[i-1]-h[i])+dp[i-1]);
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}


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

long long R,C,startr,startc,finishr,finishc,dist[1010][1010]; 
string arr[1010]; bool visited[1010][1010];

void Input(){
	cin>>R>>C>>startr>>startc>>finishr>>finishc;
	for(long long i=0; i<R; i++){
		cin>>arr[i];
	}
}

void Initialize(){
	for(long long i=0; i<R; i++){
		for(long long j=0; j<C; j++){
			dist[i][j]=-1;
		}
	}
}

bool check(long long i, long long j){
	if(i<0||i>=R||j<0||j>=C){
		return false;
	}
	if(arr[i][j]=='.')return true;
	if(arr[i][j]=='#')return false;
}

void bfs(){
	queue<pair<long long,long long>> q[1050000];
	q[0].push(make_pair(startr-1,startc-1));
	for(long long idx=0; idx<=1010000; idx++){
		while(!q[idx].empty()){
			long long i=q[idx].front().first,j=q[idx].front().second; q[idx].pop();
			if(visited[i][j])continue;
			visited[i][j]=true; dist[i][j]=idx;
			if(check(i+1,j))q[idx].push(make_pair(i+1,j));
			if(check(i-1,j))q[idx].push(make_pair(i-1,j));
			if(check(i,j+1))q[idx].push(make_pair(i,j+1));
			if(check(i,j-1))q[idx].push(make_pair(i,j-1));
			for(long long a=-2; a<=2; a++){
				for(long long b=-2; b<=2; b++){
					if(check(i+a,j+b))q[idx+1].push(make_pair(i+a,j+b));
				}
			}
		}
	}
}

int main(){
	Input(); Initialize(); bfs();
	cout<<dist[finishr-1][finishc-1]<<'\n';
}

Measured memory_bytes: 723716
k=int(input())
A=[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]
print(A[k-1])

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

using namespace std;

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

    int ans = 1e5;
    for (int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == int(1e5)) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n;
    cin>>n;
    if(n==1 || n==0){
        cout<<0;
        return 0;
    }
    if(n%2){
        cout<<0;
    }
    else {
        long long int count =0;
        n/=2;
        while(n!=0){
            n/=5;
            count+=n;
        }
        cout<<count;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    //
    map<ll, ll> mp;

    for(ll i = 1; i < n; ++i){
        ll score = i-(a[0]+a[i]);
        if(mp.count(score) == 0)mp[score] = 1;
        else{
            mp[score] = mp[score]+1;
        }
    }

    // for(auto itr=mp.begin();itr!=mp.end();itr++)cout << itr->first << ", " << itr->second << endl;

    ll ans = mp[0];

    for(int i = 1; i < n; ++i){
        ll s0 = i-(a[0]+a[i]);
        mp[s0]--;
        ll score = i + (a[i]-a[0]);
        // cout << i << "score " << score << ", " << mp[score] << endl;
        ans += mp[score];
    }

    cout << ans << endl;
}

Measured memory_bytes: 27312
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
  ll X;
  cin >> X;

  cout << (X / 500 * 1000) + (X % 500 / 5 * 5) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define C(n,m) ((LL)fac[n]*ifac[m]%mo*ifac[(n)-(m)]%mo)

int gcd(int a,int b) {return b?gcd(b,a%b):a;}

const int maxn=55;
const int maxm=555;
const int mo=1e9+7;

int n,m,K,Ans=1,times,dfn[maxn],low[maxn];
int tote=1,TO[maxm],FIR[maxn],NEXT[maxm];
int fac[maxm],ifac[maxm];
stack<int> st;
bool iscut[maxn];
int bcc_cnt,col[maxn],point[maxn],edge[maxn];
vector<int> bcc[maxn];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

void tarjan(int u,int fp)
{
	int son=0;
	dfn[u]=low[u]=++times;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		if ((p^1)==fp) continue;
		int v=TO[p];
		if (!dfn[v])
		{
			son++;
			st.push(p);
			tarjan(v,p);
			low[u]=min(low[u],low[v]);
			if (low[v]>=dfn[u])
			{
				iscut[u]=1;
				bcc_cnt++;
				while (1)
				{
					int e=st.top(); st.pop();
					edge[bcc_cnt]++;
					v=TO[e];
					if (col[v]!=bcc_cnt)
					{
						col[v]=bcc_cnt;
						bcc[bcc_cnt].push_back(v);
						point[bcc_cnt]++;
					}
					v=TO[e^1];
					if (col[v]!=bcc_cnt)
					{
						col[v]=bcc_cnt;
						bcc[bcc_cnt].push_back(v);
						point[bcc_cnt]++;
					}
					if (e==p) break;
				}
			}
		}
		else
		{
			if (dfn[v]<dfn[u])
			{
				st.push(p);
				low[u]=min(low[u],dfn[v]);
			}
		}
	}
	if (!fp&&son==1) iscut[u]=0;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,u,v;
	fac[0]=1;
	for (i=1;i<=500;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	ifac[500]=power(fac[500],mo-2);
	for (i=500;i>=1;i--)
		ifac[i-1]=(LL)ifac[i]*i%mo;
	scanf("%d%d%d",&n,&m,&K);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	for (i=1;i<=n;i++)
		if (!dfn[i]) tarjan(i,0);

	for (i=1;i<=bcc_cnt;i++)
	{
		if (edge[i]==1)
		{
			Ans=(LL)Ans*K%mo;
			continue;
		}
		if (edge[i]==point[i])
		{
			int Sum=0;
			for (int j=1;j<=edge[i];j++)
				(Sum+=power(K,gcd(j,edge[i])))%=mo;
			Sum=(LL)Sum*power(edge[i],mo-2)%mo;
			Ans=(LL)Ans*Sum%mo;
			continue;
		}
		Ans=(LL)Ans*C(edge[i]+K-1,K-1)%mo;
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

int n;
map<pair<int, int>, bool> memo;

int divisor(int n) {
	int ret = 0;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret++;
			if (i != n / i)
				ret++;
		}
	}
	return ret;
}

int main(void) {
	cin >> n;
	int ret = 0;
	for (int i = 1; i < n; i++) {
		ret += divisor(n - i);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int answer = 753;
    for(int i=0;i<s.length()-2;i++){
      answer = Math.min(answer,Math.abs(753-Integer.parseInt(s.substring(i,i+3))));
    }
    System.out.println(answer);
      
  }
  

  
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}

int main(void){
  int N; cin >> N;
  
  bool money_equal_N = false;
  for(int i=0;i<N;i++){
  	for(int j=0;j<N;j++){
      if(i==0 && j==0) continue;
      if(N%(i*4+j*7)==0) money_equal_N = true;
    }
  }
  if(money_equal_N) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int k,n[100001]={0},q[100001]={0},i=0,j=1,l,x;
  scanf("%d",&k);
  n[1]=q[0]=1;
  while(!n[0]){
    for(l=i;l<j;l++){x=q[l]*10%k;while(!n[x]){n[x]=n[q[i]];q[j]=x;j++;x=x*10%k;}}
    for(l=i;n[q[i]]==n[q[l]];l++)if(!n[(q[l]+1)%k]){n[(q[l]+1)%k]=n[q[i]]+1;q[j]=(q[l]+1)%k;j++;}
    i=l;
  }
  printf("%d",n[0]);
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
	cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll x[n],inv[n];
    for(int i=0;i<n;i++)inv[i]=1;
    for(int i=0;i<n;i++)cin>>x[i];
    for (int i=2;i<n;i++) {
        inv[i] = ll(mod-mod/i)*inv[mod%i]%mod;
    }
    ll ret = 0, sum = 0;
    for (int i = 0; i + 1 < n; ++i) {
        sum+=inv[i + 1];
        sum%=mod;
        ret+=(x[i+1]-x[i])*sum%mod;
    }
    ret%=mod;
    for (int i=1;i<n;i++)ret=ret*i%mod;
    cout << ret<<endl;
    return 0;
}


Measured memory_bytes: 1792
#   Battle

class Monster:
    def __init__(self, hp, attack):
        self.hp = hp
        self.attack = attack
        self.death = False


class Game:
    def __init__(self, monsters: list):
        self.monsters = monsters

    def calc_damage(self, offence, defence):
        self.monsters[defence].hp -= self.monsters[offence].attack
        if self.monsters[defence].hp <= 0:
            self.monsters[defence].death = True
        return self.monsters[defence].death

    def battle(self):
        while True:
            self.calc_damage(0, 1)
            if self.monsters[1].death:
                print("Yes")
                break
            self.calc_damage(1, 0)
            if self.monsters[0].death:
                print("No")
                break


a, b, c, d = map(int, input().split())

t_monster = Monster(a, b)
a_monster = Monster(c, d)

game = Game([t_monster, a_monster])
game.battle()


Measured memory_bytes: 9124
from itertools import accumulate
from collections import Counter
N = int(input())
S = list(input())
kuro = [0]*N
shiro = [0]*N
ans = N

for i in range(N):
    if S[i] == "#":
        kuro[i] = 1
    else:
        shiro[i] = 1
shiro.reverse()
shiro = list(accumulate(shiro))
kuro = list(accumulate(kuro))

for i in range(N-1):
    ans = min(ans, kuro[i]+shiro[N-i-2])

ans = min(ans, kuro[N-1])
S = Counter(S)
ans = min(ans, S["#"], S["."])
print(ans)


Measured memory_bytes: 27952
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS        = 1e-10;
const double    PI         = acos(-1.0);
const int       INFTY_INT  = (1<<21);
const ll        INFTY_LL   = (1LL<<60);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    const int n = 10;
    int h, w; cin >> h >> w;
    vvi costs, walls;
    REP(i, n) {
        vi v;
        REP(j, n) {
            int c; cin >> c;
            v.push_back(c);
        }
        costs.push_back(v);
    }

    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
            }
        }
    }

    int ans = 0;
    REP(i, h){
        REP(j, w){
            int wall; cin >> wall;
            if (wall == -1 || wall == 1) continue;
            ans += costs[wall][1];
        }
    }

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

//nCmを n*(n-1)*(n-2)... / (1 * 2 * 3 ... )　の式で求める
//除算を行うために逆元を求める

ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

const int M = 200001;
ll fact[M];

ll mod_fact(ll n, ll p, ll &e) {
	e = 0;
	if (n == 0)return 1;
	ll res = mod_fact(n / p, p, e);
	e += n / p;

	if (n / p % 2 != 0)return res * (p - fact[n % p]) % p;
	return res * fact[n % p] % p;
}

ll mod_comb(ll n, ll k, ll p) {
	if (n < 0 || k < 0 || n < k)return 0;
	ll e1, e2, e3;
	ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	if (e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

signed main() {

	fact[0] = 0;
	fact[1] = 1;
	for (int i = 2; i < M; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}

	int ans = 0;
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	for (int x = b; x < w; x++) {
		int xt0 = x + 1, yt0 = h - a - (x - b);
		int p0 = mod_comb(xt0 + yt0 - 2, xt0 - 1 , mod);

		int xt1 = w - x, yt1 = a + 1 + (x - b);
		int p1 = mod_comb(xt1 + yt1 - 2, xt1 - 1, mod);

		ans += (p0 * p1) % mod;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	ll n; cin >> n;
	if(n) cout << "0";
	else cout << "1";
	return 0;
}


Measured memory_bytes: 3644
x = []
for i in range(5):
    x.append(int(input()))

k=int(input())

for i in range(len(x) - 1):
    for j in range(i + 1, len(x)):
        if x[j] - x[i] > k:
            print(':(')
            quit()
    
print('Yay!')

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

int main()
{
  int N;
  int K;
  cin >> N >> K;
  
  vector<int> p(N);
  int total = 0;
  
  for(int i = 0; i < N; i++){cin >> p.at(i);}
  sort(p.begin(), p.end());
  for(int i = 0; i < K; i++){total += p.at(i);}
  cout << total << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

bool map[20][20];//true??????
int W,H,X,Y;
int ct;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

bool valid(int x,int y) {
	return 0 <= x && x < W && 0 <= y && y < H && map[x][y];
}

void dfs(int x,int y) {
	map[x][y] = false;
	ct++;
	for(int i = 0;i < 4;i++) {
		if(valid(x + dx[i],y + dy[i])) dfs(x + dx[i],y + dy[i]);
	}
}

int main() {
	while(cin >> W >> H && !(W == 0 && H == 0)) {
		ct = 0;
		for(int y = 0;y < H;y++) {
			char c;
			for(int x = 0;x < W;x++) {
				cin >> c;
				map[x][y] = !(c == '#');
				if(c == '@') {
					X = x;
					Y = y;
				}
			}
		}
		dfs(X,Y);
		cout << ct << endl;
	}
}

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

double pi = acos(-1);
typedef complex<double> P;
int main(){
	int a,b;
	P p;
	P d = P(0,1);
	while( scanf("%d,%d",&a,&b) != -1 ){
		p += (1.0 * a) * d;
		d *= exp(P(0,-pi*b/180));
		
	}
	cout << (int)p.real() << "\n" << (int)p.imag() << endl;
}

Measured memory_bytes: 3508
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string[] raw = Console.ReadLine().Split(' ');
            int a = int.Parse(raw[0]);
            int b = int.Parse(raw[2]);
            switch (raw[1])
            {
                case "+":
                    Console.WriteLine(a + b);
                    break;
                case "-":
                    Console.WriteLine(a - b);
                    break;
                case "*":
                    Console.WriteLine(a * b);
                    break;
                case "/":
                    Console.WriteLine(a / b);
                    break;
                case "?":
                    return;
            }
        }
    }
}

Measured memory_bytes: 17960
def main():
  Inf = 10**8
  N, M = list(map(int, input().split(" ")))
  keys = []
  for _ in range(M):
      c = list(map(int, input().split(" ")))
      j = list(map(int, input().split(" ")))
      keys.append([c[0], sum([1 << k-1 for k in j])])
  dp = [Inf for _ in range(1 << N)]
  dp[0] = 0
  for i in range(len(dp)):
      for key in keys:
          t = i | key[1]
          dp[t] = min(dp[t], key[0] + dp[i])
  if dp[-1]==Inf:
      print(-1)
  else:
      print(dp[-1])
main()

Measured memory_bytes: 3316
n = int(input())

m = 10**5

edge = [[] for i in range(2*m)]

for i in range(n):
    x,y = map(int,input().split())
    x -= 1
    y -= 1 
    y += m
    edge[x].append(y)
    edge[y].append(x)

used = [False]*2*m

res = 0

for e in range(m):
    if used[e]:
        continue
    used[e] = True
    tank = []
    new = [e]

    px = 0
    py = 0

    if e >= 10**5:
        py += 1
    else:
        px += 1

    while len(new) > 0:
        tank = []
        for fr in new:
            for go in edge[fr]:
                if not used[go]:
                    tank.append(go)
                    used[go] = True
                    if go >= 10**5:
                        py += 1
                    else:
                        px += 1

        new = tank
    
    res += px*py
print(res-n)


Measured memory_bytes: 68684
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    vi a(n); for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    map<ll, ll> mm;
    forn(i, n) mm[a[i]]++;
    while (mm.size())
    {
        auto it = mm.end();
        it--;
        pair<ll, ll> x = *it;
        if ((x.first & (x.first - 1)) == 0)
        {
            ans = ans + x.second / 2;
            mm.erase(it);
        }
        else
        {
            int J = 0;
            for (int j = 0; j <= 30; j++)
            {
                if ((1ll << j) > x.first)
                {
                    J = j;
                    break;
                }
            }
            int y = (1ll << J) - x.first;
            int cnt = min(mm[y], x.second);
            mm[y] -= cnt;
            mm[x.first] -= cnt;
            ans += cnt;
            //cout << x.first << " " << y << endl;
            mm.erase(x.first);
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 14336
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

long long int h, w, a, b, cvp, faktoriyel[1000000];
//a=h, b=w

long long int fe(long long int base, long long int ust){
	if(ust==1)return base;
	if(ust%2==0)return (fe((base*base)%MOD, ust/2))%MOD;
	return (fe((base*base)%MOD, ust/2)*base)%MOD;
}

long long int hesapla(long long int x, long long int y){
	return  (((faktoriyel[h+w-x-y]*((fe(faktoriyel[h-x], MOD-2)*fe(faktoriyel[w-y], MOD-2))%MOD) )%MOD)
		*
			(((faktoriyel[x+y-1-1]*((fe(faktoriyel[x-1], MOD-2)*fe(faktoriyel[y-1], MOD-2))%MOD) )%MOD)
				))
	%MOD;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	faktoriyel[0]=1;
	for(int i=1;i<1000000;i++)faktoriyel[i]=(i*faktoriyel[i-1])%MOD;
	cin>>h>>w>>a>>b;
	a=h-a;
	b++;
	while(b<=w&&a>0){
		cvp=(cvp+hesapla(a, b))%MOD;
		a--;b++;
	}
	cout<<cvp;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <map>
#include <utility>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
        return 0;
    }else if(a>b){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(a<b){
        cout<<"LESS"<<endl;
        return 0;
    }else{
        cout<<"EQUAL"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

#nCrは以下のやつ全てを使ってください
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]
 
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]
 
def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def nPr(n,r):
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

S = int(input())
M = S//3

ans = 0
for i in range(1,M+1):
    t = S-i*3

    ans += nCr(t+i-1,i-1)
    ans %= MOD

print(ans)

Measured memory_bytes: 73060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 出力
		System.out.println(a == 2 || b == 2 ? "No" : "Yes");
	}
}


Measured memory_bytes: 22740
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0
for i in range(n):
  index_a = bisect.bisect_left(a, b[i])
  index_c = bisect.bisect_right(c, b[i])
  
  ans += index_a * (n - index_c)
  
print(ans)

Measured memory_bytes: 23240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int inputNum = Integer.parseInt(br.readLine());

		System.out.print(inputNum + ":");
		List<Integer> list = new ArrayList<>();

		for (int i = 2; i * i <= inputNum; i++) {
			while (inputNum % i == 0) {
				inputNum = inputNum / i;
				list.add(i);
			}
		}
		if (inputNum > 1) {
			list.add(inputNum);
		}
		Collections.sort(list);

		for (int prime : list) {
			System.out.print(" " + prime);
		}
		System.out.println();
		br.close();
	}
}

Measured memory_bytes: 24472
#include <iostream>

using namespace std;

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

	int t = 1;
	for (int i = 0; i < m; i++) {
		t *= 2;
	}
	int ans = t * (n - m) * 100;

	t *= m;
	ans += t * 1900;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    short a,b,c,count=3;
    cin>>a>>b>>c;
    if(a==b)count--;
    if(b==c)count--;
    if(a==c)count--;
    if(a==b&&b==c)count++;    
    cout<<count<<endl;
}

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


int main(void) {
    int n, q, t, u, v;
    cin >> n >> q;
    dsu d(n);
    for (int i = 0; i < q; ++i) {
        cin >> t >> u >> v;
        switch (t) {
            case 0:
                d.merge(u, v);
                break;
            case 1:
                cout << (d.same(u, v) ? 1 : 0) << endl;
                break;
            default:
                ;
        }
    }

    return 0;
}


Measured memory_bytes: 3948
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
#define N_MAX 10005

int main()
{
  	int N,M,C;
  	int A[100][100];
  	int B[N_MAX];
  	int ans = 0;
  	cin >> N >> M >> C;
  	for(int i = 0; i < M; i++){
    	cin >> B[i];
    }
  	for(int i = 0; i < N; i++){
    	for(int j = 0; j < M; j++){
          	int h;
        	cin >> h;
          	A[i][j] = h;
        }
    }
  	for(int i = 0; i < N; i++){
      	int sum = 0;
    	for(int j = 0; j < M; j++){
          int s = A[i][j];
          int t = B[j];
        	sum += s*t;
        }
      	sum += C;
      	if(sum > 0) ans++;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
/*
    Solution by Abil
*/

#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define int long long

using namespace std;

const long long N = (1e6 + 12);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 123);

int dpa[N], dpb[N], dpc[N], a[N],b[N], c[N];
main(){
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    dpa[1] = a[1];
    dpb[1] = b[1];
    dpc[1] = c[1];

    for(int i = 2;i <= n; i++){
        dpa[i] = max(dpb[i - 1],dpc[i - 1]) + a[i];
        dpb[i] = max(dpa[i - 1],dpc[i - 1]) + b[i];
        dpc[i] = max(dpb[i - 1],dpa[i - 1]) + c[i];
    }

    cout << max(dpa[n],max(dpb[n],dpc[n]));
}


Measured memory_bytes: 15360