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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e18+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll x,y,z;
ll cnt;
ll root;
vector<ll> vec[100005];
ll parent[100005];
void tree(ll par,ll n){
	if(parent[n]!=0)  return;
	parent[n]=par;
	for(auto &i:vec[n]) tree(n,i);
	return;
}
void dfs1(ll n){
	z++;
	if(n==1) return;
	dfs1(parent[n]);
	return;
}
void dfs2(ll n){
	cnt++;
	if(cnt==z/2){
		root=n; return;
	}
	dfs2(parent[n]);
	return;
}
void dfs3(ll n){
	y++;
	for(auto &i:vec[n]){
		if(i==parent[n]) continue;
		dfs3(i);
	}
	return;
}

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;
rep(i,N-1){
	ll a,b; 
	cin>>a>>b;
	vec[a].pb(b);
	vec[b].pb(a);
}

tree(-1,1);
dfs1(N); //cout<<z<<endl;
dfs2(N); //cout<<root<<endl;
dfs3(root); //cout<<y<<endl;

x=N-y;
puts(x>y?"Fennec":"Snuke");

}
	


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll mod_pow(ll a,ll b) {
    if(b==0){return 1;}
    ll res=mod_pow(a*a%MOD,b/2);
    if(b&1)res=res*a%MOD;
    return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
vector<long long> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  assert(!(n<k));
  assert(!(n<0 || k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int main(){
  ll K;
  cin>>K;
  string S;
  cin>>S;
  ll a=S.size(),dp[K+10],ans[K+10];
  for(ll i=0;i<=K;i++){
    dp[i]=mod_pow(26,i);
    ans[i]=0;
  }
  ll rock[K+10];
  init_nCk(1e7);
  for(ll i=0;i<=K;i++){
    rock[i]=nCk(i+a-1,a-1)*mod_pow(25,i);
    rock[i]%=MOD;
  }
  for(ll j=0;j<=K;j++){
    ans[K]+=dp[K-j]*rock[j];
    ans[K]%=MOD;
  }
  cout<<ans[K]<<endl;
}

Measured memory_bytes: 262064
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static String str=sc.next();
	private static int q=sc.nextInt();
	public static void main(String[] args){
		for(int i=0;i<q;i++){
			String command=sc.next();
			if(command.equals("print")) print();
			if(command.equals("reverse")) reverse();
			if(command.equals("replace")) replace();
		}
	}
	private static void print(){
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.println(str.substring(a,b+1));
	}
	private static void reverse(){
		int a=sc.nextInt();
		int b=sc.nextInt();
		String rev="";
		for(int i=b;i>=a;i--){
			rev=rev+String.valueOf(str.charAt(i));
		}
		str=str.substring(0,a)+rev+str.substring(b+1);
	}
	private static void replace(){
		int a=sc.nextInt();
		int b=sc.nextInt();
		String p=sc.next();
		StringBuilder buff=new StringBuilder();
		buff.append(str.substring(0,a));
		buff.append(p);
		buff.append(str.substring(b+1));
		str=buff.toString();
	}
}

Measured memory_bytes: 47196
def main():
    n = int(input())
    a1 = list(map(int, input().split()))
    a2 = list(map(int, input().split()))

    scores = []
    for i1 in range(n):
        score = sum(a1[:i1+1]) + sum(a2[i1:])
        scores.append(score)
    r = max(scores)
    print(r)


if __name__ == '__main__':
    main()


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

int main(){
 	ll ans;
  	int n;
  	cin>>n;
	vector<ll> a(87);
  	a[0] =2;a[1]=1;
  	for(int i=2;i<a.size();i++){
      a.at(i)=a[i-2]+a[i-1];
    }
  
  	cout<<a[n]<<endl;
}

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

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

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

def lcm(a, b):
    return (a // gcd(a, b)) * b

print(lcm(a, b))


Measured memory_bytes: 61108
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
int f[26]={0};
cin>>a;
int i=0;
while(a[i]!='\0')
{
f[a[i]-'a']++;
i++;
}
int flag=0;
for(int i=0;i<26;i++)
{
if(f[i]>1)
{
flag=1;
break;
}
}
if(flag==1)
cout<<"no";
else
cout<<"yes";
}

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

int S[1000];
int top = 0;

void push(int x)
{
	S[top++] = x;
}

int pop()
{
	top--;
	return S[top];
}

int main()
{
	int a, b;
	char s[100];
	while(cin>>s)
	{
		if (s[0] == '+')
		{
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b);
		}
		else
			push(atoi(s));
	}
	cout << S[top - 1] << endl;
}


Measured memory_bytes: 3076
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int s,h=1000000000; cin>>s; 
    int x2= (s+h-1)/h;
    int y2=h*x2-s;
    cout << "0 0 1 1000000000 " << x2 << " " << y2 << endl;
    // cout << abs(1*y2-x2*1000000000) << endl; 
    return; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
from itertools import accumulate
from collections import defaultdict

N,K = map(int,input().split())
A = list(map(int,input().split()))

S = [0] + list(accumulate(A))
S = [ s%K for s in S ]

ans = 0
counter = defaultdict(int)
queue = []
for i,s in enumerate(S):
  t = (s-i) % K

  ans += counter[t]
  counter[t] += 1

  queue.append(t)
  if len(queue) >= K:
    counter[queue[0]] -= 1
    queue.pop(0)

print(ans)

Measured memory_bytes: 127384
/* ex4_3
   moka223711 */

#include <stdio.h>

int main(void){
    // 高さがn(n+1)/2[m](n=1,2,…,999)の999本の塔が西から順に立っている
    // 雪に埋もれていない塔の高さから雪が何m積もっているか求める
    // 雪に埋もれていない西側の塔の高さをheight_west、東側の塔の高さをheight_eastとする
    int height_west, height_east, dif, ans;
    scanf("%d %d", &height_west, &height_east);
    // 東側の塔の高さから西側の塔の高さを引き、差difを求める
    dif = height_east - height_west;
    
    // 差difから西側の塔の高さを求めて、雪に埋もれていない塔の高さを引くことで
    // 雪が何m積もっているかを求める
    ans = dif * (dif - 1) / 2 - height_west;
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int a, b; cin >> a >> b;
	if (a > 9 || b > 9 || a < 1 || b < 1) cout << -1;
	else cout << a * b; 
}

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

#define debug(x) cerr << "-------- [ " << (#x) << " ] = " << x << endl
//#define bjq

using namespace std;

int main() {
#ifdef bjq
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif

	int n;
	cin >> n;
	int x = 1000 - n % 1000;
	if (x == 1000) x = 0;
	cout << x << endl;  

	return 0;
}



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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N, vector<int>());
    int Ai, Bi;
    for(int i=0;i<M;i++){
        cin >> Ai >> Bi;
        Ai--; Bi--;
        graph[Ai].push_back(Bi);
        graph[Bi].push_back(Ai);
    }
    set<int> done;
    done.insert(0);
    vector<int> res(N, -1);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        auto u = q.front(); q.pop();
        for(auto v : graph[u]){
            if(done.count(v) > 0) continue;
            q.push(v);
            res[v] = u;
            done.insert(v);
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << res[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 14908
sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]

    for j in range(m + 1):
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

typedef double d;

d cross ( d x1, d y1, d x2, d y2 )
{
  return (x1 * y2) - (y1 * x2);
}

int main ( void )
{
  d x[3], y[3], xp, yp;
  
  while( cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp )
  {
     d ret[3];
     for ( int i = 0; i < 3; ++i )
     {
        int nx = (i + 1) % 3;
        ret[i] = cross(xp - x[i], yp - y[i], x[nx] - x[i], y[nx] - y[i]);
     }
     if ( (ret[0] < 0 && ret[1] < 0 && ret[2] < 0) ||
          (ret[0] > 0 && ret[1] > 0 && ret[2] > 0) )
     {
        cout << "YES" << endl;
     }
     else
     {
        cout << "NO" << endl;
     }
  }
  return 0;
}

Measured memory_bytes: 1216
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);

$max = strlen($s);
$s .= $s[0];
$ps = [[0, 0], [0, 1], [1, 0], [1, 1]];
foreach ($ps as $p) {
	$t = $p;
	for ($i = 1; $i <= $max; $i++) {
		if ($s[$i] == 'o' && $t[$i] == 0 || $s[$i] == 'x' && $t[$i] == 1) {
			$t[$i+1] = $t[$i-1];
		} else {
			$t[$i+1] = 1 - $t[$i-1];
		}
	}
	if ($t[0] == $t[$max] && $t[1] == $t[$max+1]) {
		$x = substr(implode($t), 0, -2);
		exit(str_replace([0,1], ['S','W'], $x));
	}
}
echo '-1';

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

int main(){
  int N,i,count=0;
  char M;
  cin >> N;
  for (i=0 ; i < N ;i++){
    cin >> M;
    if (M == 'Y')count++;
}
    if(count >=1) cout << "Four" << endl;
     else cout << "Three" << endl;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <algorithm>
#include <vector>

int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int a,b,c;
    for(a=1;a<=3500;a++)
    {
        for(b=1;b<=3500;b++)
        {
            if((4*a*b - b*n - n*a) > 0 && n*a*b % (4*a*b - b*n - n*a) == 0)
            {
                c = n*a*b / (4*a*b - b*n - n*a);
                printf("%lld %lld %lld\n",a,b,c);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 128
import java.io.*;
 
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    while(true){
      String datas = br.readLine();
      String[] data = datas.split(" ");
      int a = Integer.parseInt(data[0]);
      int b = Integer.parseInt(data[1]);
      if(a == 0 && b == 0)
    	  break;
      
      if(a > b){
    	  int tmp = a;
    	  a = b;
    	  b = tmp;
      }
      
      sb.append(a).append(" ").append(b).append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    string s;
    cin>>s;
    if(s == "Sunny") cout<<"Cloudy"<<endl;
    else if(s == "Cloudy") cout<<"Rainy"<<endl;
    else if(s == "Rainy") cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  ll sum = 1000;
  for(int i=0;i<n-1;i++){
    if(a[i] < a[i+1]){
      sum += (a[i+1]-a[i])*(sum/a[i]);
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3596
local n=io.read("*n")
local a={}
for i=1,n do
    local number=io.read("*n")
    if not a[number] then
        a[number]=1
    else
        a[number]=a[number]+1
    end
end

local total=0
for i,j in pairs(a) do
    if i<j then
        total=total+j-i
    elseif i>j then
        total=total+j
    end
end
print(total)

Measured memory_bytes: 6508
#include<bits/stdc++.h>
using namespace std;
char a[10000],b[10000],n,m;
int main()
{
    gets(a),gets(b),n=strlen(a),m=strlen(b),sort(a,a+n),sort(b,b+m);
    for(int i=0; i<fmax(n,m); i++)
    {
        if(a[i]<b[m-i-1]){printf("Yes\n");return 0;}
        if(a[i]>b[m-i-1])break;
    }
    printf("No\n");
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll n,k,d;
int main()
{
    cin>>n>>k>>d;
    n=abs(n);
    ll sum=n/d;
    ll t=n%d;
    if(sum>k)
    {
        cout<<n-k*d<<endl;
    }
    else
    {
        int x=k-sum;
        if(x%2==0)
        {
            cout<<n%d<<endl;
        }
        else
        {
            cout<<d-n%d<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long[] a = in.nextLongArray(3);
			int k = in.nextInt();
			Arrays.sort(a);
			for (int i = 0; i < k; i++) {
				a[2] = a[2]*2;
			}

			long sum = 0;
			for (long l : a) {
				sum += l;
			}
			out.println(sum);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
//Kruskal's algorithm
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct E
{
    int weight;
    int begin;
    int end;
};

struct Unionfind
{
    vector<int> parents;

    Unionfind(int n) : parents(n)
    {
        for (int i = 0; i < n; i++)
        {
            parents[i] = i;
        }
    }

    int root(int x)
    {
        if (parents[x] == x)
        {
            return x;
        }
        return parents[x] = root(parents[x]);
    }

    void unite(int x, int y)
    {
        int par_x = root(x);
        int par_y = root(y);
        if (par_x == par_y)
        {
            return;
        }
        parents[par_x] = par_y;
    }

    bool same(int x, int y)
    {
        int par_x = root(x);
        int par_y = root(y);
        return par_x == par_y;
    }
};

int main()
{
    int n;
    cin >> n;
    struct Unionfind tree(n);

    vector<E> e(n * (n - 1) / 2);
    int index = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int temp;
            cin >> temp;
            if (i < j)
            {
                e[index].weight = temp;
                e[index].begin = i;
                e[index].end = j;
                index++;
            }
        }
    }

    sort(e.begin(), e.end(),
         [](const E &l, const E &r) {
             return l.weight < r.weight;
         });

    int ans = 0;
    for (int i = 0; i < e.size(); i++)
    {
        if (e[i].weight == -1)
        {
            continue;
        }

        if (tree.same(e[i].begin, e[i].end))
        {
            continue;
        }
        else
        {
            tree.unite(e[i].begin, e[i].end);
            ans += e[i].weight;
        }
    }

    cout << ans << endl;
}

/*

<INPUT>
5
 -1 2 3 1 -1
 2 -1 -1 4 -1
 3 -1 -1 1 1
 1 4 1 -1 3
 -1 -1 1 3 -1

<OUTPUT>
5

*/



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string a, b;
    cin >> a >> b;
    int N = a.size() + b.size();
    rep(i,N){
        if(i&1)cout << b[i/2];
        else cout << a[i/2];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

signed main()
{

  char c;
  int n = in(), a = in(), b = in();
  int cnt = 0, s = 0;

  REP(i, n + 1){
    scanf("%c", &c);
    if (c == 'a'){
      if (cnt < a + b){
        cnt++;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } 
    else if (c == 'b'){
      if (cnt < a + b && s < b){
        s++; cnt++;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
    else if (c == 'c'){
      cout << "No" << endl;
      continue;
    }
  }
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10005],b[10005];
long long  sum1,sum2;
long long delta,qwq;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        sum1+=a[i];
    }
    for(int i=1;i<=n;i++) 
    {
        cin>>b[i];
        sum2+=b[i];
    }
    if(sum1>sum2) 
    {
        cout<<"No";
        return 0;
    }
    delta=sum2-sum1;
    for(int i=1;i<=n;i++)
        if(b[i]>a[i]) qwq+=(b[i]+1-a[i])/2;
    if(qwq>delta) cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumleft = 0;
    int sumright = 0;
    int array[] = new int[N];
    for (int i=0;i<N;i++){
     int W = sc.nextInt();
     sumright += W;
     array[i] = W;
    }
    int ans = Math.abs(sumright-sumleft);
    for (int j=0;j<N;j++){
      sumleft += array[j];
      sumright -= array[j];
      ans = Math.min(ans, Math.abs(sumright-sumleft));
    }
    System.out.println(ans);
  }
}
  

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, m, n, ans;

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

    cin >> n;

    bool noPrime = true;
    while (noPrime)
    {
        noPrime = false;
        repm(i, 2, (n + 1) / 2)
        {
            if (n % i == 0)
            {
                noPrime = true;
                break;
            }
        }
        n++;
    }

    cout << --n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define debug(x) cerr << #x << ": " << x << "\n"
#define debugv(x) cerr << #x << ": \n" << rep(i,)
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
#define INF 1e9

#define mod 1000000007
int i, j, k, l, m;
int N, M, K;
int dp[100005][2];
signed main()
{
    cin >> N>>M;

    int ans = (N < M) ? 0 : 10;


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int N;
string s;
map<string, ll> m;

// x個の中から二つを選ぶ方法
ll comb(ll x) {
    return x * (x - 1) / 2;
}

int main() {
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    for (const auto &x: m) {
        ans += comb(x.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, D] = lines[0].split(' ').map(Number)

let count = 0
for (let i = 1; i <= N; i++) {
    const [x, y] = lines[i].split(' ').map(Number)
    let d = Math.pow(x, 2) + Math.pow(y, 2)
    d = Math.pow(d, 0.5)
    if (d <= D) {
        count++
    }
}

console.log(count)

Measured memory_bytes: 63092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            int n = s.length();
            for (int pos = s.length(); pos >= 0; pos--) {
                for (int i = (pos == n) ? 0 : (s.charAt(pos) - 'a' + 1); i < 26; i++) {
                    String newS = s.substring(0, pos) + (char) ('a' + i);
                    if (diverse(newS)) {
                        out.println(newS);
                        return;
                    }
                }
            }
            out.println(-1);
        }

        private boolean diverse(String newS) {
            char[] c = newS.toCharArray();
            Arrays.sort(c);
            for (int i = 0; i < c.length - 1; i++) {
                if (c[i] == c[i + 1]) {
                    return false;
                }
            }
            return true;
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22868
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n,k,q;
    cin >> n>> k>>q;
    int p[n];
    rep(i,n){
        p[i]=k-q;
    }
    rep(i,q){
        int a;
        cin >> a;
        a--;
        p[a]++;
    }
    rep(i,n){
        if(p[i]>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  int x,n;
  cin >> x >> n;
  vector<bool> f(102, 0);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    f[p] = 1;
  }
  if (!f[x]) cout << x <<endl;
  else {
    for (int i = 1; i < 200; i++) {
      if (!f[x-i]) {
        cout << x - i<<endl;
        break;
      }
      else if (!f[x+i]) {
        cout << x + i <<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int N,i,x=0;
    int L[30];
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>L[i];
    }
    sort(L,L+N);
    for(i=0;i<N-1;i++)
    {
        x=x+L[i];
    }
    if(x<=L[N-1])
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <iostream>
#include <memory>

constexpr int max_size()
{
    return static_cast<int>(1e+2);
}

void print(int* a, int n, int i) {
    if (i == n - 1) {
        std::cout << a[i] << std::endl;
        return;
    }

    std::cout << a[i] << " ";
    return print(a, n, i + 1);
}

void print(int* a, int n) {
    print(a, n, 0);
    return;
}

void get_array(
    int* arr, 
    const std::string& str,
    int i,  //arr index
    int s,  //start pos
    int e)  //end pos
{
    if (e == str.size()) {
        arr[i] = std::atoi(str.substr(s, e - s).c_str());
        return;
    }

    constexpr char delim = ' ';
    if (str[e] == delim) {
        arr[i] = std::atoi(str.substr(s, e - s).c_str());
        get_array(arr, str, i + 1, e + 1, e + 1);
        return;
    }

    get_array(arr, str, i, s, e + 1);
    return;
}

void get_array(int* arr, std::istream& stream)
{
    std::string buf;
    getline(stream, buf);
    get_array(arr, buf, 0, 0, 0);

    return;
}

int selection_sort(int* a, int n, int i) {
    if (i == n) {
        return 0;
    }

    int m = i;
    for (int k = i + 1; k < n; ++k) {
        if (a[k] < a[m]) {
            m = k;
        }
    }

    int count = 0;
    if (i != m) {
        std::swap(a[i], a[m]);
        count = 1;
    }

    return count + selection_sort(a, n, i + 1);
}

int selection_sort(int* a, int n) {
    return selection_sort(a, n, 0);
}

int main()
{
    int n;
    std::cin >> n;
    std::cin.ignore();  //ignore \n
    const auto arr
        = std::make_unique<int[]>(n);
    get_array(arr.get(), std::cin);

    const int count = selection_sort(arr.get(), n);
    print(arr.get(), n);
    std::cout << count << std::endl;

    return 0;
}

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

int main(){
	int k;
	cin >> k;
	vector<int> d(8);
	rep(i,8){
		d[i] = i;
	}
	
	vector<pair<int,int>> p(k);
	rep(i,k){
		cin >> p[i].first >> p[i].second;
	}
	
	
	do {
		bool ok = true;
		//queenがいるマスを管理する
		vector<vector<int>> queen(8,vector<int>(8,0));
		rep(i,8){
			queen[i][d[i]]++;
		}
		//指定されたマスにクイーンがいない場合はだめ
		rep(i,k){
			if(queen[p[i].first][p[i].second] == 0) ok = false;
		}
		
		//あるクイーンに対して斜めの位置に他のクイーンがいたらアウト
		rep(i,8){
			//クイーンは(i,d[i])にいる
			for (int j = 0; j < 8; ++j) {
				if(j == i) continue;
				if(j < i){
					if(d[i]-i+j >= 0){
						if(queen[j][d[i]-i+j] == 1) ok = false;
					}
					if(d[i]+i-j<=7){
						if(queen[j][d[i]+i-j] == 1) ok = false;
					}
				}
				if (j > i){
					if(d[i]+i-j >= 0){
						if(queen[j][d[i]+i-j] == 1) ok = false;
					}
					if(d[i]-i+j <= 7){
						if(queen[j][d[i]-i+j] == 1) ok = false;
					}
				}
				
			}
		}
		if(ok){
			rep(j,8){
				rep(k,8){
					if(queen[j][k] == 1){
						cout << 'Q';
					}else{
						cout << '.';
					}
				}
				cout << endl;
			}
			return 0;
		}
	}while(next_permutation(d.begin(),d.end()));
	
	
    return 0;
}




Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<int> A(n + 1, 0);
    for(int i = 1; i < n; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    rrep(i, n) {
        cout << A[i] << endl;
    }
    return 0;
}

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

int main() {
	int A,B,C;
    cin >> A >> B >> C;
    if(A==B){
      cout << C << endl;
    }
    else if(B==C){
      cout << A << endl;
    }
    else{
      cout << B << endl;
    }
}


Measured memory_bytes: 256
Module Module1

    Sub Main()
        Dim a, b, c, x, count As Integer
        a = Console.ReadLine
        b = Console.ReadLine
        c = Console.ReadLine
        x = Console.ReadLine
        For i As Integer = a To 0 Step -1
            For j As Integer = b To 0 Step -1
                For k As Integer = c To 0 Step -1

                    If 500 * i + 100 * j + 50 * k = x Then
                            count = count + 1
                        End If

                Next
            Next
        Next
        Console.WriteLine(count)
        Console.ReadLine()

    End Sub

End Module


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  vector<int> removeh(H);
  vector<int> removew(W);
  for (int j = 0; j < W; j++) {
    int black = false;
    for (int i = 0; i < H; i++) {
      if (a[i][j] == '#') {
        black = true;
        break;
      }
    }
    if (black == false) {
      removew[j] = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    int black = false;
    for (int j = 0; j < W; j++) {
      if (a[i][j] == '#') {
        black = true;
        break;
      }
    }
    if (black == false) {
      removeh[i] = 1;
    }
  }
  for (int i = 0; i < H; i++) {
    if (removeh[i])
      continue;
    for (int j = 0; j < W; j++) {
      if (removew[j])
        continue;
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define ll double
#define pi 3.1415926535897932384626433
#define l long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d, rad;
    ll ans;
    cin >> a >> b >> c >> d;
    rad=abs(360.0*(c/12.0+d/(60.0*12.0)) - 360.0*(c+d/60.0))*pi/180.0;
    //rad = abs(c / 12.0 + (d / 60.0) / 12.0 - d / 60.0) * 2.0 * pi;
   // cout << rad << endl;
    ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad));
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4244
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  K--;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  int minv = INT_MAX;
  for (int i = 0; i < N - K; i++) {
    minv = min(minv, vec[i + K] - vec[i]);
  }
  cout << minv << endl;
  return 0;
}


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

int main() {

  int m_day[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  int a,b,c,d,e,f;

  while(true) {
    cin>>a>>b>>c>>d>>e>>f;
    if(a==-1&&b==-1&&c==-1&&d==-1&&e==-1&&f==-1) break;
    int ans = 0;

    for(int i=a; i<=d; i++) {
      bool flag = false;
      if(i%4==0) {
        if(i%100==0) {
          if(i%400==0)flag = true;
        } else {
          flag = true;
        }
      }

      if(a == d) {
        if(b == e) {
          ans = f - c;
        } else {
          ans += m_day[b-1] - c;
          for(int j = b+1; j<e; j++) {
            if(j == 2 && flag) ans += m_day[j-1]+1;
            else ans += m_day[j-1];
          }
          ans += f;
        }

      } else {
        if(i == a) {
          for(int j=b+1; j<=12; j++) {
            if(j == 2 && flag) ans += m_day[j-1]+1;
            else ans += m_day[j-1];
          }
          ans += m_day[b-1] - c;
          if(b == 2 && flag) ans++;
        } else if(i == d) {
          for(int j=1; j<e; j++) {
            if(j == 2 && flag) ans += m_day[j-1]+1;
            else ans += m_day[j-1];
          }
          ans += f;
        } else {
          if(flag) ans += 366;
          else ans += 365;
        }
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		/*
		 * Scannerで値取得。
		 */
		Scanner sint = new Scanner(System.in);

		//値取得
		int numA = sint.nextInt();
		int numB = sint.nextInt();

		sint.close();

		final int KEISANKANOU = 10;

		int keisan = 0;
		if (numA < KEISANKANOU) {
			if (numB < KEISANKANOU) {
				keisan = numA * numB;
			}else {
				keisan = -1;
			}
		}else {
			keisan = -1;
		}
		System.out.println(keisan);

	}

}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
vector <ll> money;

void solve() {
    ll N;
    ll i,j,k,l,r,x,y; string s;
    bool exit = false;
    cin>>N;
    money.push_back(1);
    ll m=6;
    while(true){
        if(m<=100000){
            money.push_back(m);
            m *= 6;
        }else{
            break;
        }
    }
    m=9;
    while(true){
        if(m<=100000){
            money.push_back(m);
            m *= 9;
        }else{
            break;
        }
    }   
    sort(ALL(money));
    //FORR(m,money) cout<<m<<endl;
    
    int dp[100010];
    dp[0]=0;
    FOR(i,100000){
        dp[i+1] = dp[i]+1;
        FOR(j, money.size()){
            if(i+1-money[j]<0) break;
            if(dp[i+1]>dp[i+1-money[j]]+1){
                dp[i+1]= dp[i+1-money[j]]+1;
            }
        }
    }
    cout<<dp[N]<<endl;
    /*while(true){
        int index = upper_bound(ALL(money), N) - money.begin()-1;
        cout<<N<<" "<<money[index]<<endl;
        N -= money[index];
        ret+=1;
        if(N<0){
            //cout<<"error";
            break;
        }
        if(N==0){
            break;
        }
    }
    */
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 640
S = input()
int_list = []
for i in range(len(S)):
    sub_S = S[:i]
    if len(sub_S) % 2 !=0:
        continue
    if sub_S[:int(len(sub_S) / 2)] == sub_S[int(len(sub_S) / 2):]:
        int_list.append(len(sub_S))
print(max(int_list))

Measured memory_bytes: 38424
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [i for i in a]
b[0] = min(b[0], x)
for i in range(1, n):
    if b[i-1] + b[i] > x:
        b[i] = x - b[i-1]
print(sum(a) - sum(b))

Measured memory_bytes: 14052
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int H = scan.nextInt();
			int W = scan.nextInt();
			int K = scan.nextInt();

			char[][]c = new char[H][W];
			String []s = new String[H];

			for(int i = 0;i<H;i++) {
				s[i] = scan.next();
				c[i] = s[i].toCharArray();
			}

			int count = 0;

			for(int i = 0;i<(Math.pow(2, H));i++){
				for(int j = 0;j<(Math.pow(2, W));j++) {
					char[][]cha = new char[H][W];
					for(int k = 0;k<H;k++) for(int o = 0;o<W;o++)cha[k][o]=c[k][o];

					for(int w = 0;w<H;w++) {//行
						if((1&i>>w)==1) {
							for(int z = 0;z<W;z++)cha[w][z]='+';
						}
					}

					for(int w = 0;w<W;w++) {//列
						if((1&j>>w)==1) {
							for(int z = 0;z<H;z++)cha[z][w]='+';
						}
					}

					int co = 0;
					for(int h = 0;h<H;h++) {
						for(int e = 0;e<W;e++) {
							if(cha[h][e]=='#')co++;
						}
					}
					if(co==K)count++;
				}
			}

			System.out.println(count);




		}
	}
}


Measured memory_bytes: 38904
N = input()
# print(N)
d = len(N)

T = [0, 3, 5, 7]
A = []
for i in range(4**d):
    for j in range(d):
        n = i
        c = 0
        a = 0
        for k in range(j + 1):
            a += T[n % 4] * 10**c
            n //= 4
            c += 1
    A.append(a)

def is753(n):
    if n == 0:
        return False
    n_str = str(n)
    has3 = False
    has5 = False
    has7 = False
    for s in n_str:
        if s == '0':
            return False
        elif s == '3':
            has3 = True
        elif s == '5':
            has5 = True
        elif s == '7':
            has7 = True
    return has3 and has5 and has7

ans = []
ans = [x for x in A if x <= int(N) and is753(x)]
# print(A)
# print(ans)
print(len(ans))


Measured memory_bytes: 62940
import sys
def ttt(o):
    if (o[0]==o[4]==o[8] or o[2]==o[4]==o[6]) and o[4]!="s":
        return o[4]
    for i in range(3):
        if o[i*3]!="s" and o[i*3]==o[i*3+1]==o[i*3+2]:
            return o[i*3]
        if o[i]!="s" and o[i]==o[i+3]==o[i+6]:
            return o[i]
    return "d"
[print(ttt(j)) for j in [i for i in sys.stdin]]



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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<int>> pos(10, vector<int>());
    for (int i = 0; i < N; i++) {
        int t = S[i] - '0';
        pos[t].push_back(i);
    }
    
    int cnt = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                if (pos[i].size() == 0) continue;
                int a = pos[i][0];
                auto it = upper_bound(pos[j].begin(), pos[j].end(), a);
                if (it == pos[j].end()) continue;
                int b = (*it);
                auto it2 = upper_bound(pos[k].begin(), pos[k].end(), b);
                if (it2 != pos[k].end()) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n); rep (i, n) cin >> a[i];
    ll sum = 0, s2 = 0;
    rep (i, n) sum = mod(sum + a[i]);
    rep (i, n) s2 = mod(s2 + mul_mod(a[i], a[i]));
    ll ans = mod(div_mod(mul_mod(sum, sum) - s2, 2));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4780
using System;

namespace ITP1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else if (a == b)
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

Measured memory_bytes: 8944
// スマホコーディング
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
int main(){

int n,h,w;
int ans = 0;
cin >> n >> h >> w;
FOR(i,0,n){
 int a,b;
 cin >> a >> b;
if(h<=a&&w<=b)ans++;
}
cout << ans << endl;

}


Measured memory_bytes: 256