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

int main()
{
    string s,y,m;
    int a,b,c,d,e;
    cin>>s;
    y+=s[0];
    y+=s[1];
    stringstream ss (y);
    ss>>b;
    m+=s[2];
    m+=s[3];
    stringstream rr (m);
    rr>>c;
    int ck=0;

    if(b<=12 && b>0){
        if(c<=12 && c>0)
            cout<<"AMBIGUOUS"<<endl,ck=1;
        else
            cout<<"MMYY"<<endl,ck=1;
    }
    else if (b>12){
        if(c>12)
            cout<<"NA"<<endl,ck=1;
        else if(c>0 && c<=12)
            cout<<"YYMM"<<endl,ck=1;
        else
            cout<<"NA"<<endl;
    }
    else{

        if (c>12||c==0)
            cout<<"NA"<<endl;
        else if(c<=12)
            cout<<"YYMM"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#30 ABC133C
l,r=map(int,input().split())
j=(r-l>=2019)
l%=2019
r%=2019
if l>=r:
	print(0)
elif j:
	print(0)
else:
	res=1<<32
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			res=min(res,(i*j)%2019)
	print(res)

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int d = Integer.parseInt(str[3]);
    int x = (a+d-1)/d;
    int y = (c+b-1)/b;
    System.out.println(x>=y?"Yes":"No");
  }
}

Measured memory_bytes: 32528
// abc133c: Remainder Minimization 2019
#include <bits/stdc++.h>
using namespace std;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))

int main(){
  int l,r; cin>>l>>r;
  if(r-l>=2019)// 1周すれば余り0となる数が必ずある
    cout<<0<<endl;
  else{
    int a = l%2019;
    int b = r%2019;
    if(a>b) //余りの大小が逆転する間に余り0となる数が必ずある
      cout<<0<<endl;
    else{ // a<=b : この間で最小の数２つをとればよい
      int min = 2018;
      upto(i,a,b,1){
        upto(j,i+1,b+1,1){
          int x = (i*j)%2019;
          if(min>x) min = x;
        }
      }
      cout<<min<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>>k;
    int ans=0;
    for(int i=1;i<k;i++){
        for(int j=i;j<=k;j++){
            if(i%2!=0 && j%2==0)ans++;
            else if(i%2==0 && j%2!=0)ans++;
            }
        }
    cout<<ans<<endl;
    return 0;
    }


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

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

    int last;
    scanf("%d", &last);
    for (int i = 1; i < n; ++i)
    {
        static int cur;
        scanf("%d", &cur);
        if (cur < last)
        {
            printf("No");
            return 0;
        }
        if (cur > last)
            --cur;

        last = cur;
    }

    printf("Yes");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int[] col = new int[13];
		for(int i=0;i<N;i++){
			col[io.nextInt()/400] ++;
		}
		int min = 0;
		for(int i=0;i<8;i++){
			if(col[i]>0) min++;
		}
		int topCoders=0;
		for(int i=8;i<13;i++){
			topCoders += col[i];
		}
		
		int max;
		if(min == 0){
			min = 1;
			max = topCoders;
		}else if(topCoders>0){
			max = min + topCoders;
		}else{
			max = min;
		}
			
		System.out.println(min + " "+ max);
		
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
    int n, k;cin >> n >> k;int sum = k;
    if (k != 1) k--;
    rep(i, n - 1) {
            sum *= k;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
aa =  list(map(int, input().split()))
ai = aa.index(min(aa))

x = (ai + 1) // (k -1 )
n = n - (k - 1) * x - 1
y = (n + k -2) // (k-1)

print(x + y)

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

using namespace std;

typedef long long ll;

int main(){
	int n,k;
	cin >> n >> k;
	ll h[n];
	for(int i = 0; i < n; i++)cin >> h[i];
	sort(h,h+n);
	//for(int i = 0; i < n; i++)cout << h[i] << endl;
	ll ans = 9999999999;
	for(int i = 0; i <= n-k; i++)ans = min(ans,h[i+k-1]-h[i]);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int n,h,m,s;
  cin >> n;
 
  h = n / 3600;
  m = n % 3600 / 60;
  s = n % 3600 % 60;
 
  cout << h << ':' << m << ':' << s << endl;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x,n;
    cin >> x >> n;
    set<int> se;
    F0R(i,n) {
        int e;
        cin >> e;
        se.insert(e);
    }
    int hi=-1;
    FOR(i,x,102) {
        if(se.find(i)==se.end()) {
            hi=i;
            break;
        }
    }
    int lo=-1;
    for(int i=x; i>=-1; i--) {
        if(se.find(i)==se.end()) {
            lo=i;
            break;
        }
    }
    if(abs(hi-x)>=abs(lo-x))
        cout << lo;
    else
        cout << hi;

    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main(){
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define RANGE(a, l, r) lower_bound(a, a + N, r) - lower_bound(a, a + N, l)
using namespace std;
typedef int ll;

ll N, A[200000], B[200000];
ll pow2[31], l1[29], r1[29], l2[29], r2[29];
ll moda[29][200000], modb[29][200000];

int main(void) {
  scanf("%d", &N);
  REP(i, 0, N) scanf("%d", &A[i]);
  REP(i, 0, N) scanf("%d", &B[i]);

  REP(i, 0, 31) pow2[i] = (1 << i);
  REP(i, 0, 29) {
    l1[i] = pow2[i];
    r1[i] = pow2[i + 1];
    l2[i] = pow2[i + 1] + pow2[i];
    r2[i] = pow2[i + 2];
  }
  REP(i, 0, 29) REP(j, 0, N) moda[i][j] = A[j] % pow2[i + 1];
  REP(i, 0, 29) {
    REP(j, 0, N) modb[i][j] = B[j] % pow2[i + 1];
    sort(modb[i], modb[i] + N);
  }

  ll ans = 0;
  REP(i, 0, N) {
    REP(k, 0, 29) {
      ll cnt = 0;
      cnt += RANGE(modb[k], l1[k] - moda[k][i], r1[k] - moda[k][i]);
      cnt += RANGE(modb[k], l2[k] - moda[k][i], r2[k] - moda[k][i]);
      if(cnt & 1) ans = ans ^ pow2[k];
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 47104
#include<stdio.h>

int main(){
    
	int len;
	
	scanf("%d",&len);
	char str[len+5];
	scanf("%s",&str);
	if(len % 2 != 0){
		printf("No\n");
	}
	else{
		int left = 0, right = 0;
		
		for(int i = 0;i<len;i++){
			if(i<len/2) left+=str[i];
			else if (i>=len/2) right+=str[i];
		}
		
		if(right == left) printf("Yes\n");
		else printf("No\n");		
	}
	
	return 0;
}

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

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

    long long int A[N];
    rep(i, N){
        cin >> A[i];
    }

    long long int B[M];
    rep(i, M){
        cin >> B[i];
    }

    //ここから処理
    int time_A=0, time_B=0;
    int num_A=0, num_B=0;
    while(true){
        if(num_A == N) break;
        if(time_A+A[num_A] <= K) time_A += A[num_A++];
        else break;
    }
    //K時間でnum_A冊読める
    int ans=num_A;
    if(num_A == 0){
        while(true){
            if(num_B == M) break;
            if(time_B+B[num_B] <= K) time_B += B[num_B++];
            else break;
        }
        ans = num_B;
    }else{
        int n=num_A+1;
        rep(i, n){
            long long int K_sub = K-time_A;
            while(true){
                if(num_B == M) break;
                if(time_B+B[num_B] <= K_sub) time_B += B[num_B++];
                else break;
            }
            if(ans <= num_A+num_B) ans = num_A+num_B;
            time_A -= A[num_A-1];
            num_A--;
        }
    }

    cout << ans << endl;
}

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

struct Node { int p, depth, l; vector<int> v; };

Node T[100001];
int n;

int main() {
	int n, id, k, c, tmp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].p = -1;
		T[i].depth = T[i].l = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> id >> k;
		if (k == 0) {
			T[id].l = 1;
			if (T[id].p != -1) {
				T[id].depth = T[T[id].p].depth + 1;
			}
		}
		for (int j = 0; j < k; j++) {
			cin >> c;
			T[id].v.push_back(c);
			T[c].p = id;
			T[c].depth = T[id].depth + 1;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": " << "parent = ";
		if (T[i].depth == 0) {
			cout << "-1";
		}
		else {
			cout << T[i].p;
		}
		cout << ", depth = " << T[i].depth << ", ";
		if (T[i].depth == 0) {
			cout << "root";
		}
		else if (T[i].l == 1) {
			cout << "leaf";
		}
		else {
			cout << "internal node";
		}
		cout << ", [";
		tmp = 0;
		for (int j = 0; j < T[i].v.size(); j++) {
			if (tmp != 0) {
				cout << ", ";
			}
			cout << T[i].v[j];
			tmp += 1;
		}
		tmp = 0;
		cout << "]" << endl;
	}
	
 }


Measured memory_bytes: 7852
#include<bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

string s;

int main(){
	cin>>s;
	for(int i=0;i<s.size();++i) cout<<'x';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  bool reversed = false;
  deque<char>deq;
  string s;
  cin>>s;
  for(int i=0; s[i]; i++) deq.push_back(s[i]);
  int q;
  cin>>q;
  while(q--){
  	int t;
  	cin>>t;
  	if(t==1) reversed = !reversed;
	else{
		int f;
		char ch;
		cin>>f>>ch;
		if(f==1){
			if(reversed) deq.push_back(ch);
			else deq.push_front(ch);
		}
		else{
			if(reversed) deq.push_front(ch);
			else deq.push_back(ch);
		}
	}
  }
  if(!reversed){
	  while(deq.size()){
	  	cout<<deq.front();
	  	deq.pop_front();
	  }
	}
	else{
		while(deq.size()){
			cout<<deq.back();
			deq.pop_back();
		}
	}
  
}

Measured memory_bytes: 4060
xs = list(map(int,input().split(' ')))
if xs[0] < xs[1]:
  if xs[0] < xs[2] and xs[2] < xs[1]:
    print('Yes')
  else:
    print('No')
else:
  if xs[0] > xs[2] and xs[2] > xs[1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
struct sd{int t,num;bool operator < (const sd &fu) const {return t<fu.t;};};
vector<sd>in[100005];
char ans[100005][12];
int main()
{
	scanf("%d%d",&n,&m);int A,B;
	for(int i=1;i<=m;++i) {scanf("%d%d",&A,&B);in[A].push_back((sd){B,i});}
	for(int i=1;i<=n;++i) sort(in[i].begin(),in[i].end());
	char now[12];
	for(int i=1;i<=n;++i) {
		int nn=i;
		for(int j=5;j!=-1;--j) {now[j]=nn%10+'0';nn/=10;}
		for(int j=in[i].size()-1;j!=-1;--j) {
			int mm=j+1;
			for(int k=11;k!=5;--k) {now[k]=mm%10+'0';mm/=10;} 
			for(int k=0;k<=11;++k) ans[in[i][j].num][k]=now[k];
		}
	}
	for(int i=1;i<=m;++i) {for(int j=0;j<=11;++j) putchar(ans[i][j]);putchar('\n');}
	return 0;
}

Measured memory_bytes: 8192
for _ in range(int(input())):
    x, y = map(int, input().split())
    m = set()
    for _ in range(int(input())):m.add(tuple(map(int, input().split())))
    q = {(0,0):1}
    for _ in range(x + y):
        nq = {}
        for i in q:
            if (i[0], i[1], i[0] + 1, i[1]) not in m and (i[0] + 1, i[1], i[0], i[1]) not in m and i[0] + 1 <= x:
                if (i[0] + 1, i[1]) in nq:nq[(i[0] + 1, i[1])] += q[i]
                else:nq[(i[0] + 1, i[1])] = q[i]
            if (i[0], i[1], i[0], i[1] + 1) not in m and (i[0], i[1] + 1, i[0], i[1]) not in m and i[1] + 1 <= y:
                if (i[0], i[1] + 1) in nq:nq[(i[0], i[1] + 1)] += q[i]
                else:nq[(i[0], i[1] + 1)] = q[i]
        q = nq
    if nq == {}:print("Miserable Hokusai!")
    else:print(q[(x, y)])


Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

const ll MOD=1000000007;
int n,m;
ll s[2020]={0},t[2020]={0};
ll dp[2020][2020]={0};

signed main(){
    cin>>n>>m;
    for(int i=0;i<n;++i){
        cin>>s[i];
        dp[i][0]=1LL;
    }
    for(int i=0;i<m;++i){
        cin>>t[i];
        dp[0][i]=1LL;
    }
    dp[0][m]=1LL,dp[n][0]=1LL;

    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]+=dp[i][j-1];
            dp[i][j]+=MOD-dp[i-1][j-1];
            if(s[i-1]==t[j-1])dp[i][j]+=dp[i-1][j-1];
            dp[i][j]%=MOD;
        }
    }

    cout<<dp[n][m]<<endl;

    return 0;
}

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

int main() {
    int H, W, N; cin >> H >> W >> N;
    int sx, sy; cin >> sx >> sy;
    string s,t; cin >> s >> t;
    
    // L
    int x = sy;
    for(int i=0; i<N; ++i) {
        if(s[i] == 'L') --x;
        if(x < 1) {
            cout << "NO" << endl; return 0;
        }
        if(t[i] == 'R' && x < W) ++x;
    }

    // R
    x = sy;
    for(int i=0; i<N; ++i) {
        if(s[i] == 'R') ++x;
        if(x > W) {
            cout << "NO" << endl; return 0;
        }
        if(t[i] == 'L' && x > 1) --x;
    }

    // U
    int y = sx;
    for(int i=0; i<N; ++i) {
        if(s[i] == 'U') --y;
        if(y < 1) {
            cout << "NO" << endl; return 0;
        }
        if(t[i] == 'D' && y < H) ++y;
    }

    // D
    y = sx;
    for(int i=0; i<N; ++i) {
        if(s[i] == 'D') ++y;
        if(y > H) {
            cout << "NO" << endl; return 0;
        }
        if(t[i] == 'U' && y > 1) --y;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  while (1){
    int W, H;
    cin >> W >> H;
    if (W == 0 && H == 0){
      break;
    }
    vector<vector<char>> A(H + 2, vector<char>(W + 2, '#'));
    vector<vector<char>> B(H + 2, vector<char>(W + 2, '#'));
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        cin >> A[i][j];
      }
      for (int j = 1; j <= W; j++){
        cin >> B[i][j];
      }
    }
    int syl, sxl, gyl, gxl;
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        if (A[i][j] == 'L'){
          syl = i;
          sxl = j;
        }
        if (A[i][j] == '%'){
          gyl = i;
          gxl = j;
        }
      }
    }
    A[syl][sxl] = '.';
    A[gyl][gxl] = '.';
    int syr, sxr, gyr, gxr;
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        if (B[i][j] == 'R'){
          syr = i;
          sxr = j;
        }
        if (B[i][j] == '%'){
          gyr = i;
          gxr = j;
        }
      }
    }
    B[syr][sxr] = '.';
    B[gyr][gxr] = '.';
    vector<vector<vector<vector<bool>>>> used(H + 2, vector<vector<vector<bool>>>(W + 2, vector<vector<bool>>(H + 2, vector<bool>(W + 2, false))));
    used[syl][sxl][syr][sxr] = true;
    queue<tuple<int, int, int, int>> Q;
    Q.push(make_tuple(syl, sxl, syr, sxr));
    while (!Q.empty()){
      int y1 = get<0>(Q.front());
      int x1 = get<1>(Q.front());
      int y2 = get<2>(Q.front());
      int x2 = get<3>(Q.front());
      Q.pop();
      for (int d = 0; d < 4; d++){
        int y3 = y1;
        if (A[y3 + dy[d]][x1] == '.'){
          y3 += dy[d];
        }
        int x3 = x1;
        if (A[y1][x3 + dx[d]] == '.'){
          x3 += dx[d];
        }
        int y4 = y2;
        if (B[y4 + dy[d]][x2] == '.'){
          y4 += dy[d];
        }
        int x4 = x2;
        if (B[y2][x4 - dx[d]] == '.'){
          x4 -= dx[d];
        }
        if (!((y3 == gyl && x3 == gxl) ^ (y4 == gyr && x4 == gxr))){
          if (!used[y3][x3][y4][x4]){
            used[y3][x3][y4][x4] = true;
            Q.push(make_tuple(y3, x3, y4, x4));
          }
        }
      }
    }
    if (used[gyl][gxl][gyr][gxr]){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 13292
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(S: str):
    return 'x'*len(S)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(f'{solve(S)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75296
#include <iostream>
#include <string>
#include <bitset>
#define ll long long
using namespace std;

bitset<200010> bs, fn, xx;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	for(int i=0; i<N; ++i){
		bs[i]=(S[i]=='B');
		fn[i]=(N-1-i)%2;
		xx[i]=1;
	}
	int cnt=0;
	while(bs!=fn && cnt<K){
		if(bs[0]){
			bs ^= xx;
			bs >>= 1;
			bs[N-1]=0;
		}else{
			bs[0]=1;
		}
		++cnt;
	}
	if(N%2==1 && (K-cnt)%2==1) bs[0]=1;
	for(int i=0; i<N; ++i){
		if(bs[i]) cout << 'B';
		else cout << 'A';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 772
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    S = input()
    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)
resolve()

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int N, W; cin >> N >> W;
    vl v(N), w(N);
    vl dp(W+1);

    rep(i,N) cin >> v[i] >> w[i];
    rep(i,N) rep(j,W+1){
        if(j-w[i] >= 0)
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 3300
n = int(input())
colorU = [-1 for _ in range(n)]
colorD = [-1 for _ in range(n)]
colorU[0] = 0

ab = []
ans = [0 for _ in range(n - 1)]
n -= 1
for i in range(n):
    a, b = map(int, input().split())
    ab.append([a, b, i])
ab.sort()
for i in range(n):
    # print(i)
    a = ab[i][0]
    b = ab[i][1]
    c = ab[i][2]

    a -= 1
    b -= 1
    # print(i)
    if colorD[a] == -1:
        if colorU[a] == 1:
            thiscolor = 2
        else:
            thiscolor = 1
    else:
        thiscolor = colorD[a] + 1
        if thiscolor == colorU[a]: #1本目以外
            thiscolor += 1

    colorU[b] = thiscolor
    colorD[a] = thiscolor
    ans[c] = thiscolor
    # print(i)
    # print(thiscolor, i)

print(max(ans))
for i in ans:
    print(i)

# i = 0
# j = 0
# lasta = 0
#
# for l in range(n):
#     a, b = map(int, input().split())
#     if a != lasta:
#         i = a - 1
#         j = 0
#
#     if j == 0:
#         thiscolor = color[i] + 1
#     else:
#         thiscolor = graf[a][j - 1] + 1
#
#     graf[i].append()

Measured memory_bytes: 69936
#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 REP(i,n) for(int i=(0);i<(n);i++)
#define qwq(x) cerr<<"# "<<#x<<" = "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long u64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int T=20,S=(2<<T)+5,N=105,mod=998244353;
int f[S],g[N][N],h[N],a[N],n;
unordered_map<u64,int> F;
char s[N];

int fix(int x){
	return x>=mod?x-mod:x;
}

int solve(u64 s,int n){
	if(n<=1)return (s&1)+1;
	if(n<=T&&f[s|(1<<n)])return f[s|(1<<n)];
	if(n>T&&F.count(s|(1ll<<n)))return F[s|(1ll<<n)];	
	int res=solve(s>>1,n-1);
	if(s&1)res=fix(res+res);
	int suf[n+1];
	fill(suf,suf+n+1,-1);
	rep(len,1,n/2){
		u64 st=(1ll<<len)-1,las=-1; int ans=0;
		for(int p=0,k=1;p+len<=n;p+=len,k++){
			st&=s>>p;
			if(k>=2){
				if(st!=las)ans=solve(st,len);
				if(suf[p+len]==-1)
					suf[p+len]=solve(s>>(p+len),n-p-len);
				las=st,res=(res+(ll)ans*suf[p+len])%mod;
			}
		}
	}
	if(n<=T)f[s|(1<<n)]=res;
	else F[s|(1ll<<n)]=res;
	return res;
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n)a[i]=s[i]-'0',g[i][i]=a[i]+1;
	rep(len,1,n/2)
		rep(l,1,n-2*len+1){
			u64 full=(1ll<<len)-1,st=(1ll<<len)-1,las=-1; int ans=0;
			for(int p=l,k=1;p+len<=n+1;p+=len,k++){
				REP(i,len)st&=full-(1ll<<i)+((1ll*a[p+i])<<i);
				if(k>=2){
					if(st!=las)ans=solve(st,len);
					las=st,g[l][p+len-1]=fix(g[l][p+len-1]+ans);
				}
			}
		}
	h[0]=1;
	rep(i,1,n)rep(j,0,i-1)
		h[i]=(h[i]+(ll)h[j]*g[j+1][i])%mod;
	cout<<h[n]<<endl;
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <algorithm>
#define N 1000
using namespace std;

int lcs(string S1,string S2){
	int c[N+1][N+1];
	int S1_size = S1.size();
	int S2_size = S2.size();
	
	for(int i=1;i<S1_size;i++) c[i][0] = 0;
	for(int i=1;i<S2_size;i++) c[0][i] = 0;
	
	S1 = ' '+S1;
	S2 = ' '+S2;
	
	int max_lcs=0;
	for(int j=1;j<=S1_size;j++){
		for(int k=1;k<=S2_size;k++){
			if(S1[j]==S2[k]){
				c[j][k] = c[j-1][k-1] + 1;
			}else{
				c[j][k] = max(c[j-1][k],c[j][k-1]);
			}
			max_lcs = max(max_lcs,c[j][k]);
		}
	}
	return max_lcs;
}

int main() {
	// your code goes here
	int q;
	string str1,str2;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>str1>>str2;
		cout<<lcs(str1,str2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int i,n,s;
 s=0;
 cin >> n;
 int b[n-1];
 for(i=0;i<n;i++)
 cin >> b[i];
 s=b[0]+b[n-2];
 for(i=0;i<(n-2);i++)
 s+=min(b[i],b[i+1]);
 cout << s;
 return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_BIT = (int)(5e3 + 5);

int n, m;

vector<ll> as;
vector<int> cs;

ll memo[MAX_BIT];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    ll a;
    int b;
    scanf("%lld %d", &a, &b);
    as.push_back(a);

    int empty_bit = 0;
    cs.push_back(empty_bit);

    for (int j = 0; j < b; ++j) {
      int c;
      scanf("%d", &c);

      cs.back() |= (1 << (c - 1));
    }
  }

  for (int i = 0; i < MAX_BIT; ++i) {
    memo[i] = INF;
  }

  int empty_bit = 0;
  memo[empty_bit] = 0L;

  for (int b = 0; b < (1 << n); ++b) {
    if (memo[b] == INF) continue;

    for (int i = 0; i < cs.size(); ++i) {
      int new_bit = b;

      new_bit |= cs[i];

      memo[new_bit] = min(memo[new_bit], memo[b] + as[i]);
    }
  }

  // for (int b = 0; b < (1 << n); ++b) {
  //   printf("bit: %d, %lld\n", b, memo[b]);
  // }

  int key = 0;
  for (int i = 0; i < n; ++i) {
    key |= (1 << i);
  }

  if (memo[key] == INF) {
    printf("%lld\n", -1L);
  } else {
    printf("%lld\n", memo[key]);
  }

  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n : i32 = n.trim().parse().unwrap();

    let mut res = 1;
    if n > 63 {
        res = 64;
    } else if n > 31 {
        res = 32;
    } else if n > 15 {
        res = 16;
    } else if n > 7 {
        res = 8;
    } else if n > 3 {
        res = 4;
    } else if n > 1 {
        res = 2;
    }

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


Measured memory_bytes: 4352
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
string a, b;
int main()
{
	cin >> a >> b;
	if(a.length() > b.length())
		printf("GREATER\n");
	else if(a.length() < b.length())
		printf("LESS\n");
	else
	{
		if(a > b)		
			printf("GREATER\n");
		if(a < b)
			printf("LESS\n");
		if(a == b)
			printf("EQUAL\n");
	}
	return 0;	
}

Measured memory_bytes: 768
def cnct(lint,lim):
    global list753
    global list357
    global list333
    lint1int=lint*10+3
    if lint1int<=lim and not lint1int in list357:
        list357.add(lint1int)
        cnct(lint1int,lim)
    lint2int=lint*10+5
    if lint2int<=lim and not lint2int in list357:
        list357.add(lint2int)
        cnct(lint2int,lim)
    lint3int=lint*10+7
    if lint3int<=lim and not lint3int in list357:
        list357.add(lint3int)
        cnct(lint3int,lim) 

def D(lint):
    lista=list(str(lint))
    if lista.count("3") and lista.count("5") and lista.count("7"):
        return True
    else:
        return False

list753=[3,5,7]
list357=set()
k=int(input())
for b in list753:
    cnct(b,k)
for c in [x for x in list357]:
    if not D(c):
        list357.remove(c)
print(len(list357))

Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	vector<int> num(999, 0);
	num[0] = 1;
	for (int i = 1; i < 999; i++) {
		num[i] = num[i - 1] + (i + 1);
	}
	int a, b,sub;
	cin >> a >> b;
	sub = b - a;
	for (int i = 1; i < 999; i++) {
		if (sub == (num[i] - num[i - 1])) {
			cout << num[i - 1]-a << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
S = list(input())
S_reverse1 = list(reversed(S))

flag = 0
if S == S_reverse1:
  flag += 1

S_reverse2 = list(reversed(S[: (len(S) - 1) // 2]))
S_reverse3 = list(reversed(S[(len(S) + 1) // 2 :]))

if S_reverse2 == S[: (len(S) - 1) // 2] and S_reverse3 == S[(len(S) + 1) // 2 :]:
  flag += 1
  
if flag == 2:
  print('Yes')
else:
  print('No')

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

using namespace std; 

#define N 1000000

long long a[N + 2]; 
long long l[N + 2];
long long r[N + 2];  


long long gcd(long long a, long long b) {

	if(b == 0) {
		return a; 
	}

	else {
		return gcd(b, a%b); 
	}

}

int main() {

	int n; 
	cin >> n; 

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

	for(int i = 1; i <= n; i++) {
		l[i] = gcd(a[i], l[i - 1]); 
	}

	for(int i = n; i >= 1; i--) {
		r[i] = gcd(a[i], r[i + 1]); 
	}

	long long maxGCD = 0; 

	for(int i = 1; i <= n; i++) {
		long long curr = gcd(l[i - 1], r[i + 1]); 
		maxGCD = maxGCD > curr? maxGCD : curr; 
	}

	cout << maxGCD << endl; 

	return 0; 
}

Measured memory_bytes: 9216
// abc102_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> cumsum(N+1);
    REP(i, N){
        cumsum[i+1] = cumsum[i] + A[i];
    }

//    print(A);
//    print(cumsum);

    ll ans = 1e15;
    REPN(m, 1, N-2){ // 0-m, m+1-N
//        print(m);
        ll l_sum = cumsum[m+1] - cumsum[0];
        auto l_it = lower_bound(cumsum.begin(), cumsum.begin() + m + 1 + 1, l_sum/2);
        ll p = *l_it - cumsum[0];
        ll q = l_sum - p;
        if (l_it != cumsum.begin()){
            ll p2 = *(--l_it) - cumsum[0];
            ll q2 = l_sum - p2;
            if (abs(p2-q2) < abs(p-q)) p=p2,q=q2;
        }

//        print("l", l_sum, l_it-cumsum.begin(), p, q);

        ll r_sum = cumsum[N] - cumsum[m+1];
        auto r_it = lower_bound(cumsum.begin()+m+1+1, cumsum.end(), l_sum + r_sum/2);
        ll s = *r_it - cumsum[m+1];
        ll t = r_sum - s;
        if (r_it != cumsum.begin()+m+1+1){
            ll s2 = *(--r_it) - cumsum[m+1];
            ll t2 = r_sum - s2;
            if (abs(s2-t2) < abs(s-t)) s=s2,t=t2;
        }

//        print("r", r_sum, r_it-cumsum.begin(), s, t);

        ll mn = min(min(p, q), min(s, t));
        ll mx = max(max(p, q), max(s, t));
        ans = min(ans, mx-mn);
    }

    print(ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);

    rep(i,n){
        cin>>v[i];
    }
    Vec w = v;
    sort(ALL(w));
    ll max = w[n-1];
    ll second = w[n-2];
    rep(i,n){
        if(v[i]==max){
            cout<<second<<endl;
        }else{
            cout<<max<<endl;
        }
    }
    return  0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	
	int N;
	int s[100];
	
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++){
		scanf("%d", &s[i]);
	}
	
	sort(s, s+N);
	int MAX = 0;
	
	for(int i = 0; i < N; i++){
		MAX += s[i];
	}
	
	if(MAX % 10 == 0){
		for(int i = 0; i < N; i++){
			if((MAX - s[i]) % 10 != 0){
				MAX -= s[i];
				break;
			}
			if(i == N - 1){
				break;
			}
		}
	}
	
	if(MAX % 10 == 0){
		printf("0\n");
	}
	else{
		printf("%d\n", MAX);
	}
	
	return 0;
}

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


int main() {
  vector<int> x(5);
  rep(i,5) cin >> x.at(i);
  rep(i,5){
    if(x.at(i)==0){
      cout << i+1 << endl;
    }
  }
  return 0;
}

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

#define vi vector<int>

int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;

    map<char, int> ctoi;
    map<int, char> itoc;
    int itr = 0;
    for (char c='A'; c<='Z'; c++) {
        ctoi[c] = itr;
        itoc[itr] = c;
        itr++;
    }

    for (int i = 0; i < S.length(); i++) {
        cout << itoc[(ctoi[S[i]] + N) % 26];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int N,A,B;

int main()
{
	scanf("%d%d%d",&N,&A,&B);
	if((B - A) % 2 == 1)
		printf("Borys\n");
	else
		printf("Alice\n");
	return 0;
} 

Measured memory_bytes: 256
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, K, A):
    import math
    max_K = 0
    for i in reversed(list(range(int(math.log2(K + 1)) + 1))):
        cnt = 0
        for a in A:
            if a >> i & 1:
                cnt += 1
        if cnt <= N // 2:
            if max_K + (1 << i) <= K:
                max_K += 1 << i
    ans = 0
    for a in A:
        ans += a ^ max_K
    print(ans)



if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    solve(N, K, A)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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

ll n,m,k;
string s;
int main() {
    INIT();
    unordered_map<string, ll> ma;
    cin >> n;
    ma["AC"] = 0;
    ma["WA"] = 0;
    ma["TLE"] = 0;
    ma["RE"] = 0;
    REP(i,n) {
        cin >> s;
        ma[s]++;
    }
    cout << "AC x " << ma["AC"] << endl;
    cout << "WA x " << ma["WA"] << endl;
    cout << "TLE x " << ma["TLE"] << endl;
    cout << "RE x " << ma["RE"];
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	vi a(9);

	for(;;)
	{
		for(int y=0;y<3;y++)
		{
			for(int x=0;x<3;x++) if(scanf("%d", &a[y*3+x])!=1) return 0;
		}
		int n;
		scanf("%d", &n);
		vi b(n);
		for(auto&m:b) scanf("%d", &m);

		vector<bool> f(9);
		for(auto m:b)
		{
			for(int i=0;i<9;i++) if(a[i]==m) f[i]=true;
		}

		bool ans=false;
		for(int y=0;y<3;y++)
		{
			int c=0;
			for(int x=0;x<3;x++) if(f[y*3+x]) c++;
			if(c>=3) ans=true;
		}
		for(int x=0;x<3;x++)
		{
			int c=0;
			for(int y=0;y<3;y++) if(f[y*3+x]) c++;
			if(c>=3) ans=true;
		}
		{
			int c=0;
			for(int i=0;i<3;i++) if(f[i*3+i]) c++;
			if(c>=3) ans=true;
		}
		{
			int c=0;
			for(int i=0;i<3;i++) if(f[i*3+2-i]) c++;
			if(c>=3) ans=true;
		}
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define dls 1000000007
using namespace std;
int main(int argc, char** argv) {
	long long ans=0,n,k;
	cin >> n >> k;
	for(long long i=k;i<=n+1;i++)
	{
		long long l=i*(i-1)/2,r=n*(n+1)/2-(n-i)*(n-i+1)/2;
	//	cout << l << " " << r << "\n";
		ans+=r-l+1,ans%=dls;
	}
	cout << ans;
	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)){
    cout << "Left" << endl;
  }
  else if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else 
    cout << "Right" << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc126/tasks/abc126_a

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;

    s[k-1] = tolower(s[k-1]);
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long n,m;
	bool b;
	while(scanf("%lld%lld",&n,&m)!=-1)
	{
		b=0;
		if(n%m==0)printf("-1\n");
		else {
			for(int i=1;i<=m;i++)
		  {
		    	n*=i;
			  if(n%m!=0)
			  {
			      b=1;
				  break;	
			  }
		  }
		  if(b==1&&n<pow(10,18))printf("%lld\n",n);
		  else printf("-1\n");
		}
	}
}

Measured memory_bytes: 128
import fractions
import functools
import sys

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)
"""
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
"""
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

lcm_A = functools.reduce(lcm_base, A, 1)
B = [None]*N
B = [lcm_A//a for a in A]
#B[i] = lcm_A//A[i]

print(sum(B)%(10**9+7))

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

int main() {
  int N, A;
  int m;
  
  cin >> N >> A;
  
  m = N % 500;
  
  if(m <= A){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char s[MAXN];

vi vv;
vector<pair<ll, ll> > vv1;

void solve(){
	int n, k;
	scanf("%s%d", &s[0], &k);
	n = strlen(s);
	for(int i = 0; i < n; ) {
		int r;
		for(r = i; s[r] == s[i]; r++);
		vv.pb(r - i);
		i = r;
	}
	if (SZ(vv) == 1) {
		vv1.pb(mp((ll)n * (ll)k, 1ll));
	} else {
		if (s[0] == s[n - 1]) {
			REP(i, 1, SZ(vv) - 1) {
				vv1.pb(mp(vv[i], k));
			}
			vv1.pb(mp(vv[0], 1));
			vv1.pb(mp(vv[SZ(vv) - 1], 1));
			vv1.pb(mp(vv[0] + vv[SZ(vv) - 1], k - 1));
		} else {
			REP(i, 0, SZ(vv)) {
				vv1.pb(mp(vv[i], k));
			}
		}
	}
	ll ans = 0ll;
	REP(i, 0, SZ(vv1)) {
		ans += vv1[i]._1 / 2 * vv1[i]._2;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(){
    string s;
    cin >> s;
    bool a=false,b=false;
    for(int i = 0; i < s.size();i++){
        if(s[i] == 'A'){
            a = true;
        }
        if(s[i]=='B'){
            b = true;
        }
    }
    if(a == true && b == true){
        puts("Yes");
    }
    else{
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 256
a,b,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ans=min(x)+min(y)
for i in range(m):
  q,w,e=map(int,input().split())
  ans=min(ans,x[q-1]+y[w-1]-e)
print(ans)

Measured memory_bytes: 18612
require 'set'
def f(a, c, n)
    g = group(a, 0, 0)
    return g.size if n == 0

    max = 0
    (n == 1 ? [c] : (1..6).to_a - [a[0][0]]).each do |k|
        b = (0..a.size-1).map do |i|
            (0..a[0].size-1).map do |j|
                g.include?([i, j]) ? k : a[i][j]
            end
        end
        m = f(b, c, n-1)
        max = m if m > max
    end
    max
end

def group(a, i, j)
    reached = Set[[i, j]]
    stack = [[i, j]]
    until stack.empty?
        y, x = stack.pop
        [[1, 0], [-1, 0], [0, 1], [0, -1]].each do |dy, dx|
            v, u = y + dy, x + dx
            next if v < 0 || v >= a.size || u < 0 || u >= a[0].size
            next if a[v][u] != a[i][j]
            pos = [v, u]
            next if reached.include?(pos)
            reached << pos
            stack << pos
        end
    end
    reached
end

loop do
    h, w, c = gets.split.map(&:to_i)
    break if h == 0
    a = (1..h).map { gets.split.map(&:to_i) }
    p f(a, c, 5)
end

Measured memory_bytes: 9332
N = int(input())
Z = list(map(int, input().split()))
Z.sort(reverse=True)
A = sum([Z[i] if i % 2 == 0 else 0 for i in range(N)])
B = sum([Z[i] if i % 2 == 1 else 0 for i in range(N)])
print(A-B)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int n; cin>>n;
	vector<int> ans(10050, 0);
	forr(i, 1, 105)
		forr(j, 1, 105)
			forr(k, 1, 105){
				int v = i * i + j * j + k * k + i * j + i * k + j * k;
				if(v < 10050)
					ans[v]++;
			}
	rep(i, n)
		cout<<ans[i + 1]<<endl;
}
	


Measured memory_bytes: 3580
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = input().rstrip()

ans = ""
for n in N:
    if n == "1":
        ans += "9"
    elif n == "9":
        ans += "1"
    else:
        ans += n

print(ans)

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

using namespace std;

constexpr int MOD = (int)1e9 + 7;

long long fac(int n){
  long long tempAns = 1;
  for(int i = 1; i <= n; ++i){
    tempAns = tempAns * i % MOD;
  }
  return tempAns;
}

int main(){
  int n, m;
  scanf("%d%d", &n, &m);
  if(n < m){
    swap(n, m);
  }
  if(n - m >= 2){
    puts("0");
  }
  else{
    if(n == m){
      cout << 2 * fac(n) * fac(m) % MOD;
    }
    else{
      cout << fac(n) * fac(m) % MOD;
    }
  }
  return 0;
}


Measured memory_bytes: 256
class MIGI_HIDARI():

    def __init__(self,up,down,ue,shita,migi,hidari,value):
        self.up = up
        self.down = down
        self.ue = ue
        self.shita = shita
        self.migi = migi
        self.hidari = hidari
        self.value = value

    def MIGI(self):
        self.value = self.up
        self.up = self.hidari
        self.hidari = self.down
        self.down = self.migi
        self.migi = self.value


    def SHITA(self):
        self.value = self.up
        self.up = self.ue
        self.ue = self.down
        self.down = self.shita
        self.shita = self.value

    def HIDARI(self):
        self.value = self.up
        self.up = self.migi
        self.migi = self.down
        self.down = self.hidari
        self.hidari = self.value

    def UE(self):
        self.value = self.up
        self.up = self.shita
        self.shita = self.down
        self.down = self.ue
        self.ue = self.value

nums = input().rstrip().split(' ')

up = int(nums[0])
shita = int(nums[1])
migi = int(nums[2])
hidari = int(nums[3])
ue = int(nums[4])
down = int(nums[5])
value = ue

EWSN = list(input())

migi_hidari = MIGI_HIDARI(up,down,ue,shita,migi,hidari,value)

for i in EWSN:
    if i =="E":
        migi_hidari.MIGI()
    elif i =="W":
        migi_hidari.HIDARI()
    elif i =="S":
        migi_hidari.SHITA()
    else:
        migi_hidari.UE()
print(migi_hidari.up)



Measured memory_bytes: 5608
#include <iostream>
#include <iomanip>
#include <complex>
using namespace std;
using C = complex<double>;

C proj(C a, C b){
  return a * (conj(a)*b).real() / norm(a);  // ベクトルaにbを投影する。
}

int main(){
  double x[2], y[2], xq, yq;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", x, y, x+1, y+1, &xq, &yq) != EOF){
    C P1(x[0], y[0]), P2(x[1], y[1]), Q(xq, yq);
    C M = proj(P2-P1, Q-P1) + P1, R = (M - Q) * 2.0 + Q;
    cout << fixed << setprecision(6) << R.real() << " " << R.imag() << endl;
  }
}


Measured memory_bytes: 3200
import sys
from collections import deque
n,m = map(int,sys.stdin.readline().split())
vertices = [[] for _ in range(n+1)]
jumpValue = [[-1,-1,-1] for _ in range(n+1)]
queue = []
def bfs(arr,jump):
    for node in arr:
        if jumpValue[node][(jump+1)%3]==-1:
            queue.append([node,jump+1])
for i in range(m):
    a,b = map(int,sys.stdin.readline().split())
    vertices[a].append(b)
s,t = map(int,sys.stdin.readline().split())
queue=deque()
queue.append([s,0])
while(len(queue)>0 ):
    next=queue.popleft()
    if jumpValue[next[0]][next[1]%3] == -1:
        jumpValue[next[0]][next[1]%3] = next[1]
        bfs(vertices[next[0]], next[1])
        if jumpValue[t][0]!=-1:
            break
print(max(jumpValue[t][0]//3,-1))

Measured memory_bytes: 73068
N, M = map(int, input().split())
H = list(map(int, input().split()))

graph = [[] for _ in range(N)]

for query in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0

for now in range(N):
    good = True
    for neighbor in graph[now]:
        if H[now] <= H[neighbor]:
            good = False
    if good:
        ans += 1
        #print(now)

print(ans)

Measured memory_bytes: 29436