akhauriyash/Code-Regression huggingface dataset:
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


bool comp(pi &a, pi &b){
  return a.fs*b.sc>a.sc*b.fs;
}

int dp[100101];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int h,n;
  cin >> h >> n;
  vpi v(n);
  for(int i=0;i<n;i++){
    cin >> v[i].fs >> v[i].sc;
  }
  for(int i=0;i<=h;i++){
    dp[i]=1e18;
  }
  dp[h]=0;
  for(int i=h;i>0;i--){
    for(int j=0;j<v.size();j++){
      int nxt = max(i-v[j].fs,0LL);
      dp[nxt] = min(dp[nxt],dp[i]+v[j].sc);
    }
  }
  cout << dp[0] << endl;

  // sort(v.begin(),v.end(),comp);
  // while(h>0){
  //   if(h>=v[0].fs){
  //     h-=v[i].fs;
  //     ans+=v[0].sc;
  //   }
  //   else {
  //     int mn = v[0].sc;
  //     for(int i=0;i<n;i++){
  //       if(v[])
  //     }
  //   }
  // }


return 0;
}
///....


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<b)return 0; a=b; return 1;}



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

    double n;
    cin>>n;
    double ans = n*n*n;
    for(int i=0;i<3;i++){
        ans /= 3.00;
    }
    cout << ans << endl;
}

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

int main() {
    string S, T;
    cin >> S >> T;

    string ans = "";
    bool restorable = false;
    for (int i = S.size(); i >= T.size(); --i) {
        int pos = i - T.size();
        bool accept = true;
        for (int j = 0; j < T.size(); ++j) {
            if (S[pos + j] != '?' && S[pos + j] != T[j]) {
                accept = false;
                break;
            }
        }
        if (accept) {
            restorable = true;
            if (pos != 0) {
                ans += S.substr(0, pos);
            }
            ans += T;
            if (pos + T.size() < S.size()) {
                int idx = pos + T.size();
                int len = S.size() - idx;
                ans += S.substr(idx, len);
            }
            break;
        }
    }
    if (!restorable) {
        cout << "UNRESTORABLE" << endl;
    } else {
        rep(i, ans.size()) {
            if (ans[i] == '?') {
                ans[i] = 'a';
            }
        }
        cout << ans << endl;
    }
}

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

bool isValid(int c[3][3]) {
  for (int i = 0; i < 2; ++i) {
    if (c[i][0] - c[i][1] != c[i + 1][0] - c[i + 1][1]) return false;
    if (c[i][1] - c[i][2] != c[i + 1][1] - c[i + 1][2]) return false;
    if (c[0][i] - c[1][i] != c[0][i + 1] - c[1][i + 1]) return false;
    if (c[1][i] - c[2][i] != c[1][i + 1] - c[2][i + 1]) return false;
  }
  return true;
}

int main() {
  int c[3][3];
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> c[i][j];
  cout << (isValid(c) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
xy = [[int(i) for i in input().split()] for _ in range(m)]
num = [1]*n
red = [False]*n
red[0] = True
flag = True
for i in range(m):
    p = xy[i][0]
    q = xy[i][1]
    num[p-1] -= 1
    num[q-1] += 1
    if red[p-1]==True:
        red[q-1] = True
    
    if num[p-1]==0:
        red[p-1] = False
        

count = 0
for i in range(n):
    if num[i]>0 and red[i]:
        count += 1
print(count)

Measured memory_bytes: 62296
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int e[12],i,n,m;
	for(i=0;i<12;i++){
		scanf("%d",&e[i]);
	}
	sort(e,e+12);
	m=0;
	for(i=0;i<3;i++){
		if(e[i]!=e[i+1]){
			m++;
		}
		
	}
	for(i=4;i<7;i++){
		if(e[i]!=e[i+1]){
			m++;
		}
	}
	for(i=8;i<11;i++){
		if(e[i]!=e[i+1]){
			m++;
		}
	}
	if(m==0){
		printf("yes\n");
	}
	else{
		printf("no\n");
	}
	return 0;
}



Measured memory_bytes: 2744
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<cassert>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define all(n) (n).begin(),(n).end()
#define inf (1<<29)

using namespace std;
typedef pair<int,int> ii;

struct P
{
  ii time;
  bool dir;//0->上, 1->下
  P(ii time=ii(inf,inf),bool dir=false):time(time),dir(dir){}
};

int ans;
int n;

void compute(vector<vector<P> > &record,ii person)
{
  int cur = 0;
  record.push_back(vector<P>());


  rep(i,person.second*2)
    {
      bool dir = i % 2;//0->上,1->下
      int next = cur + person.first;

      rep(j,record.size()-1)
	{
	  rep(k,record[j].size())
	    {
	      P p = record[j][k];
	      if(p.dir != dir)continue;
	      if(p.time.first > cur)break;

	      if(p.time.second == next || p.time.first == cur)
		{
		  break;		  
		}
	      else if(p.time.first < next && next < p.time.second)
		{
		  next = max(p.time.second,next);
		  break;
		}
	    }
	}

      record[record.size()-1].push_back(P(ii(cur,next),dir));
      cur = next;
      ans = max(ans,next);
    } 
}

int main()
{
  while(scanf("%d",&n),n)
    {
      ans = 0;
      vector<ii> info(n);
      rep(i,n)scanf("%d %d",&info[i].first,&info[i].second);
      sort(all(info),greater<ii>());

      vector<vector<P> > record;

      rep(i,n)compute(record,info[i]);

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

    }
  return 0;
}

Measured memory_bytes: 1492
data class HWC(val h: Int, val w: Int, val c: Int) {
    constructor(hwc: List<Int>): this(hwc[0], hwc[1], hwc[2])
}
fun main(args: Array<String>) {
    val dh = listOf(0, 1, 0, -1)
    val dw = listOf(1, 0, -1, 0)
    val (H, W) = listOfInt()
    var S = Array(H) { next().toCharArray() }
    val white = '.'; val black = '#'; val white2 = '@'
    var whiteCnt = S.sumBy { s -> s.count { it == white } }
    var goal = false
    val que = Queue<HWC>()
    que.enqueue(HWC(0, 0, 1))
    while (!que.isEmpty()) {
        val p = que.dequeue()!!
        val h = p.h; val w = p.w; val c = p.c
        if (S[h][w] != white) continue
        if (h == H - 1 && w == W - 1) {
            goal = true
            whiteCnt -= c
            break
        }
        for (n in 0 until 4) {
            val nh = h + dh[n]; val nw =  w + dw[n]
            if (nh < 0 || nw < 0 || nw > W - 1 || nh > H - 1) continue
            if (S[nh][nw] == white) {
                que.enqueue(HWC(nh, nw, c + 1))
                S[h][w] = white2
            }
        }
    }
    val ans = if (goal) whiteCnt else -1
    println(ans)
}
class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }




Measured memory_bytes: 37956
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main()
{
	int n;
	cin >> n;
	vector<int> hap[n+5];
	vector<int> dp[n+5];
	for (int i=0 ; i<n ; i++) 
	{
		int a,b,c;
		cin >> a >> b >> c;
		hap[i].pb(a);
		hap[i].pb(b);
		hap[i].pb(c);
		dp[i].pb(0);
		dp[i].pb(0);
		dp[i].pb(0);
	}
	//memset(dp,0,sizeof(dp));
	dp[0][0] = hap[0][0];
	dp[0][1] = hap[0][1];
	dp[0][2] = hap[0][2];
	for(int i = 1; i < n; i++){
			dp[i][0] = hap[i][0]+max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = hap[i][1]+max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = hap[i][2]+max(dp[i-1][0], dp[i-1][1]);
	}
	int ans = *max_element(dp[n-1].begin(),dp[n-1].end());
//	for (int i=0 ; i<n ; i++)
//	{
//		ans = max(ans,dp[n-1][i]);
//	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14496
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int H, W;
	string a[150];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}
	string base;
	for (int i = 0; i < W+2; i++) {
		base += "#";
	}
	print(base);
	for (int i = 0; i < H; i++) {
		a[i] = "#" + a[i] + "#";
		print(a[i]);
	}
	print(base);



	return 0;
}

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

typedef long long ll;

int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i=0; i<N; i++) cin >> a[i];

  ll ans=0;
  if (a[0] > x) {
    ans += a[0] - x;
    a[0] = x;
  }
  for (int i=1; i<N; i++) {
    if (a[i-1] + a[i] > x) {
      ans += a[i-1] + a[i] - x;
      a[i] = x - a[i-1]; 
    }
  }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    ll N;
    cin >> N;

    vl A;
    ll a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
    }

    sort(A.begin(), A.end());

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

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 2420
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,k=LI()
r,s,p=LI()
t=input()
m=list('rsp')
a=[p,r,s]
dc=dict(zip(m,a))
z=[]
for i in range(k):
    z.append(''.join(t[i::k]))
for zz in z:
    pre=None
    for zzz in zz:
        if pre!=zzz:
            ans+=dc[zzz]
            pre=zzz
        else:
            pre=None
#        show(ans,zzz)
print(ans)


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

class UF {
	int par[50], sz;
public:
	void init(int n) { for (int i = 0; i < n; i++) par[i] = i; sz = n; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void marge(int x, int y) { x = root(x); y = root(y); if (x != y) { par[x] = y; sz--; } }
	int getSize() { return sz; }
};

int main() {
	int i, j;
	int n, m;
	int a[2500], b[2500];
	
	cin >> n >> m;
	for (i = 0; i < m; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; }
	
	int ans = 0;
	for (i = 0; i < m; i++) {
		UF uf;
		uf.init(n);
		for (j = 0; j < m; j++) {
			if (i == j) continue;
			uf.marge(a[j], b[j]);
		}
		ans += (uf.getSize() >= 2);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        if (row[i])
        {
            for (int j = 0; j < w; j++)
            {
                if (col[j])
                {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll suma = max({a*c , a*d, b*c , b*d});
	cout << suma << endl;
	return 0;
} 





Measured memory_bytes: 3592
N, M = map(int,input().split())
A = list(map(int,input().split()))

A_sum = sum(A)
evo = A_sum/(4*M)

counter = 0
for vote in A:
    if vote >= evo:
        counter += 1

if counter < M:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
require 'prime'

def factorial(number)
  (1..number).inject(1,:*)
end

n = gets.chomp.to_i

s = factorial(n).prime_division.map{|a| a[1]}

total = 0

# 75
count75 = s.select{|x| x >= 74}.size

total += count75

# 25, 3
count25 = s.select{|x| x >= 24}.size
count3 = s.select{|x| x >= 2}.size

total += count25 * (count3 - 1)

# 15, 5
count15 = s.select{|x| x >= 14}.size
count5 = s.select{|x| x >= 4}.size

total += count15 * (count5 - 1)

# 5, 5, 3
total += count5 * (count5 - 1) * (count3 - 2) / 2

puts total

Measured memory_bytes: 2428
import sys

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = sorted([Z() for _ in range(N)])
    used = [0] * (N)
    output1 = output2 = 0

    i1 = i2 = 0
    j1, j2 = N-1, N-2
    f1 = f2 = True
    used[i1], used[i2], used[j1], used[j2] = 1, 1, 1, 1

    while f1 or f2:
        if f1: output1 += (A[j1]-A[i1])
        if f2: output1 += (A[j2]-A[i2])

        while used[i1]:
            if i1 == N-1:
                f1 = False
                break
            i1 += 1
        used[i1] = 1

        while used[i2]:
            if i2 == N-1:
                f2 = False
                break
            i2 += 1
        used[i2] = 1

        if f1: output1 += (A[j1]-A[i1])
        if f2: output1 += (A[j2]-A[i2])

        while used[j1]:
            if j1 == 0:
                f1 = False
                break
            j1 -= 1
        used[j1] = 1
        while used[j2]:
            if j2 == 0:
                f2 = False
                break
            j2 -= 1
        used[j2] = 1

    i1, i2 = 0, 1
    j1 = j2 = N-1
    f1 = f2 = True
    used = [0] * (N)
    used[i1], used[i2], used[j1], used[j2] = 1, 1, 1, 1

    while f1 or f2:
        if f1: output2 += (A[j1]-A[i1])
        if f2: output2 += (A[j2]-A[i2])

        while used[j1]:
            if j1 == 0:
                f1 = False
                break
            j1 -= 1
        used[j1] = 1
        while used[j2]:
            if j2 == 0:
                f2 = False
                break
            j2 -= 1
        used[j2] = 1

        if f1: output2 += (A[j1]-A[i1])
        if f2: output2 += (A[j2]-A[i2])

        while used[i1]:
            if i1 == N-1:
                f1 = False
                break
            i1 += 1
        used[i1] = 1

        while used[i2]:
            if i2 == N-1:
                f2 = False
                break
            i2 += 1
        used[i2] = 1


    print(max(output1, output2))

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 8588
N, W = map(int, input().split())

d = [[0 for i in range(W + 1)]]

for i in range(0, N):
    d.append([])
    v_i, w_i = map(int, input().split())
    for k in range(0, W + 1):
        if k >= w_i:
            d[i + 1].append(max(d[i][k - w_i] + v_i, d[i][k]))
        else:
            d[i + 1].append(d[i][k])
            
print(max(d[N]))


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

int main(){
  int n;
  cin >>n;
  long long ans = 1;
  for(int i=0;i<n;i++){
    long long x;
    cin >>x;
    ans = ans/__gcd(ans,x)*x;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int dp[10000];
    dp[0] = 0;
    for(int i = 1; i < 10000; i++) dp[i] = -1;
    
    int N, M;
    cin >> N >> M;
    int a[M];
    int types[M];
    
    for(int i = 0; i < M; i++){
        types[i] = 0;
        int b;
        cin >> a[i] >> b;
        for(int j = 0; j < b; j++){
            int c;
            cin >> c;
            types[i] += pow(2, N-c);
        }
    }
    
    int checkpoint = pow(2, N) - 1;
    

    for(int keyNum = 0; keyNum < M; keyNum++){
        for(int i = checkpoint; i >= 0; i--){
            
            if(dp[i] != -1){
                int tmp = i | types[keyNum];
                if(dp[tmp] == -1)   dp[tmp] = dp[i] + a[keyNum];
                else    dp[tmp] = min(dp[tmp], dp[i] + a[keyNum]);
            }
            
        }
    }
    
    cout << dp[checkpoint] << "\n";
    return 0;
}


Measured memory_bytes: 256
# Depth First Search
from collections import deque

N = int(input())
nodes = []
G ={}
is_visited = {}

for _ in range(N):
    lst = list(map(int, input().split()))
    idx = lst[0]
    nodes.append(idx)
    is_visited[idx] = False
    degree = lst[1]
    if degree > 0:
        G[idx] = lst[2:]
    else:
        G[idx] = []
        
d = {}  # 最初に訪問したときの発見時刻を記録する
f = {}  # 隣接リストを調べ終えた完了時刻を記録する
t = 1

def dfs(node):
    global t
    if (is_visited[node] == True):
        return
    is_visited[node] = True
    d[node] = t
    t += 1  # 時刻を一つ進める
    # 再帰探索
    for idx in G[node]:
        dfs(idx)
    f[node] = t
    t += 1  # 関数を終了するときにも+1する


for node in nodes:  # 孤立しているノードもあるためこうして対処
    dfs(node)

for node in nodes:
    print(node, d[node], f[node])



Measured memory_bytes: 6108
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int inA = in.nextInt();
	int inB = in.nextInt();
	int inC = in.nextInt();
	while (inA != -1 || inB != -1 || inC != -1) {
	 int s = inA * 3600 + inB * 60 + inC;
	 int a = 2 * 3600 - s;
	 int b = a * 3;
	 System.out.format("%02d:%02d:%02d", a / 3600,
		 (a % 3600) / 60, a % 60);
	 System.out.println();
	 System.out.format("%02d:%02d:%02d", b / 3600,
		 (b % 3600) / 60, b % 60);
	 System.out.println();
	 inA = in.nextInt();
	 inB = in.nextInt();
	 inC = in.nextInt();
	}
 }
}

Measured memory_bytes: 18556
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int coin[]={10,50,100,500};
int main(){
    int n;
    bool flag=false;
    while(cin>>n,n){
        int c=0;
        int r[4];
        for(int i=0;i<4;i++){
            cin>>r[i];
            c+=r[i]*coin[i];
        }
        int s[4];
        c-=n;
        for(int i=3;i>=0;i--){
            s[i]=c/coin[i];
            c%=coin[i];
        }
        if(flag)cout<<endl;
        else flag=true;
        for(int i=0;i<4;i++){
            int val=max(0,r[i]-s[i]);
            if(val)cout<<coin[i]<<" "<<val<<endl;
        }
    }
    return 0;
}

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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int n;
  std::cin >> n;
  cout("ABC" + std::to_string(n));
}


Measured memory_bytes: 256
from bisect import bisect_right
import sys
from functools import lru_cache

sys.setrecursionlimit(10**8)

N = int(input())

# Nの範囲に伴う累乗の範囲
# 1: inf
# 6: 1-6
# 9: 1-5

l = [6**i for i in range(1, 6+1)] + [9**i for i in range(1, 5+1)]
l.sort()

# print(l)

@lru_cache(maxsize=None)
def dfs(n):
	r = bisect_right(l, n)
	if r <= 0:
		return n
	min_num = 10**9
	for i in range(r):
		min_num = min(min_num, dfs(n-l[i])+1)
	return min_num

print(dfs(N))

Measured memory_bytes: 47328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,k;
	while(cin>>n,n){
		vvl vv;
		rep(i,n){
			cin>>m;
			vl v(m);
			rep(j,m)cin>>v[j];
			vv.push_back(v);
		}
		cin>>k;
		vl l(k);
		rep(i,k)cin>>l[i];
		vb po(n,true);
		rep(i,k){
			rep(j,n){
				bool ok=false;
				rep(k,vv[j].size()){
					ok|=(vv[j][k]==l[i]);
				}
				po[j]=po[j]&ok;
			}
		}
		int cnt=0,ans=-1;
		rep(i,n){
			if(po[i]){
				cnt++;
				ans=i+1;
			}
		}
		cout<<(cnt==1?ans:-1)<<endl;
	}
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, w; cin >> n >> w;
    vector<ll> value(n);
    vector<ll> weight(n);
    rep(i, n){
        cin >> value[i] >> weight[i];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(w+1));

    for(ll i = 0; i < n; i++){
        for(ll j = 0; j <= w; j++){
            if(j - weight[i] >= 0){
                dp[i+1][j] = max(dp[i][j] , dp[i + 1][j - weight[i]] + value[i]);
            }else{
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            }
        }
    }

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

}


Measured memory_bytes: 10724
#include<bits/stdc++.h>
using namespace std;
int q;
long long a,b;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>q;
	while(q--){
		cin>>a>>b;
		if(a<b)
			swap(a,b);
		long long le=b,ri=3e9;
		while(le+1<ri){
			long long mid=(le+ri)>>1;
			if(mid*(mid+1)<a*b)
				le=mid;
			else
				ri=mid;
		}
		long long ret=ri-2;
		ret+=(a*b-1)/ri;
		cout<<ret<<endl;
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  char c[n];
  cin >> c;
  int rc=0;
  REP(i,n) {
    if(c[i]=='R') rc++;
  }
  int ans=0;
  REP(i,rc) {
    if(c[i]=='W') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3824
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int x,y;cin>>x>>y;
	int U=0,D=0,L=0,R=0;
	int sa=1,sb=1,col=1;
	while(-1){
		if(-L<=x&&x<=R&&-D<=y&&y<=U){cout<<col<<endl;break;}
		R+=sa;swap(sa,sb);sa+=sb;col++;if(col>3){col-=3;}
		if(-L<=x&&x<=R&&-D<=y&&y<=U){cout<<col<<endl;break;}
		U+=sa;swap(sa,sb);sa+=sb;col++;if(col>3){col-=3;}
		if(-L<=x&&x<=R&&-D<=y&&y<=U){cout<<col<<endl;break;}
		L+=sa;swap(sa,sb);sa+=sb;col++;if(col>3){col-=3;}
		if(-L<=x&&x<=R&&-D<=y&&y<=U){cout<<col<<endl;break;}
		D+=sa;swap(sa,sb);sa+=sb;col++;if(col>3){col-=3;}
	}
	return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  if (D == 25){
  cout << "Christmas";
  }else if (D == 24){
  cout << "Christmas Eve";
  }else if (D == 23){
  cout << "Christmas Eve Eve";
  }else if (D == 22){
  cout << "Christmas Eve Eve Eve";
  }
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
bl = [True] * (N + 10)
for aa in a:
    bl[aa] = False

dp = [0] * (N + 10)
dp[0] = 1

for step_frm in range(N):
    if bl[step_frm]:
        dp[step_frm + 2] += dp[step_frm]
        dp[step_frm + 2] %= mod
        dp[step_frm + 1] += dp[step_frm]
        dp[step_frm + 1] %= mod
print(dp[N])


Measured memory_bytes: 50904
#include <stdio.h>


int main()
{
    int n, rk, c[4][13] = {0};
    char s;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf(" %c %d", &s, &rk);
        if (s == 'S')
        {
            c[0][rk - 1] = 1;
        }
        else if (s == 'H')
        {
            c[1][rk - 1] = 1;
        }
        else if (s == 'C')
        {
            c[2][rk - 1] = 1;
        }
        else if (s == 'D')
        {
            c[3][rk - 1] = 1;
        }
    }
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            if (c[i][j] == 0)
            {
            if (i == 0)
            {
                printf("S %d\n", j+1);
            }
            else if (i == 1)
            {
                printf("H %d\n", j+1);
            }
            
            else if (i == 2)
            {
                printf("C %d\n", j+1);
            }
            
            else if (i == 3)
            {
                printf("D %d\n", j+1);
            }
            
            }
        }
    }
  
    return 0;
}


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

int main()
{
    long long A[6] = {0};
    cin >> A[0];
    cin >> A[1];
    cin >> A[2];
    cin >> A[3];
    cin >> A[4];
    cin >> A[5];

    long long minval = A[1];
    for(int i = 2; i < 6; i++)
    {
        if(minval > A[i]) minval = A[i];
    }

    long long time;
    if(A[0] % minval == 0) time = A[0] / minval + 4;
    else time = A[0] / minval + 1 + 4;

    cout << time << endl;

    return 0;
}

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

using namespace std;
int main()
{
  int L,R,D;
  int count=0;
  cin>>L>>R>>D;
  for(int i=L;i<=R;i++){
    if(i%D==0)count++;
  }
  cout<<count;
  return 0;
}





Measured memory_bytes: 3592
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [f64; n],
    }

    // dp[i][j] := i枚目まで投げて表がj枚出る確率
    // dp[i+1][j] = dp[i][j-1] * p[i] + dp[i][j] * p[i-1];
    let mut dp: Vec<Vec<f64>> = vec![vec![0.0; n+1]; n+1];
    dp[1][1] = p[0];
    dp[1][0] = 1.0 - p[0];

    for i in 1..n {
        dp[i+1][0] = dp[i][0] * (1.0 - p[i]);
        for j in 1..=n {
            dp[i+1][j] = dp[i][j-1] * p[i] + dp[i][j] * (1.0 - p[i]);
        }
    }

    let mut ans: f64 = 0.0;
    for i in 0..=n {
        if i > n/2 {
            ans += dp[n][i];
        }
    }
    println!("{:.10}", ans);
}


Measured memory_bytes: 72576
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


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


    int h,w,a;
    cin>>h>>w>>a;
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    sx--,sy--,gx--,gy--;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    s[sx][sy]='S';
    s[gx][gy]='G';
    UnionFind uni(h*w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '@')continue;
            for(int k=0;k<4;k++){
                int x = i+dx[k];
                int y = j+dy[k];
                if(x>=0 && y>=0 && x<h && y<w){
                    if(s[x][y] == '@')continue;
                    uni.unite(i*w+j,x*w+y);
                }
            }
        }
    }
    if(uni.same(sx*w+sy,gx*w+gy) == false){
        cout << -1 << endl;
        return 0;
    }
    int d[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j] = 1e9;
        }
    }
    queue<array<int,5>> q;
    q.push({0,sx,sy,-1,0});
    while(q.size()){
        array<int,5> p = q.front(); q.pop();
        int x = p[1], y = p[2], dist = p[0];
        int r = p[3], ok = (p[4]==a);
        if(d[x][y] < dist) continue;
        for(int i=0;i<4;i++){
            if(i + r == 3)continue;
            if(i == r && !ok)continue;
            for(int k=1;k<=a;k++){
                int nx = x + k*dx[i];
                int ny = y + k*dy[i];
                if(nx>=h || ny>=w)break;
                if(nx>=0 && ny>=0){
                    if(s[nx][ny] == '@')break;
                    if(d[nx][ny] <= dist+1)continue;
                    chmin(d[nx][ny],dist+1);
                    if(s[nx][ny] == 'G'){
                        cout << dist+1 << endl;
                        return 0;
                    }
                    q.push({dist+1,nx,ny,i,k});
                }
            }
        }
    }
    
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

bool cp(int n)
{
    if(n<=1)
        return false;

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

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    string s;

    while(n>0)
    {
        //cout<<n<< " ";
        if(n%26==0)
        {
            s+="z";
            n=(n/26);
            n--;
        }
        else
        {
            s+=(char)(n%26+96);
            n/=26;
        }
        //if(n==0 and c==0)
    }
    reverse(all(s));
    for(auto x:s)
        cout<<x;
    return 0;
}


Measured memory_bytes: 3632
input_lines = gets.chop.split.map(&:to_i)
input_lines2 = gets.chop.split.map(&:to_i)

answer = 0 
for i in 0...input_lines[0]
    if input_lines2[i] >= input_lines[1]
        answer = answer + 1
    end
end

puts  answer

Measured memory_bytes: 8324
import itertools
N, K = map(int,input().split())
D = list(map(int,input().split()))

not_D = []
siharai = []
for i in range(0,10):
  if i not in D:
    not_D.append(i)

#print(not_D)
c = list(itertools.product(not_D,repeat = len(str(N))))
c += (list(itertools.product(not_D,repeat = len(str(N))+1)))

for row in c:
  num = ""
  for i in row:
    num += str(i)
  siharai.append(int(num))
#print(siharai)
  
for i in siharai:
  if i >=N:
    print(i)
    break
    

Measured memory_bytes: 11876
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	ll N;
	ll con = 0;
	ll ans = 0;
	cin >> N;
	rep(i, N) {
		ll D1, D2;
		cin >> D1 >> D2;
		if (D1 == D2) con++;
		else con = 0;
		if (con == 3) {
			ans = 1;
		}
	}
	if (ans == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

const ll INF = 1LL<<60;

int main(){

    int K, A, B;
    cin >> K >> A >> B;

    bool ans = false;
    for (int i = A; i<= B; i++){
        if (i % K == 0){
            ans = true;
            break;
        }
    }

    if (ans){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }

}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll ans = 0;
    ll num = 0;
    REP(i, S.length()) {
        if (S[i] == 'B')
            continue;
        ans += i - num;
        num++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	string faces;
	cin >> faces;

	int happy = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (faces[i] == faces[i + 1]) {
			++happy;
		}
	}

	cout << min(n - 1, happy + 2 * k) << "\n";

	return 0;

}

Measured memory_bytes: 3780
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>

using namespace std;

bool isTurn[10];
int tate;
int yoko;
int max_cont;
int ban[11][10001];
void cont_senbei(int r);

int test = 0;

int main()
{
    for(;;){
        test = 0;
        max_cont = 0;
        int cont = 0;
        for(int i = 0; i < 10; i++){
            isTurn[i] = false;
        }
        cin >> tate >> yoko;

        if(tate == 0){
            break;
        }
        for(int i = 0; i < tate; i++){
            for(int j = 0; j < yoko; j++){
                cin >> ban[i][j];
                if(ban[i][j] == 0){
                    cont++;
                }
            }
        }
        max_cont = cont;                         //横を総当り
        for(int i = 0; i < tate; i++){
            cont_senbei(i);
            for(int j = 0; j < yoko; j++){
                if(ban[i][j] == 0){
                    ban[i][j] = 1;
                }
                else{
                    ban[i][j] = 0;
                }
            }
        }
        cout << max_cont << endl;
   //     cout << test << "回呼び出し" << endl;
        }
}
void cont_senbei(int r) {
    int cont = 0;
    int cont2 = 0;           //rをひっくり返す

    test++;

    isTurn[r] = true;           //ひっくり返せ

    for(int j = 0; j < yoko; j++){
        if(ban[r][j] == 0){
            ban[r][j] = 1;
        }
        else{
            ban[r][j] = 0;
        }
    }

    /***************************
    cout << "**********盤面*********" << endl;
    for(int i= 0; i < tate; i++){
        for(int j = 0; j < yoko; j++){
            printf("%d",ban[i][j]);
        }
        cout << endl;
    }
    cout << "************************" << endl;
    /****************************/

    //有効せんべいをカウント

    int yuko_senbei = 0;

    for(int i = 0; i < yoko; i++){
        for(int j = 0; j < tate; j++){
            if(ban[j][i] == 1){
                cont++;
            }
            else{
                cont2++;
            }
        }
        if(cont > (tate/2)){
            yuko_senbei += cont;
        }
        else{
            yuko_senbei += cont2;
        }

        cont = cont2 = 0;
    }

    //  cout << "有効せんべい:" << yuko_senbei << endl;

    //更新

    if(max_cont < yuko_senbei){
        max_cont = yuko_senbei;
    }

    for(int i = r; i < tate; i++){
        if(isTurn[i] == false){
 //           cout << i << "本目をひっくり返すよ" << endl;
            cont_senbei(i);
            isTurn[i] = false;
            for(int j = 0; j < yoko; j++){
                if(ban[i][j] == 0){
                    ban[i][j] = 1;
                }
                else{
                ban[i][j] = 0;
                }
            }
        }
    }
}

Measured memory_bytes: 1552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int ans=0;
    int n=str.size();
    int a[n+5];
    int digit=1;
    for(int i=n-1;i>=0;i--)
    {
        a[i]=digit%2019;
        digit=(digit*10)%2019;
    }
    int mid=0;
    map<int,int>mp;
    mp[mid]++;
    for(int i=n-1;i>=0;i--)
    {
        //cout<<a[i]<<" "<<mid<<'\n';
        mid+=a[i]*(str[i]-'0');
        mid%=2019;
        mp[mid]++;
    }
    for(auto itr : mp)
    ans=ans+((itr.second-1)*(itr.second))/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4540