akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){

    //データ定義
    int num1;
    int num2;
    int num3;

    //3つの整数を読み込む
    cin >> num1 >> num2 >> num3;

    //結果出力
    if( num1 < num2 && num2 < num3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;   
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;


typedef long long ll;
    typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
ll n;
ll m;
ll ans;
string str;

int main(){
    ll a,b;
    cin>>a>>b;
    ans=(a>b)?a--:b--;
    ans+=(a>b)?a--:b--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    int alice = 0;
    int bob = 0;
    rep(i, n){
        if(i % 2  == 0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 3616
#たどれる2要素の互換が可能
n,m = map(int, input().split( ))

*p, = map(int, input().split( ))

E = [tuple(map(int, input().split( ))) for _ in range(m)]

r = [i for i in range(n+1)]
rank = [0]*(n+1)

###UnionFind
def root(x):
    if x==r[x]:
        return x
    r[x]=y=root(r[x])##
    return y
def union(x,y):
    rx,ry = root(x),root(y)
    if rx!=ry:
        if rank[x]<rank[y]:
            r[rx] = ry##ここrx,ryであってx,yではない
        else:
            r[ry] = rx

for xi,yi in E:
    union(xi,yi)

cnt = 0
for i in range(1,n+1):
    #if r[i]==r[p[i-1]]:
    if root(i)==root(p[i-1]):
        cnt += 1
print(cnt)


Measured memory_bytes: 25168
import sys
sys.setrecursionlimit(10 ** 7)

N = input()

# TLE ()

# DP
INF = pow(10, 8)
L = len(N)
dp = [[INF] * 2 for _ in range(L+2)]
dp[0][0] = 0

# reverse
N = N[::-1] + '0'


for i in range(L+1):
    for j in range(2):
        # 繰り下がりも加味
        n = int(N[i])
        n += j

        # 更新後のdp
        ni = i + 1

        # 同じだけ払う
        if n < 10:
            dp[ni][0] = min(dp[ni][0], dp[i][j] + n)
        else:
            dp[ni][1] = min(dp[ni][1], dp[i][j])

        # 繰り下がりあり
        if n > 0:
            dp[ni][1] = min(dp[ni][1], dp[i][j] + (10 - n))
        else:
            dp[ni][0] = min(dp[ni][0], dp[i][j])


ans = min(dp[L+1][0], dp[L+1][1])

print(ans)


Measured memory_bytes: 152136
#include <stdio.h>

int main(){
    int limit1, b, c, anser;

    anser = 0;

    scanf("%d %d %d", &limit1, &b, &c);

    if(c <= (limit1 - b))
    {
        anser = 0;
    } else {
        anser = c - (limit1 - b);
    }
    
    printf("%d", anser);

}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  string c = input<string>(); 

  int i = c[0];
  i++;
  char answer = i;

  output(answer);

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
b = []
ans = ""
for i in range(m):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)

xton = set()
#nへ向かう便が出てる島を確認する
for i in range(m):
    if b[i] == n:
        xton.add(a[i])
#nへ向かう便が出ている島へ1から向かう便があるか確認する
for i in range(m):
    if a[i] == 1 and b[i] in xton:
        ans = "POSSIBLE"
        break
    else:
        ans = "IMPOSSIBLE"
print(ans)

Measured memory_bytes: 21920
#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>

using namespace std;

int main(){
	
	int n,q;
	
	while(cin>>n>>q, n){
		
		int m;
		int date[256]={0};
		
		for(int i=0; i<n; ++i){
		
			cin >> m;
			
			for(int j=0; j<m; ++j){
				int tmp;
				cin >> tmp;
				date[tmp]++;
			}
		}
		
		int res=0, mx=0;
		
		for(int i=1; i<=100; ++i){
			
			if(date[i] > mx){
				mx = date[i];
				res = i;
			}
		}
		
		cout << (mx>=q?res:0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    // n-1個の要素を長さk-1のタイル（？）で覆う
    ll ans = (n - 1 + (k - 2)) / (k - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import functools

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b / gcd(a, b)

N = int(input())
a = list(map(int, input().split()))

lcmVal = int(functools.reduce(lcm, a, 0))
print(sum(map(lambda x: (lcmVal-1) % x, a)))


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005

int dp[3][MAXN];

int main() 
{
	int n;
	cin >> n;
	int hei[3][MAXN];
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= 2; j++)
		{
			if (i==0) cin >> dp[j][i];
			else cin >> hei[j][i];
		}
	}
	
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			dp[j][i] = max(dp[(j+1)%3][i-1], dp[(j+2)%3][i-1]) + hei[j][i];
		}
	}
	
	cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << "\n";
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if N>=30:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 77496
#include<iostream>
using namespace std;
int  main(){
    int x,n;
    cin>>x;
    cin>>n;
    int arr[100];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int c=0,ans;
    while(1){
        bool flag=false;
        for(int i=0;i<n;i++){
            if(x-c==arr[i]){
                flag=true;
                break;
            }
        }
        if(!flag){
            ans=x-c;
            break;
        }
        flag=false;
        for(int i=0;i<n;i++){
            if(x+c==arr[i]){
                flag=true;
                c++;
                break;
            }
        }
        if(!flag){
            ans=x+c;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
from math import gcd
N = int(input())
def lcm(a,b):
    return a*b//gcd(a,b)

T1 = int(input())
ans = T1
for i in range(N-1):
    T2 = int(input())
    ans = lcm(ans,T2)
    T1 = T2

print(ans)

Measured memory_bytes: 9176
n, m = map(int, input().split())
sl = list(list(map(int, input().split())) for _ in range(m))
sl = list(map(list, set(map(tuple, sl))))

cnt = [0]*n
cnn = [0]*n

for s in sl:
    if s[0] > n:
        print(-1)
        exit()
    if n > 1 and s[0] == 1 and s[1] == 0:
        print(-1)
        exit()
    elif cnn[s[0]-1] == 0:
        cnn[s[0] - 1] = s[1]
    # elif cnn[s[0]-1] != s[1] and cnn[s[0]-1] > s[1]:
    #     cnn[s[0] - 1] = s[1]
    elif cnn[s[0]-1] != s[1]:
        print(-1)
        exit()
    else:
        print(-1)
        exit()

if n > 1 and cnn[0] == 0:
    cnn[0] = 1
    print(*cnn, sep='')
else:
    print(*cnn, sep='')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
constexpr long long INF64 = 1e18;
 
using Weight=long long;

using Array=vector<Weight>;
using Matrix=vector<Array>;

struct flow{
    int n;
    Matrix g;
    vector<int> itr,level;

    flow(int n):n(n){g.assign(n,Array(n,0));}

    void add_edge(int from,int to,Weight cap){
        g[from][to]+=cap;
    }

    void bfs(int s){
        level.assign(n,-1);
        queue<int>q;
        level[s]=0;
        q.push(s);
        while(!q.empty()){
            int u=q.front();q.pop();
            for(int v=0;v<n;++v){
                if(g[u][v]>0 && level[v]<0){
                    level[v]=level[u]+1;
                    q.push(v);
                }
            }
        }
    }

    Weight dfs(int u,int t,Weight f){
        if(u==t)return f;
        for(int &i=itr[u];i<n;++i){
            if(g[u][i]>0 && level[u]<level[i]){
                Weight d=dfs(i,t,min(f,g[u][i]));
                if(d>0){
                    g[u][i]-=d;
                    g[i][u]+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    Weight dinic(int s,int t){
        Weight ret=0,f;
        while(bfs(s),level[t]>=0){
            itr.assign(n,0);
            while((f=dfs(s,t,INF64))>0)ret+=f;
        }
        return ret;
    }
};
 
int main(){
  int n;
  cin>>n;
  flow g(2*n+2);
  int redx[101],redy[101],bluex[101],bluey[101];
  for(int i=0;i<n;++i){
    cin>>redx[i];
    cin>>redy[i];
  }
  for(int i=0;i<n;++i){
    cin>>bluex[i];
    cin>>bluey[i];
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(redx[i]<bluex[j] && redy[i]<bluey[j]){
        g.add_edge(i,j+n,1);
      }
    }
    g.add_edge(2*n,i,1);
    g.add_edge(i+n,2*n+1,1);
  }
  cout<<g.dinic(2*n,2*n+1)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
unsigned long long int gcd(ull a, ull b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int main(){
    unsigned long long int n, k;
    cin >> n>> k;
    if(k == 1 || n == 0 || n%k == 0)
    cout<<"0\n";
    else 
    {
    	n=n%k;
    	cout<<min(n,k-n);
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

typedef struct {
    int index;
    int num;
} Num;

int my(const void *a, const void *b) {
  return (((const Num*)a)->num - ((const Num*)b)->num);
}

int main() {
    int n = ri();
    Num x[n];
    FOR(i,n) x[i].index = i, x[i].num = ri();
    qsort(x,countof(x),sizeof(*x),my);
    
    int addr[n];
    FOR(i,n) addr[x[i].index] = i;
    int r1 = x[n/2-1].num;
    int r2 = x[n/2].num;
    FOR(i,n) {
        if (addr[i] >= n/2) cout << r1 << endl;
        else cout << r2 << endl;
    }
 return 0;
}


Measured memory_bytes: 4576
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int n,T;
  while(cin>>n>>T) {
    ll pre = -1;
    vector<string> a1;
    vector<int> a2;
    REP(i,n) {
      string a,b,c,d;
      cin>>a>>b>>c>>d;
      int t1 = atoi(a.substr(0,2).c_str()) * 60 + atoi(a.substr(3,2).c_str());
      int t2 = atoi(c.substr(0,2).c_str()) * 60 + atoi(c.substr(3,2).c_str());
      if (i) {
        if (t1-pre >= T) {
          a1.push_back(b);
          a2.push_back(t1-pre);
        }
      }
      pre = t2;
    }
    cout << a1.size() << endl;
    REP(i,a1.size()) {
      cout << a1[i] << " " << a2[i] << endl;
    }
  }
}

Measured memory_bytes: 1244
A, B, C = map(int, input().split())

l = sorted([A, B, C])
c = 0
while l[1] != l[2]:
	#print(l)
	c += 1
	l[0] += 1
	l[1] += 1

#print(l)

if (l[0] == l[1] == l[2]):
	print(c)
	exit()

print(c + (l[1] - l[0] + 1) // 2 + (l[1] - l[0]) % 2)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll H, W, K;
    cin >> H >> W >> K; K--;
    if(W == 1){
        printf("%d\n", 1);
        return 0;
    }
    vector<vector<ll>> dp(H+1, vector<ll> (W, 0));
    vector<ll> c(W, 2), cl(W, 1), cm(W, 1);
    for (int i = 2; i < W; i++) {
        cl[i] = cm[i-1];
        cm[i] = cl[i-1] + cm[i-1];
        c[i] = cl[i] + cm[i];
    }
    c[0] = 1;

    dp[0][0] = 1;
    for (int h = 1; h < H+1; h++) {
        for (int k = 0; k < W; k++) {
            if(k >= 2 && k <= W-2){
                dp[h][k] = (dp[h][k] + dp[h-1][k-1] * c[k-2] * c[W-k-2]) % MOD;
            }
            else if(k == 1){
                dp[h][k] = (dp[h][k] + dp[h-1][k-1] * c[W-k-2]) % MOD;
            }
            else if(k == W-1){
                dp[h][k] = (dp[h][k] + dp[h-1][k-1] * c[k-2]) % MOD;
            }

            if(k <= W-3 && k >= 1){
                dp[h][k] = (dp[h][k] + dp[h-1][k+1] * c[k-1] * c[W-k-3]) % MOD;
            }
            else if(k == 0){
                dp[h][k] = (dp[h][k] + dp[h-1][k+1] * c[W-k-3]) % MOD;
            }
            else if(k == W-2){
                dp[h][k] = (dp[h][k] + dp[h-1][k+1] * c[k-1]) % MOD;
            }

            if(k >= 1 && k <= W-2){
                dp[h][k] = (dp[h][k] + dp[h-1][k] * c[k-1] * c[W-k-2]) % MOD;
            }
            else if(k == 0){
                dp[h][k] = (dp[h][k] + dp[h-1][k] * c[W-k-2]) % MOD;
            }
            else if(k == W-1){
                dp[h][k] = (dp[h][k] + dp[h-1][k] * c[k-1]) % MOD;
            }
        }
    }

    printf("%lld\n", dp[H][K]);

}

Measured memory_bytes: 3728
w,h,n=map(int,input().split())


x_min=0
y_min=0

for i in range(n):
    x,y,a=map(int,input().split())

    if a==1:
        x_min=max(x_min,x)

    elif a==2:
        w=min(x,w)

    elif a==3:
        y_min=max(y_min,y)

    elif a==4:
        h=min(y,h)

print(max(0,w-x_min)*max(0,h-y_min))


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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int dis[n*m][n*m];
    fill(&dis[0][0], &dis[n*m][0], n * m);

    const int dx[4] = {1, 0, -1, 0};
    const int dy[4] = {0, -1, 0, 1};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '#') {
                continue;
            }

            dis[i*m+j][i*m+j] = 0;
            for (int k = 0; k < 4; k++) {
                int tx = i + dx[k], ty = j + dy[k];
                if (tx >= 0 && tx < n && ty >= 0 && ty < m && s[tx][ty] == '.') {
                    dis[i*m+j][tx*m+ty] = 1;
                }
            }
        }
    }

    for (int k = 0; k < n * m; k++) {
        for (int i = 0; i < n * m; i++) {
            for (int j = 0; j < n * m; j++) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n * m; i++) {
        for (int j = 0; j < n * m; j++) {
            if (dis[i][j] != n * m) {
                ans = max(ans, dis[i][j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
# coding: utf-8
# Your code here!
N = int(input())

box = []
for i in range(N):
     line = input().split()
     if line[0] == line[1]:
          box.append(1)
     else:
          box.append(0)
#print(box)

m = 0
for j in range(N-2):
     #print(box[j],box [j+1],box[j+2])
     n = box[j]+box [j+1]+box[j+2]
     if n == 3:
          m = 1
     
if m == 1:
     print("Yes")
else:
     print("No")

Measured memory_bytes: 9200
n, m = map(int, input().split())
l, r = map(int, input().split())
for _ in range(1, m):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)
if r-l<0:
    print(0)
else:
    print(r-l+1)

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

int n;
double dp[3000][3000];
int main(){
    cin>>n;

    double pro[n+1];
    for(int x=1;x<=n;x++)
        cin>>pro[x];

    dp[0][0] = 1;

    for(int x=1;x<=n;x++){
        for(int y = 0; y<=n;y++){
            if(y > x) break;
            if(y==0){
                dp[x][y] = (1-pro[x]) * dp[x-1][0];
                continue;
            }
            dp[x][y] = pro[x] * dp[x-1][y-1] + dp[x-1][y] * (1-pro[x]);
        }
    }
    double ans = 0;

    for(int x=(n+1)/2;x<=n;x++){
        ans += dp[n][x];
    }
    printf("%.9f", ans);
}


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    string s; cin >> s;

    ll cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        cnt += s[i] -'0';
    }

    if (cnt % 9 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[100];
	int l=0,c=0,t;
	scanf("%s",s);
	l = strlen(s);
	for(int i=0;i<l;i++){
		c = 0;
		t = 1;
		if(s[i] == 'B'){
			while(c == 0){
				if(s[i-t] != 'B'){
					s[i-t] = 'B';
					c = 1;
				}
				else{
					t++;
				}
				if(i-t == -1){
					break;
				}
			}
		}
	}
	for(int i=0;i<l;i++){
		if(s[i] != 'B'){
			printf("%c",s[i]);
		}
	}
}

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

int main()
{
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
	{
		for(int j=i+1;j<s.size();j++)
		{
			if(s[i]==s[j])
			{
				cout<<"no";
				return 0;
			}
		}
	}
	cout<<"yes";
	return 0;
}

Measured memory_bytes: 256
X,Y = (str(i) for i in input().split())

def odd16(Z):
    if Z == 'A':
        return(11)
    elif Z == 'B':
        return(12)
    elif Z == 'C':
        return(13)
    elif Z == 'D':
        return(14)
    elif Z == 'E':
        return(15)
    elif Z == 'F':
        return(16)
    
x = odd16(X)
y = odd16(Y)

if x == y:
    print('=')
elif x > y:
    print('>')
else:
    print('<')
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);

int n, m;
ll x[1000], y[1000], z[1000];
typedef struct {
    ll x;
    ll y;
    ll z;
} Cake;

template<class sFunc>
auto solve(vector<Cake> c, sFunc sfunc) -> ll
{
    sort(begin(c), end(c), [sfunc](Cake a, Cake b) -> ll {
                return sfunc(a) > sfunc(b);
            });
    ll res = 0LL;
    REP(i, m) {
        // cout << "(" << c[i].x << ", " << c[i].y << ", " << c[i].z << ")" << endl;
        res += sfunc(c[i]);
    }

    return res;
}


auto main() -> int
{
    cin >> n >> m;

    vector<Cake> c;
    REP(i, n) {
        cin >> x[i] >> y[i] >> z[i];
        c.push_back({x[i], y[i], z[i]});
    }

    ll r[8];
    r[0] = solve(c, [](Cake c) -> ll { return c.x + c.y + c.z; });
    r[1] = solve(c, [](Cake c) -> ll { return c.x + c.y - c.z; });
    r[2] = solve(c, [](Cake c) -> ll { return c.x - c.y + c.z; });
    r[3] = solve(c, [](Cake c) -> ll { return c.x - c.y - c.z; });
    r[4] = solve(c, [](Cake c) -> ll { return -c.x + c.y + c.z; });
    r[5] = solve(c, [](Cake c) -> ll { return -c.x + c.y - c.z; });
    r[6] = solve(c, [](Cake c) -> ll { return -c.x - c.y + c.z; });
    r[7] = solve(c, [](Cake c) -> ll { return -c.x - c.y - c.z; });

    cout << *max_element(r, r+8) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int c=min(a,b);
  int d=max(a,b);
  string s=to_string(c);
  for(int i=0;i<d;i++)cout<<s;
  cout<<endl;
}




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,A,B;
int BM[1<<17];

vector<int> hoge(int C) {
	vector<int> R;
	int x,y;
	if(__builtin_popcount(C)==1) {
		FOR(x,N) if(C&(1<<x)) break;
		R.push_back(0);
		R.push_back(1<<x);
		return R;
	}
	FOR(x,N) if(C&(1<<x)) break;
	FOR(y,N) if(x!=y && (C&(1<<y))) break;
	vector<int> T=hoge(C^(1<<x)^(1<<y));
	
	R=T;
	reverse(ALL(T));
	FORR(t,T) R.push_back(t^(1<<x));
	reverse(ALL(T));
	int step=0;
	FORR(t,T) {
		if(step==0) {
			R.push_back(t^(1<<x)^(1<<y));
			R.push_back(t^(1<<y));
		}
		else {
			R.push_back(t^(1<<y));
			R.push_back(t^(1<<x)^(1<<y));
		}
		step^=1;
	}
	return R;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	int num[2]={};
	for(int mask=0;mask<1<<N;mask++) {
		BM[mask]=__builtin_popcount(mask)%2;
	}
	if(BM[A]==BM[B]) {
		cout<<"NO"<<endl;
		return;
	}
	int C=A^B;
	int sub=C^((1<<N)-1);
	vector<int> V;
	V.push_back(0);
	FOR(i,N) if(sub&(1<<i)) {
		vector<int> V2=V;
		reverse(ALL(V));
		FORR(v,V) V2.push_back((1<<i)|v);
		swap(V,V2);
	}
	
	vector<int> W=hoge(C);
	
	vector<int> R;
	FORR(w,W) {
		FORR(v,V) R.push_back(w^v^A);
		reverse(ALL(V));
	}
	FOR(i,R.size()-1) {
		assert(__builtin_popcount(R[i]^R[i+1])==1);
	}
	assert(R[0]==A);
	assert(R.back()==B);
	
	cout<<"YES"<<endl;
	FORR(r,R) cout<<r<<" ";
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2332
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, q;
    cin >> n >> q;
    VI a(n);
    REP(i,n) a[i] = in();
    VI left(q), right(q);
    REP(i,q){
        scanf("%d %d", &left[i], &right[i]);
        left[i]--;
        right[i];
    }

    int width = sqrt(n);
    VI ord(q);
    REP(i,q) ord[i] = i;
    sort(begin(ord), end(ord), [&](int a, int b)
    {
        if(left[a] / width != left[b] / width) return left[a] < left[b];
        return right[a] < right[b];
    });

    VI ans(q);
    int cnt = 0;
    VI mp(n + 1);
    int x = 0, y = 0;
    REP(j,q){
        int i = ord[j];
        while (x > left[i]){
            x--;
            mp[a[x]]++;
            if (mp[a[x]] == 1) cnt++;
        }
        while (y < right[i]){
            mp[a[y]]++;
            if (mp[a[y]] == 1) cnt++;
            y++;
        }
        while (x < left[i]){
            mp[a[x]]--;
            if (mp[a[x]] == 0) cnt--;
            x++;
        }
        while (y > right[i]){
            y--;
            mp[a[y]]--;
            if (mp[a[y]] == 0) cnt--;
        }
        ans[i] = cnt;
    }

    REP(i,q) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 15456
#include"bits/stdc++.h"
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
   int d,s,t; 
   cin>>d>>s>>t; 
  if(d<=s*t){ puts("Yes"); } else puts("No"); 
  return 0; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll x, y;
	cin >> x >> y;
	ll sum = (x * (x - 1)) / 2;
	sum += ((y * (y - 1)) / 2);
	cout << sum << endl;
	//main();
}

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

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      String[] line0 = br.readLine().split(" ");
      int n = Integer.parseInt(line0[0]);
      int m = Integer.parseInt(line0[1]);
      String[] line1 = br.readLine().split(" ");
      long result = 0;
      if(n == 1) {
        result = Long.parseLong(line1[0]) / (long)Math.pow(2, m);
        System.out.println(result);
        return;
      }
      PriorityQueue<Long> price
       = new PriorityQueue<Long>(Comparator.reverseOrder());
      for(int i = 0; i < n; i++) {
        price.offer(Long.parseLong(line1[i]));
      } 
      long ele = 0;
      for(int i = 0; i < m; i++) {
        ele = price.poll() / 2;
        price.offer(ele);
      }
      while(price.peek() != null) {
        result += price.poll();
      }
      System.out.println(result);
      br.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 46932
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N, X = LI()
    S = [0]*(N+1)
    P = [0]*(N+1)
    S[0] = 1; P[0] = 1
    for i in range(N):
        S[i+1] = S[i]*2 + 3
        P[i+1] = P[i]*2 + 1

    def dfs(n,x):
        if n==0:
            return 0<x
        if x>=S[n-1]+2:
            return 1 + P[n-1] + dfs(n-1,x-2-S[n-1])
        return dfs(n-1,x-1)
    ans = int(dfs(N,X))
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10548
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	const int N = 10;
	vector<vector<int>> map(N, vector<int>(N));

	vector<vector<int>> s1 =
	{
		{ 0, 1, 0 },
		{ 1, 1, 1 },
		{ 0, 1, 0 } ,
	};
	vector<vector<int>> s2 =
	{
		{ 1, 1, 1 },
		{ 1, 1, 1 },
		{ 1, 1, 1 },
	};
	vector<vector<int>> s3 =
	{
		{ 0, 0, 1, 0, 0},
		{ 0, 1, 1, 1, 0 },
		{ 1, 1, 1, 1, 1 },
		{ 0, 1, 1, 1, 0 },
		{ 0, 0, 1, 0, 0 },
	};


	string s;
	for (; getline(cin, s);)
	{
		stringstream ss;
		ss << s;

		int x;
		ss >> x;
		ss.ignore();
		int y;
		ss >> y;
		ss.ignore();
		int s;
		ss >> s;

		vector<vector<int>> sn;
		switch (s)
		{
			case 1:
				sn = s1;
				break;
			case 2:
				sn = s2;
				break;
			case 3:
				sn = s3;
				break;
		}

		for (int i = 0; i < sn.size(); i++)
		{
			int y0 = i + y - sn.size() / 2;
			if (y0 < 0 || y0 >= N)
			{
				continue;
			}
			for (int j = 0; j < sn.size(); j++)
			{
				int x0 = j + x - sn.size() / 2;
				if (x0 < 0 || x0 >= N)
				{
					continue;
				}
				map.at(y0).at(x0) += sn.at(i).at(j);
			}
		}
	}

	int maxd = 0;
	int dr = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (map.at(i).at(j) > 0)
			{
				dr++;
				maxd = max(maxd, map.at(i).at(j));
			}
		
		}
	}

	cout << 100 - dr << endl;
	cout << maxd << endl;
}


Measured memory_bytes: 3216
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[][] student = new long[n][2];
		for(int i = 0; i < n; i++){
		    student[i][0] = sc.nextInt();
		    student[i][1] = sc.nextInt();
		}
		long[][] check = new long[m][2];
		for(int i = 0; i < m; i++){
		    check[i][0] = sc.nextInt();
		    check[i][1] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		for(int i = 0; i < n; i++){
		    int num = 0;
		    long dist = Long.MAX_VALUE;
		    for(int j = 0; j < m; j++){
		        long d = abs(student[i][0]-check[j][0]) + abs(student[i][1]-check[j][1]);
		        if(dist > d){
		            dist = d;
		            num = j+1;
		        }
		    }
		    System.out.println(num);
		}
		
		
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 21332
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, T; cin >> N >> T;
    int A[N], B[N]; F0R(i, N) cin >> A[i] >> B[i];

    int dp[T][2];
    F0R(i, T) F0R(j, 2) dp[i][j] = 0;
    F0R(x, N) {
        F0Rd(i, T) {
            if (i + A[x] < T) {
                dp[i+A[x]][0] = max(dp[i+A[x]][0], dp[i][0] + B[x]);
                dp[i+A[x]][1] = max(dp[i+A[x]][1], dp[i][1] + B[x]);
            }
            dp[i][1] = max(dp[i][1], dp[i][0] + B[x]);
        }
    }

    cout << dp[T-1][1] << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    
    if(a < 1200)
      System.out.println("ABC");
    else if(a < 2800)
      System.out.println("ARC");
    else
      System.out.println("AGC");
  }
}

Measured memory_bytes: 23636
use proconio::input;

fn main() {
    input! {
        mut s: String,
        q: usize,
    }
    let mut queries = vec![Vec::new(); q];
    for i in 0..q {
        input! {
            head: char
        }
        queries[i].push(head);
        if head == '2' {
            input! {
                x: char,
                y: char
            }
            queries[i].push(x);
            queries[i].push(y);
        }
    }

    let mut now = 0;
    let mut former = String::new();
    while queries[now][0] == '2' {
        if queries[now][1] == '1' {
            former.push(queries[now][2]);
        } else {
            s.push(queries[now][2]);
        }
        now += 1;
        if now == q {
            break;
        }
    }
    let mut s = format!("{}{}", former.chars().rev().collect::<String>(), s);

    if now == q {
        println!("{}",s)
    } else {
        let mut rev = Vec::new();
        if queries[q-1][0] == '1' {
            rev.push(1);
        } else {
            rev.push(0);
        }
        for i in 1..q-now {
            if queries[q-i-1][0] == '1' {
                rev.push(rev[i-1]+1);
            } else {
                rev.push(rev[i-1]);
            }
        }
        rev.reverse();

        if rev[0]%2 == 1 {
            s = s.chars().rev().collect::<String>();
        }

        let mut former = String::new();
        for i in 1..q-now {
            if queries[i+now][0] == '2' {
                if queries[i+now][1] == '1' && rev[i]%2 == 0 || queries[i+now][1] == '2' && rev[i]%2 == 1 {
                    former.push(queries[i+now][2]);
                } else {
                    s.push(queries[i+now][2]);
                }
            }
        }
        let ans = format!("{}{}", former.chars().rev().collect::<String>(), s);
        println!("{}",ans)
    }
}

Measured memory_bytes: 15788
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    string s1 = S.substr(0, S.size()/2);
    string s2 = S.substr(S.size()/2 + 1);
    bool ans = true;
    REP(i, s1.size())
        if (s1[i] != s2[i]) ans = false;
    if (ans) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
if n < 10:
  print(0)
  exit()
  
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret
  
d = defaultdict(int)
for i in range(2,n+1):
  f = primeFactor(i)
  for j,k in f.items():
    d[j] += k

lim_74 = -1
lim_24 = -1
lim_14 = -1
lim_4 = -1
lim_2 = -1
cnt = 0
for i in d.values():
  if lim_74 == -1 and i < 74:
    lim_74 = cnt
  if lim_24 == -1 and i < 24:
    lim_24 = cnt
  if lim_14 == -1 and i < 14:
    lim_14 = cnt
  if lim_4 == -1 and i < 4:
    lim_4 = cnt
  if lim_2 == -1 and i < 2:
    lim_2 = cnt
    break
  cnt += 1
  
ans = lim_74
ans += lim_24*(lim_24-1)
ans += lim_14*(lim_14-1)
ans += lim_24*(lim_2-lim_24)
ans += lim_14*(lim_4-lim_14)
ans += lim_4*(lim_4-1)*(lim_4-2)//2
ans += lim_4*(lim_4-1)*(lim_2-lim_4)//2
print(ans)

Measured memory_bytes: 65736
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S, T, R;
  int A, B;
  cin >> S >> T >> A >> B >> R;
  if(S == R){
    cout << A-1 << ' ' << B << endl;
  }
  else{
    cout << A << ' ' << B-1 << endl;
  }
}

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

int main() {
  string s, a[26];
   cin >> s;

   a[0]='a';
   a[1]='b';
   a[2]='c';
   a[3]='d';
   a[4]='e';
   a[5]='f';
   a[6]='g';
   a[7]='h';

   a[8]='i';
   a[9]='j';
   a[10]='k';
   a[11]='l';
   a[12]='m';
   a[13]='n';
   a[14]='o';
   a[15]='p';
   a[16]='q';
   a[17]='r';
   a[18]='s';
   a[19]='t';
   a[20]='u';
   a[21]='v';
   a[22]='w';
   a[23]='x';
   a[24]='y';
    a[25]='z';
  for(int i=0;i<26;i++){
  if(a[i]==s){  
  cout << a[i+1];
  break;}
}}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>
#include <list>
#include <queue>

using namespace std;

int S[10000];
int n;

void unite(int x, int y) {
	int SetID1 = S[x];
	int SetID2 = S[y];
	if (SetID1 > SetID2) {
		for (int i = 0; i < n; i++) {
			if (S[i] == SetID2) {
				S[i] = SetID1;
			}
		}
	}
	else if (SetID1 < SetID2) {
		for (int i = 0; i < n; i++) {
			if (S[i] == SetID1) {
				S[i] = SetID2;
			}
		}
	}
}

int same(int x, int y) {
	return (S[x]==S[y]) ? 1 : 0;
}

int main() {
	int q;
	int com, x, y;
	cin >> n >> q;
	
	for (int i = 0; i < n; i++) {
		S[i] = i;
	}
	
	for (int i = 1; i <= q; i++) {
		cin >> com >> x >> y;
		if (com == 0) {
			unite(x, y);
		}
		else {
			printf("%d\n", same(x, y));
		}
	}
	return 0;
}

Measured memory_bytes: 1184
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(n):
    c += [i+1]*a[i]
ans = []
for h_ in range(h):
    a = c[h_*w: w+h_*w]
    if h_ % 2 == 0:
        ans.append(a)
    else:
        ans.append(a[::-1])
for i in ans:
    print(*i)

Measured memory_bytes: 3952
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
    vector<int> height(N+100);
    for (int i = 0; i < N; i++)  cin >> height[i];
    
    // グラフ
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int H = height[i];
        bool isGood = true;
        for (auto v: G[i])
        {
            if (G[i].empty())  break;
            
            if (H <= height[v])  {
                isGood =false; 
                break;
            }
        }
        if (isGood)  ans++;
    }

    cout << ans;
    return 0;
    
}

Measured memory_bytes: 8812
# coding: utf-8
#解法1 ABのK番まで　＋　CのK番まで
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC=[]

for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ABC.append(A[i]+B[j]+C[k])
        if (i+1)*(j+1)>K:
            break
    if i+1>K:
        break

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])


Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
int ans=0,i,c=1,x;
int main()
{
    scanf("%d",&x);
    for(i=0;i<1000000;i++,c++)
    {
        ans=ans*10+7;
        ans=ans%x;
        if(ans==0)break;
    }
    if(i==1000000)printf("-1");
    else printf("%d",c);
    return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<utility>
#include<vector>
#include<functional>
#include<math.h>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {
	string s; 
	char find;
	int cnt = 0;
	cin >> s;

	find = s[0];

	for (int i = 0; i < s.length(); i++) {
		if (find != s[i]) {
			cnt++;
			find = s[i];
		}
	}

	cout << cnt << endl;




	return 0;

}

Measured memory_bytes: 512
def solve():
    n = int(input()[-1])
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    bon = [3]
    if n in hon:
        print('hon')
    elif n in pon:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9180
S=str(input())
S=list(map(str,S))
T=str(input())
T=list(map(str,T))
Ca=len(T)
for i in range(len(S)-len(T)+1):
  Cb=len(T)
  for j in range(len(T)):
    if S[i+j]==T[j]:
      Cb-=1
  if Ca>Cb:
    Ca=Cb
print(Ca)

Measured memory_bytes: 8988