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

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

  int y = 1;
  while (y <= x) y <<= 1;

  constexpr int kMod = 998244353;
  vector<vector<int>> dp(x + 1, vector<int>(y));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    vector<vector<int>> nxt(x + 1, vector<int>(y));
    for (int j = 0; j < y; ++j) {
      for (int k = 1; k <= x; ++k) {
        (dp[k][j] += dp[k - 1][j]) >= kMod ? dp[k][j] -= kMod : 0;
      }
    }
    for (int j = 0; j <= x; ++j) {
      for (int k = 0; k < y; ++k) {
        (nxt[j][k ^ j] += dp[j][k]) >= kMod ? nxt[j + 1][k ^ j] -= kMod : 0;
      }
    }
    dp = nxt;
  }
  int res = 0;
  for (int i = 0; i <= x; ++i) {
    (res += dp[i][x]) >= kMod ? res -= kMod : 0;
  }
  cout << res << "\n";
}



Measured memory_bytes: 4952
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

    ull n, W;
    cin >> n >> W;

    vector<ll> w(n);
    vector<ll> v(n);
    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];

    vector<ll> currentSol(W + 1);
    vector<ll> lastSol(W + 1);

    for (int i = 1; i <= W; ++i)
        currentSol[i] = 0;

    for (int i = 0; i < n; ++i)
    {
        swap(currentSol, lastSol);
        for (int j = 1; j <= W; ++j)
            currentSol[j] = w[i] > j ? lastSol[j] : max(lastSol[j], lastSol[j - w[i]] + v[i]);
    }

    cout << currentSol[W];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
typedef long long ll;
ll n, t, gcd, ans=1;
 
ll f(ll p, ll q) {
    if (q==0) return p;
    return f(q, p%q);
}
 
int main() {
    cin >> n;
    while (n--) {
        cin >> t;
        gcd = f(ans, t);
        ans *= t / gcd;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int num=0,upper=0,lower=0,i;
    char pass[21];
    scanf("%s\n",pass);
    if (strlen(pass)<6) {
        printf("INVALID\n");
        return 0;
    }
    for (i=0; i<strlen(pass); i++) {
        if (isdigit(pass[i])) {
            num=1;
        } else if (islower(pass[i])) {
            lower=1;
        } else if (isupper(pass[i])) {
            upper=1;
        }
    }
    if (num==1&&lower==1&&upper==1) {
        printf("VALID\n");
    } else {
        printf("INVALID\n");
    }
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 505050
    typedef long long ll;
    typedef double db;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(register int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
    void file()
    {
        #ifdef NTFOrz
        freopen("a.in","r",stdin);
        #endif
    }
    inline void chktime()
    {
        #ifndef ONLINE_JUDGE
        cout<<(clock()-t)/1000.0<<'\n';
        #endif
    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
ll a[sz];
ll len[sz];
ll st;
int ans[sz];

int main()
{
    file();
    read(n,st);
    rep(i,1,n) read(a[i]);
    len[n]=0;drep(i,n-1,1) len[i]=len[i+1]+(a[i+1]<=len[i+1]*2+1?a[i+1]:0);
    rep(i,1,n) ans[i]=(len[i]>=st),chkmin(st,abs(st-a[i]));
    int Q,x;read(Q);
    while (Q--) read(x),puts(ans[x]?"NO":"YES");
    return 0;
}

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

int main(){
    long long N, K;cin >> N >> K;
    string S; cin >> S;

    long long n = 0;
    for(long long i = 0;i <= N - 1;i++){
        if ((S[i] == 'L' and S[i + 1] == 'L') or (S[i] == 'R' and S[i + 1] == 'R')){
            n ++;
        }
    }

    cout << min(n + 2*K,N-1) << endl;
}

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

using namespace std;

string S;

bool can_reach(int start, int end) {
  for (int i = start - 1; i < end; i++) {
    if (i + 1 < end && S[i] == '#' && S[i + 1] == '#') {
      return false;
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D >> S;
  S = S + "#";
  if (!can_reach(A - 1, C - 1) || !can_reach(B - 1, D - 1)) {
    cout << "No" << '\n';
    return 0;
  }
  if (D < C) {
    bool flag = false;
    for (int i = max(0, B - 2); i <= D; i++) {
      if (i + 2 <= D && S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')
        flag = true;
    }
    if (!flag) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

//public class atcoder0221_A{
public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int R = scan.nextInt();
		//		int C = scan.nextInt();
		int result = R;
		//
		if(N<10) {
			result = result+(100*(10-N));
		}
		//		if(A==B && B==C && A==C) {
		//			result="No";
		//
		//		}else if(A!=B && B!=C && A!=C) {
		//			result="No";
		System.out.println(result);
	}
}

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

int main() {
    ll a,b,c;
    std::cin >> a>>b>>c;
    if(a+b+c>=22){
        std::cout << "bust" << std::endl;
    }else{
        std::cout << "win" << std::endl;
    }
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            money = 500 * i + 100 * j + 50 * k
            if money == x:
                count += 1

print(count)

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 1)
    a = 14;
  if(b == 1)
    b = 14;
  
  if(a > b)
    cout << "Alice" << endl;
  else if(b > a)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

MAXN = 1005
MAXV = MAXN*(MAXN-1)//2
to = [[] for _ in range(MAXV)] # 頂点間の辺の情報
id = [[[] for _ in range(MAXN)] for _ in range(MAXN)] # 試合のid=DAGの頂点番号
def toId(i,j): # 選手idから試合idを返す関数
    if i > j: # i,jが逆になっても試合idは同じ
        i,j = j,i
    return id[i][j]

visited = [False]*MAXV
calculated = [False]*MAXV
dp = [1]*MAXV # Vからスタートしたときの最長経路。頂点の個数ベースで経路の長さを数えるので、初期値は1

def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1 # 計算が終わっていない頂点を2度訪れるのはループがあるということ
        return dp[v]
    visited[v] = True
    for u in to[v]: # 全ての辺をなめる
        res = dfs(u)
        if res == -1: return -1 # ループがあれば-1を返す
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]

def main():
    n = int(input())
    a = [[int(i) for i in readline().split()] for _ in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1 # 選手idを0始まりに変換
    V = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                id[i][j] = V
                V += 1 # 0から順に各試合にidを割り振る
    for i in range(n):
        for j in range(n-1):
            a[i][j] = toId(i,a[i][j]) # 選手idを試合id(頂点番号)に置き換える
        for j in range(n-2): # 頂点間の依存関係はn-2個
            to[a[i][j+1]].append(a[i][j])
    ans = 0
    for i in range(V):
        res = dfs(i)
        if res == -1:
            print('-1') # ループがあれば-1を返す（問題文の指示）
            return
        ans = max(ans, res)
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 224560
n = int(input())
tall = list(map(int, input().split()))
lar = tall[0]
lno = 0
frag = 0


for i in range(n):
    if(tall[i]>lar):
        lar= tall[i]
    if(lar - tall[i] >= 2):
        frag = 1
        break

if(frag == 1):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 15020
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N, M;
    void Solve()
    {
        N = cin.Nextint;
        M = cin.Nextint;
        var D = new int[N];


        for (int i = 0; i < M; i++)
        {
            var A = cin.Nextint - 1;
            var B = cin.Nextint - 1;
            D[A]++;
            D[B]++;
        }

        //Array.Sort(A, B);
        bool flag = true;
        for (int i = 0; i < N; i++)
        {
            if (D[i] % 2 == 1)
            {
                flag = false;
                break;
            }
        }
        //WriteLine(string.Join(" ", D));

        if (flag)
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 17500
import java.util.*;
import java.math.*;

class Main {
  public static void main(String[] args){
  Scanner stdIn = new Scanner(System.in);
  int a = stdIn.nextInt();
  int b = stdIn.nextInt();
  int T = stdIn.nextInt();
  int count = 0;
  for(int i = a;i<T+0.5;i+=a) {
    count += b;
  }
  System.out.println(count);
}
}

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

int main(){
  string s,t;
  cin >> s >> t;
  bool is_ok = false;
  for (int i = 0; i < (int)s.size(); ++i) {
    char c = s[(int)s.size()-1];
    s.pop_back();
    s = c + s;
    if (s == t) is_ok = true;
  }
  if ( is_ok == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    for h in range(1, 3501):
        for n in range(1, 3501):
            denom = 4 * h * n - N * n - N * h
            numer = N * h * n
            if denom > 0 and numer % denom == 0:
                print(h, n, numer // denom)
                return

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 65184
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), q = fs.nextInt();
		UnionFind uf = new UnionFind(n);
		for(int i=0;i<q;i++) {
			int c = fs.nextInt();
			int x = fs.nextInt(), y = fs.nextInt();
			if(c == 0) {
				uf.unite(x,y);
			}
			else {
				if(uf.same(x, y)) System.out.println(1);
				else System.out.println(0);
			}
		}
	}
}

class UnionFind{
	int parent[];
	
	UnionFind(int n){
		parent = new int[n];
		Arrays.fill(parent,-1);
	}
	
	int root(int x) {
		if(parent[x] < 0) return x;
		return parent[x] = root(parent[x]);
	}
	
	boolean same(int x, int y) {
		if(root(x) == root(y)) return true;
		else return false;
	}
	
	int size(int x) {
		return -parent[root(x)];
	}
	
	void unite(int x, int y) {
		if(same(x, y))return;
		if(size(x)>size(y)) unite(y,x);
		else {
			parent[root(y)] += -size(x);
			parent[root(x)] = root(y);
		}
	}
	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 63716
#include<iostream>
#include<math.h>

using namespace std;

int main(){
	while(1){
		double d,e,ans=1000000007;
		cin>>d>>e;
		if(d==0 && e==0)break;

		for (int i = 0; i < d+1; ++i)
		{
			double y=d-i;

			if(ans>fabs(e-sqrt(i*i + y*y))){
				ans=fabs(e-sqrt(i*i + y*y));
			}

		}

		printf("%.8f\n",ans);

	}
}


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

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

	int m, d; cin >> m >> d;
	int cnt = 0;
	for (int i = 22; i <= d; i++) {
		int k = i % 10, l = i / 10;
		int ans = k * l;
		if (0 < ans && ans <= m&&k>1&&l>1)cnt++;
	}
	cout << cnt;
}

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

int main() {
	// your code goes here
	int a,b,c,x;
	int cnt=0;
	cin >> a >> b >> c >> x;
	for(int i=0; i<=a; i++)
	{
		for(int j=0; j<=b; j++)
		{
			for(int k=0;k<=c;k++)
			{
			   if((i*500+j*100+k*50)==x) cnt++;	
			}
			
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi ans(n + 1);
  for(int i = 1; i <= n; i++){
    for(int j = i; j <= n; j += i){
      ans[j]++;
    }
  }
  ll res = 0;
  for(ll i = 1; i <= n; i++) res += ans[i] * i;
  cout << res << endl;
}

Measured memory_bytes: 42292
def gcd(a,b):
	if a==0:
		return b
	else:
		return gcd(b%a,a)


N = int(input())
add = 0
for i in range(1,N+1):
	for j in range(1,N+1):
		for k in range(1,N+1):
			temp = gcd(i,j)
			add += gcd(temp,k)
print(add)




















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


vector<vector<int>> G;
vector<int> parent, used, outDegree;
vector<vector<int>> d;

void dfs(int u, int t) {
  used[u] = 1;
  d[t].push_back(u);
  for(int v : G[u]) {
    if(used[v]) continue;
    parent[v] = u;
    dfs(v, t+1);
  }
}

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

  G.resize(N);

  rep(i,M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if(M % 2) {
    cout << -1 << endl;
    return 0;
  }

  parent.resize(N, 0);
  outDegree.resize(N, 0);
  used.resize(N, 0);
  d.resize(N);

  dfs(0, 0);

  rep(u,N) {
    for(int v: G[u]) {
      if(u < v && parent[v] != u && parent[u] != v) {
        printf("%d %d\n", u+1, v+1);
        outDegree[u]++;
      }
    }
  }

  for(int t = N - 1; t > 0; t--) {
    for(int u: d[t]) {
      int v = parent[u];
      if(outDegree[u] % 2) {
        printf("%d %d\n", u+1, v+1);
        outDegree[u]++;
      } else {
        printf("%d %d\n", v+1, u+1);
        outDegree[v]++;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
// #include <boost/functional/hash.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (~(x) & 1)

using namespace std;

// typedef boost::multiprecision::cpp_int mlint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-9;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}
mat mulmat(mat &x, mat &y, ll md = mod) {
    int xrow = x.size();
    int xcol = x[0].size();
    int ycol = y[0].size();
    mat ret(xrow,vct<ll>(ycol));
    rep(i,xrow)rep(j,ycol)rep(k,xcol) ret[i][j] += x[i][k] * y[k][j] % md,ret[i][j] %= md;
    return ret;
}

template<class T> T gcd(T a, T b){ if(a % b) return gcd(b, a % b); return b; }

/*ll modpow(ll n, ll e, ll md = mod) {
    n %= md;
    if(!n) return 0;
    e %= md - 1;
    ll ret = 1;
    while(e) {
        if(e & 1) ret = ret * n % md;
        n = n * n % md;
        e /= 2;
    }
    return ret;
}*/

ll modpow(ll n, ull e, ll md = mod) {
    n %= md;
    if(!e) return 0;
    return modpow(n * n % md,e / 2,md) * (e & 1 ? n : 1) % md;
}

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

    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='1'||s[0]=='0') esc(-1);
    rep(i,n-1) if(s[i]!=s[n-2-i]) esc(-1);
    int now=1;
    for(int i=2;i<=n;i++){
        cout<<now<<' '<<i<<endl;
        if(s[i-2]=='1') now=i;
    }
}


Measured memory_bytes: 1616
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, P = map(int, input().split())
S = list(map(int, input()))

if P == 2:
    print(sum(i + 1 for i in range(N) if S[i] % 2 == 0))
elif P == 5:
    print(sum(i + 1 for i in range(N) if S[i] % 5 == 0))
else:
    x = [None] * (N + 1)
    x[N] = 0
    tmp = 1
    for i in reversed(range(N)):
        x[i] = (x[i + 1] + S[i] * tmp) % P
        tmp = tmp * 10 % P
    print(sum(i * (i - 1) // 2 for i in Counter(x).values()))



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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int main() {
  ll h, w;
  scanf("%lld %lld", &h, &w);
  if(min(h, w) == 1){
    printf("1\n");
  }
  else{
    printf("%lld\n", ((h+1) / 2) * ((w + 1) / 2) + (h/2) * (w / 2));
  }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int n, a, b;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> a >> b;
	if ((a + b) & 1) {
		cout << "Borys\n";
	}
	else {
		cout << "Alice\n";
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

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

using namespace std;

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

    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z')
        cout << "a";
    else
        cout << "A";

    return 0;
}


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

int K, T;
vector<int> A;

int main(){
    cin >> K >> T;
    A.resize(T);
    for(auto &v: A)
        cin >> v;
    
    sort(A.begin(), A.end());
    int sum = 0;
    for(int i=0; i<T-1; i++)
        sum +=  A[i];
    
    if(sum < A[T-1] - 1){
        cout << A[T-1] - 1 - sum << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

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

signed main() {
  int n, k;
  cin >> n >> k;
  vector<P> c;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c.push_back(make_pair(a[i], b[i]));
  }
  sort(begin(c), end(c));
  int t = 0, ans;
  for (int i = 0; i < n; i++) {
    t += c[i].second;
    if (t >= k) {
      ans = c[i].first;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll N;
    cin >> N;
    vector<ll> V(5);
    rep(i, 5) cin >> V.at(i);
    sort(all(V));
    ll ans = (N - 1) / V.at(0) + 5 ;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	string S;

	cin >> S;

	if (S[0] == S[1] && S[1] == S[2]) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}

}

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

using namespace std;

#define il inline
#define re register
#define rep(i, n) for(re ll (i) = 0; (i) < (n); ++(i))

typedef long long ll;
typedef vector<ll> V;

const int N = 200010;

il ll read() {
	ll x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

ll n, d, a;
ll sumd, ans;

int main() {
    n = read(), d = read(), a = read();
	vector<pair<ll, ll> > e(n);
    rep(i, n) {
        ll xx = read(), hh = read();
        e[i] = make_pair(xx, hh);
    }
    sort(e.begin(),e.end());
	V h(n), x(n);
    rep(i, n) x[i] = e[i].first, h[i] = e[i].second;
    V imos(n + 1, 0);
    rep(l, n) {
        sumd += imos[l];
        if (sumd >= h[l]) continue;
        ll r = upper_bound(x.begin(), x.end(), x[l] + (d << 1)) - x.begin();
        ll damage = ((h[l] - sumd + a - 1) / a) * a;
        imos[l] += damage, imos[min(r,n)] -= damage;
        ans += (h[l] - sumd + a - 1) / a, sumd += damage;
    }
    return printf("%lld", ans) & 0;
}

Measured memory_bytes: 8064
N,P=map(int,input().split())
S=str(input())
ans=0

if 10%P==0:
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
else:
    rem = [0]*P
    mod = 0
    ten = 1
    rem[mod]=1
    for i in range(N):
        mod=(mod+int(S[N-i-1])*ten)%P
        ten=ten*10%P
        rem[mod]+=1
    for j in rem:
        ans+=(j*(j-1))//2
print(ans)


Measured memory_bytes: 3500
#include<stdio.h>
#define N 100
int main(){
  int M[N][N];
  int n,u,k,v,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j){
	printf(" ");
      }
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 3) {
        for(; arr[1]+3 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 3) {
        for(; arr[0]+3 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2]);
      t.step = step;

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2));
        que.peekLast().step = cur.step + 1;
      }

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      }
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      step = 0;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 22484
#include "bits/stdc++.h"
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define ll long long

signed main() {
	int N, Q; cin >> N >> Q;
	dsu d(N);
	for (int _ = 0; _ < Q; _++) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) {
			d.merge(u, v);
		}
		else {
			if (d.same(u, v)) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4072
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

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

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

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<endl;cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 200050
#define INF 9223372036854775807
signed main(){
    fastio
	ld n,ans=1,x;
	cin>>n;
	vector<ld> a(n);
	f(i,0,n){
	   cin>>a[i];
	   if(a[i]==0){
	      cout<<"0";
	      return 0;
	   }
	}
	f(i,0,n){
		if(a[i]>(1e18)/ans){
			cout<<"-1";
			return 0;
		}
		ans*=a[i];
	}
	cout<<(int)ans;
}

Measured memory_bytes: 4880
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
vector<int> ans;
bool isOK(vector<int> &b)
{
    for(int i = 0; i < b.size(); i++) if(b[i] > i + 1) return true;
    return false;
}
void solve(vector<int>& v)
{
    int d = 0;
    for(int i = v.size() - 1; i >= 0; i--)
    {
        if(v[i] == v.size() - d)
        {
            ans.push_back(v[i]);
            v.erase(v.begin() + i);
            solve(v);
            return;
        }
        d++;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];
    if(isOK(b))
    {
        cout << -1 << endl;
        return 0;
    }
    solve(b);
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
    return 0;
}

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

struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

int k,n;
VI rullonz;

void subtract(int d){
    if(rullonz[d]>1){
        rullonz[d] --;
    } else if(rullonz[d]==0){
        if(rullonz[d-1]>1){
            for(int i=d;i<=n-1;i++) rullonz[i] += k;
        }
        subtract(d-1);
    } else {
        rullonz[d] --;
    }
    return;
}

void output(){
    for(int i=0;i<n;i++){
        if(rullonz[i]==0) break;
        printf("%d ",rullonz[i]);
    }
    printf("\n");
    return;
}

void solveOdd(){
    for(int i=0;i<n;i++) rullonz.pb((k+1)/2);
    int N;
    n%2==1 ? N=n-1 : N=n;
    for(int i=0;i<N/2;i++) /*output(),*/subtract(n-1);
    output();
    return;
}

void solveEven(){
    printf("%d ",k/2);
    for(int i=1;i<n;i++) printf("%d ",k);
    printf("\n");
    return;
}

signed main(){
    scanf("%d%d",&k,&n);
    if(n==1){
        printf("%d\n",(k+1)/2);
        return 0;
    }
    if (k == 1) {
        for (int i = 0; i < (n + 1) / 2; ++i) {
            printf("%d ", k);
        }
        printf("\n");
        return 0;
    }
    if(k%2==0) solveEven();
    else solveOdd();
    return 0;
}

Measured memory_bytes: 3568
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();
		int c =sc.nextInt();
		int d =sc.nextInt();
		int i=1;
		while(b<=a&&i<=d) {
			b*=2;
			++i;
		}

		while(Math.max(a, b)>=c&&i<=d) {
			c*=2;
			++i;
		}
		
			
			
			if(b>a&&c>b) {
				System.out.println("Yes");
				return;
			}
		
		
		System.out.println("No");
		

		

	}

}



Measured memory_bytes: 35644
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    while(true){
        ll n;
        cin>>n;
        if(n==0) break;
        vll v(n);
        ll sum=0;
        ll m=LLINF,M=-LLINF;
        rep(i,n){
            cin>>v[i];
            chmax(M,v[i]);
            chmin(m,v[i]);
            sum+=v[i];
        }
        cout<<(sum-m-M)/(n-2)<<endl;
    }
    return 0;
}


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

int main(int argc, char* argv[]) {
  long long int l, r;
  cin >> l >> r;

  ll min_val = 2018;
  if ((r - l) > 2019) {
    cout << 0 << endl;
  } else {
    for (ll i = l; i < r; i++) {
      for (ll j = i + 1; j <= r; j++) {
        min_val = min(min_val, (i * j) % 2019);
      }
    }
    cout << min_val << endl;
  }
}


Measured memory_bytes: 1144
import sys
l = 10**10-1
r = 10**11-1
while True:
  x = (l+r)//2
  print("? "+str(x))
  sys.stdout.flush()
  res = input()
  if res == "Y":
    r = x
  else:
    l = x
  if l+1 == r:
    break
cand = r
ansls = []
while True:
  if cand%10 == 0:
    s = cand//10
    if 1 <= s <= 10**9:
      ansls.append(s)
    cand //= 10
  else:
    break
ansls = ansls[::-1]
ln = len(ansls)
flg = 0
if len(str(ansls[0]+1)) > len(str(ansls[0])):
  flg = 1
l = -1
r = ln-1
while l+1<r:
  x = (l+r)//2
  print("? "+str(ansls[x]+1))
  sys.stdout.flush()
  if input() == "Y":
    r = x
  else:
    l = x
if flg == 1 and r == 1:
  print("! "+str(ansls[l]))
  sys.stdout.flush()
else:
  print("! "+str(ansls[r]))
  sys.stdout.flush()

Measured memory_bytes: 38848
using System;

namespace A___Anti_Adjacency
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            var a = 0;
            if (n % 2 == 0)
                a = n / 2;

            else
                a = n / 2 + 1;

            if (a >= k)
                Console.WriteLine ("YES");

            else
                Console.WriteLine ("NO");
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main()
{
	int i, N, K, A[100001], B[100001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d %d", &(A[i]), &(B[i]));
	
	int j, k, bit[31];
	long long max, tmp;
	for (i = 1, bit[0] = 1; i <= 30; i++) bit[i] = bit[i-1] << 1;
	
	for (i = 1, max = 0; i <= N; i++) if ((A[i] & K) == A[i]) max += B[i];
	for (k = 0; bit[k] <= K; k++) {
		if ((K | bit[k]) != K) continue;
		for (j = k - 1, K ^= bit[k]; j >= 0; j--) K |= bit[j];
		for (i = 1, tmp = 0; i <= N; i++) if ((A[i] & K) == A[i]) tmp += B[i];
		if (tmp > max) max = tmp;
	}
	
	printf("%lld\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2496
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  /* 自然数 */
  ll num;

  cin >> num;

  ll n = num;

  /* 各桁の数字 */
  int dig;

  /* 和 */
  int sum = 0;



  /* 自然数の各桁の数字の和を計算 */
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }

  if(n % sum == 0) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
# ABC 109 D - Make Them Even

h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

# 左上から一筆書きの経路を作成
step = []
for i in range(h):
  for j in range(w):
    if i % 2 == 0:
      step.append((i, j))
    else:
      step.append((i, w - j - 1))  
    
ans = []
for (a, b), (c, d) in zip(step, step[1:]):
  if A[a][b] % 2 == 1:
    A[c][d] += 1
    ans.append([a + 1, b + 1, c + 1, d + 1])

print(len(ans))
for a in ans:
  print(*a)

Measured memory_bytes: 51972
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;

const int BLACKJACK = 0;
const int BUST = -1;

map<string,int> val = {
    {"A", 1},
    {"2", 2},
    {"3", 3},
    {"4", 4},
    {"5", 5},
    {"6", 6},
    {"7", 7},
    {"8", 8},
    {"9", 9},
    {"T", 10},
    {"J", 10},
    {"Q", 10},
    {"K", 10}
};

pair<int,bool> score(const vector<string> &v) {
    int ret = 0;
    bool hasAce = false, useAce = false;
    for (int i=0; i<(int)v.size(); ++i) {
        ret += val[v[i]];
        if (v[i] == "A") hasAce = true;
    }
    if (hasAce && ret+10 <= 21) {
        ret += 10;
        useAce = true;
    }
    if ((int)v.size() == 2 && ret == 21) {
        ret = BLACKJACK;
    } else if (21 < ret) {
        ret = BUST;
    }
    return make_pair(ret, useAce);
}

bool need(const vector<string> &v) {
    pair<int,bool> t = score(v);
    if (t.first <= 0) {
        return false;
    } else if (t.first <= 16 || (t.first == 17 && t.second)) {
        return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    for (int i=0; i<N; ++i) {
        vector<string> v(2);
        for (int j=0; j<2; ++j) cin >> v[j];
        vector<string> pile(8);
        for (int j=0; j<8; ++j) cin >> pile[j];

        int k = 0;
        while (need(v)) {
            v.push_back(pile[k++]);
        }

        pair<int,bool> ret = score(v);
        if (ret.first == BLACKJACK) {
            cout << "blackjack" << endl;
        } else if (ret.first == BUST) {
            cout << "bust" << endl;
        } else {
            cout << ret.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
// Written by newbiechd
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;

const int BUF = 1000003;
inline char getChar() {
  static char buf[BUF], *bufS, *bufT;
  if (bufS == bufT) {
    bufT = (bufS = buf) + fread(buf, 1, BUF, stdin);
    if (bufS == bufT)
      return EOF;
  }
  return *bufS++;
}
inline int read() {
  int f = 0;
  bool b = 1;
  char ch;
  while (!isdigit(ch = getChar()))
    if (ch == 45)
      b = 0;
  do f = f * 10 + (ch ^ 48);
  while (isdigit(ch = getChar()));
  return b ? f : ~f + 1;
}

const int maxN = 100003, maxE = 1000003, S = maxN - 2, T = maxN - 1;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int cntNode;

int h[maxN], cntE = 1;
struct Edge {
  int tar, val, cost, nxt;
  Edge() {}
  Edge(int tar, int val, int cost, int nxt)
    : tar(tar), val(val), cost(cost), nxt(nxt) {}
}ed[maxE];
inline void addEdge(int x, int y, int z, int w) {
  ed[++cntE] = Edge(y, z, w, h[x]), h[x] = cntE;
  ed[++cntE] = Edge(x, 0, -w, h[y]), h[y] = cntE;
}

int cur[maxN], pre[maxN], maxCost;
inline bool SPFA() {
  static int dis[maxN], que[maxN];
  static bool inq[maxN];
  int hd = 1, tl = 0, i, x, y;
  memset(dis + 1, -0x3f, sizeof(int) * cntNode);
  memcpy(cur + 1, h + 1, sizeof(int) * cntNode);
  dis[S] = 0, dis[T] = -inf, cur[S] = h[S], que[++tl] = S, inq[S] = 1;
  while (hd <= tl) {
    x = que[hd++], inq[x] = 0;
    for (i = h[x]; i; i = ed[i].nxt)
      if (ed[i].val && dis[y = ed[i].tar] < dis[x] + ed[i].cost) {
        dis[y] = dis[x] + ed[i].cost, pre[y] = x;
        if (!inq[y])
          que[++tl] = y, inq[y] = 1;
      }
  }
  return dis[T] > -inf;
}
int dfs(int x, int flow) {
  if (x == T)
    return flow;
  int i, y, k, res = flow;
  for (i = cur[x]; i && res; i = ed[i].nxt) {
    if (ed[i].val && pre[y = ed[i].tar] == x
        && (k = dfs(y, min(res, ed[i].val))))
      ed[i].val -= k, ed[i ^ 1].val += k, res -= k, maxCost += ed[i].cost * k;
    cur[x] = i;
  }
  return flow - res;
}
int maxFlow;
inline void Dinic() {
  while (SPFA())
    maxFlow += dfs(S, inf);
}

signed main() {
  int n = read(), i, x, y, z;
  int p[4] = {2 * n + 1, 2 * n + 2, 2 * n + 3, 2 * n + 4};
  cntNode = 2 * n + 4;
  for (i = 1; i <= n; ++i) {
    x = read(), y = read(), z = read(), addEdge(S, i, z, 0);
    addEdge(i, p[0], inf, x + y), addEdge(i, p[1], inf, -x - y);
    addEdge(i, p[2], inf, x - y), addEdge(i, p[3], inf, y - x);
  }
  for (i = 1; i <= n; ++i) {
    x = read(), y = read(), z = read(), addEdge(i + n, T, z, 0);
    addEdge(p[0], i + n, inf, -x - y), addEdge(p[1], i + n, inf, x + y);
    addEdge(p[2], i + n, inf, y - x), addEdge(p[3], i + n, inf, x - y);
  }
  
  Dinic(), printf("%lld\n", maxCost);
  return 0;
}


Measured memory_bytes: 4864
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ts = readLine()!!.toMutableList()
    ts.add(0, 'x')
    ts.add('x')
    val s = ts.toCharArray()
    if (n < 4) {
        println(0)
        return
    }
    val jmap = mutableMapOf<Char, LongArray>()
    jmap['R'] = LongArray(4001)
    jmap['G'] = LongArray(4001)
    jmap['B'] = LongArray(4001)

    for (c in "RGB") {
        for (j in 1..n - 1) {
            var tempSum = 0L
            for (k in j + 1..n) {
                if (c != s[j] && c != s[k] && s[j] != s[k]) tempSum++
            }
            jmap[c]!![j] = tempSum
        }
    }

    var ans = 0L

    for (i in 1..n - 2) {
        for (j in i + 1..n - 1) {
            val add = jmap[s[i]]!![j]
            ans += add
            if (add > 0) {
                val diff = j - i
                val k = j + diff
                if (k <= n)
                    if (s[k] != s[i] && s[k] != s[j]) ans--
            }
        }
    }

    println(ans)
}


Measured memory_bytes: 38920