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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int is_uruu(int year)
{
    if(year%400 == 0) return 1;
    if(year%100 == 0) return 0;
    if(year%4 == 0) return 1;
    return 0;
}

int main()
{
    // ?????°????????¨?????????????????????????????±
    int bit[10] = {119,36,93,109,46,107,123,37,127,111};

    // ??\???
    vector<int> mask(14,(1<<7)-1);

    int N,K;
    cin >>N >>K;
    rep(i,K)
    {
        int p,q;
        cin >>p >>q;

        mask[p] -= (1<<q);
    }

    // ????????¨???????????????????????????
    ll time_count[100]={};
    rep(h,24)rep(m,60)rep(s,60)
    {
        int ct=0;

        ct += __builtin_popcount(mask[8] & bit[h/10]);
        ct += __builtin_popcount(mask[9] & bit[h%10]);

        ct += __builtin_popcount(mask[10] & bit[m/10]);
        ct += __builtin_popcount(mask[11] & bit[m%10]);

        ct += __builtin_popcount(mask[12] & bit[s/10]);
        ct += __builtin_popcount(mask[13] & bit[s%10]);

        ++time_count[ct];
    }

    // ??\?????¨???????????????????????????(???????????´ 0/1)
    int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    ll day_count[2][100]={};
    for(int m=1; m<=12; ++m)for(int d=1; d<=days[m]; ++d)
    {
        int ct = 0;

        ct += __builtin_popcount(mask[4] & bit[m/10]);
        ct += __builtin_popcount(mask[5] & bit[m%10]);

        ct += __builtin_popcount(mask[6] & bit[d/10]);
        ct += __builtin_popcount(mask[7] & bit[d%10]);

        ++day_count[0][ct];
    }
    // 2/29?????????
    int uruu_day = 0;
    uruu_day += __builtin_popcount(mask[4] & bit[0]);
    uruu_day += __builtin_popcount(mask[5] & bit[2]);

    uruu_day += __builtin_popcount(mask[6] & bit[2]);
    uruu_day += __builtin_popcount(mask[7] & bit[9]);

    rep(i,100) day_count[1][i] = day_count[0][i];
    ++day_count[1][uruu_day];

    // ??´??¨???????????????????????????
    ll year_count[2][100]={};
    rep(y,10000)
    {
        int ct = 0;

        int ty = y;
        for(int i=3; i>=0; --i)
        {
            ct += __builtin_popcount(mask[i] & bit[ty%10]);
            ty /= 10;
        }

        ++year_count[is_uruu(y)][ct];
    }

    ll ans = 0;
    rep(yc,100)rep(dc,100)rep(tc,100)if(yc+dc+tc == N)
    {
        rep(i,2) ans += year_count[i][yc]*day_count[i][dc]*time_count[tc];

    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3112
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int one = n % 10;
      if (one == 2 || one == 4 || one == 5 || one == 7 || one == 9) {
        System.out.println("hon");
      } else if (one == 0 || one == 1 || one == 6 || one == 8) {
        System.out.println("pon");
      } else {
        System.out.println("bon");
      }
	}
}

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

int main() {
    int H, W;
    while (1) {
        cin >> H >> W;
        if (H==0 && W==0) break;
        for (int i=0; i < H; i++) {
            for (int j=0; j < W; j++) {
                if (i%2==1) {
                    if (j%2 == 1) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                } else {
                    if (j%2 == 0) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    s = f.read_str()
    n = len(s)
    a = map(int, list(s))

    if a[-1] == 1: return -1
    if a[0] == 0: return -1

    va = [n]
    for i in xrange(n/2):
        if a[i] != a[-i-2]: return -1
        if a[i] == 1:
            vv = va.pop()
            va.extend([vv-(n-(i+1)), n-(i+1)])

    ans = ["%d %d"%(i+1, i+2) for i in xrange(len(va)-1)]
    c = len(va) + 1
    for i, v in enumerate(va):
        for _ in xrange(v-1):
            ans.append("%d %d"%(i+1, c))
            c += 1

    return "\n".join(ans)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, w;
  cin >> n >> w;

  const int N = 1e5+1;
  long long wei[N+5];
  memset(wei, 0x3f, sizeof wei);
  wei[0] = 0;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int wi, v;
    cin >> wi >> v;

    for (int j = N-v; j >= 0; --j) {
      wei[j+v] = min(wei[j+v], wei[j] + wi);
      if (wei[j+v] <= w)  ans = max(ans, j+v);
    }  
  }

  cout << ans << '\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>S;
    N=S.size();
    vector<char>ans;
    rep(i,N){
        if(ans.size()!=0&&S[i]=='B'){
            ans.pop_back();
        }else if(S[i]!='B'){
            ans.pb(S[i]);
        }
    }    
    rep(i,ans.size()){
        cout<<ans[i];
    }
    cout << endl;


    return 0;
    

}

Measured memory_bytes: 3600
k, a, b = map(int, input().split())
bis = 1

if b - a  >= 2 and a < k:
	n = k - a - 1
	if n % 2 == 0:
		bis = b + (b - a) * int(n / 2)
	else:
		bis = b + (b - a) * int(n // 2) + 1

else:
	bis = k + 1

print(bis)

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

int solve(string &s, int cnt = 0){
  while(s != "6174"){
    if(s == "0000")return -1;
    cnt++;
    sort(s.begin(), s.end());
    string tmp = s;
    reverse(tmp.begin(), tmp.end());
    int a = stoi(s), b = stoi(tmp);
    s = to_string(b - a);
    while(s.length() != 4)s.push_back('0');
  }
  return cnt;
}

int main(int argc, char *argv[]){
  string s;
  while(cin >> s){
    if(s == "0000")break;
    int ans = solve(s);
    if(ans != -1)
      std::cout << ans << std::endl;
    else
      std::cout << "NA" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1248
//We Love Golf

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int K,A,B;cin >> K >> A >> B;
    bool flag = false;
    rep(i,A,B+1){
        if(i%K==0)flag=true;
    }
    cout << (flag ? "OK" : "NG") << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=2e5+5,inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
//	cout.tie(0);
	int n,x,y,a=0,b=0,t,pre=0;
	bool ok=true;
	cin>>n;
	rep(i,0,n-1)
	{
		cin>>t>>x>>y;
		int dis=abs(a-x)+abs(b-y);
		int dif=(t-pre)-dis;
	//	cout<<dis<<' '<<dif<<endl;
		if(dif<0||dif%2)
			ok=false;
		a=x,b=y,pre=t;	
	}
	puts(ok?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")

from math import pi, sin, cos, sqrt

def solve(a, b, h, m):
    h = h % 12
    m = m % 60

    hr = h / 12 * 2 * pi + m / 60 / 12 * 2 * pi
    mr = m / 60 * 2 * pi

    hr += 2*pi + pi/4
    mr += 2*pi + pi/4

    hr %= 2*pi
    mr %= 2*pi
    return sqrt(pow(sin(hr)*a - sin(mr)*b,2) + pow(cos(hr)*a - cos(mr)*b,2))



if __name__ == "__main__":
    a, b, h, m = arr_in()
    out(solve(a, b, h ,m))

Measured memory_bytes: 62616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
	int n, m;
	double ans  = 0;
	cin >> n;
	m = ((n - 1) / 2 + 1);
	ans = (double)m / n;

	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<bool> a(101);
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            a[i*j]=true;
        }
    }
    if(a[n])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3600
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

int n,p;

int pw(int x,int n)
{
    int res=1;

    x%=p;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res*x)%p;

        x=(x*x)%p;
    }

    return res;
}


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

    n=s.length();
    p=2019;

    vector<int> pre(n+1,0),cnt(2019,0);
    ++cnt[0];
    for(int i=0;i<n;++i)
    {
        pre[i+1]=(pre[i]+((s[i]-'0')*pw(10,n-i-1))%p)%p;
        ++cnt[pre[i+1]];
    }

    int ans=0;
    for(int i=0;i<p;++i)
        ans+=(cnt[i]*(cnt[i]-1))/2;

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 5136
from heapq import heapify,heappush,heappop
N,M = map(int,input().split())
room = [[] for i in range(0,N+1,1)]
mitisirube = [-1]*(N+1)

for i in range(0,M,1):
    a,b=map(int,input().split())
    room[a].append(b)
    room[b].append(a)

D_INF = 10**10
d = [D_INF]*(N+1)
d[1] = 0
que =[]
heapify(que)
heappush(que,(d[1],1))

while(len(que)):
    time,place = heappop(que)
    if time > d[place]:
        continue
    for i in range(0,len(room[place]),1):
        if d[room[place][i]] > time + 1:
            d[room[place][i]]=time+1
            heappush(que,(time+1,room[place][i]))
            mitisirube[room[place][i]] = place
        
print("Yes")
for i in range(2,N+1,1):
    print(mitisirube[i])

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

int n,ans,cc,blok[105][105],arr[105];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
		for(int j =1;j<=arr[i];j++){
			blok[j][i] = 1;
		}
	}
	for(int i =1;i<=100;i++){
		cc = 0;
		for(int j =0;j<n;j++){
			// printf("%d ",blok[i][j]);
			if(blok[i][j]){
				cc = 1;
			} else {
				if(cc) ans++;
				cc =0;
			}
		}
		if(cc) ans++;
		// printf(">> %d\n", ans);
		// printf("\n");
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc086 {
    export class Program {
        constructor(private readonly args: string[][]) {
        }

        main(this: Program): void {
            const [s]: string[] = this.args[0];
            console.log (s.replace('2017', '2018'));

        }
    }
}

const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
const prg: AtCoder.abc086.Program = new AtCoder.abc086.Program(args);
prg.main();


Measured memory_bytes: 7372
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    int a,b,C;
    double c,S,L,h;
    cin >> a >> b >> C;
    h = b*sin(C*M_PI/180);
    S = a*h/2;
    c = sqrt(a*a + b*b - 2*a*b*cos(C*M_PI/180));
    L = a+b+c;
    cout  << fixed << S << endl;
    cout  << fixed << L << endl;
    cout  << fixed << h << endl;
}


Measured memory_bytes: 3520
//ueharasatoshi@g.ecc.u-tokyo.ac.jp
#include <bits/stdc++.h>
using namespace std;

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

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll gcdd(int a, int b) {
  if(a % b == 0) return b;
  else return gcdd(b, a % b);
}

ll lcmm(int a, int b) {
  return a / gcdd(a, b) * b;
}

signed main() {
	ll n, t, result = 0;
  cin >> n;
  rep(i, n) {
    cin >> t;
    t -= 1;
    result += t;
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,m;
  int i,a,sum=0;
  scanf("%d",&n); //休みの日数
  scanf("%d",&m); //宿題の数
  for(i=0;i<m;i++){
    scanf("%d",&a); //終わらせるまでの日数
    sum+=a;
  }
  if(n-sum>=0) printf("%d",n-sum);
  else printf("-1");
  return 0;
}

Measured memory_bytes: 1708
S = input()

ans = ""
for i in range(len(S)):
    if S[i] == "B":
        if ans == "":
            pass
        else:
            ans = ans[:-1]
    elif S[i] == "0":
        ans += "0"
    elif S[i] == "1":
        ans += "1"

print(ans) 

Measured memory_bytes: 2940
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>

using namespace std;
int main(){
    int n, sum = 0;
    cin >> n;
    vector<int>v(n);
    for(int i = 0; i<n; i++){
        cin >> v[i];
    }
    for(int i = 0; i<n-1; i++){
        for(int j = i+1; j<n; j++){
            sum+=(v[i]*v[j]);
        }
    }
    
    cout << sum;
    
}




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

typedef long long ll;
typedef double db;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int mod   = 1e9 + 7;
const int maxn  = 3e6;
const int inf   = 2e9;


int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    int a,b,c;
    int ans;
    cin>>a>>b>>c;
    ans+=a+b+c;
    int k=max(a,max(b,c));
    cout<<ans-k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int i,j;
  int n,k;

  cin>>n>>k;

  ll ans=k;

  rep(i,n-1)
    ans*=k-1;
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int h,w;
  int final = 0;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char tmp;
      cin >> tmp;
      if(tmp=='#' && j<final){
        cout<< "Impossible" <<endl;
        return 0;
      }
      if(tmp=='#') final = j;
    }
  }
  cout<< "Possible" <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	long int n,m;
	long int l;
	long int l_n,l_m;
	long int div_n,div_m;
	long int cnt_n,cnt_m;

	char s[500001], t[500001];
	

	scanf("%ld %ld",&n,&m);
	scanf("%s",s);
	scanf("%s",t);

//	printf("n:%d m:%d\n",n,m);
//	printf("s:%s\n",s);
//	printf("t:%s\n",t);

	l_n = n;
	l_m = m;
	div_n = 1;
	div_m = 1;

	while(l_n != l_m){
		while(l_n < l_m){
			l_n += n;
			div_n++;
		}
		while(l_m < l_n){
			l_m += m;
			div_m++;
		}
	}

	l = l_n;

	//printf("l:%d\n",l);
	//printf("div_n:%d\n",div_n);
	//printf("div_m:%d\n",div_m);

	cnt_n = 0;
	cnt_m = 0;
	//printf("check %c vs %c (n:%d,m:%d)\n",s[cnt_n],t[cnt_m],cnt_n,cnt_m);
	if(s[cnt_n] == t[cnt_m]){
		//競合しない場合(OK)
		//両方のカウントを進める。
		cnt_n++;
		cnt_m++;

	}
	else{
		//競合する場合(NG)
		//文字列なし
		printf("-1\n");

		return 0;
	}


	while(cnt_n < n || cnt_m < m){
		if(cnt_n * div_n == cnt_m * div_m){
			//printf("check %c vs %c (n:%d,m:%d)\n",s[cnt_n],t[cnt_m],cnt_n,cnt_m);
			if(s[cnt_n] == t[cnt_m]){
				//競合しない場合(OK)
				//両方のカウントを進める。
				cnt_n++;
				cnt_m++;

			}
			else{
				//競合する場合(NG)
				//文字列なし
				printf("-1\n");
				return 0;
			}
		}
		else if(cnt_n * div_n > cnt_m * div_m){
			//printf("m++ (n:%d,m:%d)\n",cnt_n,cnt_m);
			cnt_m++;
		}

		else{	//(cnt_n * div_n < cnt_m * div_m)
			//printf("n++ (n:%d,m:%d)\n",cnt_n,cnt_m);
			cnt_n++;
		}
	}

	//最後まで来れた場合は最小公倍数の長さが回答
	printf("%ld\n",l);
	return 0;

}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    long long d = c - b - a;
    if(d > 0 && d*d > 4*a*b) {
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 384
//syntaxerorr
#include<bits/stdc++.h>
using namespace std;
#define i_am_speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define r(i,a) for(i=a;i>=0;i--)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define ff first
#define sc second
#define mp make_pair
#define pb push_back
#define nl cout<<endl
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define sz(a) a.size()
#define llu unsigned long long int
#define pi pair<int,int>
#define plli pair<lli,lli>
#define ppl pair<lli,pair<lli,lli> >
#define ppi pair<int,pair<int,int> >
#define vlli vector<lli> v;
#define vii vector<int> v;
#define vl(n) vector<lli> v[n];
#define fu fflush(stdout)
#define in(a,n) lli a[n]; for(lli i=0;i<n;i++)  cin>>a[i];
#define pv(v) for(auto it=v.begin(),v.end(),it++) cout<<*it<<" ";
#define ps(s) for(auto it=s.begin();it!=s.end();it++) cout<<*it<<" ";
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005

int main()
{
    i_am_speed;
    lli t,n, i, u, v,cnt= 0, d;
    cin >> n >> d;
    f(i,0,n)
    {
        cin >> u >> v;
        if((u*u) + (v*v) <= d*d)
            cnt++;
    }
    cout << cnt << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll a,b;
    cin >> a >> b;
    ll cnt = 0;
    ll memo = 1;
    while(memo < b){
        memo += a-1;
        cnt++;
    }

    cout << cnt << endl;
}


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

int n, k;

int d;
int a;

int main(){
  cin >> n >> k;
  vector<int> get(n);
  for(int i=0; i<k; i++){
    cin >> d;
    for(int j=0; j<d; j++){
      cin >> a;
      get[a-1] = 1;
    }
  }
  int count=0;
  for(int i=0; i<n; i++){
    if(get[i] == 1){
      count++;
    }
  }
  cout << n-count << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[][] AB = new int[N][2];
    for (int i = 0; i < N; i++) {
      AB[i][0] = sc.nextInt();
      AB[i][1] = sc.nextInt();
    }
    
    Arrays.sort(AB, (i, j) -> {
      return i[0] - j[0];
    });
    
    long pay = 0;
    int remain = M;
    for (int i = 0; i < N ; i++) {
      int price = AB[i][0];
      int count = AB[i][1];
      if (remain - count > 0) {
        pay += ((long) count*price);
        remain -= count;
      } else {
        pay += ((long) remain*price);
        break;
      }
    }

    System.out.println(pay);
  }
}

Measured memory_bytes: 93132
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int n;
    string t;
    cin >> n >> t;
    int ans = 0;
    rep(now,n){
        string s = t.substr(now);
        int l = s.size();
        vector<int>z(l);
        z[0]=l;
        int i = 1,j = 0;
        while(i<l){
            while(i+j < l && s[j] == s[i+j]) j++;
            z[i] = j;
            if(j == 0){
                i++;
                continue;
            }
            int k = 1;
            while(k < j && k+z[k] < j){
                z[i + k] = z[k];
                k++;
            }
            i += k;
            j -= k;
        }
        rep(i,l){
            if (i == 0)continue;
            chmax(ans,min(i,z[i]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        HashSet<Integer> hashSet = new HashSet<>();

        int candidate = A;

        while (!hashSet.contains(candidate)){
            if(C == (candidate % B)){
                System.out.println("YES");
                return;
            }else{
                if(hashSet.contains(candidate % B)){
                    break;
                }
                hashSet.add(candidate % B);
                candidate += A;
            }
        }

        System.out.println("NO");

    }
}


Measured memory_bytes: 22608
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main()
{
    int n;cin>>n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    vector<pair<int, int>> p(n);
    for(i=0;i<n;i++)p.at(i)=make_pair(a.at(i),i+1);
    sort(p.begin(),p.end());
    for(i=0;i<n;i++)
    {
        if(i==0)cout<<p.at(i).second;
        else cout<<' '<<p.at(i).second;
    }
    cout<<endl;
}


Measured memory_bytes: 2048
S = list(input())
long = len(S)
max = 0
for i in range(long):
    count=0
    for j in range(i,long):
        if S[j] == "A" or S[j] =="C" or S[j] == "G" or S[j] == "T":
            count +=1
        else:
            break
    if count >max:
        max=count
print(max)

Measured memory_bytes: 3064
n, m = map(int,input().split())
sList = []
for i in range(m):
  tempList = list(map(int, input().split()))
  k = tempList.pop(0)
  num = 0
  for j in tempList:
    num += 2 ** (j-1)
  sList.append(num)
pList = list(map(int,input().split()))
answer = 0
sw = True

for i in range(2**n):
  for j in range(len(sList)):
    p = i & sList[j]
    tf = (bin(p).count('1') + pList[j]) % 2
    if tf == 1:
      sw = False
      break
  if sw == True:
    answer += 1
  else:
    sw = True
    
print(answer)

Measured memory_bytes: 3064
// Problem : A - Restaurant
// Contest : AtCoder - AtCoder Beginner Contest 055
// URL : https://atcoder.jp/contests/abc055/tasks/abc055_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

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

void solve()
{
int n;cin>>n;
cout<<n*800-(n/15)*200;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_B&lang=jp>
 */

func init() {
}

func main() {
	for {
		var H, W int
		fmt.Scanf("%d %d", &H, &W)
		if H == 0 && W == 0{
			break
		}
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				if i == 0 || j == 0 || i == H-1 || j == W-1{
					fmt.Print("#")
				}else {
					fmt.Print(".")
				}
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    bool rev = false;
    deque<char> deq;
	for(auto e:S) deq.push_back(e);
    rep(i, Q) {
        int q = 0;
        cin >> q;
        if (q == 1) {
            rev = !rev;
            continue;
        }
        int F;
        char C;
        cin >> F >> C;
        if (!rev) {
            if (F == 1)
                deq.push_front(C);
            else
                deq.push_back(C);

        } else {
            if (F == 1)
                deq.push_back(C);
            else
                deq.push_front(C);
        }
    }

    if(!rev){
		for(auto e:deq) cout << e;
	} else {
		for(int i = deq.size()-1;i>=0;--i){
            cout << deq[i];
        }
	}
	cout << endl;
}

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

#define ll long long
#define ull unsigned long long

int main()
{
	const ull M = 1000000007;
	ull n, k;
	cin >> n >> k;
	ull ans = 0;
	for (ull i=k-1; i<n; i++)
	{
		ull mn = i*(i+1)/2;
		ull mx = (n-i+n)*(i+1)/2;
		ans = (ans + mx-mn+1) % M;
	}
	cout << (ans+1) % M;
}

Measured memory_bytes: 3624
n=int(input())
a=[int(input()) for i in range(n)]
max1=sorted(a)[-1]
if n==2:
    print(a[1])
    print(a[0])
elif sorted(a)[-2]!=max1:
    max=sorted(a)
    max2=0
    for i in range(2,n):
        if max[-i]!=max1:
            max2=max[-i]
            break
    for i in range(n):
        if a[i]==max1:
            print(max2)
        else:
            print(max1)
else:
    for i in range(n):
        print(max1)


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

int main()
{
	string str;
	cin >> str;
	
	int count = 0;
	
	for (int i = 0; i < 3; ++i)
		if (str[i] == '1'){
			count += 1;
		}
		
	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){

  int a,d,s,i;

  while(scanf("%d",&d) != EOF)
    {
      s=0;
      i=1;
      a = round(600/d);
      while(i<a)
	{
	  s += pow(600-(d*i),2) * d;
	  i++;
	}

      printf("%d\n",s);
    }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#define x first
#define y second

using namespace std;

int check_elimination(int n, int q, int idx, string &s, vector <pair <char, char> > &st) {
    int curr_pos = idx, curr_char = s[idx];
    for (auto &&spell: st) {
        if (spell.x == curr_char) {
            if (spell.y == 'L') {
                curr_pos--;
                if (curr_pos == -1)
                    return 1;
            }
            else {
                curr_pos++;
                if (curr_pos == n)
                    return 2;
            }
            curr_char = s[curr_pos];
        }
    }
    return 0;
}

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector <pair <char, char> > st(q);
    for (int i = 0; i < q; i++) {
        cin >> st[i].x >> st[i].y;
    }

    int rightmost = -1, leftmost = n, left = 0, right = n - 1, middle;
    while (left <= right) {
        middle = left + (right - left) / 2;
        if (check_elimination(n, q, middle, s, st) == 1) {
            rightmost = middle;
            left = middle + 1;
        }
        else {
            right = middle - 1;
        }
    }

    left = 0; 
    right = n - 1;

    while (left <= right) {
        middle = left + (right - left) / 2;
        if (check_elimination(n, q, middle, s, st) == 2) {
            leftmost = middle;
            right = middle - 1;
        }
        else {
            left = middle + 1;
        }
    }

    cout << n - (rightmost + 1 + n - leftmost) << '\n';
    return 0;
}

Measured memory_bytes: 900
x, y = gets.split.map &:to_i
# a = 2 * x - y / 2
# b = y / 2 - x
# puts (a >= 0 && b >= 0)  ? "Yes" : "No"
flag = 0

0.upto(x) { |kame|
  turu = x - kame
  if turu * 2 + kame * 4 == y
    flag = 1 # detected
    break
  end
}

puts flag == 1 ? "Yes" : "No"


Measured memory_bytes: 14356
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           
           vector <int>  a(n , 0);
           for(int i = 0 ; i < n ; i++)cin >> a[i];
           
           ll sum = 0;
           for(int i = 1 ; i < n ; i++)
           {
               if(a[i] < a[i - 1])
               {
                   int d = a[i - 1] - a[i];
                   sum += d;
                   a[i] += d;
               }
           }
           
           cout << sum << endl;
        }
    }



Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    int c=0;
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        if(c==3)
        {
            flag=true;
            break;
        }
        if(v[i].first==v[i].second)
            c++;
        else
            c=0; 
        
        if(c==3)
        {
            flag=true;
            break;
        }
        
    }
    if(flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main(){
  int k;
  int a, b;

  cin >> k;
  cin >> a >> b;

  if (k == 1){
    cout << "OK";
    return 0;
  }

  if (a % k == 0 || b % k == 0){
    cout << "OK";
    return 0;
  } else {
    a /= k;
    b /= k;

    if (b - a >= 1){
      cout << "OK";
    } else {
      cout << "NG";
    }
  }

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


//1104

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

//d:n-0 e-1 s-2 w-3

int main(){
	int w[2], d, p[2];
	string s;
	int n;
	while(cin>>w[0]>>w[1]){
		if(w[0] == 0 && w[1] == 0) break;
		d = 0;
		p[0] = p[1] = 1;
		while(cin>>s && s != "STOP"){
			// cout<<d<<endl;
			// cout<<p[0]<<" "<<p[1]<<endl;
			if(s == "FORWARD"){
				cin>>n;
				p[d % 2] = p[d % 2] + (d/2==0?n:-n);
			}
			else if(s == "RIGHT") d = (d + 1) % 4;
			else if(s == "LEFT") d = (d + 3) % 4;
			else if(s == "BACKWARD"){
				cin>>n;
				p[d % 2] = p[d % 2] + (d/2==0?-n:n);
			}
			p[d % 2] = min(w[(d + 1) % 2], p[d % 2]);
			p[d % 2] = max(1, p[d % 2]);
		}
		//cout<<d<<endl;
		cout<<p[1]<<" "<<p[0]<<endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=2e5+20;
const ll mod=1e9+7;
ll f[N],n,m,A,B;
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n){
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n,ll m)
{
    ll a=f[n];
    ll b=(f[m]*f[n-m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    f[0]=1;
    for(ll i=1;i<N;i++)
        f[i]=(f[i-1]*i)%mod;
    while(cin>>n>>m>>A>>B){
        ll res=0;
        for(ll i=B+1;i<=m;i++){
            ll tmp=(C(i-1+n-A-1,n-A-1)*C(m-i+A-1,m-i))%mod;
            res=(res+tmp)%mod;
        }
        cout<<res<<endl;
    }
    return 0;
}


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

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

  vector<pair<int, int> > d(n + 1);
  for (int i = 1; i <= n; i++) cin >> d[i].first >> d[i].second;

  for (int i = 1; i <= n - 2; i++) {
    if (d[i].first == d[i].second && d[i + 1].first == d[i + 1].second &&
        d[i + 2].first == d[i + 2].second) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3640
local mmin, mfl, ior = math.min, math.floor, io.read
local n, c = ior("*n", "*n")
local d = {}
for i = 1, c * c do
  d[i] = ior("*n")
end
local diffsum = {}
for i = 1, 3 * c do
  diffsum[i] = 0
end
for pos = 1, n * n do
  local row, col = 1 + mfl((pos - 1) / n), pos % n
  if(col == 0) then col = n end
  local md = (row + col) % 3
  local a = ior("*n")
  for i_c = 1, c do
    local idx = md * c + i_c
    diffsum[idx] = diffsum[idx] + d[(a - 1) * c + i_c]
  end
end
local dfmin = diffsum[1] + diffsum[c + 2] + diffsum[2 * c + 3]
for i_1 = 1, c do
  for i_2 = 1, c do
    if(i_1 ~= i_2) then
      for i_3 = 1, c do
        if(i_1 ~= i_3 and i_2 ~= i_3) then
          dfmin = mmin(dfmin, diffsum[i_1] + diffsum[c + i_2] + diffsum[2 * c + i_3])
        end
      end
    end
  end
end
print(dfmin)


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>


using namespace std;


int main() {
	int K, X;
	cin >> K >> X;

	for (int i = X-K+1; i < X+K; i++) {
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
function gcd($x,$y){
    if($y === 0) {
        return $x;
    } else {
        return gcd($y, $x%$y);
    }
}
$gcd = gcd($a, $b);

$init = 2;
$comPrime = array();
while($init <= floor(sqrt($gcd))){
    if($gcd % $init === 0) {
        $gcd /= $init;
        $comPrime[] = $init;
    } else {
        $init++;
    }
}
if($gcd > 1){
    $comPrime[] = $gcd;
}
$uniquePrime = array_unique($comPrime);
echo count($uniquePrime) + 1;

Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N=2e5+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int to[N<<1],nt[N<<1],hd[N],dg[N][2],tot=1;
void adde(int x,int y)
{
    ++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot;
    ++tot,to[tot]=x,nt[tot]=hd[y],hd[y]=tot;
}
char cc[N];
int n,m,tt;
bool v[N];

int main()
{
    n=rd(),m=rd();
    scanf("%s",cc+1);
    for(int i=1;i<=m;++i)
    {
	int x=rd(),y=rd();
	adde(x,y);
	++dg[x][cc[y]-'A'],++dg[y][cc[x]-'A'];
    }
    queue<int> q;
    for(int i=1;i<=n;++i)
	if(!dg[i][0]||!dg[i][1]) v[i]=1,q.push(i);
    while(!q.empty())
    {
	int x=q.front();
	q.pop();
	++tt;
	for(int i=hd[x];i;i=nt[i])
	{
	    int y=to[i];
	    --dg[y][cc[x]-'A'];
	    if(!v[y]&&!dg[y][cc[x]-'A']) v[y]=1,q.push(y);
	}
    }
    puts(tt==n?"No":"Yes");
    return 0;
}




Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = b*d;
    chmax(ans,a*c);
    chmax(ans,a*d);
    chmax(ans,b*c);
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int x;
int main(){
	scanf("%d", &x);
	int ans = 1;
	for(int i = 2; i*i <= x; i++){
		int vis = i*i;
		while(vis <= x){
			ans = std::max(ans, vis);
			vis *= i;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)] #親
        self.rank = [0 for _ in range(n)] #根の深さ

    #xの属する木の根を求める
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    #xとyの属する集合のマージ
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    #xとyが同じ集合に属するかを判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    
N, K, L = map(int, input().split())
    
p = [list(map(int, input().split())) for _ in range(K)]

r = [list(map(int, input().split())) for _ in range(L)]

res = [1 for _ in range(N)]
    
load = UnionFind(N)
train = UnionFind(N)

for i in range(K):
    load.unite(p[i][0]-1, p[i][1]-1)
    
for i in range(L):
    train.unite(r[i][0]-1, r[i][1]-1)
    
    
dic= {}
for i in range(N):
    tmp = (load.find(i), train.find(i))
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

        
for i in range(N):
    tmp = (load.find(i), train.find(i))
    res[i] = dic[tmp]
    
result = ''
for i in range(N):
    result += str(res[i]) + ' '
    
print(result)

Measured memory_bytes: 102168
n = int(input())
costs = list(map(int, input().split()))
a, b = 0, abs(costs[1]-costs[0])
i = 2
while i < n:
	a, b = b, min(abs(costs[i] - costs[i-1]) + b, abs(costs[i] - costs[i-2]) + a)
	i += 1
print(b)

Measured memory_bytes: 13928
o = int(input())
a = list(map(int,input().split()))

b,c = 0,0
for i in a:
    if (i%2)==0:
        b += 1
        if(i%3 == 0) or (i%5 == 0):
            c += 1

if (b == c):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060