akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
Int happy[110000][3];
Int dp[110000][3];
// 0: umi
// 1: yama
// 2: HW

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }

    for(int i = 1;i <= n;i++){
        for(int place = 0;place < 3;place++){
            for(int placeY = 0; placeY < 3;placeY++){
                if(place == placeY)continue;
                dp[i][place] = max(dp[i][place],
                                   dp[i-1][placeY] + happy[i][place]);
            }
        }
    }
    
    Int ans = 0;
    for(int place = 0;place < 3;place++){
        ans = max(ans, dp[n][place]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n,m,l):
        k = sorted(LI())
        s = LI()
        wam = [0] * (m+1)
        for i in range(m):
            wam[i+1] = wam[i] + s[i]
        wa = [0] * n
        wb = [0] * n
        for i in range(n):
            wa[i] = wam[k[i]]
            wb[i] = wam[k[i]-1]

        fm = {}
        fm[(0,0)] = 0
        fm[(0,1)] = (wa[1] - wb[0]) // l
        def _f(i,j):
            key = (i,j)
            if key in fm:
                return fm[key]
            r = inf
            if i == j-1:
                for k in range(i):
                    t = _f(k,i) + (wa[j] - wb[k]) // l
                    if r > t:
                        r = t
            else:
                t = _f(i,j-1) + (wa[j] - wb[j-1]) // l
                if r > t:
                    r = t
            fm[key] = r
            return r

        r = inf
        for i in range(1,n-1):
            t = _f(i,n-1)
            u = (wa[n-1] - wb[i]) // l
            if r > t + u:
                r = t + u

        return r

    while 1:
        n,m,l = LI()
        if n == 0:
            break
        rr.append(f(n,m,l))
        break

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 370772
import java.util.Scanner;

public class Main {
	static int[] subTreeSize;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		
		if (k > s.length()) {
			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				if (c != '1') {
					System.out.println(c);
					return;
				}
			}
			System.out.println('1');
			return;
		} else {
			for (int i = 0; i < k; i++) {
				char c = s.charAt(i);
				if (c != '1') {
					System.out.println(c);
					return;
				}
			}
			System.out.println('1');
			return;
		}
	}
}


Measured memory_bytes: 21844
i;main(void){
	char str[20];
	int r = 999;
	gets(str);
	for (; i < 9; i++) {
		char s[] = {str[i], str[i + 1], str[i + 2]};
		if (abs(753 - atoi(s)) < r) {
			r = abs(753 - atoi(s));
		}
	}
	printf("%d\n", r);
}

Measured memory_bytes: 128
s = input()

mods0 = [1]
for i in range(len(s)):
    tmp = mods0[-1] * 10
    mods0.append(tmp % 2019)

mods = [0]
for i in reversed(range(len(s))):
    tmp = mods[-1] + int(s[i]) * mods0[len(s) - i - 1]
    mods.append(tmp % 2019)

from collections import Counter
c = Counter(mods)
ans = 0
for key in c.keys():
    v = c[key]
    ans += v * (v - 1) // 2
print(ans)


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  unordered_map<int64_t, int> diff_counts;
  for (int i = 1; i < N; i++) {
    diff_counts[A[i] - i]++;
  }

  int64_t answer = 0;
  for (int i = 0; i < N; i++) {
    if (diff_counts.find(-A[i] - i) != diff_counts.end()) {
      answer += diff_counts[-A[i] - i];
    }

    if (i > 0) {
      diff_counts[A[i] - i]--;
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 12668
#include <iostream>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const int INF = 1000000;

int main() {
	int a, b;
	cin >> a >> b;
	int res = max(max(max(a + a - 1, b + b - 1), a + b - 1),a+b);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;

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

	if ((a<b)&&(b<c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


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

#define MN 100000
#define FOR(i, n) for (int i = 0; i < n; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back


int main() {
    int N; cin >> N;
    int arr[N];
    FOR(i, N) cin >> arr[i];
    sort(arr, arr + N);
    cout << arr[N - 1] - arr[0] << "\n";
}


Measured memory_bytes: 256
# Problem C - Many Requirements

# input
N, M, Q = map(int, input().split())
rules = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    rules.append([a, b, c, d])

# initialization
ans_score = 0
num_list = []

# calc func
def dfs(num_list, keta, c):
    global ans_score
    global N
    if keta==N:
        # check
        tmp = 0
        for r in rules:
            if num_list[r[1]-1]-num_list[r[0]-1]==r[2]:
                tmp += r[3]
        ans_score = max(ans_score, tmp)
        return

    for n in range(c, M+1):
        num_list.append(n)
        dfs(num_list, keta+1, n)
        num_list.pop(-1)

# calc
dfs(num_list, 0, 1)

# output
print(ans_score)


Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;


int main(){

    int h,w;
    cin>>h>>w;
    vector<string> grid(h);
    REP(i,h){
        cin >> grid[i];

    }
    int white = 0;
    REP(i,h){
        REP(j,w){
            if(grid[i][j]=='.'){
                white++;
            }
        }
    }
    vector<vector<int>> distances(h, vector<int>(w,inf));
    queue<tuple<int, int, int>> q;
    q.push(make_tuple(0, 0, 0));
    array<pair<int, int>,4> d={make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
    bool flag = false;
    while(!q.empty()){
        if(get<0>(q.front())==h-1&&get<1>(q.front())==w-1){
            cout << white-get<2>(q.front())-1 << endl;
            flag = true;
            break;
        }
        REP(i,4){
            if(0<=get<0>(q.front())+d[i].first&&get<0>(q.front())+d[i].first<h
            &&0<=get<1>(q.front())+d[i].second&&get<1>(q.front())+d[i].second<w&&
            grid[get<0>(q.front())+d[i].first][get<1>(q.front())+d[i].second]!='#'&&distances[get<0>(q.front())+d[i].first][get<1>(q.front())+d[i].second]==inf){
                q.push(make_tuple(get<0>(q.front()) + d[i].first, get<1>(q.front()) + d[i].second, get<2>(q.front()) + 1));
                distances[get<0>(q.front())+d[i].first][get<1>(q.front())+d[i].second]=get<2>(q.front()) + 1;
            }
            cerr << i << endl;
        }
        q.pop();
    }
    if(flag==false){
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
def main():
  S=list(sys.stdin.readline())[:-1]
  T=list(sys.stdin.readline())[:-1]
  lS=len(S)
  lT=len(T)
  dp=[[0]*(lS+1) for _ in range(lT+1)]
  for iT in range(lT):
    for iS in range(lS):
      if S[iS]==T[iT]:
        dp[iT+1][iS+1] = max(dp[iT+1][iS],dp[iT][iS+1],dp[iT][iS]+1)
      else:
        dp[iT+1][iS+1] = max(dp[iT+1][iS],dp[iT][iS+1])

  iS = lS
  iT = lT
  ans = ""
  while(iS>0 and iT>0):
    if dp[iT][iS]==dp[iT-1][iS-1]:
      iS -= 1
      iT -= 1
    elif dp[iT][iS]==dp[iT][iS-1]:
      iS -= 1
    elif dp[iT][iS]==dp[iT-1][iS]:
      iT -= 1
    else:
      ans = S[iS-1]+ans
      iS -= 1
      iT -= 1
  print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 112220
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
ll n,m;
cin>>n>>m;
ll ans=0;
if(m<2)ans=0;
else if(n>=m)ans=m/2;
else{
m-=2*n;
ans+=n;
ans+=m/4;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll h, a;
    ll n;

    cin >> h >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a;
        ans += a;
    }
    if (ans >= h)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

int pro(string x) {
	if (x == "SUN") return 7;
	if (x == "MON") return 6;
	if (x == "TUE") return 5;
	if (x == "WED") return 4;
	if (x == "THU") return 3;
	if (x == "FRI") return 2;
	if (x == "SAT") return 1;
	return 0;
}
int main() {
	string s; cin >> s; cout << pro(s) << endl;

}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

flag = 1
cnt = 1
for i in range(1,len(h)):
    if h[i]>h[i-1]: cnt = 1
    elif h[i]==h[i-1]: cnt += 1
    elif h[i]==h[i-1]-1:
        if i==1: continue
        if h[i-1]-1>=h[i-1-cnt]: continue
        else: flag = 0; break
    else: flag = 0; break

if flag: print("Yes")
else: print("No")



Measured memory_bytes: 14396
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void){
    int N, xbuf, ybuf;
    vector<int> x, y;
    double R;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> xbuf >> ybuf;
        x.push_back(xbuf);
        y.push_back(ybuf);
    }
    double res = 0.0;
    if(N==2){
        res = sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]))/2.0;
    }else{
        for(int i=0; i<N-2; i++){
            for(int j=i+1; j<N-1; j++){
                for(int k=j+1; k<N; k++){
                    double rij=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
                    double rik=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
                    double rjk=sqrt((x[k]-x[j])*(x[k]-x[j])+(y[k]-y[j])*(y[k]-y[j]));
                    if(rij<1.0){
                        R=rik/2.0;
                    }else if(rik<1.0){
                        R=rij/2.0;
                    }else if(rjk<1.0){
                        R=rjk/2.0;
                    }else{
                        double thetai=(rij*rij+rik*rik-rjk*rjk)/2.0/rij/rik;
                        double thetaj=(rij*rij+rjk*rjk-rik*rik)/2.0/rij/rjk;
                        double thetak=(rjk*rjk+rik*rik-rij*rij)/2.0/rjk/rik;
                        if((thetai>=0.0)&&(thetaj>=0.0)&&(thetak>=0.0)){
                            thetai=sqrt(1-thetai*thetai);
                            if(thetai>0.0001){
                                R=rjk/thetai/2.0;
                            }else{
                                R=max(max(rij,rik),rjk)/2.0;
                            }
                        }else R=max(max(rij,rik),rjk)/2.0;
                    }
                    if(R>res)res=R;
                }
            }
        }
    }
    cout << fixed;
    cout << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    vector<string> str(n);
    for(i=0;i<n;i++)
    {
        cin>>str[i];
    }
    int p=1;
    for(i=1;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j) continue;
            if(str[i]==str[j])
                p=0;
        }
        if(str[i][0]!=str[i-1][str[i-1].size()-1])
            p=0;
    }
    if(p)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3588
<?php

fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);

$l = $a + $b;
$r = $c + $d;

if ($l > $r) {
    echo "Left";
} elseif ($l === $r) {
    echo "Balanced";
} else {
    echo "Right";
}


?>

Measured memory_bytes: 16164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll n,c,k;
  cin>>n>>c>>k;
  v(ll) t(n);
  ll ans=1;
  rep(i,n) cin>>t[i];
  sort(all(t));
  ll cnt=c-1;
  ll state=t[0];
  rrep(i,n-1){
    if(cnt==0||t[i]>state+k){
      state=t[i];
      cnt=c;
      ans++;
    }
    if(t[i]<=state+k){
      cnt--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4048
;

import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int center_test = 0;
		int end_test = 0;
		int re_test = 0;
		ArrayList<String> score = new ArrayList<String>();

		// テキスト入力
		Scanner sc = new Scanner(System.in);

		//
		while (sc.hasNext()) {

			//
			center_test = sc.nextInt();
			end_test = sc.nextInt();
			re_test = sc.nextInt();

			// 中間試験と期末試験の合計点
			int sum_center_end = (center_test + end_test);

			// 全てマイナス1の場合は出力へ
			if (center_test == -1 && end_test == -1 && re_test == -1) {
				break;
			}

			// 中間試験、期末試験のいずれかを欠席した場合成績は F。
			if (center_test == -1 || end_test == -1) {
				score.add("F");
			} else {
				// 中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
				if (sum_center_end >= 80) {
					score.add("A");
				}
				// 中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
				if (sum_center_end >= 65 && sum_center_end < 80) {
					score.add("B");
				}
				// 中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
				if (sum_center_end >= 50 && sum_center_end < 65) {
					score.add("C");
				}
				// 中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は
				// C。
				if (sum_center_end >= 30 && sum_center_end < 50) {
					if (re_test >= 50) {
						score.add("C");
					} else {
						score.add("D");
					}
				}
				// 中間試験と期末試験の合計点数が 30 未満ならば成績は F。
				if (sum_center_end < 30) {
					score.add("F");
				}
			}
		}

		// 出力
		for (String val : score) {
			System.out.println(val);
		}
	}

}

Measured memory_bytes: 19812
// AOJ 2021: Princess in Danger
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 10000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x07070707

typedef struct { int to[70], t[70]; } TBL;
TBL tbl[10200];
int len[10200];
int f[101];
int dist[10200];

void dijkstra(int start)
{
	int i, s, t, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node, t = que[0].t; deq();
		if (dist[s] < t) continue;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i], d = dist[s] + tbl[s].t[i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
}

char buf[400], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}


int main()
{
	int n, m, l, k, a, h, i, j, ans;
	int x, y, t, u, v, u2, v2, m1;

	while (fgets(p=buf, 60, stdin) && *p != '0') {
		n = getint(), m = getint(), l = getint();
		k = getint(), a = getint(), h = getint();
		m1 = m+1;

		if (l > 0) {
			fgets(p=buf, sizeof(buf), stdin);
			for (i = 0; i < l; i++) f[i] = getint();
		}
		f[l++] = a, f[l++] = h;

		memset(len, 0, sizeof(len));
		while (k--) {
			fgets(p=buf, 20, stdin);
			x = getint()*m1, y = getint()*m1, t = getint();
			for (j = t; j <= m; j++) {
				u  = x + j, v  = y + j;
				u2 = u - t, v2 = v - t;
				i = len[u]++, tbl[u].to[i] = v2, tbl[u].t[i] = t;
				i = len[v]++, tbl[v].to[i] = u2, tbl[v].t[i] = t;
			}
		}
		for (i = 0; i < l; i++) {
			u = f[i]*m1;
			for (j = 0; j < m; j++) {
				v = u+j, v2 = v+1;
				t = len[v]++, tbl[v].to[t] = v2, tbl[v].t[t] = 1;
			}
		}

		dijkstra(a*m1+m);

		ans = INF; m1 *= h;
		for (i = 0; i <= m; i++) if (dist[m1+i] < ans) ans = dist[m1+i];
		if (ans == INF) puts("Help!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 7512
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<utility>
#include<stack>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 1e5 + 5;
char str[maxn];
int main() {
	int s = -1, e = -1;
	scanf("%s", str);
	int len = strlen(str);
	for(int i = 0; str[i]; i++) {
		if(str[i] == str[i + 1]) {
			s = i + 1;
			e = i + 2;
			break;
		} else if(str[i] == str[i + 2]) {
			s = i + 1;
			e = i + 3;
			break;
		}
	}
	cout << s << ' ' << e << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = unsigned long long;

const LL P = 1000000007;

signed main(void)
{
	int n;
	while (cin >> n, n)
	{
		vector<LL>hash;
		for (int i = 0; i <= n; ++i)
		{
			int m;
			cin >> m;
			vector<pair<int, int>>shape;
			int x, y;
			cin >> x >> y;
			int tx = 0, ty = 0;
			bool swap = false;
			for (int j = 1; j < m; ++j)
			{
				int xx, yy;
				cin >> xx >> yy;
				if (j == 1)
				{
					if (yy - y > 0)
					{
						tx = 1, ty = 1;
					}
					else if (yy - y < 0)
					{
						tx = -1, ty = -1;
					}
					else if (xx - x > 0)
					{
						tx = 1, ty = -1;
						swap = true;
					}
					else
					{
						tx = -1, ty = 1;
						swap = true;
					}
					if (swap)
					{
						shape.push_back({ y*ty,x*tx });
					}
					else
					{
						shape.push_back({ x*tx,y*ty });
					}
				}
				if (swap)
				{
					shape.push_back({ yy*ty,xx*tx });
				}
				else
				{
					shape.push_back({ xx*tx,yy*ty });
				}
			}
			LL hs1 = 0, hs2 = 0;
			for (auto s : shape)
			{
				hs1 *= P;
				hs1 += s.first - shape[0].first;
				hs1 *= P;
				hs1 += s.second - shape[0].second;
			}
			reverse(shape.begin(), shape.end());
			for (auto s : shape)
			{
				hs2 *= P;
				hs2 += s.first - shape[0].first;
				hs2 *= P;
				hs2 += s.second - shape[0].second;
			}
			hash.push_back(min(hs1, hs2));
		}
		int tot = 0;
		for (int i = 1; i <= n; ++i)
		{
			if (hash[0] == hash[i])
			{
				cout << i << endl;
				tot += i;
			}
			else if (tot == 6 && i == 4)
			{
				cout << i << endl;
			}
		}
		cout << "+++++\n";
	}
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  vector<string> vs(3);
  REP(i, 3)
    cin >> vs[i];
  
  REP(i, 3)
    cout << vs[i][i];
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const long long MOD = 924844033;
int N, head[200001], next[399999], to[399999], E, size[200001], fa[200001], q[200001], D[200001], L = 1;
long long A[524288], B[524288], _B[200001];
long long POWER(long long a, long long b)
{
	long long r = 1;
	for (; b; b >>= 1)
	{
		if (b & 1)
			r = r * a % MOD;
		a = a * a % MOD;
	}
	return r;
}
void FFT(long long *a, int f = 1)
{
	static int p[524288];
	for (int i = 1; i < L; i++)
		p[i] = i & 1 ? p[i - 1] | L >> 1 : p[i >> 1] >> 1;
	for (int i = 0; i < L; i++)
		if (i < p[i])
			std::swap(a[i], a[p[i]]);
	for (int i = 1; i < L; i <<= 1)
	{
		long long w, wn = POWER(5, (MOD - 1) / 2 / i), x, y;
		if (f == -1)
			wn = POWER(wn, MOD - 2);
		for (int j = 0; j < L; j += i + i)
		{
			w = 1;
			for (int k = j; k < j + i; k++)
			{
				x = a[k];
				y = a[k + i] * w % MOD;
				a[k] = x + y < MOD ? x + y : x + y - MOD;
				a[k + i] = x - y < 0 ? x - y + MOD : x - y;
				w = w * wn % MOD;
			}
		}
	}
	if (f == -1)
	{
		long long D = POWER(L, MOD - 2);
		for (int i = 0; i < L; i++)
			a[i] = a[i] * D % MOD;
	}
}
int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		next[++E] = head[u], to[E] = v, head[u] = E;
		next[++E] = head[v], to[E] = u, head[v] = E;
	}
	int H = 0, T = 1, u;
	q[1] = 1;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u])
				fa[q[++T] = to[e]] = u;
	for (int i = 1; i <= N; i++)
		size[i] = 1;
	for (int i = N; i > 1; i--)
		size[fa[q[i]]] += size[q[i]];
	A[0] = B[0] = B[1] = 1;
	for (int i = 2; i <= N; i++)
		B[i] = (MOD - MOD / i) * B[MOD % i] % MOD;
	for (int i = 1; i <= N; i++)
	{
		A[i] = A[i - 1] * i % MOD;
		B[i] = B[i - 1] * B[i] % MOD;
	}
	D[N] = N;
	for (int i = 2; i <= N; i++)
	{
		D[N - size[i]]--;
		D[size[i]]--;
	}
	for (int i = 1; i <= N; i++)
		A[i] = A[i] * (MOD + D[i]) % MOD;
	std::reverse(B, B + N + 1);
	std::copy(B, B + N + 1, _B);
	while (L <= N + N)
		L <<= 1;
	FFT(A);
	FFT(B);
	for (int i = 0; i < L; i++)
		A[i] = A[i] * B[i] % MOD;
	FFT(A, -1);
	for (int i = 1; i <= N; i++)
		printf("%lld\n", A[N + i] * _B[N - i] % MOD);
	return 0;
}


Measured memory_bytes: 20992
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    cin >> n ;
    vector<ll> a(n);
    j=0;
    rep(i,n) 
    {
        cin >> a[i] ;
        j=j^a[i];
    }
    rep(i,n)
    {
        ll temp=j^a[i];
        cout << temp << " ";
    }
   
    
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    ll n, w;
    cin >> n >> w;
    ll kp[w + 1][n];
    ll val[n], wt[n];
    For(i, 0, n)
    {
        cin >> wt[i] >> val[i];
    }
    For(i, 0, w + 1)
    {
        For(j, 0, n)
        {
            kp[i][j] = 0;
        }
    }
    For(i, 0, w + 1)
    {
        if (wt[0] <= i)
            kp[i][0] = val[0];
    }
    For(i, 1, w + 1)
    {
        For(j, 1, n)
        {
            if (i - wt[j] >= 0)
            {
                kp[i][j] = max(
                    kp[i][j - 1], kp[i - wt[j]][j - 1] + val[j]);
            }
            else
                kp[i][j] = kp[i][j - 1];
        }
    }

    cout << kp[w][n - 1] << endl;
    return 0;
}

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////
// Ford-Fulkerson //
////////////////////

class MaxFlow {
private:
	using vi64 = std::vector<int64_t>;
	using Matrix = std::vector<vi64>;

	std::vector<bool> visited_;
	Matrix graph_;
	const int source_, sink_;

	int64_t findPath(const int node_i, const int64_t flow)
	{
		if (node_i == sink_) return flow;
		visited_[node_i] = true;
		for (int next_i{}; next_i < (int)graph_.size(); next_i++)
		{
			if (!graph_[node_i][next_i] || visited_[next_i]) continue;
			const int64_t additional_flow{findPath(next_i, std::min(flow, graph_[node_i][next_i]))};
			if (!additional_flow) continue;

			graph_[node_i][next_i] -= additional_flow;
			graph_[next_i][node_i] += additional_flow;
			return additional_flow;
		}
		return 0;
	}
public:
	MaxFlow(const int node_num, const int source, const int sink)
		: graph_(node_num, vi64(node_num)), visited_(node_num), source_(source), sink_(sink){}
	void addEdge(const int from, const int to, const int64_t flow)
	{
		graph_[from][to] += flow;
	}
	int64_t operator()()
	{
		int64_t flow_sum{};
		while (true)
		{
			std::fill(visited_.begin(),visited_.end(), false);
			int64_t additional_flow{findPath(source_, LLONG_MAX)};
			if (!additional_flow) break;
			flow_sum += additional_flow;
		}
		return flow_sum;
	}
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
int main()
{
	int V, E;
	scanf("%d%d", &V, &E);
	MaxFlow max_flow(V, 0 , V - 1);

	for (int e_i{}; e_i < E; e_i++)
	{
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		max_flow.addEdge(u, v, c);
	}
	printf("%lld\n", max_flow());
	return 0;
}


Measured memory_bytes: 3352
N = int(input())
K = int(input())

L = list(map(int, list(str(N))))
M = len(L)
DP = [[[0] * 2 for _ in range(K + 1)] for _ in range(M)]

DP[0][1] = [L[0] - 1, 1]
DP[0][0][0] = 1

for i in range(1, M):
  DP[i][0][0] = DP[i - 1][0][0]
  for j in range(1, K + 1):
    if L[i] != 0:
      DP[i][j][0] = DP[i - 1][j][0]
      DP[i][j][0] += DP[i - 1][j][1]
      DP[i][j][0] += DP[i - 1][j - 1][0] * 9
      DP[i][j][0] += DP[i - 1][j - 1][1] * (L[i] - 1)
      DP[i][j][1] = DP[i - 1][j - 1][1]
    else:
      DP[i][j][0] = DP[i - 1][j][0]
      DP[i][j][0] += DP[i - 1][j - 1][0] * 9
      DP[i][j][1] = DP[i - 1][j][1]

ans = DP[-1][-1][0] + DP[-1][-1][1]
ans = max(0, ans)
print(ans)


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

using namespace std;
using ll = long long;

using Graph = vector<vector<int>>;
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;}

vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0){
    color[v] = cur;
    for(auto next_v : G[v]){
        if(color[next_v] != -1){
            if(color[next_v] == cur) return false;
            continue;
        }
        if(!dfs(G, next_v, 1-cur)) return false;
    }
    return true;
}

const ll INF = 1LL << 60;
int N;
vector<ll> h(1e5+10);

vector<ll> dp(1e5+10);

int main(){
    int N, K; cin >> N >> K;
    rep(i, N) cin >> h[i];
    rep(i, 1e5+10) dp[i] = INF;

    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
<?php
# 整数の入力
fscanf(STDIN, "%d %d", $k, $x);

$min = $x - ($k - 1);
$max = $x + ($k - 1);
$s = [];
for ($i = $min; $i <= $max; $i++) {
  $s[] = $i;
}

echo implode(' ', $s);


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if(a <= 5) ans = 0;
  else if(a <= 12) ans = b/2;
  else ans = b;
  cout << ans << endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Maxn=2001;
int a[Maxn],n,f,q;

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

int main(){
	init();
	int x,y,ans=2147483647;
	
	for(int i=1;i<=n;i++){
		x=a[i];
		int l[n+1],r[n+1];
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		l[1]=1; int c=1;
		for(int j=1;j<=n;j++){
			if(a[j]<x){
				if(a[j-1]>=x)r[c]=j-1;
				
				if(j!=n&&a[j+1]>=x)l[++c]=j+1;
			}
		}
		if(a[n]>=x)r[c]=n;
		
		/*for(int j=1;j<=c;j++){
			cout<<l[j]<<' '<<r[j]<<endl;
		}*/
		
		int e[n+1],tot=0;
		memset(e,0,sizeof(e));
		for(int j=1;j<=c;j++){
			int w[n+1],size=r[j]-l[j]+1;
			for(int k=l[j];k<=r[j];k++)
				w[k-l[j]]=a[k];
			
			sort(w,w+size);
			for(int k=0;k<=size-f;k++){
				e[++tot]=w[k];
			}
		}
		sort(e+1,e+tot+1);
		
		y=e[q];
		//cout<<x<<' '<<y<<endl;
		if(e[q]==0)continue ;
		ans=min(ans,y-x);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi A(N);

    map<int, int> L, R;
    rep(i, N) {
        cin >> A[i];
        L[A[i]+i]++;
        R[i-A[i]]++;
    }

    int res = 0;
    for(auto &l : L) {
        res += l.se * R[l.fi];
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 39096
#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(){
    for (int i = 0; i < 5;++i){
        int x;
        cin >> x;
        if (!x) return cout << i + 1, 0;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pll = pair<long, long>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) if (scanf("%d", &v)<1);

bool comp(pll a, pll b) {
  return atan2(a.second, a.first) < atan2(b.second, b.first);
}
int main() {
  int N;
  IN(N);

  vector<pll> xy;
  REP(i, N) {
    ll x, y;
    scanf("%lld%lld", &x, &y);
    if (x != 0 || y != 0)
      xy.push_back(make_pair(x, y));
  }
  if (xy.size() == 0) {
    printf("%.15f\n", 0.0);
    return 0;
  }
  N = xy.size();
  sort(ALL(xy), comp);

  ll ans = 0;
  REP(s, N) {
    ll x = 0, y = 0;
    REP(t, N) {
      x += xy[(s+t) % N].first;
      y += xy[(s+t) % N].second;
      ans = max(ans, x*x+y*y);
    }
  }
  printf("%.15f\n", sqrt((double)ans));

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    int ans = 0;
    if (a < c) {
        if (b < c) {
            ans = 0;
        } else if (b < d) {
            ans = b-c;
        } else {
            ans = d-c;
        }
    } else {
        if (d < a) {
            ans = 0;
        } else if (b < d) {
            ans = b-a;
        } else {
            ans = d-a;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main{
	public static void main(String[] args) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				
					System.out.println(i + "x" + j + "=" + (i * j));
				
			}
		}
	}
}

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

using namespace std;

const int MAXK = 1e5 + 10;
const int MOD = 1e9 + 7;

int pref[MAXK],dp[MAXK],N,K;

int calc(int a,int b){
	if(a < 0) a = 0;
	int ans = pref[b];
	if(a != 0) ans -= pref[a-1];
	return ans % MOD;
}

int main(){
	cin >> N >> K;
	dp[0] = 1;
	for(int kid = 1;kid<=N;kid++){
		int c;
		cin >> c;
		pref[0] = dp[0];
		dp[0] = 0;
		for(int i = 1;i<=K;i++){
			pref[i] = (pref[i-1] + dp[i]) % MOD;
		}
		for(int i = 0;i<=K;i++){
			dp[i] = calc(i-c,i);
		}
	}

	int ans = dp[K];
	if(ans < 0) ans += MOD; 
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(Math.min(n*a,  b));
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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

int x;

bool is_prime(int x)
{
	bool ans=true;
	for(int i=2; i<=sqrt(x); i++)
	{
		if(x%i==0)
		{
			ans=false;
			break;
		}
	}
	return ans;
}
int main()
{
	cin>>x;
	for(int i=x; ; i++)
	{
		if(is_prime(i))
		{
			cout<<i<<endl; 
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
// // If you want something you've never had, you must be willing to do
// // something you've never done

// //  When the going gets tough,  the tough get going

// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define int ll
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int INF = 2e9;

// ----------------------------------------------------------
// #define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 1e9 + 7;

signed main() {
    int k;
    int a, b;
    cin >> k >> a >> b;
    if(b/k - (a-1)/k > 0) {
        cout << "OK\n";
    }
    else cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3640
n = int(input())
a = [int(i) for i in input().split(" ")]
f = [0] * n
r = [0] * n

def gcd(x ,y):
    while y != 0:
        x, y = y, x%y
    return x

f[0] = a[0]
r[0] = a[n - 1]
for i in range(1, n):
    f[i] = gcd(f[i - 1], a[i])
    r[i] = gcd(r[i - 1], a[n - i - 1])

m = max(f[n - 2], r[n - 2])
for i in range(0, n - 2):
    g = gcd(f[i], r[n - i - 3])
    if g > m:
        m = g

print(m)

Measured memory_bytes: 14428
// https://atcoder.jp/contests/abc056/tasks/arc070_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll X, r;
int main()
{
  cin >> X;

  r = ceil((sqrt(1 + 8 * X) - 1) / 2);

  cout << r << '\n';

  return 0;
}


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

typedef pair<int,int> p;
vector<p> que;

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        que.push_back(p(x,y));
    }
    sort(que.begin(),que.end());
    int minx=0,maxx=0x3fffffff,res=0;
    for(int i=0;i<que.size();i++)
    {
        if(que[i].first>=maxx)
        {
            res++;
            minx=0;
            maxx=0x3fffffff;
        }
        if(que[i].first>minx)
            minx=que[i].first;
        if(que[i].second<maxx)
            maxx=que[i].second;
    }
    if(minx)
        res++;
    printf("%d",res);
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int popCount(int a)
{
	int res = 0;
	while (a)
	{
		++res;
		a&=a - 1;
	}
	return res;
}

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N, pc = 0;
	string S;
	cin >> N >> S;
	forn(i, S.size())
		if (S[i] == '1')
			++pc;
	reverse(S.begin(), S.end());
	int TT = max(pc + 3, 100);
	vector<int> v(TT);
	fore(i, 1, v.size()-1)
	{
		int cpc = popCount(i);
		v[i] = v[i%cpc] + 1;
	}

	vector<vector<int> > w(3, vector<int>(N));

	w[0][0] = pc > 2 ? 1 :0;
	w[1][0] = pc == 1 ? 0: 1;
	w[2][0] = 1;

	forn(i, 3)
	{
		fore(j,1, N-1)
		{
			if (pc > 1)
			{
				w[0][j] = (w[0][j - 1] * 2) % (pc - 1);
			}
			else
				w[0][j] = 0;
			w[1][j] = (w[1][j - 1] * 2) % (pc);
			w[2][j] = (w[2][j - 1] * 2) % (pc + 1);
		}
	}

	vector<int> r(3);
	forn(i, N)
	{
		if (S[i] == '1')
		{
			if (pc > 1)
				r[0] = (r[0] + w[0][i]) % (pc - 1);
			r[1] = (r[1] + w[1][i]) % (pc);
			r[2] = (r[2] + w[2][i]) % (pc+1);
		}
			
	}
	ford(i, N)
	{
		if (S[i] == '0')
		{
			int tmp = (r[2] + w[2][i])%(pc+1);
			int res = 1 + v[tmp];
			cout << res << endl;
		}
		else
		{
			if (pc == 1)
			{
				cout << 0 << endl;
			}
			else
			{
				int tmp = (r[0] + pc - 1 - w[0][i]) % (pc - 1);
				int res = 1 + v[tmp];
				cout << res << endl;
			}
		}
	}
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<long long> B(N + 1, 0); //0で初期化
    int mod = 1000000007;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[i + 1] = B[i] + A[i];
    }

    long ans = 0;

    for (int i = 0; i < N; i++)
    {
        long long sum = (B[N] - B[i + 1]) % mod;
        ans += A[i] * sum;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
h = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    dp[i] = min(dp[i-k]+abs(h[i-k]-h[i]) for k in (1,2))

print(dp[-1])

Measured memory_bytes: 14228
#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <regex>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) obj.begin(), obj.end()
#define UNIQUE(v) v.erase(unique(All(v)), v.end());
typedef long long ll;

typedef pair<int, int> P;
vector<P> vecp;
int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};
// input

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vector<int> M [m];
  int P[m];
  bool N[n];
  fill(N, N+n,false);
  REP(i, m){
    int k; cin >> k;
    REP(j, k){
      int t; cin >> t;
      M[i].push_back(t);
    }
  }
  REP(i, m){
    cin >> P[i];
  }
  int count=0;
  REP(i, pow(2,n)){
    bitset<10> bs1(i);
    int SSS[m];
    fill(SSS, SSS + m, 0);
    REP(b, n){
      //cout << bs1 << ":" << b << endl;
      if(bs1[b]){
        REP(z, m){
          if (find(M[z].begin(), M[z].end(), b+1) != M[z].end()){
            SSS[z]++;
          }
        }
      }
    }
    bool flg = true;
    REP(b, m){
      if (SSS[b] % 2 != P[b]){
        flg = false;
        break;
      }
    }
    if (flg){
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
"use strict";

async function main(input) {
  input = input.trim().split(" ");
  let A = Number(input[0]);
  let B = Number(input[1]);
  while (true) {
    if (A == B) break;
    if (A > B) {
      B = B + Number(input[1]);
    } else {
      A = A + Number(input[0]);
    }
  }
  console.log(A);
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 33260
"use strict"

function Main(input) {
  const args = input.split('\n'); // args = ["2", "3 1 2", "6 1 1"]
  const N = parseInt(args[0], 10); // N = 2
  const nums = args.slice(1, N + 1); // nums = ["3 1 2", "6 1 1"]

  const isValid = nums.every((n) => {

    var ns = n.split(' '); // ns = ["3", "1", "2"]
    var t = parseInt(ns[0], 10), // t = 3
      x = parseInt(ns[1], 10), // x = 1
      y = parseInt(ns[2], 10); // y = 2
    var sum = x + y;

    return (t >= sum) && ((t % 2) === (sum % 2));
  });

  if (isValid) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int n;
	cin >> n;
	int x[101], y[101], h[101];
	rep(i, n) cin >> x[i] >> y[i] >> h[i];
	rep(cx, 101) rep(cy, 101) {
		int t;
	       	rep(i, n) {
			if (h[i] > 0) {
				t = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
				break;
			}
		}
		bool ok = true;
		rep(i, n) {
			if (max(0, t - abs(x[i]-cx) - abs(y[i]-cy)) != h[i]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			cout << cx << ' ' << cy << ' ' << t << endl;
		}
	}

	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int x;
	int ans=0;
	bool k=1;
	while(cin>>x){
		if(x && k)ans++;
		else k=0;
	}
	ans++;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 4; j++) {
            if (s[i] == s[j]) {
                count++;
            }
        }
    }

    if (count == 2) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
import sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()


Measured memory_bytes: 28572