akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string toUpper( string s ){
  string t = s;
  for(int i = 0; i < s.size(); i++){
    t[i] = toupper(s[i]);
  }
  return t;
}
  
int main(){
  string target, source;

  cin >> target;
  target = toUpper(target);

  int cnt = 0;

  while(1){
    cin >> source;
    if( source == "END_OF_TEXT" ) break;
    source = toUpper(source);
    if( target == source ) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1196
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

data class Key(val i: Int, val k: Int)
class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val runnable = Runnable {
      run()
    }

    val th = Thread(null, runnable, "solve", 1 shl 26)
    th.start()
    th.join()
  }

  fun run() {
    val N = ni()
    val A = na(N)
    val memo = mutableMapOf<Key, Long>()
    fun dfs(i: Int, k: Int): Long {
      if (i >= N) {
        return if (k == 0) 0 else -1
      }
      val remain = N - i
      if (remain < 2 * k - 1) return -1

      val key = Key(i, k)
      if (memo.containsKey(key)) return memo[key]!!

      val res1 = dfs(i + 2, k - 1)
      val res2 = dfs(i + 1, k)
      var mx = 0L
      if (res1 != -1L) {
        mx = res1 + A[i]
      }
      if (res2 != -1L) {
        mx = max(mx, dfs(i + 1, k))
      }
      memo[Key(i, k)] = mx
      return mx
    }

    out.println(dfs(0, N / 2))
    debug{"size:${memo.size}"}
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

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

int main( void )
{
    int a,b;
    cin >> a >> b;
    
    if ( a % 2 == 0 || b % 2 == 0 )
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    int L[N];
    for(int i = 0; i < N; i++) cin >> L[i];

    //ボールの位置
    int bound = 0;
    //バウンド回数
    int count = 1;

    
    int M[N];
    for(int i = 0; i < N; i++) {
        if(i == 0) M[i] = L[i];
        else {
            M[i] = M[i-1]+L[i];
        }
    }
    // for(int i = 0; i < N; i++) cout << M[i] << endl;

    for(int i = 0; i < N; i++) {
        if(M[i] <= X) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int X,Y,even;
	scanf("%d%d",&X,&Y);
	even=Y%2;
	if(X==0&&Y<=100)
		{
			printf("%d\n",Y);
		}
	else if(X!=0&&even==0)
		{
			printf("%d\n",X+Y/2);
		}
	return 0;
}

Measured memory_bytes: 1736
N = int(input())
k = int(input())
x = list(map(int, input().split()))

result = 0
for i in range(N):
    if k - x[i] > x[i] :
        result += x[i] *2
    
    else:
        result += (k - x[i]) *2
                

print(result)
        

Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int L[200001], R[200001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	rep(i, N) {
		int l, r;
		cin >> l >> r;
		L[l + 100000]++;
		R[r + 100000]++;
	}

	int L2[200001], R2[200001];
	rep(i, 200001) {
		R2[i] = R[i];
		L2[i] = L[i];
	}
	ll kotae = 0;
	int ima = 100000;
	int l = 200000;
	int r = 0;
	while (l > r) {
		while (l >= 0 && !L2[l]) l--;
		if (ima >= l) break;
		L2[l]--;
		kotae += l - ima;
		ima = l;

		while (r <= 200000 && !R2[r]) r++;
		if (ima <= r) break;
		R2[r]--;
		kotae += ima - r;
		ima = r;
	}
	kotae += abs(ima - 100000);
	ll kotae2 = 0;
	ima = 100000;
	l = 200000;
	r = 0;
	while (l > r) {
		while (r <= 200000 && !R[r]) r++;
		if (ima <= r) break;
		R[r]--;
		kotae2 += ima - r;
		ima = r;

		while (l >= 0 && !L[l]) l--;
		if (ima >= l) break;
		L[l]--;
		kotae2 += l - ima;
		ima = l;
	}
	kotae2 += abs(ima - 100000);

	co(max(kotae, kotae2));

	Would you please return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
const int MAX = 200000;

int main(){
  long n;
  cin >> n;
 
  long ct = 0;
  long val = 1;
  
  if(n>=10){
    if(n%2==0){
      for(int j=0; j<MAX; j++){
        val *= 5;
        if(2*val>n) break;
        ct += (long double)floor((long double)(n/(2*val)));
//        cout << ct << endl;
      }
    }
  }
  
  cout << (long)ct << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,i,t;
    cin>>x>>n;
    bool b[102]={0};
    for(i=0;i<n;i++)
    {
        cin>>t;
        b[t]=1;
    }
    int c1,c2;
    for(i=x;i<102;i++)
    {
        if(!b[i])
        {
            c1=i;
            break;
        }
    }
    for(i=x-1;i>-1;i--)
    {
        if(!b[i])
        {
            c2=i;
            break;
        }
    }
    if((c1-x)>=(x-c2))
    {
        cout<<c2;
    }
    else
    cout<<c1;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
ll dp[100004][2];

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	dp[0][1] = 1;
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='0')
		{
			(dp[i+1][0] += dp[i][0]*3)%=MOD;
			(dp[i+1][1] += dp[i][1]);
		}
		else
		{
			(dp[i+1][0] += dp[i][0]*3)%=MOD;
			(dp[i+1][1] += dp[i][1]*2)%=MOD;
			(dp[i+1][0] += dp[i][1]);
		}
	}
	cout<<(dp[n][1]+dp[n][0])%MOD<<endl;

}


Measured memory_bytes: 5264
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var list = [];
  for(var i = 1; i < input.length; i++){
    if(i == 1){
       list.push(input[i]);
       }else{
       	if(list.indexOf(input[i]) == -1){
           var tmp = list[list.length - 1].split("");
          tmp = tmp[tmp.length - 1];
          var tmp2 = input[i].slice(0,1);
          //myout(tmp2);
          if(tmp == tmp2){
             list.push(input[i]);
             }else{
               myout("No");
            return;
             }
          }else{
           myout("No");
            return;
          }
       }
  }
  myout("Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

class SegTree {
    int n = 1;
    // represents the tree as an array
    // parent of k: (k-1)/2, child of k: 2*k+1, 2*k+2
    vector<ll> nodes;

public:
    SegTree(int size, ll v) {
        while (n < size) n*= 2;
        nodes.resize(2*n-1, v);
    }

    SegTree(vector<ll> v) {
        while (n < v.size()) n*= 2;
        nodes.resize(2*n-1, inf);

        for (int i = 0; i < v.size(); i++) nodes[n-1+i] = v[i];
        for (int i = n-2; i >= 0; i++) nodes[i] = min(nodes[2*i+1], nodes[2*i+2]);
    }

    // return minimum value in [a, b). ([l, r) is interval in which k is.)
    ll rmq(int a, int b, int k = 0, int l = 0, int r = 0) {
        if (l >= r) r = n;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return nodes[k];

        ll vl = rmq(a, b, 2*k+1, l, (l+r)/2);
        ll vr = rmq(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }

    void update(int k, ll v) {
        k += n - 1;
        nodes[k] = v;
        // traverse from leaf to root
        while (k>0) {
            k = (k-1)/2;
            nodes[k] = min(nodes[k*2+1], nodes[k*2+2]);
        }
    }
};

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

    int N, Q;
    cin>>N>>Q;
    SegTree sg(N, (2ll<<30)-1);
    for (int q = 0; q < Q; q++) {
        int com;
        ll x, y;
        cin>>com>>x>>y;
        if (com == 0) sg.update(x, y);
        else cout<<sg.rmq(x, y+1)<<endl;
    }
    return 0;
}


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

int main(){
while(1){
	int n,m,a,ans=0;
	vector<int> p,pp;
	scanf("%d%d",&n,&m);
if(n==0&&m==0)break;
	p.push_back(0);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		p.push_back(a);
	}
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			pp.push_back(p[i]+p[j]);
		}
	}
	sort(pp.begin(),pp.end());
	int s=pp.size()-1;
	for(int i=0;i<=s;i++){
		while(pp[i]+pp[s]>m)s--;
		if(ans<pp[i]+pp[s])ans=pp[i]+pp[s];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 5012
#include <cstdio>
#include <algorithm>

int main() {
	long long K,A,B;
	scanf("%lld%lld%lld",&K,&A,&B);
	if(A+2>=B) {
		printf("%lld\n", K+1);
		return 0;
	}
	long long times=(K-A+1)/2;
	long long another=K+1-times*2+(B-A)*times;
	printf("%lld\n", std::max(K+1, another));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <ctime>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

ll N;
int x;
ll ans = 0;

int main(){
	
	cin>>N;
	
	x = int(sqrt( N )+0.5);
	
	
	FOR( i, 1, x ) if( N % i == 0 ) ans += (N/i-1);
	
	cout<<ans<<endl;
	
	return 0;
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int r, g, b;
	int seisu;
	if (scanf("%d%d%d", &r, &g, &b) != 3) return 1;
	seisu = r * 100 + g * 10 + b;
	puts(seisu % 4 == 0 ? "YES" : "NO");
	return 0;
}


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

int main() {

  string mid_name, _;

  for (int i=0; i<3; i++) {
    if (i != 1) {
      cin >> _;
    } else {
      cin >> mid_name;
    }
  }
  cout << 'A' << mid_name.at(0) << 'C' << endl;
}


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

using namespace std;

int main(void)
{
	int n;
	cin>>n;
	int a[n][2];
	a[0][0] = 0;
	a[0][1] = 0;
	for(int i = 1; i < n; i++){
		cin>>a[i][0];
		a[i][1] = 0;
	}
	for(int i = 1; i < n; i++){
		a[a[i][0]-1][1]++;
	}
	for(int i = 0; i < n; i++){
		cout<<a[i][1]<<endl;
	}
	return 0;
}



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

using namespace std;

int main()
{
    int t=1;
    //cin>>t;
    while(t--){
        int x;
        cin>>x;
        if(x>=400 && x<600) cout<<"8";
        else if(x>=600 && x<800) cout<<"7";
        else if(x>=800 && x<1000) cout<<"6";
        else if(x>=1000 && x<1200) cout<<"5";
        else if(x>=1200 && x<1400) cout<<"4";
        else if(x>=1400 && x<1600) cout<<"3";
        else if(x>=1600 && x<1800) cout<<"2";
        else cout<<"1";

    }
    return 0;
}


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

using namespace std;

struct Graph {
	struct Vertex {
		Vertex() {}
	};
	struct Edge {
		int to;
		Edge(int t) : to(t) {}
		Edge() {}
	};
	int sz;
	vector<Vertex> v;
	vector<vector<Edge>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = Vertex(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

struct TopologicalSort : public Graph {
	TopologicalSort(int n) : Graph(n) {}
	pair<bool, vector<int>> Topological_solve() {
		int V = size();
		vector<char> visited(V, false);
		vector<int> cnt(V, 0);
		for (int i = 0; i < V; i++) {
			for (auto& x : e[i]) {
				cnt[x.to]++;
			}
		}
		stack<int> s;
		vector<int> res;
		for (int i = 0; i < V; i++) {
			if (cnt[i] == 0) s.push(i);
		}
		while (!s.empty()) {
			int v = s.top(); s.pop();
			res.push_back(v);
			for (auto& x : e[v]) {
				if (--cnt[x.to] == 0) s.push(x.to);
			}
		}
		return make_pair((int)res.size() == size(), res);
	}
};

int main() {
	int V, E; cin >> V >> E;
	TopologicalSort G(V);
	for (int i = 0; i < E; i++) {
		int v, u; cin >> v >> u;
		G.add_edge(v, u);
	}
	auto res = G.Topological_solve();
	for (auto& x : res.second) cout << x << endl;
}


Measured memory_bytes: 3716
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int A, P;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> A >> P;
	cout << (A*3 + P)/2 << endl;

	return 0;
}



Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var d = int.Parse(line[3]);
        var e = int.Parse(line[4]);
        var f = int.Parse(line[5]);
        var water = new List<int>();
        for (int i = 1; 100 * i <= f; i++)
            if (canMake(100 * i, 100 * a, 100 * b)) water.Add(i);
        var sugar = new List<int>();
        for (int i = 0; i <= f; i++)
            if (canMake(i, c, d)) sugar.Add(i);
        var ret = 0d; var retwater = 0; var retsugar = 0;
        foreach (var w in water)
            foreach (var s in sugar)
                if (s <= w * e && w * 100 + s <= f)
                {
                    var t = (double)s / (w * 100d + s);
                    if (t > ret) { ret = t; retwater = w; retsugar = s; }
                }
        if (retwater == 0) retwater = a;
        Console.WriteLine("{0} {1}", retwater * 100 + retsugar, retsugar);
    }
    public static bool canMake(int t, int a, int b)
    {
        var imax = t / a;
        for (int i = 0; i <= imax; i++)
            if ((t - a * i) % b == 0) return true;
        return false;
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>

int a[110];
bool dp[100010];

int main(){
    int n, k;
    std::cin >> n >> k;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    for(int i = 0; i < k; i++){
        for(int j = 0; j < n; j++){
            if(i + a[j] <= k) dp[i + a[j]] |= !dp[i];
        }
    }
    std::cout << (dp[k] ? "First" : "Second") << std::endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

ll T[105];

ll gcd(ll x, ll y)
{
    ll r;
    while((r = x % y) != 0ll)
    {
        x = y;
        y = r;
    }
    return y;
}

ll calc(ll a,ll b){

	if(a>b){swap(a,b);}

	ll tmp=b;

	ll d=gcd(a,b);

	a/=d;
	b/=d;

	return tmp*a;

}

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
		scanf("%lld",&T[i]);
	}

	ll ans=1ll;

	for(i=0;i<N;i++){
	ans=calc(ans,T[i]);
	}

	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def solve():
    ofs = 700
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [0 for _ in range(w+1)]
    x = abs(A[0][0]-B[0][0])
    dp[0] = 1 << ofs

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = dp[j] | dp[j-1]
            dp[j] = (t << x) | (t >> x)

    for i, s in enumerate(bin(dp[w-1])[-ofs-1:]):
        if(int(s)):
            print(i)
            return


if __name__ == "__main__":
    solve()


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

int main()
{
    int A,B;
    cin >> A >> B;

    if(A==B)
        cout << "Draw";
    else if(A==1 || (B < A && B!=1))
        cout << "Alice";
    else
        cout << "Bob";
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 3548
while True:
    x, y, s = map(int, input().split())
    if x == 0: break
    ans = 0
    for p1 in range(1, s+1):
        for p2 in range(p1, s+1):
            t = p1 + p2 + (p1*x)//100 + (p2*x)//100
            if t > s: break
            if t != s: continue
            t = p1 + p2 + (p1*y)//100 + (p2*y)//100
            if t > ans: ans = t
    print(ans)


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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

int as[111], bs[111], cs[111], ds[111];

int main () {
    int n = getint(), m = getint();

    for (auto i = 0; i < n; ++i) {
        as[i] = getint(), bs[i] = getint();
    }
    for (auto i = 0; i < m; ++i) {
        cs[i] = getint(), ds[i] = getint();
    }
    for (auto i = 0; i < n; ++i) {
        int mx = 1 << 28;
        int idx = 0;
        for (auto j = 0; j < m; ++j) {
            auto d = abs(as[i] - cs[j]) + abs(bs[i] - ds[j]);
            if (chmin(mx, d)) idx = j;
        }
        cout << idx + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())

N_list = [1,3,3,7,7,7,14,22,22,22,33,33,46,60,60]
N_add15 = [1,2,2,3,3,3,4,5,5,5,6,6,7,8,8]


num_15 = N // 15

n_list = N_list[N%15-1] + 15 * N_add15[N%15-1] * (num_15)

if(N < 16):
    ans = N_list[N-1]
else:
    ans = num_15 * num_15 * 60 + n_list

print(ans)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int n,k;
ll a[2005],sum[2005],sum2[2005];
ll qpow(ll base,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=ans*base%mod;
        base=base*base%mod;
        b>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]>a[j])
                sum[i]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(a[i]>a[j])
                sum2[i]++;
        }
    }
    ll ans=0;
    ll res=qpow(2,mod-2);
    for(int i=1;i<=n;i++)
    {
        ans=(ans+sum[i]*k%mod)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        ans=(ans+((sum2[i]+sum2[i]*(k-1)%mod)*(k-1)%mod)*res%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int k;
  string s;
  scanf("%d\n",&k);
  cin >> s;
  if(s.size()<=k){
    cout << s << endl;
  }
  else{
    string t;
    t=s.substr(0,k);
    cout << t <<  "..." <<endl;
  }
  return 0;
}

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

vector<vector<long long> > cvv;

void c(int n){
	cvv.push_back(vector<long long>());
	cvv[0].push_back(1);
	for(int i = 1;i <= n;i++){
		cvv.push_back(vector<long long>());
		cvv[i].push_back(1);
		for(int j = 1;j < i;j++){
			cvv[i].push_back(cvv[i-1][j]+cvv[i-1][j-1]);
		}
		cvv[i].push_back(1);
	}
}

int main(){
	c(51);
	int n,a,b;
	cin >> n >> a >> b;
	vector<long long> v;
	long long l;
	int i;
	for(i = 0;i < n;i++){
		cin >> l;
		v.push_back(l);
	}
	sort(v.begin(),v.end());
	int in = 0,bn;
	long long an = v[n-a];
	long long sum = 0;
	for(i = 0;i < a;i++){
		sum += v[n-1-i];
		if(v[n-1-i] == an) in++;
	}
	bn = in;
	long long bsum = 0;
	for(i = a;i < n;i++){
		if(v[n-1-i] == an) in++;
	}
	if(bn == a){
	for(i = a;i <= b;i++){
		if(v[n-i] != an) break;
		bsum += cvv[in][bn];
		bn++;
	}}
	else{
		bsum = cvv[in][bn];
	}
	printf("%20f\n",((double)sum)/a);
	cout << bsum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <sys/time.h>

#define N	50
#define S	(N * N * N + N * 2)
#define INF	0x3f3f3f3f
#define INF_	0x3f3f3f3f3f3f3f3fLL

int min(int a, int b) { return a < b ? a : b; }

unsigned int X;

void srand_() {
	struct timeval tv;

	gettimeofday(&tv, NULL);
	X = tv.tv_sec ^ tv.tv_usec;
	X = 1;
	if (X % 2 == 0)
		X++;
}

int rand_() {
	return (X *= 3) >> 1;
}

long long xx[N]; int yy[N];

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k) {
			long long c = xx[ii[j]] * yy[i_] - xx[i_] * yy[ii[j]];

			if (c == 0)
				j++;
			else if (c < 0) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		}
		sort(ii, l, i);
		l = k;
	}
}

int main() {
	static int pp[N], ii[N], kk[N], qu[S + 1];
	static long long dp[S + 1], dq[S + 1], tt[S + 1];
	int n, x, k_, i, r, s, head, cnt, ans, y;

	srand_();
	scanf("%d%d%d", &n, &x, &k_);
	for (i = 0; i < n; i++) {
		scanf("%lld", &xx[i]);
		yy[i] = 1;
		if (i > 0)
			scanf("%d", &pp[i]), pp[i]--;
	}
	for (i = n - 1; i > 0; i--) {
		xx[pp[i]] += xx[i];
		yy[pp[i]] += yy[i];
	}
	for (i = 0; i < n; i++)
		ii[i] = i;
	sort(ii, 0, n);
	ans = 0;
	for (i = 0; i < n; i++) {
		kk[ii[i]] = min(x / xx[ii[i]], ii[i] == 0 ? INF : k_);
		x -= xx[ii[i]] * kk[ii[i]];
		ans += yy[ii[i]] * kk[ii[i]];
		if (kk[ii[i]] < k_)
			break;
	}
	for (s = 0; s <= S; s++)
		dp[s] = INF_;
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		long long x = xx[i];
		int k;

		y = yy[i], k = i == 0 ? INF : k_ - kk[i];
		if (k > 0) {
			for (r = 0; r < y; r++) {
				head = cnt = 0;
				for (s = r; s <= S; s += y) {
					if (dp[s] != INF_) {
						while (cnt && dp[s] - (s / y) * x <= dp[qu[head + cnt - 1]] - (qu[head + cnt - 1] / y) * x)
							cnt--;
						qu[head + cnt++] = s;
					}
					tt[s] = cnt == 0 ? INF_ : dp[qu[head]] + (s - qu[head]) / y * x;
					if (cnt && s / y >= k && qu[head] == s - k * y)
						head++, cnt--;
				}
			}
			for (s = 0; s <= S; s++)
				dp[s] = tt[s];
		}
	}
	for (s = 0; s <= S; s++)
		dq[s] = -INF_;
	dq[0] = 0;
	for (i = 0; i < n; i++) {
		long long x = xx[i];
		int k;

		y = yy[i], k = kk[i];
		if (k > 0) {
			for (r = 0; r < y; r++) {
				head = cnt = 0;
				for (s = r; s <= S; s += y) {
					if (dq[s] != -INF_) {
						while (cnt && dq[s] - (s / y) * x >= dq[qu[head + cnt - 1]] - (qu[head + cnt - 1] / y) * x)
							cnt--;
						qu[head + cnt++] = s;
					}
					tt[s] = cnt == 0 ? -INF_ : dq[qu[head]] + (s - qu[head]) / y * x;
					if (cnt && s / y >= k && qu[head] == s - k * y)
						head++, cnt--;
				}
			}
			for (s = 0; s <= S; s++)
				dq[s] = tt[s];
		}
	}
	for (y = n * 2; y >= 0; y--)
		for (s = y; s <= S; s++)
			if (x >= dp[s] - dq[s - y]) {
				ans += y;
				printf("%d\n", ans);
				return 0;
			}
	return 0;
}


Measured memory_bytes: 5148
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int total = 0;
		int N = sc.nextInt();
		int[] tako = new int[N];
		for(int i = 0; i<N; i++) {
			tako[i] = sc.nextInt();
		}
		for(int j = 0; j<tako.length; j++) {
			for(int k = j+1; k<tako.length; k++) {
				total = total + (tako[j] * tako[k]);
			}
		}
		System.out.println(total);
    }
}

Measured memory_bytes: 21844
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,l,r;
vector<pair<pi,int>> lbig, rsmall;
int used[100010],ctr,lind,rind,pos;

int main(){
    I(n);
    REP(i,n){
        I(l); I(r);
        lbig.eb(mp(l,r),i);
        rsmall.eb(mp(r,l),i);
    }
    if (n == 1){
        if (l <= 0 && 0 <= r){
            cout << 0 << endl;
        } else {
            cout << min(abs(l),abs(r)) * 2 << endl;
        }
        return 0;
    }
    sort(lbig.begin(),lbig.end(),greater<pair<pi,int>>());
    sort(rsmall.begin(),rsmall.end());
    ll ret = 0;
    
    /*
    if (lbig[lind].first.first < 0){
        auto sel = rsmall[rind];
        r = sel.first.first;
        l = sel.first.second;

        if (pos < l) { ret += l-pos; pos = l;}
        if (r < pos) { ret += pos-r; pos = r;}

        used[sel.second] = 1;
        ctr++;
    }
    */
    while (ctr < n){
        //cerr << ret << endl;

        while (used[lbig[lind].second]) lind++;
        auto sel = lbig[lind];
        l = sel.first.first;
        r = sel.first.second;

        if (pos < l) { ret += l-pos; pos = l;}
        if (r < pos) { ret += pos-r; pos = r;}

        used[sel.second] = 1;
        ctr++;

        if (ctr == n ) break;

        //cerr << ret << endl;
        while (used[rsmall[rind].second]) rind++;
        sel = rsmall[rind];
        r = sel.first.first;
        l = sel.first.second;

        if (pos < l) { ret += l-pos; pos = l;}
        if (r < pos) { ret += pos-r; pos = r;}

        used[sel.second] = 1;
        ctr++;
    }
    ret += abs(pos);
    
    ll ret2 = 0;
    pos = 0;
    ctr = 0;
    lind = 0;
    rind = 0;
    REP(i,n) used[i] = 0;
    while (ctr < n){
        //cerr << ret << endl;

        //cerr << ret << endl;
        while (used[rsmall[rind].second]) rind++;
        auto sel = rsmall[rind];
        r = sel.first.first;
        l = sel.first.second;

        if (pos < l) { ret2 += l-pos; pos = l;}
        if (r < pos) { ret2 += pos-r; pos = r;}

        used[sel.second] = 1;
        ctr++;
        if (ctr == n ) break;

        while (used[lbig[lind].second]) lind++;
        sel = lbig[lind];
        l = sel.first.first;
        r = sel.first.second;

        if (pos < l) { ret2 += l-pos; pos = l;}
        if (r < pos) { ret2 += pos-r; pos = r;}

        used[sel.second] = 1;
        ctr++;

    }
    ret2 += abs(pos);

    cout << max(ret,ret2) << endl;
}


Measured memory_bytes: 3372
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    writeln(180 * (n - 2));

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t MOD = 1e+9 + 7;

uint64_t bin_pow(uint64_t x, uint64_t y)
{
  if (y <= 1) {
    return (y == 0) ? 1 : (x % MOD);
  }

  uint64_t w = bin_pow(x, y >> 1);
  uint64_t z = (w * w) % MOD;

  if (y % 2 == 1) {
    z = (x * z) % MOD;
  }

  return z;
}

uint64_t comb(uint64_t n, uint64_t k)
{
  k = std::min(k, n - k);

  uint64_t ret = 1;

  for (uint64_t i = 1; i <= k; ++i) {
    ret = (ret * ((n - i + 1) % MOD)) % MOD;
    ret = (ret * (bin_pow(i, MOD - 2) % MOD)) % MOD;
  }

  return ret;
}

int main()
{
  uint64_t N, A, B;
  cin >> N >> A >> B;

  uint64_t T = bin_pow(2, N);
  T = ((T + MOD) - 1) % MOD;
  
  uint64_t U = (comb(N, A) + comb(N, B)) % MOD;
  
  uint64_t S = ((T + MOD) - U) % MOD;
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 200005;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    f1(k) {
        if ((i * 2) % k)continue;
        if (n < i)continue;
        ll cnt = (n - i) / k + 1;
        //cout << cnt << endl;
        ans += cnt * cnt * cnt;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
s = input()

for bit in range(1<<3):
  ans=""
  for i in range(3):
    if bit & (1<<i):
      ans+="+"
    else:
      ans+="-"
  ans=s[0]+ans[0]+s[1]+ans[1]+s[2]+ans[2]+s[3]
  if eval(ans)==7:
    print(ans+"=7")
    break

Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;
    int cnt = 0;
    rep(i, N) {
        string left = s.substr(N - i - 1, i + 1);
        string right = t.substr(0, i + 1);
        if (right == left) cnt = i + 1;
    }
    cout << 2*N - cnt << endl;
    return 0;
}

Measured memory_bytes: 3648
N,Q=map(int,input().split())
S=input()

num=[0]*N

for i in range(1,N):
    if S[i-1:i+1]=="AC":
        num[i]+=1

sums=[0]*(N+1)
for i in range(1,N+1):
    sums[i]=sums[i-1]+num[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    print(sums[r]-sums[l])



Measured memory_bytes: 10228
n, m=map(int, input().split())
results=[0]*m

for i in range(n):
    check=list(map(int, input().split()))
    num=check[0]
    for j in range(1, num+1):
        results[check[j]-1]+=1

ans=0  
for result in results:
    if result==n:
        ans+=1

print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ill long long int
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ill n;
  cin >> n;
  cout << n * (n + 1) / 2 << "\n";
}

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

long long attack(long long n){
  if(n == 1)return 1;
  
  return attack(n / 2) * 2 + 1;
}

int main() {
  long long H;
  cin >> H;
  
  cout << attack(H) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M, Q; cin >> N >> M >> Q;
    vector<vector<int>> vvLR(N+1, vector<int>(N+1, 0));
    vector<vector<int>> vvS (N+1, vector<int>(N+1, 0));
    
    for(int i=0; i<M; ++i){
        int l, r; cin >> l >> r;
        ++vvLR[l][r];
    }
    
    for(int p=1; p<=N; ++p){
        for(int q=1; q<=N; ++q){
            vvS[p][q] = vvLR[p][q] + vvS[p-1][q] + vvS[p][q-1] - vvS[p-1][q-1];
        }
    }
    
    for(int i=0; i<Q; ++i){
        int p, q; cin >> p >> q;
        int num = vvS[q][q] - vvS[p-1][q] - vvS[q][p-1] + vvS[p-1][p-1];
        cout << num << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2944
M,N = map(int,input().rstrip().split(" "))
if N != 0:
    A = set(map(int,input().rstrip().split(" ")))
    ans = -100
    sa = 10 ** 5
    for i in range(-1,102):
        if not i in A:
            if sa > abs(M - i):
                sa = abs(M - i)
                ans = i
    print(ans)
else:
    print(M)

Measured memory_bytes: 9188
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

// vector<vector<int>> data(3, vector<int>(4));

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

  double d, t, s;
  cin >> d >> t >> s;

  if (d / s <= t) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		
		int count = 0;
		for(int i=0 ;i<n;i++) {
			int a =sc.nextInt();
			if((i+1)%2 != 0 && a%2 != 0)
				count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 27188
/*
* @Author: wxyww
* @Date: 2020-03-16 21:08:12
* @Last Modified time: 2020-03-16 21:27:12
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 5010,mod = 1e9 + 7;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int f[N][N],siz[N],tmp[N + N],g[N];
struct node {
	int v,nxt;
}e[N << 1];
int head[N],ejs;
void add(int u,int v) {
	e[++ejs].v = v;e[ejs].nxt = head[u];head[u] = ejs;
}
void dfs(int u,int fa) {
	siz[u] = 1;
	f[u][1] = 1;
	for(int i = head[u];i;i = e[i].nxt) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs(v,u);
		for(int j = 0;j <= siz[u];++j) {
			for(int k = 0;k <= siz[v];++k) {
				tmp[j + k] += 1ll * f[v][k] * f[u][j] % mod;
				tmp[j + k] %= mod;
			}
		}
		siz[u] += siz[v];
		for(int j = 0;j <= siz[u];++j) f[u][j] = tmp[j],tmp[j] = 0;
	}
	
	for(int i = 0;i <= siz[u];i += 2) f[u][0] += -1ll * f[u][i] * g[i] % mod,f[u][0] %= mod;

}
int main() {
	int n = read();
	for(int i = 1;i < n;++i) {
		int u = read(),v = read();
		add(u,v);add(v,u);
	}

	g[0] = 1;
	for(int i = 2;i <= n;i += 2)
		g[i] = 1ll * g[i - 2] * (i - 1) % mod;

	dfs(1,0);

	cout<<(-f[1][0] + mod) % mod;
	return 0;
}

Measured memory_bytes: 97408
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
int main(){
	int n;
  	cin >> n;
  	int num;
  	for(int i = 1;i<10;i++){
      	num =  i*100+i*10+i;
    	if(n <= num) break;
    }
    cout << num;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func rcv() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func max(a []int) (x int) {
	x = a[0]
	for _, i := range a {
		if i > x {
			x = i
		}
	}
	return
}

func min(a []int) (x int) {
	x = a[0]
	for _, i := range a {
		if i < x {
			x = i
		}
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m, xCap, yCap := rcv(), rcv(), rcv(), rcv()

	x := make([]int, n)
	y := make([]int, m)
	for i := 0; i < n; i++ {
		x[i] = rcv()
	}
	for i := 0; i < m; i++ {
		y[i] = rcv()
	}
	x = append(x, xCap)
	y = append(y, yCap)

	if max(x) < min(y) {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int ans, cnt, tmp, idx, mx = -infll, mn = infll;
int x, y, z;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
int q = 1;
//cin >> q;
while (q--){
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int k;
	string s;
	
	cin >> k >> s;
	
	for(auto &c : s){
		int p = c - 'A';
		p += k;
		p %= 26;
		cout << (char)('A' + p);
	}
	
	cout << endl;

	return 0;
}


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

const int MAX_V=2501*50;
const int64_t INF=1e15;

struct edge{
  int to;
  int64_t cost;
};

typedef pair<int64_t,int> P;

vector<edge> G[MAX_V];
int64_t d[MAX_V];
int V;

void dijkstra(int s){

  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;

    if(d[v]<p.first) continue;
    for(int i=0;i<G[v].size();++i){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }

}

int main(){
  int64_t N,M,S;
  cin>>N>>M>>S;

  V=2501*N;

  for(int i=0;i<M;++i){
    int64_t u,v,a,b;
    cin>>u>>v>>a>>b;
    --u,--v;
    for(int j=a;j<=2500;++j){
      int x=2501*u+j;
      int y=2501*v+(j-a);
      G[x].push_back(edge{y,b});
    }
    for(int j=a;j<=2500;++j){
      int x=2501*v+j;
      int y=2501*u+(j-a);
      G[x].push_back(edge{y,b});
    }
  }

  for(int i=0;i<N;++i){
    int64_t c,d;
    cin>>c>>d;
    for(int j=0;j<=2500;++j){
      int x=2501*i+j;
      int y;
      if(j<=2500-c) y=2501*i+(j+c);
      else y=2501*i+2500;
      G[x].push_back(edge{y,d});
    }
  }
  
  if(S>=2500) dijkstra(2500);
  else dijkstra((int)S);

  for(int i=1;i<N;++i){
    int64_t ans=1e15;
    for(int j=0;j<=2500;++j){
      int x=2501*i+j;
      ans=min(ans,d[x]);
    }
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 23624
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  int N, K;
  cin >> N >> K;
  Graph G(N);
  for( int i = 0; i < N-1; i++ ){
    int A, B;
    cin >> A >> B;
    A--; B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  int ans = K;
  vector<bool> seen(N, 0);
  queue<int> que;

  //1段目
  que.push(0);
  seen[0] = 1;
  int num = 0;
  for( int nv : G[0] ){
    if( seen[nv] ) continue;
    que.push(nv);
    seen[nv] = 1;
    int kake = max(0LL, K-1-num);
    ans *= kake;
    ans %= MOD;
    num++;
  }

  //2段目以降
  while( !que.empty() ){
    int v = que.front();
    que.pop();
    num = 0;
    for( int nv : G[v] ){
      if( seen[nv] ) continue;
      que.push(nv);
      seen[nv] = 1;
      int kake = max(0LL, K-2-num);
      ans *= kake;
      ans %= MOD;
      num++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 10288
use proconio::input;

#[allow(unused_imports)]
use std::collections::HashSet;

use std::cmp;


fn main() {
    input! {
        n: usize,
        k: usize,
    }
    solve(n, k);
}

fn prepare(m: usize, k: usize, p :u64) -> Vec<Vec<u64>> {
    let mut v : Vec<Vec<u64>> = Vec::<Vec<u64>>::with_capacity(m + 1);
    let v0 : Vec<u64> = vec![1; 1];
    v.push(v0);
    for i in 1..m+1 {
        let mut vi : Vec<u64>;
        if i <= k {
            vi = vec![0; i+1];
            vi[0] = 1;
            vi[i] = 1;
            for j in 1..i/2+1 {
                vi[j] = (v[i-1][j-1] + v[i-1][j]) % p;
                vi[i-j] = vi[j];
            }
        }
        else {
            vi = vec![0; k+1];
            vi[0] = 1;
            if i < 2 * k {
                for j in 1..i/2+1 {
                    vi[j] = (v[i-1][j-1] + v[i-1][j]) % p;
                    let jx = i - j;
                    if jx <= k {
                        vi[jx] = vi[j];
                    }
                }
            } else {
                for j in 1..k+1 {
                    vi[j] = (v[i-1][j-1] + v[i-1][j]) % p;
                }
            } 
        }
        v.push(vi);
    }
    return v;
}

fn solve(n: usize, k: usize) {
    let p : u64 = (10u32.pow(9u32) + 7) as u64;

    // 1. Calculate all combinations
    let m = cmp::max(k-1, n-k+1);
    let c = prepare(m, k, p);

    // 2. Calculate possible ways
    for i in 1..k+1 {
        if i > n-k+1 { 
            println!("0");
        } else {
            let t =  c[n-k+1][i] * c[k-1][i-1] % p;
            println!("{}", t);
        }
    }
}


Measured memory_bytes: 17736
#include <bits/stdc++.h>
using namespace std;
int n,m;
#define mod 1000000007
#define ll long long
vector<int> br;
vector<ll> DP;

ll dp(int i){
  if(i==n) return 1;
  if(i>n) return 0;
  if(br[i]==1) return 0;
  if(DP[i]!=-1) return DP[i];
  return DP[i]=(dp(i+1)+dp(i+2))%mod;
}

int main(){
  scanf("%d %d",&n,&m);
  br.resize(n+1,0);
  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);
    br[a]=1;
  }

  DP.resize(n+1,-1);
  printf("%lld\n",dp(0));

  return 0;
}


Measured memory_bytes: 4480