akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    string s;
    cin>>s;
    int n = s.size();

    vector<ll>a(n+1,0);
    for(int i=0;i<n;)
    {
        int j = i;
        if( s[i] == '<' )
        {
            while( s[j] == '<' )
            {
                a[j+1] = max(a[j+1], a[j] + 1);
                j++;
            }
            i = j;
        }
        else
            i++;
    }

    for(int i=n-1;i>=0;)
    {
        int j = i;
        if( s[i] == '>' )
        {
            while( s[j] == '>' )
            {
                a[j] = max(a[j], a[j+1] + 1);
                j--;
            }
            i = j;
        }
        else
            i--;
    }

    ll ans = 0;
    for(int i=0;i<n+1;i++)
    {
        ans += a[i];
    }
    cout<<ans,nl;

    return 0;
}

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

int main(int argc, char const *argv[]){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> point(n,k-q);

    for (int i = 0; i < q; i++)
    {
        int ans;
        cin >> ans;
        point[ans-1] += 1;
    }
    
    for (int i = 0; i < n; i++)
    {
        if (point[i] > 0) {
            cout << "Yes" << endl;
        }
        else   {
            cout << "No" << endl; 
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void){
	int t,i,h,b,a;

while(scanf("%d %d",&a,&b)!=EOF){
	h=a+b;
	for(t=0;h!=0;t++){
		h=h/10;
	}
	printf("%d\n",t);
}




return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
hlst = list(map(int, input().split()))
lst = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lst[a].append(hlst[b])
    lst[b].append(hlst[a])
i = 0
for _ in range(n):
  if sum([o for o in lst[_] if o >= hlst[_]]) == 0:
    i += 1
print(i)

Measured memory_bytes: 23460
#include <iostream>
using namespace std;
int main(void){
    long long N,M,i,j,x;
    string S;
    cin>>N>>M>>S;
    x=N;
    long long a[N];
    j=0;
    while(x>0){
        for(i=M;i>0;i--){
            if(x-i<0){
                i=x;
            }
            if(S[x-i]=='0'){
                a[j]=i;
                j++;
                x-=i;
                break;
            }
        }
        if(i==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    j--;
    cout<<a[j];
    while(j>0){
        j--;
        cout<<" "<<a[j];
    }
    cout<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long cum [ 100001];

int main(){
        int n , m ,time ; 
        cin>>n>>m>>time ; 
        int a[n],b[m];
        for(int i =0;i<n;i++)cin>>a[i];
        for(int i =0;i<m;i++)cin>>b[i];
        vector<long long> v ; 
        long long sum = 0 , Max=0 ; 
        for(int i =0;i<m;i++){
                sum+=b[i];
                if(sum<=time)Max=i +1; 
                v.push_back(sum);
        }
       
      sum=0; 
        for(int i =0;i<n;i++){
                sum+=a[i];
                if( time-sum < 0 ){ 
                        if(Max<i)Max=i ;
                        break ;
                        
                } 
                int l=0,r=m-1 ;
                while(l<=r){
                        int mid =r+l ;
                        mid /=2;
                        if(v[mid]<=time-sum)l=mid+1;
                        else r=mid-1; 
                        
                }if(i+l+1>Max)Max=i+l+1 ; 
        }cout<<Max ; }
        
       
        
        
        


Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,count=0;
  string S1,S2,S3;
  char c;
  cin >> S1 >> S2 >> S3;
  cout << S1.at(0) << S2.at(0) << S3.at(0) <<endl;
}

Measured memory_bytes: 256
package main

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func main() {
	// 入力
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
	}
	// DP, dp[0], dp[1]は手計算
	dp := make([]int, n+1)
	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		// 2個前から飛んでくる場合と1個前から飛んでくる場合のコストを比較して小さい方を取る。
		dp[i] = min(abs(h[i]-h[i-2])+dp[i-2], abs(h[i]-h[i-1])+dp[i-1])
	}
	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
// 提出時はMainに変更
object Main extends App {
  val i = {
    val s = new java.util.Scanner(System.in)
    s.next.toList.map(_.asDigit)
  }

  val c1 = i.zipWithIndex.count(n => (n._2 % 2 == 0 && n._1 == 0) || (n._2 % 2 == 1 && n._1 == 1))
  val c2 = i.zipWithIndex.count(n => (n._2 % 2 == 0 && n._1 == 1) || (n._2 % 2 == 1 && n._1 == 0))
  val result = i.length - Seq(c1, c2).max

  println(result)
}


Measured memory_bytes: 65616
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    ax, ay, bx, by, cx, cy, dx, dy = map(float, s.split())

    AB = (bx - ax, by - ay)
    CD = (dx - cx, dy - cy)

    cross = AB[0] * CD[0] + AB[1] * CD[1]

    epsilon = 1e-10
    if abs(cross) < epsilon:
        print('YES')
    else:
        print('NO')

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

using namespace std;

int main(){
	int h,m,s1,s2;
	cin >> s1;
	h=s1/3600;
	m=(s1-h*3600)/60;
	s2=(s1-h*3600)-60*m;
	cout << h << ":" << m << ":" << s2 << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
using namespace std;

int main(){
    int n;
    cin >> n;
    char s[n];
    int r = 0, b = 0;
    scanf("%s", s);
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r++;
        else b++;
    }
    if(r > b ) cout << "Yes\n";
    else cout << "No\n";

    return 0;    
}

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

int main(){
    int n,m;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    rep(i,m){
        string s;
        cin>>s;
        mp[s]--;
    }
    int mx=0;
    for(auto p:mp)mx=max(mx,p.second);
    cout<<mx<<endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split(' '))
H = [int(input()) for _ in range(N)]

import math
def enough(n):
    rest = [h - B * n * 1.0 for h in H]
    m = sum([ math.ceil(r/(A-B)) for r in rest if r > 0])
    return m <= n

l, r = 0, 10**9

while r - l > 1:
    mid = (l + r) // 2
    if enough(mid):
        r = mid

    else:
        l = mid

    # print(l, r, mid)

print(r)


Measured memory_bytes: 131204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
	
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		//*
		//new Main().test();
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		//System.out.println(l2-l);
		/*/
		new Main().test();
		//*/
	}
	
	public void test() {
	}
	
	long[] Combi_n_2_Array = new long[200001];
	int[] charCountArray = new int[26];
	
	public void exec() throws IOException {
		SimpleInputUtil in = new SimpleInputUtil();
		PrintWriter out = new PrintWriter(System.out);
		initPattern();
		String A = in.br.readLine();
		int lenA = A.length();
		countCharacter(A);
		long patternNum = Combi_n_2_Array[lenA] + 1;
		for(int i=0; i<26; i++){
			patternNum -= Combi_n_2_Array[charCountArray[i]];
		}
		out.println(patternNum);
		out.flush();
	}
	
	private void initPattern() {
		Combi_n_2_Array[1]=0;
		Combi_n_2_Array[2]=1;
		for(int i=3; i<Combi_n_2_Array.length; i++) {
			Combi_n_2_Array[i] = Combi_n_2_Array[i-1]+i-1;
		}
	}
	
	private void countCharacter(String A) {
		for(char c: A.toCharArray()){
			charCountArray[c-'a'] ++;
		}
	}
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
    public int nextInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    
    public int[] nextInt(int[] a, int num) throws NumberFormatException, IOException{
        int i=0;
        while(i<num) {
            for(String s: br.readLine().split(" ")){
            	if(i<num) {
                    a[i++] = Integer.parseInt(s);
            	}
            }
        }
        return a;
    }
}

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

int main() {
  int N;
  cin >> N;
  int order4, order3, order2, order1;
  order4 = N /1000;
  order3 = (N / 100) % 10;
  order2 = (N / 10) % 10;
  order1 = N % 10;
  
  if (order2 == order3) {
    if (order2 == order1 || order2 == order4) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5, maxl = (int) 1e6 + 5;
char tmp[maxl];
int n;
string s[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", tmp);
    s[i] = tmp;
    reverse(s[i].begin(), s[i].end());
  }
  return true;
}

const int sigma = 26;
int go[maxl][sigma];
int cnt[maxl][sigma];
int p[maxl];
int vs;

int newNode(int par) {
  for (int i = 0; i < sigma; ++i) {
    go[vs][i] = -1;
    cnt[vs][i] = 0;
  }
  p[vs] = par;
  return vs++;
}

int a[sigma];

void add(const string &s) {
  int v = 0;
  for (int i = 0; i < sz(s); ++i) {
    int c = s[i] - 'a';
    if (go[v][c] == -1) {
      go[v][c] = newNode(v);
    }
    v = go[v][c];
  }
  for (int i = 0; i < sigma; ++i) {
    a[i] = 0;
  }
  for (int i = sz(s) - 1; i >= 0; --i) {
    v = p[v];
    int c = s[i] - 'a';
    a[c] = 1;
    for (int cc = 0; cc < sigma; ++cc) {
      cnt[v][cc] += a[cc];
    }
  }
}

int get(const string &s) {
  int v = 0;
  for (int i = 0; i < sz(s) - 1; ++i) {
    int c = s[i] - 'a';
    v = go[v][c];
  }
  int c = s[sz(s) - 1] - 'a';
  return cnt[v][c];
}

void solve() {
  vs = 0;
  newNode(-1);
  for (int i = 0; i < n; ++i) {
    add(s[i]);
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res += get(s[i]);
  }
  res -= n;
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 217708
// Problem Code: abc177_e

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string coprime(int N, vector<int>& A) {
	int g = A[0], mx = *max_element(A.begin(), A.end());
	vector<bool> is_factor(mx);
	
	// gcd of all the elements
	for (int& x: A)
		g = __gcd(x, g);
	if (g > 1)
		return "not coprime";
	
	// check for pairwise coprime
	for (int x: A) {
		for (int y = 2; y * y <= x; y++)
			if (x % y == 0) {
				if (is_factor[y])
					return "setwise coprime";
				while (x % y == 0)
					x /= y;
				is_factor[y] = true;
			}
		if (x > 1) {
			if (is_factor[x])
				return "setwise coprime";
			is_factor[x] = true;
		}
	}
	
	return "pairwise coprime";
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << coprime(N, A);
	return 0;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

const int mod = 1000000007;

int main(int argc, char* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<vector<ll>> x(h, vector<ll>(w, 1));

  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '#') x[i][j] = 0;
    }
  }

  rep(i, h) rep(j, w) {
    if (x[i][j] == 0) continue;
    if (i == 0 && j == 0) {
      continue;
    } else if (i == 0) {
      x[i][j] = x[i][j-1];
    } else if (j == 0) {
      x[i][j] = x[i-1][j];
    } else {
      x[i][j] = (x[i-1][j] + x[i][j-1]) % mod;
    }
  }

  cout << x[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	ll n, q, k;
	cin >> n >> k >> q;
	vector<int> aa(n, 0);
	vector<int> ter(n, q-k + 1); //耐えないといけない回数
	rep(i, min(k, q)) {
		int x;
		cin >> x;
		aa[x - 1]++;
	}
	rep(i, q - k) {
		int yy; cin >> yy;
		ter[yy - 1]--;
	}
	rep(i, n) {
		if (aa[i] >= ter[i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 4012
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

int cost[3005][3005];

bool Compare(pii a, pii b)
{
   return cost[a.ff][a.ss] < cost[b.ff][b.ss];
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[j]=1;
		}
	}
}

// https://codeforces.com/blog/entry/79048



void solve(){
	int h,w,m;  cin>>h>>w>>m;
	mpi x,y;
	mpii ss;
	int a[m][2];
	f(i,0,m){
		cin>>a[i][0]>>a[i][1];
		x[a[i][0]]++; y[a[i][1]]++;
		ss[{a[i][0],a[i][1]}]++;
	}
	int mx,my;
	int cx=-1,cy=-1;
	for(auto it : x){
		if(it.ss>cx){
			cx=it.ss;
			mx=it.ff;
		}
	}
	for(auto it : y){
		if(it.ss>cy){
			cy=it.ss;
			my=it.ff;
		}
	}
	vi d,dd; 
	for(auto it : y)
		if(it.ss==cy) d.pb(it.ff);
	for(auto it : x)
		if(it.ss==cx) dd.pb(it.ff);
	int cnt=0;
	for(auto it : d){
		int th=x[mx] + y[it] - 	ss[{mx,it}]++;
		cnt=max(cnt,th);
	}
	for(auto it : dd){
		int th=x[it] + y[my] - 	ss[{it,my}]++;
		cnt=max(cnt,th);
	}
	cout<<cnt;
}

void D(){
	int h,w; cin>>h>>w;
	int ch,cw; cin>>ch>>cw; --ch; --cw;
	int dh,dw; cin>>dh>>dw; --dh; --dw;
	string s[h]; f(i,0,h) cin>>s[i];
	if(s[ch][cw]=='#') {
		cout<<"-1\n";
		return ;
	}
	int cost[h][w]; f(i,0,h) f(j,0,w) cost[i][j]=INT_MAX;
	cost[ch][cw]=0;
	priority_queue<pii, vector<pii>, function<bool(pii, pii)>> p(Compare);
	p.push({ch,cw});
	while(!p.empty()){
		pii tp=p.top(); p.pop();
		f(i,-2,3) {
			f(j,-2,3){
				int cx=tp.ff+i,cy;
			}
		}	
	}
	if(cost[dh][dw]==INT_MAX)	cost[dh][dw]=-1;
	cout<<cost[dh][dw];
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int Ans=0;
  int n1, n2, n3, n4, n5;
  for(int i=1; i<=N; i++){
    n1=i/10000;
    n2=i/1000-10*n1;
    n3=i/100-10*n2-100*n1;
    n4=i/10-10*n3-100*n2-1000*n1;
    n5=i-10*n4-100*n3-1000*n2-10000*n1;
    if(A<=n1+n2+n3+n4+n5 && n1+n2+n3+n4+n5<=B){
      Ans+=i;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef unsigned long long ull;

int	main(void)
{
  	ull	a;
  	char    b[5];
  	char    c[4];
  	ull bb;
  	ull r;

  	scanf("%llu %s", &a, b);
  
    c[0] = b[0];
    c[1] = b[2];
    c[2] = b[3];
    c[3] = '\0';
    bb = (ull)atoi(c);
/*  	bb = (ull)(b * 100.0);
*/  	
    if (a % 100ULL == 0ULL)
    {
        r = a / 100ULL * bb;
    }
    else if (a % 10ULL == 0ULL)
    {
        r = a / 10ULL * bb / 10ULL;
    }
    else
    {
      	r = a * bb / 100ULL;
    }
 
  	printf("%llu", r);
  	return (0);
}

Measured memory_bytes: 1736
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    h=LI()
    
    h.sort()
    
    if K>=N:
        print(0)
        exit()
        
    for i in range(K):
        h[-1-i]=0
        
    ans=sum(h)
    print(ans)

main()


Measured memory_bytes: 103480
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    int num[101];
    for (int i = 0; i < n-1; i++) 
        cin >> num[i];
    int dest;
    cin >> dest;

    long long a[21][101] = {};
    a[num[0]][0] = 1;
    for (int i = 1; i < n-1; i++) 
        for (int j = 0; j < 21; j++) 
            a[j][i] += ((j + num[i] < 21) ? a[j + num[i]][i-1] : 0) + ((j - num[i] >= 0) ? a[j - num[i]][i-1] : 0);
    cout << a[dest][n-1-1] << endl;

    return 0;
}

Measured memory_bytes: 1180
from queue import Queue
s = input()

prev = ""
ls = []
part = ""
for c in s:
    if prev == 'L' and c == "R":
        ls.append(part)
        part = c
    else:
        part += c
    prev = c
ls.append(part)


num_ls = Queue()
for block in ls:
    len_block = len(block)
    if len_block % 2 == 0:
        num_ls.put((len_block//2, len_block//2))
    else:
        if block.index("L") % 2 == 1:
            num_ls.put((-(-len_block//2), len_block//2))
        else:
            num_ls.put((len_block//2, -(-len_block//2)))

ans = [0]*len(s)

prev = ""
for i, c in enumerate(s):
    if prev == "R" and c == "L":
        left, right = num_ls.get()
        ans[i-1] = left
        ans[i] = right
    prev = c

print(*ans)


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

alist = []
blist = []
for _ in range(N):
    a, b = map(int, input().split())
    alist.append((b, a))

for _ in range(N):
    c, d = map(int, input().split())
    blist.append((c, d))

alist.sort(reverse=True)
blist.sort()

ans = 0
for i in range(N):
    for j in range(len(alist)):
        if blist[i][0] > alist[j][1] and blist[i][1] > alist[j][0]:
            ans += 1
            alist = alist[:j] + alist[j+1:]
            break

print(ans)


Measured memory_bytes: 38768
#include <stdio.h>
#include <math.h>



 

    
    int main()
    {
        
        int n = 0,k = 0;
        
        scanf("%d %d",&n,&k);
        
        if(n%k != 0)
        {
            printf("1\n");
            
        }
        
        else if (n%k == 0)
        {
            printf("0\n");
        }
        
        return 0;
        
    }
    
    


Measured memory_bytes: 128
#include <iostream>
//#include <bits/stdc++.h>
// a&1 check odd or not and a>>=1 halfs a
// (n-1-i)%i previous in circle (i+n-1)%n next one
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long n;
	cin>>n;
	cout<<n*(n+1)/2<<endl;


	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

int p[N];
int d[N];

void init(void) {
	f(i, N) {
		p[i] = i;
		d[i] = 1;
	}
	return;
}

int pa(int x) {
	if (p[x] == x)return x;
	else return p[x] = pa(p[x]);
}


void uni(int x, int y) {
	int px = pa(x);
	int py = pa(y);
	if (px == py)return;
	if (d[px] < d[py]) {
		p[px] = py;
		d[py] = max(d[py], d[px] + 1);
	}
	else {
		p[py] = px;
		d[px] = max(d[px], d[py] + 1);
	}
	return;
}

bool jud(int x, int y) {
	int px = pa(x);
	int py = pa(y);
	if (px == py)return true;
	else return false;
}

int main(void){
	int n, q;
	long long m;
	long long nn;
	long long ccc;
	long long xxx, yyy;
	int xx[N];
	int yy[N];
	int k = 0;
	int kk;
	int x, y, z;
	int cc;
	scanf("%d %lld %d", &n, &m, &q);
	init();
	f(qq, q) {
		scanf("%d %d %d", &x, &y, &z);
		if (z == 0) {
			uni(x, y);
		}
		else {
			xx[k] = x;
			yy[k] = y;
			k++;
		}
	}
	f(i, n) {
		x = pa(i);
		if (x == i)cc++;
	}
	if ((cc <= 2) && (k > 0)) {
		printf("No\n");
		return 0;
	}
	f(i, k) {
		x = pa(xx[i]);
		y = pa(yy[i]);
		if (x == y) {
			printf("No\n");
			return 0;
		}
	}
	nn = (long long)n;
	ccc = (long long)cc;
	if (k == 0) {
		xxx = nn - 1;
		yyy = (ccc - 1)*ccc;
		yyy = yyy / 2;
		yyy += (nn - ccc);
		if ((m < xxx) || (yyy < m)) {
			printf("No\n");
			return 0;
		}
	}
	else {
		xxx = nn;
		yyy = (ccc - 1)*ccc;
		yyy = yyy / 2;
		yyy += (nn - ccc);
		if ((m < xxx) || (yyy < m)) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;++i)cin>>p[i],q[i]=i;
  sort(q.begin(),q.end(),[&](int a,int b){return p[a]>p[b];});
  set<int,less<>> s;
  set<int,greater<>> t;
  s.insert(-1);s.insert(n);
  t.insert(-1);t.insert(n);
  for(auto i:q){
    auto r1=s.lower_bound(i);
    auto r2=(*r1==n?r1:s.upper_bound(*r1));
    auto l1=t.lower_bound(i);
    auto l2=(*l1==-1?l1:t.upper_bound(*l1));
    r+=((*r2-*r1)*(i-*l1) + (*r1-i)*(*l1-*l2))*p[i];
    s.insert(i);
    t.insert(i);
  }
  cout<<r;
}

Measured memory_bytes: 11136
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main {
    public static void main(String args[]) {
		 Scanner sc = new Scanner(System.in);
		 int s = sc.nextInt();
		 int total = 0;
		 total += s/500 * 1000;
		 s %= 500;
		 total += s/5 *5;
		 System.out.println(total);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};

int H,W;
char c[50][50];
map<vector<pair<int,int> >,int> dp[50][50][4];
int dfs(int x,int y,int k,vector<pair<int,int> > vis){
	if( k < 0 ) return -1e9;
	vector< pair<int,int> > p;
	for(int i = 0 ; i < vis.size() ; i++){
		if( max(0,x-vis[i].first)+max(0,y-vis[i].second) <= k )
			p.push_back(vis[i]);
	}
	sort(p.begin(),p.end());
	vis = p;
	if( dp[x][y][k].count(vis) ) return dp[x][y][k][vis];
	
	int ans = ( x==W-1&&y==H-1 ? 0 : -1e9 );
	for(int i = 0 ;i < 4 ; i++){
		int tx = x + dx[i];
		int ty = y + dy[i];
		if( tx < 0 || tx >= W || ty < 0 || ty >= H || c[ty][tx] == '#') continue;
		int cst = 0;
		vector<pair<int,int> > t = vis;
		if( !binary_search(vis.begin(),vis.end(),make_pair(tx,ty)) ){
			cst = c[ty][tx] - '0';
			t.push_back(make_pair(tx,ty));
		}
		ans = max( ans , dfs(tx,ty,k-(i<2),t)+cst );
	}
	//cout << x << " " << y << " " << k << " " << vis.size() << endl;
	return dp[x][y][k][vis] = ans;
}
int main(){
	int K;
	cin >> H >> W >> K;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			cin >> c[i][j];
			if( c[i][j] == '.' ) c[i][j] = '0';
		}
	}
	cout << dfs(0,0,K,vector<pair<int,int> >(0)) << endl;
}

Measured memory_bytes: 43100
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define S ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std; 
signed main()
{
    S;
    char x;
    cin>>x;
    if(x>='A' && x<='Z')
    cout<<"A";
    else cout<<"a";
}
    

Measured memory_bytes: 3604
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n / 10 % 111 == 0 || n % 1000 % 111 == 0)cout << "Yes";
	else cout << "No";

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 998244353;
int n, sz, G, R, B, GR, RB, BG;
ll ans = 1;
char s[300005];
int main(){
	scanf("%d\n%s", &n, s);
	sz = (int)strlen(s);
	rep(i,n) (ans *= (i+1)) %= MD;
	rep(i,sz){
		if(s[i] == 'R'){
			if(BG) ans = ans * BG-- % MD;
			else if(B){
				ans = ans * B-- % MD;
				RB++;
			}else if(G){
				ans = ans * G-- % MD;
				GR++;
			}else R++;
		}else if(s[i] == 'G'){
			if(RB) ans = ans * RB-- % MD;
			else if(R){
				ans = ans * R-- % MD;
				GR++;
			}else if(B){
				ans = ans * B-- % MD;
				BG++;
			}else G++;
		}else{
			if(GR) ans = ans * GR-- % MD;
			else if(G){
				ans = ans * G-- % MD;
				BG++;
			}else  if(R){
				ans = ans * R-- % MD;
				RB++;
			} else B++;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 512
n,m=map(int,input().split())
l=list(map(int,input().split()))

if n>=m:
  print(0)
else:
  num=n-1
  sl=sorted(l)

  dsl=[abs(sl[i+1]-sl[i]) for i in range(m-1)]

  dsl=sorted(dsl)
  print(sum(dsl[0:len(dsl)-num]))


Measured memory_bytes: 20500
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pis =  pair<int,string>;

bool comp(const pis &a,const pis &b){
    if(a.first > b.first) return true;
    return false;
}

int main(){
    int n;
    map<string,int> mp;
    string s;
    cin >> n;
    rep(i,n){
        cin >> s;
        mp[s]++;
    }

    vector<pair<int,string> > vec;
    vector<string> vec2;
    
    for(auto e: mp){
        vec.push_back(make_pair(e.second,e.first));
    }
    sort(vec.begin(),vec.end(),comp);
    
    // for(auto e: vec){
    //     cout << e.first << " " << e.second << endl;
    // }

    int cnt = vec[0].first;
    vec2.push_back(vec[0].second);
//    cout << "  " << len << endl;
    
    for(int i = 1; i < vec.size(); i++){
        
        if(cnt == vec[i].first ){
            vec2.push_back(vec[i].second);
        }else{
            break;
        }
    }

    sort(vec2.begin(),vec2.end());
    for(auto e: vec2){
        cout << e << endl;
    }

    return 0;
}

Measured memory_bytes: 32624
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        if(a<105)
            printf("0\n");
        else if(a==105)
            printf("1\n");
        else
        {
            int con=1;
            for(int c=106; c<=a; c++)
            {
                if(c%2==1)
                {
                    int sum=0;
                    for(int i=1; i<sqrt(c); i++)
                    {
                        if(c%i==0)
                            sum++;
                    }
                    if(sum==4)
                        con++;
                }
            }
            printf("%d\n",con);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>

using namespace std;

int main() {
  string str;
  cin >> str;
  int max,len;
  max = 0;
  len = 0;

//   cout << (int)(S.length()) << endl;
  for(int i=0; i<(int)(str.length()); i++){
      char ch = str[i];
      if (ch =='A' || ch =='T' || ch =='C' || ch =='G'){
          len++;
      }else{
          len=0;
      }
      
      if(len > max){
          max = len;
      }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner (System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		if(K > (N-1)*(N-2)/2) {
			System.out.println(-1);
		}else {
			int p = (N-1)*(N-2)/2 - K;
			System.out.println(N-1+p);
			for(int i = 2;i <= N;i++) {
				System.out.println(1 + " " + i);
			}
			int count = 0;
			for(int i = 2;i < N;i++) {
				for(int j = 1+i; j <= N;j++) {
					if(count == p)break;
					System.out.println(i + " " + j);
					count++;
				}
			}
		}
	}

}


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


ll n,m,k;
ll ar[200007];
ll br[200007];

int main()
{


    ll i,j,l,cnt = 0,baki,ke;

    scanf("%lld %lld %lld",&n,&m,&k);

    for(i = 0 ; i < n; i++)
        cin >> ar[i];
    for(i = 0 ; i < m; i++)
        cin >> br[i];

    for(i = 1 ; i < n; i++)
        ar[i] += ar[i-1];
    for(i = 1 ; i < m; i++)
        br[i] += br[i-1];

    for(i = 0 ;  i < n ; i++)
    {
        baki = k - ar[i];
        if(baki < 0)
            break;
        ke = lower_bound(br,br+m,baki) - br;
        if(ke == m)
            continue;
        if(br[ke] > baki)
            ke--;
        cnt = max(cnt,i+1+ke+1);
    }

    for(i = 0 ;  i < m ; i++)
    {
        baki = k - br[i];
        if(baki < 0)
            break;
        ke = lower_bound(ar,ar+n,baki) - ar;
        if(ke == n)
            continue;
        if(ar[ke] > baki)
            ke--;
        cnt = max(cnt,i+1+ke+1);
    }

    printf("%lld\n",cnt);
    //cout << tt << " " << cal << endl;
}


Measured memory_bytes: 6932
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    string s;
    cin >> s;
    string ans;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ans = "Bad";
    else ans = "Good";
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3592
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,z,w = map(int, readline().split())
a = [w]+[*map(int, readline().split())]
n += 1

INF = 1<<30
dp0 = [-INF]*n
dp1 = [INF]*n

dp0[-1] = dp1[-1] = abs(a[-1]-a[-2])
for i in range(n-2,0,-1):
    dp0[i] = max(abs(a[-1]-a[i-1]),max(dp1[i+1:]))
    dp1[i] = min(abs(a[-1]-a[i-1]),min(dp0[i+1:]))

print(dp0[1])

#print(a)
#print(dp0)
#print(dp1)





Measured memory_bytes: 9344
def partition(A, p, r):
  x = A[r]
  i = p-1
  for j in range(p,r):
    if A[j] <= x:
      i = i+1
      A[i], A[j] = A[j], A[i]
  A[i+1],A[r] = A[r], A[i+1]
  return i+1

n = int(input())
A = list(map(int, input().split()))
mid = partition(A,0,n-1)
print(' '.join(map(str,A[:mid])),'['+str(A[mid])+']',' '.join(map(str,A[mid+1:])))


Measured memory_bytes: 16384
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
vi G[100005];
bool vs[100005];
int p[100005];
int n, m;
void dfs(int u, s_i& s1, s_i&s2)
{
	vs[u]=1;
	s1.insert(u);
	s2.insert(p[u]);
	for(auto v: G[u]) 
	{
		if(!vs[v]) dfs(v, s1, s2);
	}
}
void solve()
{
	int ans=0;
	for(int i=1; i<=n ;i++)
	{
		if(!vs[i]) 
		{
			s_i s1, s2;
			dfs(i, s1,s2);
			for(auto tmp: s1)
			{
				if(s2.count(tmp)) ans++;
			}
		}
	}
	cout<<ans;
}
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	cin>>n>>m;
	for(int i=1; i<=n; i++)
	{
		cin>>p[i];
	}
	for(int i=1; i<=m; i++)
	{
		int u, v;
		cin>>u>>v;
		G[u].eb(v);
		G[v].eb(u);
	}
	solve();
}




Measured memory_bytes: 19968
class UnionFind():
 def __init__(self,n):
   self.n=n
   self.root=[-1]*(n+1)
   self.rank=[0]*(n+1)
 def FindRoot(self,x):
   if self.root[x]<0:
     return x
   else:
     self.root[x]=self.FindRoot(self.root[x])
     return self.root[x]
 def Unite(self,x,y):
   x=self.FindRoot(x)
   y=self.FindRoot(y)
   if x==y:
     return
   else:
     if self.rank[x]>self.rank[y]:
       self.root[x]+=self.root[y]
       self.root[y]=x
     elif self.rank[x]<=self.rank[y]:
       self.root[y]+=self.root[x]
       self.root[x]=y
       if self.rank[x]==self.rank[y]:
         self.rank[y]+=1
 def isSameGroup(self,x,y):
   return self.FindRoot(x)==self.FindRoot(y)
 def Count(self,x):
   return -self.root[self.FindRoot(x)]
 
n,m,k=map(int,input().split())
t=UnionFind(n+1)
cnt=[0]*(n+1) #各iについて、iと同一の連結成分に属する友達関係の人、ブロック関係の人の数を数える
for _ in range(m):
 a,b=map(int,input().split())
 cnt[a]+=1 #各iについて、iと同一の連結成分に属する友達関係の人の数を数える
 cnt[b]+=1
 t.Unite(a,b)
for _ in range(k):
 a,b=map(int,input().split())
 if t.isSameGroup(a,b)==True:
   cnt[a]+=1 #各iについて、iと同一の連結成分に属するブロック関係の人の数を数える
   cnt[b]+=1
ans=[0]*(n+1)
for i in range(1,n+1):
 ans[i]=(t.Count(i)-1)-cnt[i] #答えは(各iが属する連結成分のサイズ)-1-((iと同一の連結成分に含まれているiと友達関係にある人の数)+(iと同一の連結成分に含まれているiとブロック関係にある人の数)となる
print(*ans[1:])


Measured memory_bytes: 11828
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define SF scanf
#define PF printf
#define MAXN 1000010
#define INF 0x3FFFFFFF
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll n,n1;
ll a[MAXN];
map<ll,ll> mp;
ll p(ll x){
    if(mp.count(x))
        return mp[x];
    if(x<=1000000)
        return a[x];
    if(x==1)
        return 1;
    if(x%2ll==1ll)
        mp[x]=(p(x/2ll)+p(x/2ll+1ll))%MOD;
    else
        mp[x]=p(x/2ll);
    return mp[x];
}
ll que(ll x){
    if(x==1)
        return 1;
    if(x%2ll==1ll)
        return (que(x/2ll)*3ll+p(x/2ll+1ll))%MOD;
    else
        return (que(x/2ll)*3ll-p(x/2ll)+MOD)%MOD;
}
void prepare(){
    a[1]=1;
    for(int i=1;i<=1000000;i++){
        if(i%2==1)
            a[i]=(a[i/2]+a[i/2+1])%MOD; 
        else
            a[i]=a[i/2];
    }
}   
int main(){
    prepare();
    SF("%lld",&n1);
    n1++;
    PF("%lld\n",que(n1));
}

Measured memory_bytes: 8064
N,Y = [int(i) for i in input().split()]
po = False
x,y,z = -1,-1,-1
for i in range(N+1):
    for j in range(N-i+1):
        if (Y - (i * 10000 + j * 5000)) / 1000 == N - i - j:
            x = i
            y = j
            z = int((Y - (i * 10000 + j * 5000)) / 1000)
            po = True
            break
    if po:
        break

print(x,y,z)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a != b && a != c) cout << a << endl;
  if (a == b && a != c) cout << c << endl;
  if (a != b && a == c) cout << b << endl;
  return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

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

    return 0;
}











Measured memory_bytes: 3652
#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;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007
#define brk cout<<"\n"

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

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

void add_self(ll &a, ll b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

const int mx = 3005;
char cmp[mx];
ll dp[mx][mx], pref[mx][mx];

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n; cin >> n;
	cin >> cmp;
	dp[1][1] = 1;
	for (ll len = 2; len <= n; len++) {
		for (ll i = 1; i <= len - 1; i++) {
			pref[len - 1][i] = (pref[len - 1][i - 1] + dp[len - 1][i]) % MOD;
		}
		for (ll curr = 1; curr <= len; curr++) {
			ll L, R;
			if (cmp[len - 2] == '<') {
				L = 1; R = curr - 1;
			}
			else {
				L = curr, R = len - 1;
			}
			if (L <= R) {
				add_self(dp[len][curr], (pref[len - 1][R] - pref[len - 1][L - 1] + MOD) % MOD);
			}
			// for (ll prev = 1; prev <= len - 1; prev++) {
			// 	ll real_prev = prev;
			// 	if (curr <= prev) real_prev++;
			// 	if ((real_prev < curr) != (cmp[len - 2] == '<')) continue;
			// 	add_self(dp[len][curr], dp[len - 1][prev]);
			// }
		}
	}
	// for (ll i = 0; i < n; i++) {
	// 	for (ll j = 0; j < n; j++) {
	// 		cout << dp[i + 1][j + 1] << " ";
	// 	}
	// 	brk;
	// }
	ll ans = 0;
	for (ll i = 1; i <= n; i++) add_self(ans, dp[n][i]);
	cout << ans; brk;

}

Measured memory_bytes: 139648
package main

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

func solve() {
	n := int(1e5) + 100
	x := getInt()
	ps := furui(n)

	var ans int
	for i, p := range ps {
		if x > i {
			continue
		}

		if p == 1 {
			ans = i
			break
		}
	}
	fmt.Fprintln(wr, ans)
}

func furui(n int) []int {
	ns := make([]int, n+1)
	for i := range ns {
		ns[i] = 1
	}
	ns[0], ns[1] = 0, 0

	for i := 2; i*i <= n; i++ {
		if ns[i] == 1 {
			for j := i * 2; j <= n; j += i {
				ns[j] = 0
			}
		}
	}
	return ns
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

int main() {
    int a,b,c;cin>>a>>b>>c;
    if(a+b>=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> sw(n, 0);
  int p = 0, ans = 0;
  rep(i, m) {
    int x;
    cin >> x;
    rep(j, x) {
      int y;
      cin >> y;
      y--;
      sw[y] |= (1 << i);
    }
  }

  rep(i, m) {
    int x;
    cin >> x;
    p |= (x << i);
  }

  rep(bit, 1 << n) {
    int tmp = 0;
    rep(i, n) {
      if ((bit >> i) & 1) tmp ^= sw[i];
    }
    if (tmp == p) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
class Tree():
    def __init__(self):
        self.nodes = {}
        self.root = None

    def add_node(self, key):
        if key not in self.nodes:
            self.nodes[key] = Node(key)

    def insert(self, z_key):
        self.add_node(z_key)
        z = self.nodes[z_key]
        y = None  # xの親
        x = self.root
        while x is not None:
            y = x  # 親を設定
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y

        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while x is not None:
            if key < x.key:
                x = x.left
            elif key > x.key:
                x = x.right
            else:
                print('yes')
                return
        print('no')
        return

    def __str__(self):
        ans_in, ans_pre = [], []
        self.root.in_walk(ans_in)
        self.root.pre_walk(ans_pre)
        str_in = ' ' + ' '.join(map(str, ans_in))
        str_pre = ' ' + ' '.join(map(str, ans_pre))
        return str_in + '\n' + str_pre


class Node():
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        self.parent = None

    def pre_walk(self, ans):
        ans.append(self.key)
        if self.left:
            self.left.pre_walk(ans)
        if self.right:
            self.right.pre_walk(ans)

    def in_walk(self, ans):
        if self.left:
            self.left.in_walk(ans)
        ans.append(self.key)
        if self.right:
            self.right.in_walk(ans)


# ここからmain
tree = Tree()
n = int(input())
for i in range(n):
    line = list(map(str, input().split()))
    if line[0] == 'insert':
        key = int(line[1])
        tree.insert(key)
    elif line[0] == 'find':
        key = int(line[1])
        tree.find(key)
    else:
        print(tree)



Measured memory_bytes: 145284
import java.util.*;

public class Main {
 public static void main(String... args) {
   List<String> weather = Arrays.asList("Sunny","Cloudy","Rainy","Sunny");
   Scanner scan = new Scanner(System.in);
   String S = scan.next();
   System.out.println(weather.get(weather.indexOf(S)+1));
 }
}

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

int main(){
	string S;
  cin>>S;
  int count=0;

  if(S.size()<4||S.at(0)!='A')
    cout<<"WA"<<endl;
  else{
  	for(int i=0;i<S.size()-3;i++){
      if(S.at(i+2)=='C')
        count++;
    }
    if(count!=1)
      cout<<"WA"<<endl;
    else{
    	count=0;
      for(int i=0;i<S.size();i++){
      	if((S.at(i)-'a')*(S.at(i)-'z')<=0)
          count++;
      }
        if(count==S.size()-2)
          cout<<"AC"<<endl;
        else
          cout<<"WA"<<endl;
      
    }
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    str s;
    cin >> s;
    
    if (s[s.size() - 1] == 's') {
        cout << s << "es" << endl;
    }
    else {
        cout << s << "s" << endl;
    }
}

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

#define int long long
const int INF = 1e15;

int N;
int cost[15][15];
int dp[15][1<<15];

int dfs(int n, int b) {
  if ( b == (1<<N)-1 ) return 0;
  if ( dp[n][b] >= 0 ) return dp[n][b];

  int ret = INF;
  for ( int i = 0; i < N; i++ ) {
    if ( b&(1<<i) ) continue;
    if ( cost[n][i] == 0 ) {
      ret = min(ret, dfs(n, b|(1<<i)));    
    } else {
      ret = min(ret, dfs(i, b|(1<<i))+cost[n][i]);    
    }
  }

  return dp[n][b] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while ( cin >> N, N ) {
    fill_n(*cost, 15*15, INF);
    fill_n(*dp, 15*(1<<15), -1);

    vector<string> S(N);
    for ( int i = 0; i < N; i++ ) cin >> S[i];

    for ( int i = 0; i < N; i++ ) {
      for ( int j = 0; j < N; j++ ) {
	cost[i][j] = S[j].size();	
	for ( int k = 0; k < (int)S[i].size(); k++ ) {
	  bool flag = true;
	  // cout << k << endl;
	  for ( int l = 0; l < min((int)S[i].size()-k, (int)S[j].size()); l++ ) {	    
	    if ( S[i][k+l] != S[j][l] ) {
	      flag = false;
	      break;
	    }
	  }
	  if ( flag ) {
	    cost[i][j] = max(0LL, (int)S[j].size()-((int)S[i].size()-k));
	    break;
	  }
	}	
      }      
    }    

    int ans = INF;
    for ( int i = 0; i < N; i++ ) {
      ans = min(ans, dfs(i, 1<<i)+(int)S[i].size());      
    }
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 7008
#include <bits/stdc++.h>
#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 INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll a[N];
  REP(i, N) { cin >> a[i]; }
  ll ans = 0;
  REP(i, N) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 384