akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<queue>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

vector<int>E[100000];
int v[100000], d[100000], c[100000];
int c1[100000], c2[100000];
int d1[100000];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		E[a].push_back(b); E[b].push_back(a);
	}
	int q; scanf("%d", &q);
	rep(i, q) {
		scanf("%d%d%d", &v[i], &d[i], &c[i]); v[i]--;
	}
	for (int i = q - 1; i >= 0; i--) {
		queue<int>que;
		memset(d1, -1, sizeof(d1));
		d1[v[i]] = d[i];
		if (c1[v[i]] == 0)c1[v[i]] = c[i];
		if (c2[v[i]] >= d1[v[i]])continue;
		c2[v[i]] = d1[v[i]];
		if (d1[v[i]])que.push(v[i]);
		while (!que.empty()) {
			int p = que.front(); que.pop();
			for (int u : E[p]) {
				if (d1[u] != -1)continue;
				d1[u] = d1[p] - 1;
				if (c1[u] == 0)c1[u] = c[i];
				if (c2[u] >= d1[u])continue;
				c2[u] = d1[u];
				if (d1[u])que.push(u);
			}
		}
	}
	rep(i, n)printf("%d\n", c1[i]);
}

Measured memory_bytes: 9208
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print('Yes')
  exit(0)
if H[0]-H[1]>1:
  print('No')
  exit(0)
else:
  H[0]-=1
for i in range(1,N-1):
  if H[i+1]>=H[i]:
    if H[i]-H[i-1]>=1:
      H[i]-=1
    continue
  else:
    if H[i]-H[i+1]==1 and H[i]-1-H[i-1]>=0:
      H[i]-=1
      continue
    else:
      print('No')
      exit(0)
print('Yes')

Measured memory_bytes: 14708
n = int(input())
s = input()

count_w_before = []
counter = 0
for i in range(n):
    if s[i] == 'W':
        counter += 1
    count_w_before.append(counter)

count_e_after = []
counter = 0
for i in range(n):
    if s[-(i+1)] == 'E':
        counter += 1
    count_e_after.append(counter)
count_e_after = count_e_after[::-1]

counter = [w + e for (w, e) in zip(count_w_before, count_e_after)]
print(min(counter) - 1)


Measured memory_bytes: 30840
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector<vector<int>> A(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> A[i][j];
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int mn = MOD;
			for (int k = 0; k < n; k++) {
				if(k != i && k != j)
					mn = min(mn, A[i][k] + A[k][j]);
			}
			if(mn < A[i][j]) {
				cout << -1;
				return 0;
			}
			else if(mn > A[i][j]) {
				ans += A[i][j];
			}
		}
	}
	cout << ans / 2;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n;cin>>n;
    vector<long double> v(n);
    rep(i,n){
        cin>>v[i];
    }

    sort(all(v));

    for(int i=1;i < n;i++)
    {
        v[i]=(v[i-1]+v[i])/2;
    }
    cout<<fixed<<setprecision(20)<<v[n-1]<<endl;

}

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

int main(){
    int N,M;
    cin >> N >> M;;
    vector<int> A(M);
    rep(i,M) cin >> A[i];
    int ans = 0;
    int tmp = 0;
    rep(i,M) tmp += A[i];
    if(N - tmp >= 0) cout << N - tmp << endl;
    else cout << -1 << endl;
    
}

Measured memory_bytes: 3604
a, b, k = list(map(int, input().split()))
while(True):
    if a%2==1:a -= 1
    b += a / 2
    a = a/2
    k -= 1
    if k==0:break
    if b%2==1:b -= 1
    a += b / 2
    b = b/2
    k -= 1
    if k==0:break
print(int(a), int(b))

Measured memory_bytes: 3064
def collatz(a):
    if a%2 == 0:
        return int(a/2)
    else:
        return int(a*3+1)

x = []
n = int(input())
x.append(n)
test = n

for i in range(1, 1000001):
    a = collatz(test)
    if a in x:
        print(i+1)
        exit()
    else:
        x.append(a)
        test = a

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>H>>W;
	vector<string>s(H);
	for(auto &i:s)cin>>i;
	vector<vector<int>>O(H,vector<int>(W));
	vector<vector<int>>I(H,vector<int>(W));
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='O')O[i][j]++;
			else if(s[i][j]=='I')I[i][j]++;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=W-2;j>=0;j--)O[i][j]+=O[i][j+1];
	}
	for(int i=H-2;i>=0;i--){
		for(int j=0;j<W;j++)I[i][j]+=I[i+1][j];
	}
	long long int ans=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='J')ans+=O[i][j]*I[i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 83736
#include<stdio.h>
#define H 500000

int h;
int A[H];

void maxHeapify(int A[],int i){
  int l,r,big,c;
  int ch;
  l = i * 2;
  r = l + 1;
  if(l <= h && A[l] > A[i]) big = l;
  else big = i;

  if(r <= h && A[r] > A[big]) big = r;

  if(big != i){
    ch = A[i];
    A[i] = A[big];
    A[big] = ch;
    maxHeapify(A,big);
  }

}

/*void buildMaxHeap(int A[]){
  int i;
  for(i = h/2; i >= 1; i--){
    maxHeapify(A,i);
  }
  }*/

int main(){
  int i;
  
  scanf("%d",&h);
  for(i = 1; i <= h; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = h / 2; i >= 1; i--){
     maxHeapify(A,i);
  }

  /*buildMaxHeap(A);*/

  for(i = 1; i <= h; i++){
    if(i == h)  printf(" %d\n",A[i]);
    else printf(" %d",A[i]);
  }
  
  return 0;
}



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

typedef long long ll;
#define mod 1000000007

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);

    for(ll i = 0; i < n; i++)
        cin >> v[i];
    
    vector<ll> p(n);
    p[n-1] = v[n-1];

    for(ll i = n-2; i >= 0; i--){
        p[i] = p[i+1] + v[i];
    }

    ll ans = 0;

    for(ll i = 0; i < n-1; i++){
        ans += ((v[i] % mod) * (p[i+1] % mod)) % mod;
        ans %= mod;
    }

    cout << ans << "\n";
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  // a, b, c
  vector<vector<int>> dp(N+1, vector<int> (3, 0));
  // input a, b, c
  vector<vector<int>>  happy(N+1, vector<int> (3, 0));
  rep(i, 1, N+1) {
    cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
  }

  rep(i, 1, N+1) {
    dp[i][0] = happy[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = happy[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = happy[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
  }

  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
};


Measured memory_bytes: 11136
n = int(input())
a = [int(s) for s in input().split()]
d = 0
ans = 0
mod = 10**9+7
for d in range(60):
	c0 = 0
	c1 = 0
	for v in a:
		if v >> d & 1:
			c1 += 1
		else:
			c0 += 1
	ans = (ans + (c0 * c1 << d)) % mod
print(ans)

Measured memory_bytes: 122936
def main():
    N, X = (int(i) for i in input().split())
    ans = 0

    def dfs(n, x, ans):
        a = 1 + 4*(2**n - 1)
        if n == 0:
            return 1
        elif n >= x:
            return 0
        elif x == a//2:
            return 1 + 2*(2**(n-1) - 1)
        elif x == a//2 + 1:
            return 1 + 2*(2**(n-1) - 1) + 1
        elif x < a//2:
            ans += dfs(n-1, x-1, ans)
        elif x > a//2 + 1:
            ans += dfs(n-1, x-(a//2)-1, ans) + (1 + 2*(2**(n-1) - 1) + 1)
        return ans

    print(dfs(N, X, ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
s=input()
a=""
b=""
a=a+s[0]+s[1]
b=b+s[2]+s[3]
acount=0
bcount=0
if a=="00" and int(b)>=13:
  print("NA")
  acount=100
  bcount=100
if b=="00" and int(a)>=13:
  print("NA")
  acount=100
  bcount=100
if b=="00" and a=="00":
  print("NA")
  acount=100
  bcount=100
if int(b)>=13 and int(a)>=13:
  print("NA")
  acount=100
  bcount=100
  
if int(a)>=13 or a=="00":
  acount+=1
if int(b)>=13 or b== "00":
  bcount+=1
if acount+bcount==0:
  print("AMBIGUOUS")
elif acount+bcount== 1:
  if acount==0:
     print("MMYY")
  elif acount==1:
    print("YYMM")

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;
use std::cmp::{max, min};

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut A: Vec<usize> = (0..N+1).map(|_|read()).collect();
    let mut B: Vec<usize> = (0..N).map(|_|read()).collect();

    let mut ans: usize = 0;
    for i in 0..N {
        let killed = std::cmp::min(A[i], B[i]);
        B[i] -= killed;
        ans += killed;

        let killed = std::cmp::min(A[i+1], B[i]);
        A[i+1] -= killed;
        ans += killed;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <stdio.h>
int main(void)
{
	int t, m, r;
	for (r = 1; r <= 4; r++)
	{
		scanf("%d %d", &t, &m);
		if (t == 1)
		{
			printf("%d\n", 6000 * m);
		}
		else if (t == 2)
		{
			printf("%d\n", 4000 * m);
		}
		else if (t == 3)
		{
			printf("%d\n", 3000 * m);
		}
		else
		{
			printf("%d\n", 2000 * m);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#abc099-c
n=int(input())

#dp配列と引き出した金額を対応させる
dp=[float('inf')]*(n+1)
dp[0]=0
l=[1,6,9]
for i in range(n+1):

    for j in range(3):
        num=1
        deposit=l[j]
        while i+deposit<=n:
            if deposit==1:
                dp[i+1]=min(dp[i+1],dp[i]+1)
                break
            dp[deposit+i]=min(dp[deposit+i],dp[i]+1)
            num+=1
            # 次にとる金額を決める
            deposit=l[j]**num
print(dp[-1])

Measured memory_bytes: 48080
f :: [[Int]] -> IO()
f ([0,0]:_) = return ()
f ([x,y]:r) = do 
    putStrLn $ if(x < y) then (show x) ++ " " ++ (show y) else (show y) ++ " " ++ (show x) 
    f r

main = getContents >>= f . map (map read) . (map words) . lines


Measured memory_bytes: 4548
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    string s;
    cin>>s;
    int slen=s.size();
    int ansa=0,ansb=0;
    rep(i,slen){
        if(i%2==0){
            if(s[i]!='0')ansa++;
            else ansb++;
        }else{
            if(s[i]!='0')ansb++;
            else ansa++;
        }
    }
    cout<<min(ansa,ansb)<<endl;
}

Measured memory_bytes: 3744
#include<stdio.h>
int table[9][9];
bool NG[9][9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				scanf("%d",&table[i][j]);
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				NG[i][j]=false;
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				bool ok=true;
				for(int k=0;k<9;k++){
					if(table[i][j]==table[i][k]&&j!=k)ok=false;
				}
				for(int k=0;k<9;k++){
					if(table[i][j]==table[k][j]&&i!=k)ok=false;
				}
				int seci=i/3;
				int secj=j/3;
				for(int k=0;k<3;k++){
					for(int l=0;l<3;l++){
						if(table[seci*3+k][secj*3+l]==table[i][j]&&seci*3+k!=i&&secj*3+l!=j)ok=false;
					}
				}
				if(!ok)NG[i][j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(NG[i][j]?"*":" ");
				printf("%d",table[i][j]);
			}
			printf("\n");
		}
		if(a)printf("\n");
	}
}


Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli unsigned long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;


int main(){
	lli n;
	lli a,b;

	vector<lli> v;
	for(int i=0;i<3;i++){
		lli tmp;
		cin>>tmp;
		v.push_back(tmp);
	}

	sort(v.begin(),v.end());
	cout<< v[2]- v[0]<<endl;

	return 0;

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int a, b, k;
    cin >> a >> b >> k;
    int n = 0;
    for(int i=min(a,b); i>0; i--){
        if(a%i==0 && b%i==0) n++;
        if(n==k){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main { 
    public static void main(String[] args){
    Scanner scan = new java.util.Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    if(a < b){
        System.out.println("a < b");
    }else if(a > b){
        System.out.println("a > b");
    }else if(a == b){
        System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26172
n = int(input())
cnt_AB = 0
cnt_xxA = 0
cnt_Bxx = 0
cnt_BxA = 0
for i in range(n):
    s = input()
    cnt_AB += s.count('AB')
    if s[-1] == 'A':
        cnt_xxA += 1
    if s[0] == 'B':
        cnt_Bxx += 1
    if s[-1] == 'A' and s[0] == 'B':
        cnt_BxA += 1

cnt_xxA -= cnt_BxA
cnt_Bxx -= cnt_BxA

if cnt_BxA == 0:
    print(cnt_AB + min(cnt_xxA, cnt_Bxx))
else:
    if cnt_Bxx+cnt_xxA > 0:
        print(cnt_AB + cnt_BxA + min(cnt_xxA, cnt_Bxx))
    else:
        print(cnt_AB + cnt_BxA - 1)

Measured memory_bytes: 9240
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,sum=0;
    string str;
    int hoge=0;
    cin>>n>>k;
    vector<ll> v(n);
    ll size=300020;
    segtree<int, op, e> seg(size);
    rep(i,size) seg.set(i,0);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        ll left=v[i]-k;
        ll right=v[i]+k;
        if(left<0) left=0;
        if(size<=right) right=size-2;
        ll maxia=seg.prod(left,right+1);
        seg.set(v[i],maxia+1);
    }
    //rep(i,n){
    //    cout<<v[i]<<" ";
    //}ln;
    rep(i,size){
        hoge=max(seg.get(i),hoge);
      //  cout<<seg.get(i)<<" ";
    }//ln;
    cout<<hoge<<endl;

    return 0;
}


Measured memory_bytes: 9796
N = int(input())
listA = list(map(int,input().split()))
count = [0 for i in range(N)]

for i in range(N):
    flag = True
    counter = 0
    tmp = listA[i]
    while flag:
        if tmp % 2 == 0:
            tmp = tmp // 2
            counter += 1
        else:
            flag = False
    count[i] = counter


print(min(count))



Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


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


void solve()
{
	arr[0] = 0;
	for(int i=1; i<=999; i++)
		arr[i] = arr[i - 1] + i;
	cin >> a >> b;
	int temp = b - a;
	printf("%d\n",arr[temp - 1] - a);
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	vector<string> l = {"XXX", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
	string s;cin>>s;
	rep(i, 8){
		if(s==l[i]){
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a[100];
   int n, i;
   cin >> n;
   for( i = 0; i < n; i++ ){
       cin >> a[i];
   }
   for( i = n - 1; i > 0; i-- ){
       cout << a[i] << ' ';
   }
   cout << a[i] << endl;
}



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

int main(){
  int H,W;cin>>H>>W;
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  vector<vector<int> > fields(H,vector<int>(W));
  int i=0,j=0;
  for(int k=0;k<N;k++){
    int h=0;
    while(true){
      if(h==a[k]) break;
      fields[i][j]=k+1;
      j++;
      if(j==W){
        i++;
        j=0;
      }
      h++;
    }
  }
  for(int i=0;i<H;i++){
    if(i&1){
      for(auto it=fields[i].begin();it!=fields[i].end();it++){
        cout<<*it<<((it==fields[i].end()-1)?'\n':' ');
      }
    }else{
      for(auto it=fields[i].rbegin();it!=fields[i].rend();it++){
        cout<<*it<<((it==fields[i].rend()-1)?'\n':' ');
      }
    }
  }
  return 0;
}

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

int main(){
  int h, d;
  cin >> h >> d;
  if(h % 3 == 0 || d % 3 == 0){
    cout << 0 << endl;
    return 0;
  }
  int ans = 1000000;
  // case 1
  ans = min(h, d);
  
  //case 2
  int as = h/3, al = as + 1;
  int sa = as * d, sb = (h-as) * (d/2), sc = h*d - sa - sb;
  int t = max(abs(sa-sb), max(abs(sb-sc), abs(sc-sa)));
  int la = al * d, lb = (h-al) * (d/2), lc = h*d - la - lb;
  int u = max(abs(la-lb), max(abs(lb-lc), abs(lc-la)));
  ans = min(u, min(ans, t));
  
  //case 3
  as = d/3, al = as + 1;
  sa = as * h, sb = (d-as) * (h/2), sc = h*d - sa - sb;
  t = max(abs(sa-sb), max(abs(sb-sc), abs(sc-sa)));
  la = al * h, lb = (d-al) * (h/2), lc = h*d - la - lb;
  u = max(abs(la-lb), max(abs(lb-lc), abs(lc-la)));
  ans = min(u, min(ans, t));
  
  cout << ans << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#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 eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

    int a,b,c; cin >> a >> b >> c;
    if(a==b) cout << c << endl;
    else if(a==c) cout << b << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MOD 2019

int main(void){
    unsigned int l,r,end;
    unsigned int i,j;
    unsigned long long int min = 2019;
    unsigned long long int tmp;
    scanf("%u %u", &l, &r);
    
    if(r > l + MOD){
        end = l + MOD;
    }else{
        end = r;
    }
    
    for(i = l; i < end; i++){
        for(j = i+1; j <= end; j++){
            tmp = ((i % MOD) * (j % MOD)) % MOD;
            if(tmp < min){
                min = tmp;
            }
        }
    }
    
    printf("%llu", min);
    
    return 0;
}

Measured memory_bytes: 128
r = 2*123456+1
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]

while 1:
	n = input()
	if n == 0: break
	print sum(p[n+1:2*n+1])

Measured memory_bytes: 11280
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let mut xs: Vec<u64> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();
    xs.sort();

    println!("{}",
        if xs[0] + xs[1] == xs[2] {
            "Yes"
        }
        else {
            "No"
        }
    );
}


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

int A[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N, M;
    cin >> N >> M;

    while(M--)
    {
        int a, b;
        cin >> a >> b;

        A[a] ^= 1, A[b] ^= 1;
    }

    for(int i=1; i<=N; i++)
        if(A[i])
        {
            cout << "NO\n";
            return 0;
        }

    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	vector<int>ans(N);
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				int num = i * i + j * j + k * k + i * j + j * k + k * i;
				if (num <= N)ans[num-1]++;
			}
		}
	}
	for (auto i : ans)cout << i << endl;
}

Measured memory_bytes: 3612
n = input()
count357 = ["3", "5", "7"]
i = 0
while int(count357[-1]) <= int(n):
    for j in range(3):
        count357.append(str(int(count357[i])*10 + int(count357[j])))
        if int(count357[-1]) > int(n):
            break
    i += 1
count357.pop(-1)
count = 0
for i in range(len(count357)):
    count += 1 if "3" in count357[i] and "5" in count357[i] and "7" in count357[i] else 0

print(count)

Measured memory_bytes: 5156
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int a,b;
    cin>>a>>b;
    int arr[101];
    for(int i=1;i<=a;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=a;i++)
    {
        b-=arr[i];
    }
    sort(arr+1,arr+a+1,cmp);
    int c=b/arr[1]+a;
    if(b%arr[1]!=0)
    {
        if((b-arr[1]*(c-a)-arr[1])/arr[2]>=2)
            c+=1;
    }
    cout<<c<<endl;
}


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

using namespace std;

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define INF 1e18
#define eps 0.00001
#define le length
#define debug(n1) cout << n1 << endl
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
const ll N = 2e5 + 5;
const ll M = 1e7 + 5;
const ll mod = 1e18 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
ll BINARY_SEARCH(ll dp[] , ll n , ll key) {
    ll s = 1;
    ll e = n;
    while(s <= e) {
        ll mid = (s + e) / 2;
        if(dp[mid] == key) return mid;
        else if (dp[mid] > key) e = mid - 1;
        else s = mid + 1;
    }
    return -1;
}
string CONVERT_TO_BINARY(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}
bool PALIN(string s) {
    int i = 0;
    int j = s.le() - 1;
    while(i <= j) {
        if(s[i] != s[j]) return false;
        j-- , i++;
    }
    return true;
}
int main() {
    SPEED;
    cout.precision(8);
    cout << fixed;
    string a , b;
    cin >> a >> b;
    if(a > b) cout << ">" << endl;
    else if (a < b) cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<vector<ll>> dp(N, vector<ll>(N,0));
    vector<vector<ll>> sum(N, vector<ll>(N,1e18));
    rep(i,N) {
        dp[i][i] = A[i];
        sum[i][i] = 0;
    }
    for (int k = 1; k < N; k++) {
        for (int i = 0; i < N-k; i++) {
            for (int j = i; j < i+k; j++) {
                chmin(sum[i][i+k],sum[i][j] + sum[j+1][i+k] + dp[i][j] + dp[j+1][i+k]);
                dp[i][i+k] = dp[i][j] + dp[j+1][i+k];
            } 
        }
    }

    cout << sum[0][N-1] << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back
#define pf push_front
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;

    string ans = "";
    rep(i,n) ans += "0";

    vector<vector<char>> vec(m, vector<char>(2));
    for(int i=0; i<m; i++){
        for(int j=0; j<2; j++){
            cin >> vec[i][j];
        }
    }
    rep(i,m){
        for(int j=i+1; j<m; j++){
            if((vec[i][0] == vec[j][0]) && (vec[i][1] != vec[j][1])){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    int ok = 1;

    rep(i,m){
        ans.at((vec[i][0]-'0')-1) = vec[i][1];
        if((vec[i][0] == '1') && (vec[i][1] == '0')) ok = 0;//最高桁を０にしてたら0
    }

    if((ans.at(0) == '0') && n==1){
        cout << 0 << endl;
        return 0;
    }
    //最高桁を0にしてないとき
    if((ok) && (ans.at(0)=='0')){
        ans.at(0) ='1';
        cout << ans << endl;
        return 0;
    }


    if((ans.at(0) == '0') && (ans !="0")){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 256
n = int(input())
ans = 0
for i in range(1,n+1) :
    if i % 2 == 0 :
        continue
    cnt = 0
    for j in range(1,i+1) :
        if i % j == 0 :
            cnt += 1
    if cnt == 8 :
        ans += 1
print(ans)

Measured memory_bytes: 3060
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split('\n')
	var N = parseInt(input[0])
	var d = input.slice(1)
	d = d.map(function (x) {
	    return parseInt(x, 10); 
	});

	//10, 9, 8...
	d.sort(function(a,b){
        if( a < b ) return 1;
        if( a > b ) return -1;
        return 0;
	});

	d = d.filter(function(item, pos) {
    	return d.indexOf(item) == pos;
	})

	var lastMochi = d[0],
		c = 1	
	for(var i = 1; i < d.length; i++) {
		var mochi = d[i]
		if(mochi < lastMochi) c++
		else break
	}

	console.log("" + c)
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    int n,k;
    cin >> n >> s >> k;
    REP(i, s.length()) {
        if(s[i]!=s[k-1]) s[i] = '*';
    }
    cout << s << endl;

}


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

using namespace std;

const int N = 1e5 + 5;
vector<int> adj[N];
bool vis[N];
int dp[N], ans;

void dfs(int u){
	vis[u] = true;
	for(auto v : adj[u]){
		if(!vis[v])
			dfs(v);
		dp[u] = max(dp[u], dp[v] + 1);
	}
}

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

	int x, y;
	for(int i = 1; i <= m; i++){
		cin >> x >> y;
		adj[x].emplace_back(y);
	}

	for(int i = 1; i <= n; i++)
		if(!vis[i])
			dfs(i);

	for(int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);

	cout << ans << "\n";
}

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

using namespace std;

#define ll long long
#define mod (ll)1000000007

const ll INF = 1e11;

void solve(){

    string s1, s2; cin >> s1 >> s2;
    int ans = 0;
    for(int i = 0; i < s1.length(); ++i)
        if(s1[i] != s2[i]) ++ans;

    cout << ans << endl;

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}



int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string>a(h);
  for(i=0;i<h;i++)cin>>a[i];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]=='#')res++;
    }
  }
  ans(res==h+w-1,"Possible","Impossible");




  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string b;
	int len,i,s=0;
    cin>>b;
    len=b.size();
    for(i=0;i<len;i++){
    if(b[i]=='C'){
    s++;
    }
    if(s!=0 && b[i]=='F'){
    cout<<"Yes";
    return 0;
    }}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        String[] in2 = br.readLine().split(" ");
        int H = Integer.parseInt(in1[0]);
        int N = Integer.parseInt(in1[1]);

        br.close();
        int sum = Arrays.stream(in2)
                        .mapToInt(Integer::parseInt)
                        .sum();
        
        System.out.println(sum >= H ? "Yes" : "No");
    }
}

Measured memory_bytes: 35852
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
struct Edge{
    long long to,ne;
    Edge(long long _to=0,long long _ne=0):to(_to),ne(_ne){}
}edge[200003];
long long tot,ne[200003];
inline void add(int u,int v){
    edge[tot]=Edge(v,ne[u]);
    ne[u]=tot++;
}
long long n,m,c[100003];
void dfs(int u,int col){
    c[u]=col;
    for(int i=ne[u];~i;i=edge[i].ne){
        int v=edge[i].to;
        if(c[v]==-1){
        	dfs(v,!col);
		}
        if(c[v]!=!col){
        	cout<<(long long)n*(long long)(n-1)/2-m<<endl;
			exit(0);
		}
    }
}
int main(){
    cin>>n>>m;
    memset(c,-1,sizeof(c));
    memset(ne,-1,sizeof(ne));
    for(int i=0;i<m;++i){
        int u,v;
        cin>>u>>v;
        add(u,v),add(v,u);
    }
    dfs(1,0);
    long long b=0,w=0;
    for(int i=1;i<=n;++i){
    	if(c[i]){
    		++b;
		}else{
			++w;
		}
	}
	cout<<1LL*b*w-m<<endl;
    return 0;
}
/*

in:
5 5
1 2
2 3
3 1
5 4
5 1

out:
5

*/

Measured memory_bytes: 6528
k = int(input())
from collections import deque
lun = deque([str(n)for n in list(range(1,10))])
if k<=9:
    print(lun[k-1])
    exit()
l = 9
while l<k:
    n = lun.popleft()
    c = int(n[-1])
    if c>0:
        lun.append(n+str(c-1))
        l+=1
        if l==k:break
    lun.append(n+str(c))
    l+=1
    if l==k:break
    if c<9:
        lun.append(n+str(c+1))
        l+=1
        if l==k:break
    
print(lun[-1])

Measured memory_bytes: 13660
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

string S, T;
map<char, vector<char>> M[2];

int main()
{
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++)
    {
        M[0][S[i]].push_back(T[i]);
        M[1][T[i]].push_back(S[i]);
    }
    for (auto m : M)
    {
        for (auto v : m)
        {
            char c = v.second[0];
            for (auto e : v.second)
            {
                if (e != c)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1416
s = input()
same = 0
for i in range(3):
    if s[0] == s[i+1]:
        same += 1
if same == 1:
    if s[1] == s[2] or s[2] == s[3] or s[3] == s[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		char[] str = sc.next().toCharArray();
		int len = str.length / 2;
		int ans = str.length;

		
		while(len > 1) {
			len--;
			boolean flag = true;
			for(int i = 0; i < len ; i++) {
				if (str[i] != str[i + len]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				ans = len * 2;
				break;
			}
		}
		out.println(ans);

		out.close();
	}
	static boolean func(StringBuilder sb1, StringBuilder sb2) {
		boolean res = true;
		for(int i = 0; i < sb1.length(); i++) {
			if ( sb1.charAt(i) != sb2.charAt(i)) {
				res = false;
				break;
			}
		}
		return res;
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 21076
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem069c(n, a))
}
 
fun problem069c(n: Int, a: List<Long>): String {
    val fourCount = a.count { it % 4 == 0L }
    val twoCount = a.count { it % 4 == 2L }
    val oneCount = a.count { it % 2 == 1L }
    return if (oneCount + ( if(twoCount >= 1) 1 else 0 ) <= fourCount + 1) "Yes" else "No"
}


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

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a_max = max(a)
    a.remove(a_max)
    a = sorted(a)

    # See:
    # https://www.youtube.com/watch?v=RwWljbtCrPA
    # https://img.atcoder.jp/arc095/editorial.pdf
    # https://beta.atcoder.jp/contests/abc094/submissions/2354745
    k = [abs(a_max / 2 - ai) for ai in a]
    center = k.index(min(k))
    print(a_max, a[center])


Measured memory_bytes: 14052
#include<stdio.h>
int main(void)
{
        int n=0,i;
        char s[3];
        for(i=0;i<3;i++) scanf("%c",&s[i]);
        for(i=0;i<3;i++) if(s[i]=='1') n++;
        printf("%d",n);
        return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

int dx[] = { 0, 1, 0, -1};
int dy[] = {-1, 0, 1,  0};

int main()
{
  long long N, K;
  std::cin >> N >> K;
  std::vector<long long> A(N);
  for(auto& val: A)
    std::cin >> val;
  std::sort(A.begin(), A.end());
  long long inf = 1e18;
  long long l = -inf - 1, r = inf + 1;
  auto check = [&A, N, K](long long x) {
    long long cnt = 0;
    for(int i = 0; i < N; ++i)
    {
      auto val = A[i];
      if(val < 0)
      {
        int l = -1, r = N;
        while(l + 1 < r)
        {
          int m = (l + r) / 2;
          if(A[m] * val < x)
            r = m;
          else
            l = m;
        }
        cnt += N - r;
      }
      else
      {
        int l = -1, r = N;
        while(l + 1 < r)
        {
          int m = (l + r) / 2;
          if(A[m] * val < x)
            l = m;
          else
            r = m;
        }
        cnt += r;
      }
      if(val*val < x)
        cnt--;
    }
    cnt /= 2;
    return cnt < K;
  };
  while(l + 1 < r)
  {
    long long x = (l + r) / 2;
    if(check(x))
      l = x;
    else
      r = x;
  }
  std::cout << l << std::endl;
  return 0;
}



Measured memory_bytes: 1792
#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 n,m;cin>>n>>m;
    int h[n];rep(i,n)cin>>h[i];
    int t[n];rep(i,n)t[i]=1;
    
    rep(i,m){
        int a,b;cin>>a>>b;
        --a;--b;
        if(h[a]<h[b])t[a]=0;
        if(h[b]<h[a])t[b]=0;
        if(h[b]==h[a])t[a]=t[b]=0;
    }
    int ans = 0;
    rep(i,n)ans+=t[i];
    cout<<ans<<endl;
	return 0;
}

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

int main(){
 int A,B,C,D; //4つのパラメータの定義
  cin >> A >> B >> C >> D;
  for( int i = 0; i<1000; i++){
    
    C = C - B; // 青木君のダメージ
    if ( C <= 0 ){
      cout << "Yes" << endl;
      break; //決着がついたのでループ脱出
    }
    
    A = A - D; // 高橋君のダメージ
    if( A <= 0 ){
      cout << "No" << endl;
      break; //決着がついたのでループ脱出
    }
  }
}

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

const int INF=0x3f3f3f3f;
const int M=2e5+5;
int n,k,c;
char s[M];

int l[M],r[M];

int ml[M],mr[M];

inline void cmin(int &x,int y)
{
	if(x>y) x=y;
}
inline void cmax(int &x,int y)
{
	if(x<y) x=y;
}

int main()
{
	//freopen("E.in","r",stdin);
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",s+1);
	memset(ml,INF,sizeof(ml));
	for(int i=1;i<=n;i++)
	{
		l[i]=l[i-1];
		if(s[i]!='x')
			l[i]=max(l[i],i-c-1>=1?l[i-c-1]+1:1);
		cmin(ml[l[i]],i);
	}
	r[n+1]=k;
	//memset(r,INF,sizeof(r));
	for(int i=n;i>=1;i--)
	{
		r[i]=r[i+1];
		if(s[i]!='x')
			r[i]=min(r[i],i+c+1<=n?r[i+c+1]-1:k);
		if(r[i]>0)
			cmax(mr[r[i]],i);
	}
	// for(int i=1;i<=k;i++)
	// 	cout<<ml[i]<<" "<<mr[i]<<endl;
	for(int i=1;i<=n;i++)
	{
		//assert(0<=l[i]&&l[i]<M);
		if(i==ml[l[i]]&&ml[l[i]]==mr[l[i]])
			printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b) >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}	

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

#define REP(i, n) for(int (i)=0; (i)<(n); i++)

using namespace std;

int main(){
  int a, b, c;
  long long k;
  cin >> a >> b >> c >> k;
  cout << (k % 2 ? b-a : a-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{ string S,T;
  cin>>S;
 cin>>T;
 int flag=0;
 for(int i=0;i<S.size();i++)
 {	
   if(S[i]!=T[i])
   {
     flag++;
   }
 }
 cout<<flag;
 return 0;
}

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

int main(){
  int K;
  cin >> K;
  queue<int64_t> lunlun;
  
  for(int i=1; i<10; i++){
    lunlun.push(i);
  }  
  if(K <= 10) {
    cout << K;
  }
  else{
    int cnt = 9;
    while(cnt<K) {
      if(lunlun.front()%10 != 0) {
        cnt++;
        if(cnt==K){
          cout << 10*lunlun.front()+(lunlun.front()%10)-1; 
          break;
        }
        lunlun.push(10*lunlun.front()+(lunlun.front()%10)-1);
      }
      cnt++;
      if(cnt==K){
        cout << 10*lunlun.front()+(lunlun.front()%10);
        break;
      }
      lunlun.push(10*lunlun.front()+(lunlun.front()%10));
    
      if(lunlun.front()%10 == 9) {
        lunlun.pop();
      }
      else{
        cnt++;
          if(cnt==K){
            cout << 10*lunlun.front()+(lunlun.front()%10)+1;
            break;
          }
        lunlun.push(10*lunlun.front()+(lunlun.front()%10)+1);
        lunlun.pop();
      }
    }
  }
}



Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, A, B;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			A = sc.nextInt();
			B = sc.nextInt();
			int gcd = gcd(A, B);
			System.out.println(N - count(N / gcd, A / gcd, B / gcd));
		}
	}

	static int count(int n, long a, long b) {
		int ret = 0;
		for (long i = 0; i <= n && i < a * b; i += a) {
			ret += (Math.min(a * b - 1, n) - i) / b + 1;
		}
		if (n >= a * b) {
			ret += n - a * b + 1;
		}
		return ret - 1;
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}

Measured memory_bytes: 17192
#include<stdio.h>
#include<string.h>
#define N 21
int main()
{
	char s[N];
	scanf("%s",s);
	int len=strlen(s),i;
	for(i=len-1;i>=0;i--){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;

signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i-j>=0)
                dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
    }
    cout<<dp[n-1];
}



Measured memory_bytes: 1792