akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  int f=0;
  for(int i=0;i<s.size();i++){
    if(i<a){
      if(!('0'<=s[i]&&s[i]<='9'))f=1;
    }else if(i==a){
      if(s[i]!='-')f=1;
    }else {
if(!('0'<=s[i]&&s[i]<='9'))f=1;
    }
  }
  if(f==1||a+b+1!=s.size())cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

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

using namespace std;

const int MAX_H = 20;
const int MAX_W = 20;

// 入力
int W, H;
char field[MAX_H][MAX_W+1]; // ヌル文字を考慮
int startx, starty;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void dfs(int x, int y) {
	field[y][x] = '$';
	for (int i = 0; i < 4; i++) {
		int newX = x + dx[i];
		int newY = y + dy[i];
		if (field[newY][newX] == '.') {
			dfs(newX, newY);
		}
	}
}

int main() {
	while (true) {
		cin >> W >> H;
		if (W == 0) {
			break;
		}
		
		memset(field, 0, sizeof(field));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> field[i][j];
				if (field[i][j] == '@') {
					startx = j;
					starty = i;
				}
			}
		}
		
		dfs(startx, starty);
		
		int ans = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (field[i][j] == '$') {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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


int main() {
    int r,g,b,n;
    long long cnt = 0;
    cin >> r >> g >> b >> n;
    for(int i = 0 ; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int x = n - i*r - j*g;
            if(x % b == 0 & x / b <= n && x >= 0){
                cnt++;
                //cout << i << " " << j << " " << x/b << endl;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int sum(int n){
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /=10;
    }
    return sum;
    
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    for(int i = 1; i <= n; i++){
        int s = sum(i);
        if(s >= a && s <= b) total += i;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3508
import java.util.*;
class Main{
	public static void main(String[] args){
		
		int a,b,d,r;//int型変数定義
		double f;//不動小数点用変数定義
		
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		
		if(1 <= a && a <= Math.pow(10,9)){//条件 1<=a,b<=10の９乗
			d = a / b;//a÷bあまりなし
			r = a % b;//a÷bあまり
			f = (double)a/b;//a÷b小数表示
			System.out.printf(d + " " + r + " " + "%f",(double)f);
		}
		
	
	}
	
}

Measured memory_bytes: 17384
n=int(input())
d={'S':0,'H':0,'C':0,'D':0}
for _ in range(n):
  a,b=input().split()
  d[a]+=1<<(int(b)-1)
for k,v in d.items():
  for i in range(13):
    if (v&(1<<i))==0:
      print(k,i+1)


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

int main() {
  int k,a,b;
  cin >>k>>a>>b;
  bool can=false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      can=true;
      break;
    }
  }
  if(can){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" <<endl;
  }
}
  

  


Measured memory_bytes: 3624
MOD = 1000000007


def cal(a, n):
    if n == 1:
        return a
    if n % 2 == 0:
        return (cal(a, n // 2) % MOD) ** 2 % MOD
    else:
        return (cal(a, n - 1) % MOD) * a % MOD


def cal_p(n, r):
    res = 1
    for i in range(r):
        res = res * (n - i) % MOD

    return res


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

all = cal(2, n) - 1
A = cal_p(n, a) * cal(cal_p(a, a), 1000000005) % MOD
B = cal_p(n, b) * cal(cal_p(b, b), 1000000005) % MOD

print((all - A - B) % MOD)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int op[N], num[N]; LL dp[N][3]; char s[5];
int main() {
	int n; scanf("%d%d", &n, &num[1]), op[1] = 1;
	for (int i = 2; i <= n; i++) {
		scanf("%s%d", s + 1, &num[i]);
		if (s[1] == '-') op[i] = -1; else op[i] = 1;
	}
	memset(dp, -0x3f, sizeof(dp)), dp[1][0] = num[1];
	for (int i = 2; i <= n; i++) {
		dp[i][1] = dp[i - 1][1] - op[i] * num[i];
		dp[i][0] = dp[i - 1][0] + op[i] * num[i];
		dp[i][2] = dp[i - 1][2] + op[i] * num[i];
		if (op[i - 1] == -1) {
			dp[i][1] = max(dp[i][1], dp[i - 1][0] - op[i] * num[i]);
			dp[i][2] = max(dp[i][2], dp[i - 1][1] + op[i] * num[i]);
		}
		dp[i][1] = max(dp[i][1], dp[i][2]);
		dp[i][0] = max(dp[i][0], dp[i][1]);
	}
	printf("%lld\n", dp[n][0]);
}

Measured memory_bytes: 3328
import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(in);
		
		try {
			String str = reader.readLine();
			int N = Integer.parseInt(str);
			
			int sum_so = 0;
			
			if(N < 105) {
				System.out.println(0);
			} else {
				for(int i = 0; (i + 105) <= N; i +=2) {
					double kisu = i + 105;
					int count3 = 0;
					int count5 = 0;
					int count7 = 0;
					int count11 = 0;
					int count13 = 0;
					int sum = 0;
					
					while((kisu % 3) == 0) {
						count3++;
						kisu /= 3;
					}
					while((kisu % 5) == 0) {
						count5++;
						kisu /= 5;
					}
					while((kisu % 7) == 0) {
						count7++;
						kisu /= 7;
					}
					while((kisu % 11) == 0) {
						count11++;
						kisu /= 11;
					}
					while((kisu % 13) == 0) {
						count13++;
						kisu /= 13;
					}
					sum = (count3 + 1) * (count5 + 1) * (count7 + 1) * (count11 + 1) * (count13 + 1);
					if(sum == 8) {
						sum_so++;
					}
					
				}
				System.out.println(sum_so);
			}
			
		} catch(IOException e) {
			System.out.println(e);
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) x.begin(),x.end()
#define len(x) (int)(x).size()
//#define endl "\n"
#define m_p make_pair
#define int long long


using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ld,ld> pari;

ld PI = 3.14159265358979323846;


struct Point{
    string a;
    int x,ind;
};

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

void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cout << fixed;
}


int n,k;
const int N = 1e6+7;
const int alphabet = 256;
const int INF = 1e18;
const ll MOD = 1e9+7;
const ld eps = 1e-10;
const int L = 30;

int m1 = 137*137*137*137*13;
int m2 = 1e9+9;
//int p = 347;

int mas[N];

void input(){
    cin >> n >> k;
    for(int i = 0;i < n;i++)
        cin >> mas[i];
}

int used[100][100][101];
int dp[100][100][101];

multiset<int> d;

int DP(int l,int r,int cnt){
    if(cnt == 0 || l > r)
        return 0;
    if(!used[l][r][cnt]){

        int m = 0;
        
        int sum = 0;
        int c = 0;
        for(auto i : d){
            sum -= i;
            c++;
            if(c == cnt) break;
        }
        m = max(m,sum);

        if(mas[l] < 0) d.insert(mas[l]);
        m = max(m,DP(l+1,r,cnt-1)+mas[l]);
        if(mas[l] < 0) d.erase(d.find(mas[l]));

        if(mas[r] < 0) d.insert(mas[r]);
        m = max(m,DP(l,r-1,cnt-1)+mas[r]);
        if(mas[r] < 0) d.erase(d.find(mas[r]));

        dp[l][r][cnt] = m;
        used[l][r][cnt] = 1;
        //cout << l << ' ' << ' ' << r << ' ' << dp[l][r][cnt] << endl;
    }
    return dp[l][r][cnt];
}

void solve(){
    cout << DP(0,n-1,k);
}

signed main(){
    volodya22();
    input();
    solve();
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a[300]={0};
    for(int i=0;i<s.length();i++)
        a[s[i]]++;
    for(int i=0;i<300;i++)
        if(a[i]>1)
    {
      cout<<"no";
      return 0;
    }
        cout<<"yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
    if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
    if (a < b) a = b;
}
using Int = long long;
const char newl = '\n';

template <class F>
struct y_combinator {
    F f;
    template <class... Args>
    decltype(auto) operator()(Args&&... args) const {
        return f(std::ref(*this), std::forward<Args>(args)...);
    }
};

template <class F>
inline decltype(auto) Y(F&& f) {
    return y_combinator<F>{std::forward<F>(f)};
}


// INSERT ABOVE HERE
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    vector<int> cs(n);
    for (int i = 0; i < n; i++) cin >> cs[i], cs[i]--;

    vector<vector<int>> G(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    using ll = long long;
    ll all = 0;
    vector<ll> cnt(n, 0), sub(n, 0);

    vector<ll> ans(n, (ll)n * (n - 1) / 2);
    Y([&](auto dfs, int v, int p) -> int {
        sub[v] = 1;
        ll bfr = cnt[cs[v]];
        for (int u : G[v]) {
            if (u == p) continue;
            ll pre = all - cnt[cs[v]];
            sub[v] += dfs(u, v);
            ll nxt = all - cnt[cs[v]];
            ans[cs[v]] -= (nxt - pre) * (nxt - pre - 1) / 2;
        }
        cnt[cs[v]] = bfr + sub[v];
        all++;
        return sub[v];
    })
    (0, -1);

    for (int c = 0; c < n; c++) {
        ll pre = 0, nxt = n - cnt[c];
        ans[c] -= (nxt - pre) * (nxt - pre - 1) / 2;
    }
    for (int c : cs) ans[c]++;

    for (ll a : ans) cout << a << newl;
    return 0;
}


Measured memory_bytes: 38236
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

a = str(input())

if a.upper() == a:
    print('A')
else:
    print('a')

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

int main(){
  int n, s = 0;
  cin >> n;
  int p = n;

  while(p > 0){
    s += p % 10;
    p /= 10;
  }
  if(n % s == 0) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from scipy.special import comb
N, P = map(int, input().split())
A = list(map(int, input().split()))
MAX_C = 100

# def comb_dp():
#     """
#     dpテーブルを作ってnCkを計算.
#     modのpは素数でなくてよい.
#     1 <= k <= n <= 2000程度
#     O(MAX_C ** 2).
#     """
#     Com = [[0]*MAX_C for _ in range(MAX_C)]
#     for i in range(1, MAX_C):
#         # iC0 = 1
#         Com[i][0] = 1
#         for j in range(1, MAX_C):
#             # iCj = i-1_C_j-1 + i-1_C_j mod p
#             Com[i][j] = (Com[i-1][j-1] + Com[i-1][j])
        
#     return Com
# Com = comb_dp()
# print(Com[2][1])
# print(Com[2][2])
if P == 0:
    is_even = [A[i]%2==0 for i in range(N)]
    num_e = is_even.count(True)
    num_o = N-num_e
    tmp1 = 0
    tmp2 = 0
    for i in range(0, num_e+1):
        tmp1 += comb(num_e, i, exact=True)
    for i in range(0, num_o+1, 2):
        tmp2 += comb(num_o, i, exact=True)
    print(tmp1*tmp2)
else:
    is_even = [A[i]%2==0 for i in range(N)]
    num_e = is_even.count(True)
    num_o = N-num_e
    tmp1 = 0
    tmp2 = 0
    for i in range(0, num_e+1):
        tmp1 += comb(num_e, i, exact=True)
    for i in range(1, num_o+1, 2):
        tmp2 += comb(num_o, i, exact=True)
    print(tmp1*tmp2)


Measured memory_bytes: 42136
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/

int main(){
    char str[200000];
    int cnt=0;

    scanf("%s",str);
    for(int i=0;str[i+1]!='\0';i++){
        if(str[i]!=str[i+1]){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
struct node{
	ll pos,val;
}xx[300050],yy[300050];
bool cmp(node a,node b){
	return a.val>b.val;
}
map<pair<ll,ll>,ll >mp;
void solve(int T){
	ll n,m,t,x,y,maxx,maxy,ans=0;
	scanf("%lld %lld %lld",&n,&m,&t);
	for(int i=1;i<=t;i++){
		scanf("%lld %lld",&x,&y);
		xx[x].val++;
		yy[y].val++;
		mp[make_pair(x,y)]=1;
	}
	for(int i=1;i<=n;i++)xx[i].pos=i;
	for(int i=1;i<=m;i++)yy[i].pos=i;
	sort(xx+1,xx+n+1,cmp);
	sort(yy+1,yy+m+1,cmp);
	maxx=xx[1].val;
	maxy=yy[1].val;
	for(int i=1;i<=n;i++){
		if(xx[i].val!=maxx)break;
		for(int j=1;j<=m;j++){
			if(yy[j].val!=maxy)break;
			if(mp[{xx[i].pos,yy[j].pos}]==1)ans=max(ans,xx[i].val+yy[j].val-1);
			else ans=max(ans,xx[i].val+yy[j].val);
		}
		if(ans==maxx+maxy)break;
	}
	printf("%lld",ans);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

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

int a[2500000];
signed main(){
	int ans=0;
	int n;cin>>n;
	int sum=1;
	a[1]--;
	for(int i=0;i<n-1;i++){
		sum+=a[i];
		sum%=mod;
		ans+=sum*(n-1)%mod*(n-1)%mod;
		ans%=mod;
		a[i+1]+=sum;
		a[i+2]-=sum;
		a[i+3]+=sum;
		a[i+n+2]-=sum;
		a[i+1]%=mod;
		a[i+2]%=mod;
		a[i+3]%=mod;
		a[i+n+2]%=mod;
		}	
	sum+=a[n-1];
	ans+=sum*n;
	ans%=mod;
	for(int i=n;i<n*2+100;i++){
		sum+=a[i];
		ans+=sum;
		ans%=mod;
		}	
	ans+=mod*100ll;
	ans%=mod;	
	cout<<ans<<endl;	
	}


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

int main() {
	int a=0,b=0;
	cin >> a;
	cin >> b;
	
	
	
	if(a==b)cout << "Draw";
else{
  if(a==1){
		cout << "Alice";
	}
  else{
    if(a<b)cout << "Bob";
  }
	
		if(b==1){
		cout << "Bob";	
		}
 else{
   if(a>b)cout << "Alice";
 }
}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] & s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
tree = [[] for i in range(n)]
counter = [0] * n
visited = [False] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
for i in range(q):
    p, x = map(int, input().split())
    counter[p - 1] += x
queue = deque([0])
visited[0] = True
while queue:
    now = queue.pop()
    for j in tree[now]:
        if visited[j]:
            continue
        counter[j] += counter[now]
        visited[j] = True
        queue.append(j)
print(*counter)

Measured memory_bytes: 93844
n = int(input())

count = 0
flag = 0
for i in range(n):
  s,t = map(int, input().split())
  if s==t and flag == 0:
    flag = 1
  elif s==t and flag > 0:
    flag = flag+1
    if flag == 3:
      print("Yes")
      exit()
  else:
    flag = 0   
print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

// すべて0-indexed
// n := |S| とする。
// s[i,j] := sの[i,j]の範囲の連続部分文字列とする。このとき、
// s[0, n-1](= s)とs[i, n-1]の最長共通接頭辞の長さを記録した配列を返す。
// 計算量はO(|S|)
vector<int> z_algo(const string &s) {
    int c = 0, n = s.size();
    vector<int> z(n, 0);
    for(int i = 1; i < n; i++) {
        if(i + z[i - c] < c + z[c]) {
            z[i] = z[i - c];
        } else {
            int j = max(0, c + z[c] - i);
            while(i + j < n && s[j] == s[i + j]) {
                j++;
            }
            z[i] = j;
            c = i;
        }
    }
    z[0] = n;
    return z;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();
    string u = s;
    while(u.size() < (ns + nt)) {
        u += s;
    }
    string c = t + "#" + u;
    auto z = z_algo(c);
    vector<vector<int>> g(ns);
    vector<int> h(ns, 0);
    for(int i = 0; i < ns; i++) {
        int j = i + nt + 1;
        if(z[j] == nt) {
            int to = (i + nt) % ns;
            h[to]++;
            g[i].emplace_back(to);
        }
    }
    stack<int> st;
    for(int i = 0; i < ns; i++) {
        if(h[i] == 0) {
            st.push(i);
        }
    }
    vector<int> topo;
    while(st.size()) {
        int v = st.top();
        st.pop();
        topo.emplace_back(v);
        for(auto &u : g[v]) {
            h[u]--;
            if(h[u] == 0) {
                st.push(u);
            }
        }
    }
    if(topo.size() != ns) {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    vector<int> dp(ns, 0);
    for(int v : topo) {
        chmax(ans, dp[v]);
        for(int u : g[v]) {
            chmax(dp[u], dp[v] + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 41756
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

void solve(){
    string s;
    cin >> s;
    bool flag = true;
    if(s.length() == 6){
        for(int i = 0;i < s.length();i++){
            if(!(s[i] >= 'a' && s[i] <= 'z')){
                cout << "No" << '\n';
                flag = false;
                break;
            }
        }
        if(flag && s[2] == s[3] && s[4] == s[5]){
            cout << "Yes" << '\n';
        }else{
            cout << "No" << '\n';
        }
    }
    else{
        cout << "No" << '\n';
    }
}

int main(){
    solve();
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s; cin >> s;

    if(s.at(k-1)=='A'){
        s.at(k-1) = 'a';
    }
    else if(s.at(k-1)=='B'){
        s.at(k-1) = 'b';
    }
    else{
        s.at(k-1) = 'c';
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, A, B; cin >> N >> A >> B;
    int ans = 0;
    REP(i, N + 1)if (i % 10 + i % 100 / 10 + i % 1000 / 100 + i % 10000 / 1000 + i / 10000 >= A && i % 10 + i % 100 / 10 + i % 1000 / 100 + i % 10000 / 1000 + i / 10000 <= B)ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_2_D {
    class Problem {
        private List<int> _nums, _intervalList;
        private int _len, _cnt;

        public Problem(List<int> nums, int len) {
            _nums = nums;
            _len = len;
        }

        public void Run() {
            ShellSort();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(_intervalList.Count.ToString());
            sb.AppendLine(ListToString(_intervalList));
            sb.AppendLine(_cnt.ToString());
            _nums.ForEach(n => sb.AppendLine(n.ToString()));
            Console.Write(sb);
        }

        private void ShellSort() {
            _cnt = 0;
            MakeIntervalList();
            _intervalList.ForEach(n => InsertionSort(n));
        }

        private void InsertionSort(int g) {
            for (int i = g; i < _len; i++) {
                int v = _nums[i];
                int j = i - g;
                while (j >= 0 && _nums[j] > v) {
                    _nums[j + g] = _nums[j];
                    j -= g;
                    _cnt++;
                }
                _nums[j + g] = v;
            }
        }

        private void MakeIntervalList() {
            _intervalList = new List<int>();
            for (int h = 1; h <= _len; h = 3 * h + 1) {
                _intervalList.Insert(0, h);
            }
        }

        private string ListToString(List<int> list) {
            StringBuilder sb = new StringBuilder();
            list.ForEach(n => sb.AppendFormat(" {0}", n));
            return sb.ToString().TrimStart();
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            List<int> A = new List<int>();
            for(int i = 0; i < n; i++) {
                A.Add(int.Parse(Console.ReadLine()));
            }

            Problem p = new Problem(A, n);
            p.Run();
        }
    }
}

Measured memory_bytes: 80964
n, q = map(int, input().split())
ki = [[] for i in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1
  b-=1
  ki[a].append(b)
  ki[b].append(a)
  
ans=[0]*n
vis=[False]*n

for i in range(q):
  p, x = map(int, input().split())
  p-=1
  ans[p]+=x

import queue
q = queue.Queue()
q.put(0)

while not q.empty():
  temp = q.get()
  vis[temp]=True
  for next in ki[temp]:
    if not vis[next]:
      ans[next]+=ans[temp]
      q.put(next)
ans = list(map(str, ans))
print(" ".join(ans))
    

Measured memory_bytes: 69536
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    string S;
    cin >> S;

    int m = stoi(S.substr(5, 2));
    if (m >= 5)
        cout << "TBD" << endl;
    else
        cout << "Heisei" << endl;

    return 0;
}


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



int main(){
  int d , t, s;
  cin >> d >> t >> s;
  if(d>t*s) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3620
X = list(input())

count_S = 0
count_T = 0
TS_max = 0

for i in range(len(X)):
    if X[i] == 'S':
        count_S += 1
    elif X[i] == 'T':
        count_T += 1
    tmp = count_T - count_S
    TS_max = max(TS_max, tmp)

ans = TS_max * 2
print(ans)


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;

signed main()
{
    cin >> N;

    int ans = 1;
    for (int i=1; i<=N; i++) {
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math

N, A, B = map(int, input().split())
if A > B:
    print(0)
    exit()

if N < B - A:
    print(0)
    exit()

minv = A * (N - 1) + B
maxv = A + (N - 1) * B
print(maxv - minv + 1)


Measured memory_bytes: 2940
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a="";
		char[] aa;
		String ans;
		String tmp="";
		int counter=0;

		while(sc.hasNext()) {
			a=sc.next();

			aa=new char[a.length()];
			for(int i=0; i<a.length(); i++) {
				aa[i]=a.charAt(i);
			}
			ans="";

			for(int i=0; i<a.length(); i++) {
				if(aa[i]!='@') {
					ans=ans+aa[i];
				}
				else if(aa[i]=='@') {
					int kaisu=Integer.parseInt(aa[i+1]+"");

					tmp="";

					for(int j=0; j<kaisu; j++) {
						tmp=tmp+aa[i+2]+"";
					}
					ans=ans+tmp;
					i+=2;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 25832
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val alist = readIntegerList()
    val distinct = alist.distinct()
    if (alist.size == distinct.size) {
        println("YES")
    } else {
        println("NO")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 80188
#include <stdio.h>
#include <stdlib.h>

#define INF 10000

int main(void)
{
  int size = 0;
  int min = INF;
  int min_sub;
  char S[20];

  scanf("%s", S);

  for(int i=0; S[i] != '\0'; ++i) {
    size++;
  }

  for(int i=0; i<size-2; ++i) {
    int num = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
    if(abs(min-753) > abs(num-753)) {
        min = num;
        min_sub = abs(num-753);
    }
  }

  printf("%d\n", min_sub);

  return 0;
}

Measured memory_bytes: 128
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
function main(){
  var waitTime = calc();
  for(var i = 0, len = input.length - 1; i < len;i++){
    console.log(waitTime[parseInt(input[i], 10)]);
  }
}
 
function calc(){
  var seats = new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
  var groupMembers = new Int32Array([2,5,2,2,2]);
  var eatTimes = new Int32Array([19,39,25,36,22,42]);
   
  var headGroup = -1;
  var pastMinutes = 0;
  var waitTime = new Int32Array(100);
  var lastMembers = 100;
   
  while(true){
    // たべおわる
    var i;
    for(i = 17; i--;){
      seats[i] = max(--seats[i], 0);
    }
     
    // 来店
    if(headGroup == -1 && pastMinutes % 5 == 0){
      headGroup = pastMinutes / 5;
    }
     
    // ちゃくせき
    while(headGroup != -1 && i != 17){
      var needsSequencialSeats = groupMembers[headGroup % 5];
      var sequencialSeats = 0;
      var startIndex = -1;
       
      for(i = 0; i < 17; i++){
        sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
         
        if(sequencialSeats == needsSequencialSeats){
          var eatTime = eatTimes[headGroup % 6];
 
          startIndex = i - (needsSequencialSeats - 1);
          // すわれるみたい
          waitTime[headGroup] = pastMinutes - (headGroup * 5);
          for(var j = startIndex, len = (needsSequencialSeats + startIndex); j < len; j++){
            seats[j] = eatTime;
          }
           
          headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
          if(!(--lastMembers)){
            // 100グループ着席
            return waitTime;
          }
          break;
        }
      }
    }
     
    pastMinutes++;
  }
   
}
 
function max(a, b){
  var t = (a - b);
  return a - (t & (t >> 31));
}

Measured memory_bytes: 8488
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;
const int _n = 2e6 + 10;
vector<int> Fact(_n), Inv(_n);
const int kmod = 1000000007;

int mul(int a, int b, int mod = kmod)
{
    return (long long)a * b % mod;
}

int add(int a, int b, int mod = kmod)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b, int mod = kmod)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int power(int base, int index, int mod = kmod)
{
    if (index == 0)
        return 1;
    int temp = power(base, index / 2, mod);
    temp = mul(temp, temp, mod);
    if (index & 1)
        temp = mul(temp, base, mod);
    return temp;
}

void pre()
{
    Fact[0] = 1;
    for (int i = 1; i < _n; ++i)
        Fact[i] = mul(Fact[i - 1], i);
    Inv[_n - 1] = power(Fact[_n - 1], kmod - 2);
    for (int i = _n - 2; i >= 0; --i)
        Inv[i] = mul(Inv[i + 1], (1 + i));
}

int ncr(int n, int r)
{
    if (n < 0 || r < 0 || n - r < 0)
        return 0;
    return mul(Fact[n], mul(Inv[r], Inv[n - r]));
}
class Solution
{
private:
public:
    Solution()
    {
        pre();
    }
    int ways(int n, int r)
    {
        return ncr(n + r, r);
    }
    ~Solution() {}
    void solveCase()
    {
        int r1, c1, r2, c2;
        cin >> r1 >> c1 >> r2 >> c2;
        int res = 0;
        for (int i = r1; i <= r2; i++)
            res = add(res, sub(ways(i + 1, c2), ways(i + 1, c1 - 1)));
        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

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


inline int gc(void) { return getchar(); }
inline void read(long long int &x){int k;x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}}

long long N, K, b, i, r, m, n, a[40];
bool f[40];

main(){
    read(N);
    read(K);
    for(i = 0; i < N; ++i){
        read(a[i]);
        //if(m < a[i]){
        //    ++r;
        //    m = a[i];
        //}
        f[i] = (i < K);
    }
    //if(r > K){return 0&puts("0");}
    n = 1099511627774;
    do{
        r = 0;
        m = *a;
        for(i = 1; i < N; ++i){
            if(m >= a[i]){
                if(f[i]){
                    ++m;
                    r += m - a[i];
                }
            }else{
                m = a[i];
            }
        }
        n = min(r, n);
    }while(prev_permutation(f, f + N));
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int A, B;
vector<vector<bool>> ans;






//サブ関数
//入力
void input()
{
	cin >> A >> B;

}


//A,B共に、16以上の場合
void make_pattern_1()
{
	const int H = 96;
	const int W = 100;
	//init  上から3行はtrue(black)
	REP(i, H) {
		int j = i / 3;
		ans.push_back(vector<bool>(W, (j % 2 == 0)));
	}
	//6行で1セット
	A -= H / 6;
	B -= H / 6;

	//さて、AとBが消えるまで動かしていこうか
	int i = 1;
	int j = 0;
	while (A > 0) {
		ans[i][j] = false;
		j += 2;
		if (j >= 100) {
			i += 6;
			j = 0;
		}
		A--;
	}

	i = 4;
	j = 0;
	while (B > 0) {
		ans[i][j] = true;
		j += 2;
		if (j >= 100) {
			i += 6;
			j = 0;
		}
		B--;
	}
}

//片方が16以下の場合
void make_pattern_2()
{
	//true==black
	const int H = 96;
	const int W = 100;
	if (B <= A) {
		//上から、WWWBBBWWWBBB..  BBBWWWBBBBBBBBBBBBBBB
		REP(i, B) {
			REP(j, 3)ans.push_back(vector<bool>(W, false));
			REP(j, 3)ans.push_back(vector<bool>(W, true));
		}
		while (ans.size() < H) {
			ans.push_back(vector<bool>(W, true));
		}
		A -= B;
		B = 0;
		//あとは埋めるだけ
		int i = 4;
		int j = 0;
		while (A > 0) {
			ans[i][j] = false;
			j += 2;
			if (j >= 100) {
				i += 6;
				j = 0;
			}
			A--;
		}
	}
	else {
		//上から、BBBWWWBBB....BBBWWWBBBWWWWWWWWWWWWW
		REP(i, A) {
			REP(j, 3)ans.push_back(vector<bool>(W, true));
			REP(j, 3)ans.push_back(vector<bool>(W, false));
		}
		while (ans.size() < H) {
			ans.push_back(vector<bool>(W, false));
		}
		B -= A;
		A = 0;
		int i = 4;
		int j = 0;
		while (B > 0) {
			ans[i][j] = true;
			j += 2;
			if (j >= 100) {
				i += 6;
				j = 0;
			}
			B--;
		}
	}
}

//計算
void calc()
{
	if (A >= 16 && B >= 16) {
		make_pattern_1();
	}
	else {
		make_pattern_2();
	}
}


//出力
void output()
{
	cout << "96 100" << endl;
	for (auto row : ans) {
		for (bool col : row) {
			cout << (col ? "#" : ".");
		}
		cout << endl;
	}
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long int ans = 0;
  long long int now = 0;
  for(long long int i=0; i<s.size(); i++){
    if(s.at(i) == 'W'){
      ans += i-now;
      now++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
# _*_ coding:utf-8 _*_
#  Atcoder_Exawizards2019_Contest-A
#  TODO https://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_a

def solveProblem(A,B,C):
	AminusB = A - B
	AminusC = A - C
	BminusC = B - C
	if AminusB == 0 and AminusC == 0 and BminusC == 0:
		answer = "Yes"
	else:
		answer = "No"
	return answer


if __name__ == '__main__':
	A,B,C = map(int,input().strip().split(' '))
	solution = solveProblem(A,B,C)
	print("{}".format(solution))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    vector<int> h;
    cin >> n;
    h.resize(n);
    REP(i,n) cin >> h[i];
    h[0]--;
    REP(i,n-1){
        if(h[i] < h[i+1]) h[i+1]--;
    }
    bool ok = true;
    REP(i,n-1){
        ok &= h[i] <= h[i+1];
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19432
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans= a*c;
    ans= max(a*d,ans);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n;
string s;
int a[200001];


void solve() {
    F1(i, m) a[i] = 1000000001;
    F0(i, k) {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x] = min(a[x], y);
    }
    int y = 1;
    for (int i = 2; i <= m; i++) {
        if (a[i] <= y) {
            cout << i - 1 << endl;
            return;
        }
        if (a[i] != y + 1) y++;
        //cerr << i << " " << y << endl;
    }
    cout << m << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> m >> n >> k) {
        solve();
    }
    return 0;
}


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

int N;

int main(){
  
  cin >> N;
  vector<string> wor(N);
  
  bool clr = true;
  cin >> wor[0];
  char last = wor[0][wor[0].size()-1];
  for(int i = 1; i < N; i++){
    cin >> wor[i];
    if(last != wor[i][0]) clr = false;
    for(int j = 0; j < i; j++){
      if(wor[j] == wor[i]) clr = false;
    }
    if(!clr) break;
    last = wor[i][wor[i].size()-1];
  }
  
  if(clr) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<LL,LL>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main(){
	int n;cin >> n;
	ll sum = 0;
	fo(i,1,n){
		if(i % 3== 0 || i % 5 == 0)continue;
		sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  string A,B;
  cin>>A>>B;
  if(A.size()<B.size()){
    cout<<"LESS"<<endl;
    return 0;
  }else if(B.size()<A.size()){
    cout<<"GREATER"<<endl;
    return 0;
  }else{
    LOOP(i,A.size()){
      // cerr << i << ":" << A[i] << B[i] << endl;
      int a=A[i],b=B[i];
      if(a<b){
        cout<<"LESS"<<endl;
        return 0;
      }else if(b<a){
        cout<<"GREATER"<<endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s[]=new String[n];
		int sint[]=new int[n];
		for(int i=0;i<n;i++) {
			s[i]=sc.next();
			for(int j=0;j<i;j++) {
				if(s[i].equals(s[j])) {
					sint[i]++;
					sint[j]++;
				}
			}
		}
		int m=sc.nextInt();
		String t[]=new String[m];
		for(int i=0;i<m;i++) {
			t[i]=sc.next();
			for(int j=0;j<n;j++) {
				if(t[i].equals(s[j])) {
					sint[j]--;
				}
			}
		}

		int saidai=-1;

		for(int i=0;i<n;i++) {
			if(saidai<sint[i])
				saidai=sint[i];
		}
		if(saidai>=0)
			System.out.print(saidai+1);
		else
			System.out.print(0);

	}

}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    
    if(b%a==0){
      System.out.println(a+b);
    }else{
      System.out.println(b-a);
    }
  }
}


Measured memory_bytes: 21844
def test(n)
  return 90909 if n == 100000
  return (10000..n).size + 909 if n.between?(10000,99999)
  return 909 if n.between?(1000,9999)
  return (100..n).size + 9 if n.between?(10,999) 
  return (1..n).size if n.between?(1,9) 
end
puts test(gets.to_i)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  ll n,m,d; cin >> n >> m >> d;
  double a = 0;
  a += (d == 0? 1.:2.) * (n-d)/n/(n) * ( m - 1);
  cout << fixed << setprecision(10) << a << endl;
}


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;


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

    vector<ll> numbers(3 * n);
    rep(i, 3 * n) cin >> numbers[i];
//    for (int i = n; i <= 2 * n; i++) {
//        vector<ll> n2, n3;
//
//        rep(j, i) n2.push_back(numbers[j]);
//        for (int j = i; j < 3 * n; j++) n3.push_back(numbers[j]);
//
//        sort(n2.rbegin(), n2.rend());
//        sort(n3.begin(), n3.end());
//
//        ll a = accumulate(n2.begin(), n2.begin() + n, 0ll);
//        ll b = accumulate(n3.begin(), n3.begin() + n, 0ll);
//        cout << a << ' ' << b << endl;
//    }

    auto f = [&](vector<ll> &v) {
        priority_queue<ll> q;
        rep(i, n) q.push(v[i]);
        ll sum = accumulate(v.begin(), v.begin() + n, 0ll);
        vector<ll> res;
        res.push_back(sum);
        rep(i, n) {
            sum += v[n + i];
            q.push(v[n + i]);
            ll t = q.top();
            sum -= t;
            q.pop();
            res.push_back(sum);
        }
        return res;
    };

    vector<ll> n2 = numbers;
    rep(i, n * 3) n2[i] *= -1;
    vector<ll> r1 = f(n2);

    vector<ll> n3 = numbers;
    reverse(n3.begin(), n3.end());
    vector<ll> r2 = f(n3);

    rep(i, n + 1) r1[i] *= -1;
    reverse(r2.begin(), r2.end());

    ll ans = -INF;
    rep(i, n + 1) cmax(ans, r1[i] - r2[i]);
    cout << ans << endl;
}


Measured memory_bytes: 10728
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int a[50][50],b[50][50],c[50][50];
int main(){
	int ha,wa,hc,wc;
	cin >> ha >> wa;
	rep(i,ha) rep(j,wa) cin >> a[i][j];
	rep(i,ha) rep(j,wa) cin >> b[i][j];
	cin >> hc >> wc;
	rep(i,hc) rep(j,wc) cin >> c[i][j];
	int ans=-1000000000;
	rep(i,ha-hc+1) rep(j,wa-wc+1){
		int tmp=0;
		bool flag=true;
		rep(k,hc){
			rep(l,wc){
				if(c[k][l]!=b[i+k][j+l]){
					flag=false;
					break;
				}
				tmp+=a[i+k][j+l];
			}
			if(!flag) break;
		}
		if(flag) ans=max(ans,tmp);
	}
	if(ans==-1000000000) cout << "NA" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1188