akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# a, b = MAP()
# n = INT()
# a, b, c = MAP()
n = INT()
H = LIST()
R = [0]*n
for i in range(n-1):
    if H[i] >= H[i+1]:
        R[i+1] = R[i]+1
print(max(R))
        
    # while(1):

    # for j in range(n):


Measured memory_bytes: 16312
#include<bits/stdc++.h>
using namespace std;
bool c[10] = {};

bool check(int n){
  while(n != 0){
    if(c[n%10]) return false;
    n/=10;
  }
  return true;
}

int main(){
  int n, k, a;
  cin >> n >> k;
  for(int i=0;i<k;i++) {
    cin >> a;
    c[a] = true;
  }
  int ans = 0;
  for(int i=n;i<=99999;i++){
    if(check(i)){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;
		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");

				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				StringBuilder ans = new StringBuilder();

				for(int row = 0; row < H; row++){
					for(int col = 0; col < W; col++){
						if((row+col)%2 == 0){
							ans.append("#");
						}else{
							ans.append(".");
						}
					}
					ans.append("\n");
				}

				System.out.println(ans.toString());


			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}
}





Measured memory_bytes: 25856
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Measured memory_bytes: 22560
import fractions
gcd = fractions.gcd

A, B, C, D = map(int, input().split(" "))

CD =  C* D // gcd(C, D)
def calc(X):
    num_c = X // C
    num_d = X // D
    num_cd = X // CD
    ret = num_c + num_d - num_cd
    return ret

o1 = calc(B)
o2 = calc(A-1)
#print(o1, o2)
o = o1 - o2
out = B - A + 1 - o
print(out)

Measured memory_bytes: 5588
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	if((S.at(2) == S.at(3)) && (S.at(4) == S.at(5)))
	cout << "Yes" << endl;
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=1e5+1e1;
const int Mod=1e9+7;

lint dp[MAXN];

lint ans=0;
int n,k;

lint qpow(lint A,int B)
{

	lint res=1;

	while(B>0)
	{
		if(B&1) (res*=A)%=Mod;
		(A*=A)%=Mod;
		B>>=1;
	}

	return res;

}

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d%d",&n,&k);

	for(int i=k;i>=1;i--)
	{
		int num=k/i;
		dp[i]=qpow((lint)num,n);
		for(int res=i+i;res<=k;res+=i)
			(dp[i]+=(Mod-dp[res])%Mod)%=Mod;
		(ans+=(dp[i]*i)%Mod)%=Mod;
	}

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

	return 0;

}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int a;
  int b;
  cin >> a >> b;
  
  int num = b - a;
  int num2 = 0;
  int num3 = 0;
  
  int num4;
  
  while(true){
    num2++;
    num3 = num2 + num3;
    if(num2 == num){
      num4 = num3 - b;
      break;
    }
  }
  
  cout << num4 << endl;
    
  
}


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

template<typename T>
vector<T> eratosthenes(T n) {
	vector<T> ret;
	vector<bool> v;
	v.reserve(n + 1);
	for (T i = 0; i < n + 1; ++i)v.push_back(true);
	ret.push_back(2);
	for (T i = 2; i <= n; i += 2) v[i] = false;
	for (T i = 3; i <= n; ++i) {
		if (v[i]) {
			ret.push_back(i);
			for (T j = i; j <= n; j += i) v[j] = false;
		}
	}
	return ret;
}

int main() {
	ll n;
	cin >> n;
	auto v = eratosthenes<ll>(1e6);
	cout << *lower_bound(v.begin(), v.end(), n) << endl;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define ll long long
#define scan() ll n; cin>>n ; ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
int main()
{
	fast;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll dp[n+1][3];
	dp[n][0]=0;
	dp[n][1]=0;
	dp[n][2]=0;
	for(ll i=n-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			dp[i][0]=dp[i+1][0]+1;
			dp[i][1]=dp[i+1][1];
			dp[i][2]=dp[i+1][2];
		}
		else if(s[i]=='G')
		{
			dp[i][0]=dp[i+1][0];
			dp[i][1]=dp[i+1][1]+1;
			dp[i][2]=dp[i+1][2];
		}
		else
		{
			dp[i][0]=dp[i+1][0];
			dp[i][1]=dp[i+1][1];
			dp[i][2]=dp[i+1][2]+1;
		}
	}
	vi v[3];
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			v[0].pb(i);
		}
		else if(s[i]=='G')
			v[1].pb(i);
		else
			v[2].pb(i);
	}
	ll a=0,b=0,c=0,x=0,sum=0,count=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			//blueRBG
			for(ll j=0;j<v[2].size();j++)
			{
				x=v[2][j];
				if(x>i)
					sum+=dp[x][1];//add green
				if(s[2*x-i]=='G' && 2*x-i<n)
					count++;
			}
			

			//green
			for(ll j=0;j<v[1].size();j++)
			{
				x=v[1][j];
				if(x>i)
					sum+=dp[x][2];//add blue
				if(s[2*x-i]=='B' && 2*x-i<n)
				count++;
			}
		}
		else if(s[i]=='G')
		{
			// red
			for(ll j=0;j<v[0].size();j++)
			{
				x=v[0][j];
				if(x>i)
					sum+=dp[x][2];//add blue
				if(s[2*x-i]=='B' && 2*x-i<n)
					count++;
			}
			//blue
			for(ll j=0;j<v[2].size();j++)
			{
				x=v[2][j];
				if(x>i)
					sum+=dp[x][0];//add red
				if(s[2*x-i]=='R' && 2*x-i<n)
					count++;
			}
		}
		else
		{
			//red
			for(ll j=0;j<v[0].size();j++)
			{
				x=v[0][j];
				if(x>i)
					sum+=dp[x][1];//add green
				if(s[2*x-i]=='G' && 2*x-i<n)
					count++;
			}
			//green
			for(ll j=0;j<v[1].size();j++)
			{
				x=v[1][j];
				if(x>i)
					sum+=dp[x][0];//add red
				if(s[2*x-i]=='R' && 2*x-i<n)
				count++;
			}
		}
	}
	count=count/2;
	sum=sum-count;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3708
function Main(input) {
	const hands = input.split(" ").map(n => Number(n));
  const aliceHand = hands[0];
  const bobHand = hands[1];

  if(aliceHand === bobHand) {
    console.log('Draw');
  } else if(aliceHand === 1 && bobHand === 13) {
    console.log('Alice');
  } else if(aliceHand === 13 && bobHand === 1) {
    console.log('Bob');
  } else if(aliceHand > bobHand) {
    console.log('Alice');
  } else {
    console.log('Bob');
  }
}

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

Measured memory_bytes: 21064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int l;
  scanf("%d", &l);

  long double ans = powl((long double)l / 3.0, 3.0);
  printf("%10Lf\n", ans);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3

import itertools


def solve(money, dislike_numbers):
    for dm in itertools.count():
        pay = money + dm
        if set(map(int, str(pay))).isdisjoint(dislike_numbers):
            return pay


def main():
    money, _ = map(int, input().split())
    dislike_numbers = set(map(int, input().split()))
    print(solve(money, dislike_numbers))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  string ans;
  n = n % 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    ans = "hon";
  }else if(n == 0 || n == 1 || n == 6 || n == 8){
    ans = "pon";
  }else{
    ans = "bon";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

int main(void){
  string S,T;
  int A,B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  map<string, int> rb;
  rb[S] = A;
  rb[T] = B;
  
  rb[U]--;
  
  cout << rb[S] << " " << rb[T] << endl;;
  return 0;
}



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

int main(){
  long n,i,cur=0,ans=1000000;
  string s;

  cin >> n >> s;
  for(i=0; i<n; i++){
    if(s[i]=='.'){
      cur++;
     // t1[i]=cur;
    }
  }
  ans=min(ans,cur);
  for(i=0; i<n; i++){
    if(s[i]=='#'){
      cur++;
    }else{
      cur--;
    }
     ans=min(ans,cur);
  }
  /*
  cur=0;
  for(i=n-1; i>=0; i--){
    if(s[i]=='.'){
      cur++;
    }
    t1[i]+=cur;
    ans=min(ans,t1[i]);
  }
  
  for(i=0; i<n; i++){
    cout << t1[i] << ' ';
  }
  */
  cout << ans;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int b = 0;
	for (int i = 0; i < n; i++) {
		b ^= a[i];
	}

	for (int i = 0; i < n; i++) {
		cout <<( b ^ a[i]) << endl;
	}
}


Measured memory_bytes: 3960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

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

    static class DStringEquivalence {
        int n;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            dfs("", 'a');
        }

        void dfs(String res, char c) {
            if (res.length() == n) {
                System.out.println(res);
            } else {
                for (char i = 'a'; i <= c; i++) {
                    dfs(res + i, ((i == c) ? (char) (c + 1) : c));
                }
            }
        }

    }
}



Measured memory_bytes: 41620
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s1 = "keyence", s2; cin >> s2;

    for (int l = 0; l < s2.size(); l++) {
        for (int j = 0; j + l < s2.size(); j++) {
            string tmp = "";
            for (int i = 0; i < s2.size(); i++) {
                if (i >= j && i < j + l) continue;
                tmp += s2[i];
            }
            // cout << tmp << '\n';
            if (tmp == s1) {
                cout << "YES\n";
                return 0;
            }
        }
    }

    cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long K,A,B;
  cin>>K>>A>>B;
  if(K<=A)
    cout<<1<<endl;
  else if(A<=B)
    cout<<-1<<endl;
  else
    cout<<(K-B-1)/(A-B)*2+1<<endl;
}

Measured memory_bytes: 3600
/*input
3
7 6 8
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int meow[maxn];
int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	meow[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--){
		meow[i]=__gcd(meow[i+1],a[i]);
	}
	meow[n]=0;
	int ans=meow[1];
	int cur=0;
	for(int i=1;i<n;i++){
		cur=__gcd(cur,a[i-1]);
		ans=max(ans,__gcd(cur,meow[i+1]));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(2*n);
    rep(i,0,n){
        cin>>a[i];
        a[i+n] = a[i];
    }
    vector<int> v;
    rep(i,0,n){
        v.pb(a[i+1]^a[i]);
    }
    int x = 0;
    for ( int i = 0 ; i < v.size() ; i+=2 ){
        x ^= v[i];
    }
    rep(i,0,n){
        int y = (x^a[i]);
        cout<<y<<" ";
    }
    cout<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8448
use proconio::input;

fn main() {
    input!(a: [u64]);

    let ans = a
        .iter()
        .scan(0, |p, &a| {
            let ret = Some(a.max(*p) - a);
            *p = a.max(*p);
            ret
        })
        .sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[] f = new boolean[100001];
        int[] c = new int[100002];
        for (int i = 2; i <= 100000; i++) {
            if (!f[i]) {
                for (int j = i + i; j <= 100000; j += i) {
                    f[j] = true;
                }
            }
        }
        for (int i = 3; i <= 100000; i += 2) {
            if (!f[i] && !f[(i + 1) / 2]) {
                c[i]++;
            }
        }

        for (int i = 3; i <= 100000; i++) {
            c[i] += c[i - 1];
        }
        for(int k = 0; k < n; k++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println( c[r] - c[l-1]);
        }

    }
}


Measured memory_bytes: 62400
def submit():
    a, b = map(int, input().split())
    n = b - a + 1

    if a % 2:
        s = a
        a += 1
    else:
        s = 0

    if b % 2 == 0:
        r = b
        b -= 1
    else:
        r = 0
    p = (b - a + 1) // 2
    p %= 2
    print(s ^ r ^ p)


submit()

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int p, q, a;

int solve(int n, int d, int prod, int sum) {
  int cnt=0;
  for (int i=d; prod*i<=a; i++) {
    int left = p * (prod * i);
    int right = sum * i + prod;
    if (left < right * q) { continue; }
    if (left == right * q) { cnt++; continue; }
    if (n == 1) { continue; }
    cnt += solve(n-1, i, prod * i, right);
  }

  return cnt;
}

int main() {
  int n;
  while (cin >> p >> q >> a >> n, (p || q || a || n)) {
    cout << solve(n, 1, 1, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 868
p = -1
xp = -1
ans = 1
input()
for i in input().split(" "):
  i = int(i)
  if i == p: continue
  if p != -1:
    x = p < i
    if xp != -1:
      ans += x != xp
    if xp != -1 and x != xp:
      xp = -1
    else:
      xp = x
  p = i
print(ans)


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


int main()
{
    bool chk=true;
    int A;
    cin >> A;
    vector<int> S(A);
    for(int i=0; i<S.size(); i++)
    {
        cin >> S.at(i);
    }
    int count=0;
    for(int i=0; ; i++)
    {
        chk=true;
        for(int j=0; j<S.size(); j++)
        {
            if(S.at(j)%2==1)
            {
                chk=false;
            }
        }
        if(chk==false)
        {
            break;
        }
        for(int j=0; j<S.size(); j++)
        {
            S.at(j)/=2;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3556
import itertools

N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(Q)]
# print(abcd)
ans = 0
l = range(M)
c = list(itertools.combinations_with_replacement(l,N))
# print(c)

for i in range(len(c)):
    A = c[i]
    # print(A)
    ans_i = 0
    for j in range(Q):
        A_b = A[abcd[j][1]-1]
        A_a = A[abcd[j][0]-1]
        # print("A",A_b,A_a)

        c_i = A_b-A_a
        # print(j,c_i,abcd[j])
        if c_i == abcd[j][2]:
            # print("=========")
            ans_i += abcd[j][3]
    # print(ans_i,"++++++++")
    if ans_i > ans:
        ans = ans_i

print(ans)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K; cin >> N >> K;
	vll A(N); cin >> A;
	sort(begin(A), end(A));

	cout << accumulate(begin(A), begin(A) + K, 0ll) << endl;
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    cout << "2018" << date.substr(4, date.size() - 3) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPalindromePhilia solver = new BPalindromePhilia();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPalindromePhilia {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            char[] arr = sc.next().toCharArray();
            int ans = 0;
            for (int i = 0; i < arr.length / 2; i++) {
                if (arr[i] != arr[arr.length - 1 - i])
                    ans++;
            }
            pw.println(ans);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

    }
}



Measured memory_bytes: 23380
N = int(input())
numList = [list(map(int, input().split())) for _ in range(N)]

a,b,c = 0,1,2
dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(N):
    for j in range(3):
        beforeMax = max([n for index, n in enumerate(dp[i]) if index != j])
        dp[i + 1][j] = numList[i][j] + beforeMax

print(max(dp[N]))

Measured memory_bytes: 47364
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    string s; cin >> s;
    s[k-1] -= 'A'-'a';
    cout << s << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n, m, cnt[31] = {0};
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		int k, tmp = 0;
		cin >> k;
		for (int j = 1; j <= k; ++j) {
			cin >> tmp;
			cnt[tmp]++;
		}
	}
	int res = 0;
	for (int i = 1; i <= m; ++i)
		res += cnt[i] / n;
	cout << res;	
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  map<P, int> mp;
  rep(i, n) {
    string s;
    int p;
    cin >> s >> p;
    P pr = make_pair(s, -p);
    mp[pr] = i + 1;
  }
  for(auto x : mp) cout << x.second << endl;
  return 0;
}

Measured memory_bytes: 256
ONE_KETA = 10

def main():
	K = int(input())

	# 入力値が一桁
	if(K < ONE_KETA):
		print(K)
		return

	# それ以外
	# キューを作る
	queue_list = [i for i in range(1, ONE_KETA)]
	K -= len(queue_list)

	# 2桁目以降
	while(K > 0):
		# キューを取り出す
		val = queue_list.pop(0)

		# 一桁の値を取り出す
		tmp_s_num = val % ONE_KETA

		for i in range(-1, 2):
			# 末尾9、+1の時は飛ばす
			if(tmp_s_num == 9 and i == 1):
				continue
			elif(tmp_s_num == 0 and i == -1):
				continue
			else:
				# 10倍 + 元の値 + (-1,0,+1)
				tmp_val = val * 10 + tmp_s_num + i
				if(K > 0):
					queue_list.append(tmp_val)
					K -= 1

	# 最後の値が答え
	print(queue_list.pop())
	return

if __name__ == "__main__":
	main()

Measured memory_bytes: 5888
#include <iostream>
#include <set>
#include <utility>

using namespace std;
typedef pair<int, int> P;

int h, w, n;
int x[200005], y[200005];
set<P> S, T;

int main(void)
{
	cin >> h >> w >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	for(int i = 1; i <= n; i++) S.insert(make_pair(x[i], y[i]));
	for(auto it = S.begin(); it != S.end(); it++){
		if(S.count(make_pair(it->first-1, it->second)) == 0){
			if(it->first > 1) T.insert(make_pair(it->first-1, it->second));
		}
	}
	for(int i = 1; i <= min(h, w); i++) S.insert(make_pair(min(i,h), min(w+1,i+1)));
	
	int len = 0;
	for(int i = 1; i <= h-1; i++){
		len++;
		while(S.size() && S.begin()->first == i){
			len = min(len, S.begin()->second-1);
			S.erase(S.begin());
		}
		while(T.size() && T.begin()->first == i){
			if(T.begin()->second <= len){
				cout << i << endl;
				return 0;
			}
			T.erase(T.begin());
		}
	}
	cout << h << endl;
	return 0;
}

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

#define sid 15
#define ri register int
int n, k, D[sid];

int main() {
    int x, flag;
    cin >> n >> k;
    for(ri i = 1; i <= k; i ++) { cin >> x; D[x] = 1; }
    
    for(ri i = n; i; i ++) {
        x = i; flag = 0;
        while(x) { 
            if(D[x % 10]) { flag = 1; break; }
            x /= 10;
        }
        if(!flag) 
        { printf("%d\n", i); break; }
    }
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 62;
typedef pair<int, int> P;
const long long mod = 1000000007;
int kj[200006], kji[200006];

int modpow(int a, int x, int mod) {
	if (!x)return 1;
	int res = modpow(a*a%mod, x / 2, mod);
	if (x & 1)res = res*a%mod;
	return res;
}

void setkj(int n) {
	kj[0] = 1;
	rep(i, n)kj[i + 1] = kj[i] * (i + 1)%mod;
	rep(i, n + 1)kji[i] = modpow(kj[i], mod - 2, mod);
}
int comb(int r, int c) {
	int ans = kj[r] * kji[c] % mod;
	ans = ans*kji[r - c] % mod;
	return ans;
}

signed main() {
	int n, a, b, c; cin >> n >> a >> b >> c;
	setkj(200004);
	int ans = 0;
	int half = modpow(2, mod - 2, mod);
	rep(i, n) {
	//A...i B...n
		int p1 = a*modpow(a + b, mod - 2, mod)%mod;
		int p2 = b*modpow(a + b, mod - 2, mod)%mod;
		int cnt = modpow(p1, i, mod)*modpow(p2, n, mod) % mod;
		cnt = cnt*comb(n + i-1, i) % mod;
		cnt = cnt*(i + n) % mod;
		ans = (ans + cnt) % mod;

		cnt = modpow(p1, n, mod)*modpow(p2, i, mod) % mod;
		cnt = cnt*comb(n + i-1, i) % mod;
		cnt = cnt*(i + n) % mod;
		ans = (ans + cnt) % mod;
	}
	int p3 = 100 * modpow(100-c, mod - 2, mod) % mod;
	
	cout << ans*p3%mod<< endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll n,k,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;

    for(int i=k+1;i<=n;i++){
        ll b,x,y,z,temp,more;
        b = i;
        x = (n-k)/b;
        y = b-k;
        temp = (x)*y;
        more = y-1;
        z = k + b*x;
        if(z+more<=n){temp+=more+1;}
        else temp+= (n-z+1);

        ans+=temp;
    }
    if(k==0)ans = n*n;
    cout<<ans<<newl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=4010,p=924844033;
int n,k,tt=0,col[N],fac[N],f[N][N][4],ans=0;
int main(){
    scanf("%d%d",&n,&k);
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*1ll*i%p;
    for(int i=1;i<=n;i++)f[i][0][0]=1;
    for(int i=1;i<=k;i++){
        for(int j=i;j<=n;j+=k)col[++tt]=1;
        col[tt]=0;
    }
    //for(int i=1;i<tt;i++)cout<<col[i]<<" ";cout<<endl;
    for(int i=2;i<=n;i++)
        for(int j=1;j<=2*i;j++)
        {
            if(col[i-1]){
                f[i][j][0]=(1ll*f[i-1][j][0]+f[i-1][j][1]+f[i-1][j][2]+f[i-1][j][3])%p,
                f[i][j][1]=(f[i-1][j-1][0]+f[i-1][j-1][1])%p,f[i][j][2]=(f[i-1][j-1][0]+f[i-1][j-1][2])%p;
                if(j>=2)f[i][j][3]=f[i-1][j-2][0]%p;
            }
            else f[i][j][0]=(1ll*f[i-1][j][0]+f[i-1][j][1]+f[i-1][j][2]+f[i-1][j][3])%p,
            f[i][j][1]=f[i][j][2]=f[i][j][3]=0;
            //cout<<i<<" "<<j<<" "<<f[i][j][0]<<" "<<f[i][j][1]<<" "<<f[i][j][2]<<" "<<f[i][j][3]<<endl;
        }
    for(int i=0;i<=n;i++)ans=(ans+(i&1?-1:1)*(1ll*f[n][i][0]+f[n][i][1]+f[n][i][2]+f[n][i][3])*fac[n-i]%p+p)%p;
    printf("%d\n",ans);
}


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

int main(void){
    int a,b,d,r;
    double f,g;
    
    cin >> a >> b;
    f = a;g = b;
    f = f / g;
    cout << a / b << " " << a % b << " ";
    printf("%.5lf\n", f);
    
    return 0;
    
}


Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int n,k;
int head[maxn],t[maxn<<1],ne[maxn<<1];
int num,v[maxn];
int l[maxn],r[maxn];
bool godie=0;
const int inf=1e9;
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
	ne[++num]=head[y];head[y]=num;t[num]=x;
}
inline void setval(int x,int f){
	forE(i,x)if(t[i]!=f){
		if(v[t[i]]!=inf)continue;
		if(l[t[i]]<=v[x]-1&&v[x]-1<=r[t[i]]){
			v[t[i]]=v[x]-1;
			setval(t[i],x);
		}else if(l[t[i]]<=v[x]+1&&v[x]+1<=r[t[i]]){
			v[t[i]]=v[x]+1;
			setval(t[i],x);
		}else{
			godie=1;
		}
	}
}
inline void dfs(int x,int f){
	l[x]=-inf;r[x]=inf;
	forE(i,x)if(t[i]!=f){
		dfs(t[i],x);
		if(l[t[i]]!=-inf){
			l[x]=l[t[i]]-1;
			r[x]=r[t[i]]+1;
		}
	}
	if(v[x]!=inf){
		l[x]=r[x]=v[x];
		setval(x,f);
	}
	forE(i,x)if(t[i]!=f){
		int nx=l[t[i]]-1,ny=r[t[i]]+1;
		if(nx%2!=l[x]%2&&l[x]!=-inf&&l[t[i]]!=-inf){
			godie=1;
		}
		l[x]=max(l[x],nx);
		r[x]=min(r[x],ny);
	}
	if(l[x]>r[x]){
		godie=1;
	}
}
int main(){
	read(n);
	rep(i,1,n)head[i]=-1;
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		addedge(x,y);
	}
	rep(i,1,n)v[i]=inf;
	read(k);
	rep(i,1,k){
		int x,y;read(x);read(y);
		v[x]=y;
	}
	dfs(1,-1);
	if(v[1]==inf){
		v[1]=l[1];
		if(v[1]==-inf)v[1]=0;
		setval(1,-1);
	}
	if(godie){
		puts("No");
	}else{
		puts("Yes");
		rep(i,1,n)printf("%d\n",v[i]);
	}
	return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int x, y;
  cin >> x >> y;

  int ans = 0;
  if(x == 1) ans += 300000;
  else if(x == 2) ans += 200000;
  else if(x == 3) ans += 100000;
  if(y == 1) ans += 300000;
  else if(y == 2) ans += 200000;
  else if(y == 3) ans += 100000;
  if(x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

char s[20];

int main() {
  int n;
  scanf("%d", &n);
  bool found = false;
  set<string> A;
  vector<string> words(n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    words[i] = string(s);
    if (i > 0 && words[i - 1].back() != words[i][0]) {
      found = true;
    }
    if (A.count(words[i])) {
      found = true;
    } else {
      A.insert(words[i]);
    }
  }
  if (!found) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc007.contest.atcoder.jp/tasks/agc007_b>
問題文============================================================
 集合 {1,2,…,N} の要素を並び替えた順列 p が与えられます。
 以下の条件をすべて満たす 2 つの正整数列 a1, a2, ..., aN および b1, b2, ..., bN を構成してください。
 
     すべての i に対し、1≤ai,bi≤109
     a1<a2<…<aN
     b1>b2>…>bN
     a_p1+b_p1<a_p2+b_p2<…<a_pN+b_pN

 制約
 2≤N≤20,000
 p は集合 {1,2,…,N} の要素を並び替えた順列である。
=================================================================

解説=============================================================
r_pi = i ( 1<= i <= n)
 
 Ai = 30000*i               条件を満たす
 Bi = 30000*(n-i) + ri      条件を満たす
 
 
 =>
     Api + Bpi = 30000*pi + 30000*(n-pi)+r_pi = 30000*n + i
         < 30000*n + i+1 = 30000*p_i+1 + 30000*(n - p_i+1) + r_p_i+1 = Ap_i+1 + Bp_i+1

 
 難しい
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> p(N);
    for(auto &in:p) cin >> in;
    for(int i = 1; i <= N;i++){
        cout << 30000 * i << " ";
    }
    cout << endl;
    vector<ll> r(N+1);
    for(int i = 1; i <= N;i++){
        r[p[i-1]] = i;
    }
    for(int i = 1; i <= N;i++){
        cout << 30000 * (N - i) + r[i] << " ";
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int ls,lp,i,j=0,f=0;
        String s,p;
        s=scan.next();
        p=scan.next();
        ls=s.length();
        lp=p.length();
        s=s+s+s;
        for(i=0;i<ls;i++) {
        	if(s.charAt(i)==p.charAt(0)) {
        		for(j=1;j<lp;j++) {
        			if(s.charAt(i+j)!=p.charAt(j)) {
        				break;
        			}
        		}
        	}
        	if(j==lp) {
        		f=1;
        		break;
        	}
        }
        if(f==1) {
        	System.out.println("Yes");
        }
        else {
        	System.out.println("No");
        }
    }
}


Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n,baris,kolom,occ[10005],idxcolor=1,ans[105][105];
int nextcolor(){
	assert(idxcolor<=n);
	occ[idxcolor]--;
	int ret=idxcolor;
	if(occ[idxcolor]==0)
		idxcolor++;
	return ret;
}
int main()
{
	scan(baris,kolom);
	scan(n);
	for(int i=1;i<=n;i++)
		scan(occ[i]);
	for(int i=1;i<=baris;i++)
	{
		if(i&1)
			for(int j=1;j<=kolom;j++)
				ans[i][j]=nextcolor();
		else
			for(int j=kolom;j>=1;j--)
				ans[i][j]=nextcolor();
	}
	for(int i=1;i<=baris;i++)
	{
		for(int j=1;j<=kolom;j++)
		{
			cout<<ans[i][j];
			if(j<kolom)
				cout<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>//こいつを注意しろ！！！！

using namespace std;




int A[100010]={};

int main(){

  int N;
  cin>>N;
  int ans=0;
  long long B;
  for(int i=0;i<N;i++){
    cin>>B;
    if(B>N)ans++;
    else {A[B]++;}
  }

  for(int i=0;i<=N;i++){
    if(A[i]>i)ans+=A[i]-i;
    else if(A[i]<i)ans+=A[i];

    //    cout<<i<<"   "<<ans<<endl;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
int main() {
	int N, M; cin >> N >> M;
	UnionFind uf(M);
	vector<int>used(M);
	for (int i = 0; i < N; ++i) {
		int K; cin >> K;
		set<int>roots;
		vector<int>connects;
		for (int j = 0; j < K; ++j) {
			int l; cin >> l; l--;
			int r = uf.root(l);
			if (roots.find(r) == roots.end()) {
				roots.emplace(r);
				connects.push_back(l);
			}
			used[l] = true;
		}
		for (int j = 0;j <int( connects.size()) - 1; ++j) {
			uf.unionSet(connects[j], connects[j + 1]);
		}
	}
	set<int>aset;
	for (int i = 0; i < M; ++i) {
		if (used[i]) {
			aset.emplace(uf.root(i));
		}
	}
	if (aset.size() == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,i;
    string a;
    vector<string>s;
    cin>>h>>w;
    for(i=0;i<h;i++)
    {
        cin>>a;
        s.push_back(a);
    }
    for(i=0;i<w+2;i++)
        cout<<"#";
    cout<<endl;
    for(i=0;i<h;i++)
    {
        cout<<"#";
        cout<<s[i]<<"#"<<endl;
    }
    for(i=0;i<w+2;i++)
        cout<<"#";
    cout<<endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100005
using namespace std;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, nxt[N<<1], fir[N], to[N<<1], cnt;

void add(int x, int y){
	nxt[++cnt] = fir[x]; to[cnt] = y; fir[x] = cnt;
	nxt[++cnt] = fir[y]; to[cnt] = x; fir[y] = cnt;
}

bool f[N][2];

void dfs(int x, int p){
	f[x][0] = true;
	for(int i = fir[x]; i ; i = nxt[i]) if(to[i] != p){
		int y = to[i];
		dfs(y, x);
		f[x][1] = (f[x][1] & f[y][1]) | (f[x][0] & f[y][0]);
		f[x][0] &= f[y][1];
	}
}

int main(){
	n = read();
	for(int i = 1; i < n; i++) add(read(), read());
	dfs(1, 0);
	if(f[1][1]) puts("Second");
	else puts("First");
}


Measured memory_bytes: 2304
(N,M,P),*E=[list(map(int,s.split()))for s in open(0).readlines()]
D=[0]*2+[-9e9]*N
def f():
	for _ in D:
		for (a,b,c)in E:D[b]=max(D[b],D[a]+c-P)
f()
s=D[N]
f()
print([max(s,0),-1][s<D[N]])

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

int main(){
    int n; cin >> n;
    vector<int> b(100), a;
    for(int i=0; i<n; i++){
        cin >> b[i];
    }

    bool flg = true;
    int cnt = n;
    while(true){
        flg = false;
        for(int i=n-1; i>=0; i--){
            if(b[i] == i+1){
                a.push_back(b[i]);
                b.erase(b.begin()+i);
                n--;
                flg = true;
                break;
            }
        }
        if(n == 0){
            flg = true; break;
        }
        if(!flg){
            cout << -1 << endl;
            return 0;
            // break;
        }
    }
    if(flg){
        for(int i=cnt-1; i>=0; i--){
            cout << a[i] << endl;
        }
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632