akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        //入力
        int Ｎ = int.Parse(Console.ReadLine());

        Tuple<string, int, int>[] tuple = new Tuple<string, int, int>[Ｎ];
        for (int i = 0; i < Ｎ; i++) {
            string s = Console.ReadLine();
            tuple[i] = new Tuple<string, int, int>(s.Split()[0], int.Parse(s.Split()[1]), i + 1);
        }

        var a = tuple.OrderBy(v => v.Item1)
               .ThenByDescending(v => v.Item2)
               .ToArray();

        //出力
        Console.WriteLine(string.Join("\n", a.Select(v => v.Item3)));
    }
}

Measured memory_bytes: 11744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#define debug2(x, y) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define debug2(x, y) cerr << __LINE__ << " : (" << #x << ", " << #y  << ") = (" << (x) << ", " << (y) << ")" << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int test(int L, int R) {
  int ans = 0;
  for (int x=L; x<=R; x++) {
    for (int y=x; y<=R; y++) {
      if (y % x == (x ^ y)) {
        debug2(x, y);
        ans++;
      }
    }
  }
  return ans;
}

ll dp[63][2][2][2] = {}; //{[丁度, 大きい], [丁度, 小さい]}

int main() {
  ll L, R;
  int A[62] = {}, B[62] = {};

  cin >> L >> R;

  //cout << test(L, R) << endl;

  for (int i=0; i<62; i++) {
    A[61-i] = L % 2;
    B[61-i] = R % 2;
    L /= 2;
    R /= 2;
  }

  dp[0][0][0][0] = 1;

  for (int i=0; i<62; i++) {
    // (0, 0), (0, 1), (1, 1)
    for (int j=0; j<2; j++) {
      for (int k=0; k<2; k++) {
        for (int l=0; l<2; l++) {

          for (int x=0; x<2; x++) {
            for (int y=x; y<2; y++) {
              if (j == 0 && x < A[i]) continue;
              if (k == 0 && B[i] < y) continue;

              int nextj = j == 0 ? A[i] < x : 1;
              int nextk = k == 0 ? y < B[i] : 1;
              int nextl = l == 0 ? x == 1 : 1;

              if (nextl == 0 && y == 1) continue;

              dp[i+1][nextj][nextk][nextl] += dp[i][j][k][l];
              dp[i+1][nextj][nextk][nextl] %= mod;
            }
          }
        }
      }
    }
  }

  ll ans = 0;
  for (int i=0; i<4; i++) {
    ans += dp[62][i/2][i%2][0] + dp[62][i/2][i%2][1];
  }

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

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

N=intput()
A=[0]*N
for i in range(N):
    A[i]=intput()
judge(all([a%2==0 for a in A]),['second','first'])

Measured memory_bytes: 81976
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	cin >> d;
	if(d == 25)
	cout << "Christmas" << '\n';
	else if(d == 24)
	cout << "Christmas Eve" << '\n';
	else if(d == 23)
	cout << "Christmas Eve Eve" << '\n';
	else if(d == 22)
	cout << "Christmas Eve Eve Eve" << '\n';
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
m = {}
ans = 0
for i in range(n):
    if i - a[i] in m:
        ans += m[i - a[i]]
    j = i + a[i]
    if j in m:
        m[j] += 1
    else:
        m[j] = 1
print(ans)


Measured memory_bytes: 111600
from collections import Counter

N, A, B = map(int, input().split())

v = list(map(int, input().split()))
v.sort(reverse=True)

ave_max = sum(v[:A]) / A

counter = Counter(v)
cnt = counter[v[0]]
#最大のｖが一つだけなら残りの選び方、複数あるならその選び方も考慮
ans = 0
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
if cnt < A:
    m = v[A-1]
    n = counter[m] # 最小値の個数
    r = v[:A].count(m)
    ans = cmb(n,r)
elif cnt == A:
    ans = 1
    
else:
    for i in range(A, min(cnt, B) + 1):

        ans += cmb(cnt, i)

print(ave_max)
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <string>

int main(){
    int K;
    std::cin >> K;
    std::string S;
    std::cin >> S;

    std::string ans;
    if(S.size() <= K){
        ans = S;
    }else{
        ans = S.substr(0, K);
        ans += "...";
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
<?php
    while(fscanf(STDIN,"%d %s %d",$a,$op,$b)) {
        calc($a,$op,$b);
    }


    function calc($a,$op,$b) {
        switch ($op) {
            case "+":
                echo $a + $b . PHP_EOL;
                break;
            case "-":
                echo $a - $b . PHP_EOL;
                break;
            case "*":
                echo $a * $b . PHP_EOL;
                break;
            case "/":
                echo floor($a / $b) . PHP_EOL;
                break;
            case "?":
                exit;
        }
    }
?>



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    map<int,int> M;
    rep(i,n){
        int a; cin>>a;
        M[a]++;
    }
    if (M.size()<=k){
        cout<<"0\n";
        return 0;
    }
    vi cnt;
    ITR(x,M) cnt.pb(x->se);
    sort(all(cnt));
    int ans=0;
    rep(i, M.size()-k){
        ans+=cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10744
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int dp[2][32][32][32];
vector<int>r[62];
int to[62];
int p[30];
int q[30];
int n,m,s;
int calc(int a,int b,int c,int d){
	//printf("%d %d %d %d\n",a,b,c,d);
	if(~dp[a][b][c][d])return dp[a][b][c][d];
	if(b==c){
		if(a==0){
			if(d==p[b])return dp[a][b][c][d]=1;
			else return dp[a][b][c][d]=0;
		}else{
			if(d==q[b])return dp[a][b][c][d]=1;
			else return dp[a][b][c][d]=0;	
		}
	}
	int len=c-b+1;
	if(len<=0){
		if(!a)len+=n;else len+=m;
	}
	for(int v=0;v<s;v++){
		if(to[v]!=d)continue;
		int dp3[32][32];
		for(int i=0;i<32;i++)for(int j=0;j<32;j++)dp3[i][j]=0;
		dp3[0][0]=1;
	//	if(a==1&&b==1&&c==0&&d==0&&v==2)printf("%d %d\n",(int)r[v].size(),len);
		for(int i=0;i<r[v].size();i++)for(int j=0;j<len;j++){
			if(!dp3[i][j])continue;
		//	if(a==1&&b==1&&c==0&&d==0&&v==2)printf("%d %d\n",i,j);
			for(int k=j;k<len;k++){
				if(j==0&&k==len-1)continue;
				int L=b+j;
				if(!a)L%=n;
				else L%=m;
				int R=b+k;
				if(!a)R%=n;
				else R%=m;
				if(calc(a,L,R,r[v][i]))dp3[i+1][k+1]=1;
			}
		}
		if(dp3[r[v].size()][len])return dp[a][b][c][d]=1;
	}
	return dp[a][b][c][d]=0;
}
int dpv[2][32][32];
int dp2[32][32];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		n=a;m=b;s=c;
		for(int i=0;i<a;i++)scanf("%d",p+i);
		for(int i=0;i<a;i++)p[i]--;
		for(int i=0;i<b;i++)scanf("%d",q+i);
		for(int i=0;i<b;i++)q[i]--;
		for(int i=0;i<62;i++)r[i].clear();
		for(int i=0;i<c;i++){
			int d;scanf("%d",&d);
			for(int j=0;j<d;j++){
				int e;scanf("%d",&e);
				e--;
				r[i].push_back(e);
			}
			scanf("%d",to+i);
			to[i]--;
		}
		
		for(int i=0;i<2;i++)for(int j=0;j<32;j++)
			for(int k=0;k<32;k++)for(int l=0;l<32;l++)
				dp[i][j][k][l]=-1;
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)for(int k=0;k<30;k++){
	//		printf("%d %d %d %d\n",0,i,j,k);
			calc(0,i,j,k);
	//		if(dp[0][i][j][k])printf("%d %d %d %d\n",0,i,j,k);
		}
		for(int i=0;i<b;i++)for(int j=0;j<b;j++)for(int k=0;k<30;k++){
		//	printf("%d %d %d %d\n",1,i,j,k);
			calc(1,i,j,k);
		//	if(dp[1][i][j][k])printf("%d %d %d %d\n",1,i,j,k);
		}
		for(int i=0;i<2;i++)for(int j=0;j<32;j++)for(int k=0;k<32;k++){
			dpv[i][j][k]=0;
		}
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)for(int k=0;k<30;k++)if(dp[0][i][j][k])
			dpv[0][i][j]+=(1<<k);
		for(int i=0;i<b;i++)for(int j=0;j<b;j++)for(int k=0;k<30;k++)if(dp[1][i][j][k])
			dpv[1][i][j]+=(1<<k);
			
		int ret=-1;
		for(int i=0;i<n;i++){
		for(int v=0;v<m;v++){
			for(int j=0;j<32;j++)for(int k=0;k<32;k++)dp2[j][k]=-999999999;
			dp2[0][0]=0;
			for(int j=0;j<n;j++){
				for(int k=0;k<m;k++){
					for(int f=j;f<n;f++)for(int g=k;g<m;g++){
						if(dpv[0][(i+j)%n][(i+f)%n]&dpv[1][(v+k)%m][(v+g)%m])dp2[f+1][g+1]=max(dp2[f+1][g+1],dp2[j][k]+1);
					}
				}
			}
			ret=max(ret,dp2[n][m]);
		}
		}
		printf("%d\n",ret);
	}
}

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

#define ONLINE_JUDGE

using namespace std;
#ifndef ONLINE_JUDGE
#define wi(x) cerr << #x << ": " << (x) << '\n';
#else
#define wi(x)
#endif


typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
template<typename T>
inline T getNum() {
    T k = 0;
    int c = getchar(), f = 1;
    for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
    for (; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}
#define gn() getNum<int>()
#define gl() getNum<ll>()
clock_t opt, edt;
inline void init() {
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
//    freopen("../input.txt", "w", stdout);
    opt = clock();
#endif
}

inline void tini() {
#ifndef ONLINE_JUDGE
    edt = clock();
    cerr << "\n#cost: " <<  (double)(edt - opt) / CLOCKS_PER_SEC << "s\n";
#endif
}

bool ish(int l, int r, string s) {
    for (int i = l, j = r; i < j; i++, j--) {
        if (s[i] != s[j]) return false;
    }
    return true;
}

int main() {
    init();
///////////////////////////////////////////////////////////////////////////////

    int l = gn();
    printf("%.12lf", pow(l / 3.0, 3));









///////////////////////////////////////////////////////////////////////////////
    tini();
}



/*
char Ma[MAXN*2];
int Mp[MAXN*2];
void Manacher(char s[],int len){
    int l=0;
    Ma[l++]='$';
    Ma[l++]='#';
    for(int i=0;i<len;i++){
        Ma[l++]=s[i];
        Ma[l++]='#';
    }
    Ma[l]=0;
    int mx=0,id=0;
    for(int i=0;i<l;i++){
        Mp[i]=mx>i?min(Mp[2*id−i],mx−i):1;
        while(Ma[i+Mp[i]]==Ma[i−Mp[i]])Mp[i]++;
        if(i+Mp[i]>mx){
            mx=i+Mp[i];
            id=i;
        }
    }
}
*/
 /*
 * * abaaba
 * * i:     0 1 2 3 4 5 6 7 8 9 10 11 12 13
 * * Ma[i]: $ # a # b # a # a # b  #  a  #
 * * Mp[i]: 1 1 2 1 4 1 2 7 2 1 4  1  2  1
 */
 /*
char s[MAXN];
int main(){
    while(scanf("%s",s)==1){
        int len=strlen(s);
        Manacher(s,len);
        int ans=0;
        for(int i=0;i<2*len+2;i++)
            ans=max(ans,Mp[i]−1);
        printf("%d\n",ans);
    }
    return 0;
}
*/

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void) {
  int a = 0;
  int b = 0;
  int c = 0;
  while(scanf("%d %d", &a,&b) != EOF) {
    c = a + b;
    int num = 0;
    while(c != 0) {
      c = c / 10;
      num++;
    }
    printf("%d\n", num);
  }
  return 0;
}

Measured memory_bytes: 600
import static java.lang.Double.parseDouble;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static java.lang.Math.toRadians;
import static java.lang.System.out;
import java.io.File;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() {
        double ax = 0;
        double ay = 0;
        double run = 0;
        double deg = 90;
        while (judgeInData()) {
            if ("0,0".equals(getInData()))
                break;
            String[] inDataList = getInData().split(",");
            run = parseDouble(inDataList[0]);
            ax = getPX(run, deg, ax);
            ay = getPY(run, deg, ay);
            deg = getDeg(deg, parseDouble(inDataList[1]));
        }
        out.println((int) ax);
        out.println((int) ay);
    }

    private double getPX(double run, double deg, double ax) {
        return run * cos(toRadians(deg)) + ax;
    }

    private double getPY(double run, double deg, double ay) {
        return run * sin(toRadians(deg)) + ay;
    }

    private double getDeg(double deg, double plusDeg) {
        deg -= plusDeg;
        return (deg < 0.0) ? 360.0 + deg : (deg > 360.0) ? deg - 360.0 : deg;
    }
}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) {
        this.scan = scan;
        execute();
    }

    protected abstract void execute();

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        return !"".equals(inData = nextLine());
    }

    protected String getInData() {
        return inData;
    }

}

Measured memory_bytes: 25788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 
ll n,ans;
bool tr[20];
vector<pair<ll,ll>>ch[20];
void cal(){
	bool ch2=true;
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(tr[i]){
			cnt++;
			for(ll j=0;j<ch[i].size();j++){
				ll nexx=ch[i][j].first;
				ll nexy=ch[i][j].second;
				if(tr[nexx]!=nexy){
					ch2=false;
				}
			}
		}
	}
	if(ch2){
		ans=max(ans,cnt);
	}
}
void dep(ll now){
	if(now==n){
		cal();
		return ;
	}
	tr[now]=1;dep(now+1);
	tr[now]=0;dep(now+1);
}
int main() {
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		for(ll j=0;j<x;j++){
			ll now,y;
			cin>>now>>y;
			now--;
			ch[i].push_back(make_pair(now,y));
		}
	}
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

ll gcd(ll x, ll y) {  return y == 0 ? x : gcd(abs(y), abs(x) % abs(y)); }

ll lcm(ll x, ll y) {
  ll m = gcd(x, y);
  return m * (x / m) * (y / m);
}

int main()
{
  int N; scanf("%d", &N);
  vector<ll> T(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &T[i]);
  }
  ll ans = T[0];
  for (int i = 1; i < N; ++i) {
    ans = lcm(ans, T[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin>>x;
	cout<<(x>=30?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void combTable() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  int N, K; cin >> N >> K;
  combTable();
  for(int i = 1; i <= K; ++i) {
    mint blue = f(K,i);
    mint red = 0;
    {
      red += f(N-K,i-1);
      red += f(N-K,i);
      red += f(N-K,i);
      red += f(N-K,i+1);
    }
    mint ans = blue * red;
    cout << ans.x << endl;
  }
  return 0;
}


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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll m;
	if (n == 1) {
		m = a == b;
	} else if (b < a) {
		m = 0;
	} else {
		m = ((n - 1) * b + a) - ((n - 1) * a + b) + 1;
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        char c = getchar();
        while (c < 'A' || c > 'Z') c = getchar();
        if (c == 'Y') {
            puts("Four");
            return 0;
        }
    }
    puts("Three");
    return 0;
}

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

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


int main(){

    ll n;
    int a,b;
    cin >> n >> a >> b;
    ll zenbu = modpow(2,n,mod)-1;
    
    ll comb[1001000];
    comb[0] = 1;
    rep(i,b+3){
        if(i == 0)continue;
        ll waru = modpow(i,mod-2,mod);
        comb[i] = comb[i-1]*((n-i+1)*waru%mod)%mod;

    }
  
    zenbu -= comb[a];
    zenbu -= comb[b];
    zenbu%= mod;
    if (zenbu<0) zenbu += mod;
    cout << zenbu << endl;


    return 0;
}







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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}




int main()
{

  ll n;
  cin>>n;
  ll e[9]={111,222,333,444,555,666,777,888,999};
  rep(i,9){
    if(n<=e[i]){
      cout<<e[i]<<endl;
      return 0;
    }
  }



  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

vector<i64> fact;
void init_fact(i64 n,i64 m){
	fact.resize(n+1);
	fact[0]=fact[1]=1;
	for(i64 i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}

i64 extgcd(i64 a,i64 b,i64 &x,i64 &y){
	i64 d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	} else {
		x=1; y=0;
	}
	return d;
}

i64 mod_inverse(i64 a,i64 m){
	i64 x,y;
	if(extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

i64 rep_pow(i64 x,int64_t y,i64 mod){
	i64 res(1);
	while(y>0){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}

vector<vector<i64>> comb;
void init_mod_comb(int n,int k,i64 mod){
	comb.resize(n+1);
	for(int i=0; i<=n; ++i){
		comb[i].resize(min(i+1,k+1));
		comb[i][0]=1;
		if(i<=k) comb[i][i]=1;
	}
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=min(i-1,k); ++j){
			comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%mod;
		}
	}
}

void solve(){
	i64 mod=1000000007;
	init_mod_comb(1001,1001,mod);
	init_fact(1001*1001,mod);

	int table_size=10000;
	i64 inv_table[table_size];
	rep(i,1,table_size) inv_table[i]=mod_inverse(i,mod);
	auto inv=[&](i64 x){
		if(x<table_size) return inv_table[x];
		return mod_inverse(x,mod);
	};

    i64 N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    static i64 dp[1024][1024];
    fill_n((i64*)dp,1024*1024,0);
    dp[A][0]=1;
    rep(i,C,D+1){
        if(A*i>N) break;
        dp[A][A*i]=comb[N][A*i]*fact[A*i]%mod*inv(fact[i]*rep_pow(fact[A],i,mod)%mod)%mod;
    }

	rep(i,A,B){
		rep(j,0,N+1){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			rep(k,C,D+1){
				if(j+(i+1)*k>N) break;
				dp[i+1][j+(i+1)*k]=(dp[i+1][j+(i+1)*k]+dp[i][j]*comb[N-j][(i+1)*k]%mod*fact[(i+1)*k]%mod*inv(fact[k]*rep_pow(fact[i+1],k,mod)%mod)%mod)%mod;
			}
		}
	}

	cout << dp[B][N] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 20352
#include<stdio.h>

char s[100000];

int main(void){
    int N; 
    scanf("%d", &N);
    scanf("%s", s);

    int i = 0;
    int cnt = 1;
    for(i = 0; i < N-1; i++){
        if(s[i] == s[i+1]) continue;
        cnt++;
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(a[0] // (2 ** m))
    exit()
a = list(map(lambda x: x * (-1), a))
heapq.heapify(a)
while m > 0:
    m -= 1
    i = heapq.heappop(a) * (-1)
    i //= 2
    heapq.heappush(a, i * (-1))

print(sum(a) * (-1))

Measured memory_bytes: 19912
#include<stdio.h>
    int main(void)
    {
      int A,B,C;
      scanf("%d %d",&A,&B);
      C=A+B;
      if(A%3 == 0 || B%3 == 0 || C%3 == 0){
        printf("Possible\n");
      } else {
        printf("Impossible\n");
      }
      return 0;
    }



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}

template <class T> T roma_to_arabic(string s) {
    auto number = [](char c) -> int {
        if (c == 'I')
            return 1;
        if (c == 'V')
            return 5;
        if (c == 'X')
            return 10;
        if (c == 'L')
            return 50;
        if (c == 'C')
            return 100;
        if (c == 'D')
            return 500;
        if (c == 'M')
            return 1000;
    };
    T ans   = number(s[0]);
    int pre = number(s[0]);
    for (int i = 1; i < s.size(); i++) {
        int now = number(s[i]);
        now <= pre ? ans += now : ans += now - 2 * pre;
        pre = now;
    }
    return ans;
}

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

    string s;
    while (getline(cin, s)) {
        std::cout << roma_to_arabic<int>(s) << '\n';
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N ;
  vector<int> Mx(3);
  vector<int> Mn(3);
  cin >> Mn.at(0) >>  Mn.at(1) >>  Mn.at(2);
  if(N != 1){
  int a,b,c;
  for(int i=1;i<N;i++){
      cin >> a >> b >> c;
    Mx.at(0) = a + max(Mn.at(1),Mn.at(2));
    Mx.at(1) = b + max(Mn.at(0),Mn.at(2));
    Mx.at(2) = c + max(Mn.at(1),Mn.at(0));

  for(int k=0;k<3;k++){
    Mn.at(k) = Mx.at(k);
  }
  }
  sort(Mx.begin(), Mx.end());
  cout << Mx.at(2) << endl;
  }else{
  sort(Mn.begin(), Mn.end());
  cout << Mn.at(2) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
long long int a[100005];

int main(void) {

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

	int ans = 0;

	int trend = 0;

	for (int i = 2; i <= N; i++) {
		if (trend == 0) { if (a[i - 1] < a[i]) { trend = 1; } 
		else if (a[i - 1] > a[i]) { trend = -1; }
		else { trend = 0; }
		}

		if (trend == 1 && a[i - 1] > a[i]) { ans++; trend = 0; }
		if (trend == -1 && a[i - 1] < a[i]) { ans++; trend = 0; }

	}
	ans++;
	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

H, W = list(map(int, input().split(' ')))
A = [list(map(int, input().split(' '))) for _ in range(H)]

# パスの長さはすべての場所を通る H*W が最大
# 北西の端からそのマスへのパスで, 長さがその自然数であるもののうちで, そのパス上の木をすべて伐採するのにかかる時間の最小値
dp = [[[float('inf') for l in range(H*W)] for w in range(W)] for h in range(H)]
dp[0][0][0] = 0

for l in range(1, H*W): # パスの長さ
    cont_flag = False
    for h in range(H):
        for w in range(W):
            if w + h > l:
                cont_flag = True
                continue
            surs = [sur for sur in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)] if (0 <= sur[0] and sur[0] < H and 0 <= sur[1] and sur[1] < W)]
            min_cost = float('inf')
            for hs, ws in surs:
                min_cost = min(min_cost, A[h][w]*(l-1)*2 + A[h][w] + dp[hs][ws][l-1])

            dp[h][w][l] = min_cost
        if cont_flag: continue

print(min(dp[H-1][W-1]))


Measured memory_bytes: 44356
#include<stdio.h>
int main(void){
  int s[2];
  int wa1=0;
  double  wa2=0;
  int wa3=0;
  int i=0;
  while(scanf("%d,%d",&s[0],&s[1])!=EOF){
    wa1=wa1+s[0]*s[1];
    wa2=wa2+s[1];
    i++;
    //printf("%d\n%f\n",wa1,wa2);
  }
  wa2=wa2/i+0.5;
  wa3=wa2;
  printf("%d\n%d\n",wa1,wa3);
  return 0;
}

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

using ll = long long;

// 座標圧縮
map<ll, int> compress(vector<ll> &x, bool sorted = false) {
  map<ll, int> comp;
  if (!sorted) sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  for (int i = 0; i < x.size(); i++) comp[x.at(i)] = i;
  return comp;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, x, d;
  cin >> n >> x >> d;
  
  if (d == 0) {
    if (x == 0) cout << 1 << '\n';
    else cout << n + 1 << '\n';
    return 0;
  }
  
  if (d < 0) {
    x *= -1;
    d *= -1;
  }
  
  vector<ll> modulo;
  for (ll i = 0; i <= n; i++) modulo.emplace_back((((x * i) % d) + d) % d);
  
  auto mp = compress(modulo);
  vector<vector<pair<ll, ll>>> v(mp.size());
  
  for (ll i = 0; i <= n; i++) {
    ll res = (((x * i) % d) + d) % d;
    int nowit = mp[res];
    ll low = (x * i - res) / d + (i - 1) * i / 2;
    ll high = (x * i - res) / d + (2 * n - i - 1) * i / 2;
    v[nowit].emplace_back(make_pair(low, high));
  }
  
  ll ans = 0;
  for (int i = 0; i < v.size(); i++) {
    sort(v[i].begin(), v[i].end());
    ll nowlow = v[i][0].first, nowhigh = v[i][0].second;
    for (int j = 1; j < v[i].size(); j++) {
      if (v[i][j].first > nowhigh + 1) {
        ans += nowhigh - nowlow + 1;
        nowlow = v[i][j].first;
        nowhigh = v[i][j].second;
      }
      else {
        nowhigh = max(nowhigh, v[i][j].second);
      }
    }
    ans += nowhigh - nowlow + 1;
  }
  
  cout << ans << '\n';
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

ll f(ll n, ll m) {
	return (n * n) % m;
}

int main() {
	ll N, X, M; cin >> N >> X >> M;
	ll A, preA, ans = 0;
	ll loopcnt = 0, cnt = 0, sum_loop = 0, rec_A;
	vector<bool> visit(100001);
	bool dub = false;
	for(int i = 1; i <= N; i++) {
		if(i == 1) {
			A = X;
			ans += A;
			visit[A] = true;
			cnt++;
			continue;
		}
		preA = A;
		A = f(A, M);
		if(dub) {
			if(A == rec_A) break;
			ans += A; sum_loop += A; loopcnt++; cnt++;
		}
		else {
			if(visit[A]) {
				dub = true; rec_A = A; sum_loop += A; loopcnt++;
			}
			ans += A;
			cnt++;
			visit[A] = true;
		}
	}
	A = preA;
	if(dub) {
		ans += sum_loop * ((N - cnt) / loopcnt);
		ll rem = (N - cnt) % loopcnt;
		for(int i = 0; i < rem; i++) {
			A = f(A, M);
			ans += A;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main ()
{
    
    int n,i,a[100000],min=9999999,max=-9999999;
    long long int sum=0;
    scanf("%d",&n);
    
    for (i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for (i=0; i<n;  i++)
    {
        sum=sum+a[i];
        
        if (max<a[i])
        {
            max=a[i];
        }
        if (min>a[i])
        {
            min=a[i];
        }
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 644
// cand <genesis?>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll base = 7;
const ll N = 3e5 + 9;
const ll inf = 1000100009;
typedef pair<ll,ll> LL;

ll n,k,a[N],i,chk[N];
vector<ll> pos;
ll getpos(ll x){
    for (ll i = 0;i < pos.size();i++) if (pos[i] == x) return i;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("test.INP", "r", stdin);
    cin>>n>>k;
    for (i=1;i<=n;i++) cin>>a[i];
    i = 1;
    while(chk[i] != 1){
        //cout<<i<<"x\n";
        chk[i] = 1;
        pos.push_back(i);
        i = a[i];
    }
    ll p = getpos(i);
    //cout<<i<<"\n";
    if (k <= p) cout<<pos[k];
    else{
        k -= p;
        k %= (pos.size() - p);
        cout<<pos[p + k];
    }
}


Measured memory_bytes: 8376
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    string s;

    cin >> s;

    int t = 0;

    for(auto&&c:s) {
        t += c - '0';
    }

    cout << (t%9?"No\n":"Yes\n");

    return 0;
}

Measured memory_bytes: 3720
import sys
sys.setrecursionlimit(114514)

def g(i):
    global m
    if i == 10:
        if not sum(s) == 0:
            x = 0
            for j in range(n):
                c = 0
                for k in range(10):
                    if s[k] == f[j][k] == 1:
                        c += 1
                x += p[j][c]
            if m < x:
                m = x
        return
    g(i + 1)
    s[i] = 1
    g(i + 1)
    s[i] = 0

n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
s = [0] * 10
m = -10 ** 9
g(0)
print(m)

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

int main() {

  int H;
  cin >> H;

  int h[H + 1];
  for(int i = 1;i <= H;i++) {
    cin >> h[i];
  }

  for(int i = 1;i <= H;i++) {
    cout << "node " << i << ": key = " << h[i] <<", ";
    if(i / 2 >= 1) cout << "parent key = " << h[i / 2] << ", ";
    if(2 * i <= H) cout << "left key = " << h[2 * i] << ", ";
    if(2 * i + 1 <= H) cout << "right key = " << h[2 * i + 1] << ", ";
    cout << endl; 

  }


  
}



Measured memory_bytes: 3100
#!/usr/bin/env python3
import sys


def solve(N: int):
    rest = N % 1000
    if rest != 0:
        print(1000 - rest)
    else: 
        print(rest)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61716
import java.util.Scanner;
import java.util.Arrays;

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

		while(true){
			int n = scanner.nextInt();
			if(n == 0){
				break;
			}

			sum = 0;
			average = 0;
			b = 0; 
			answer = 0;
			int[] numbers = new int[n];
			for(int i = 0; i < n; i++){
				numbers[i] = scanner.nextInt();
				sum += numbers[i];
			}

			average = sum / n;

			for(int i = 0; i < n; i++){
				b += (numbers[i] - average) * (numbers[i] - average);
			}

			System.out.printf("%.5f", Math.sqrt(b / n));
			System.out.print("\n");

		}
	}
}

Measured memory_bytes: 31716
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i64,
    }

    // N / m = N % m = r と置いた時に、
    // N = r * m + r (ただし、 r < m)
    // N = r (m + 1)

    // N = 8のとき
    // (1, 8) (2, 4) [(4, 2) (8, 1) これらはr < m を満たさないのでNG]
    // 7, 3

    // O(sqrt(N)) で全探索いくかー!

    let mut ans: i64 = 0;
    let mut r = 1i64;
    while r * r <= N {
        if N % r != 0 {
            r += 1;
            continue;
        }

        let m = N / r - 1;
        if m == 0 {
            r += 1;
            continue;
        }

        if N / m == N % m {
            ans += m;
        }

        r += 1;
    }

    println!("{}", ans);
}


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

void solve(long long N, long long K){
    if (N % K) cout << 1 << '\n';
    else cout << 0 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i);
using namespace std;

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

	int ans = 0;
	while (X >= 500) {
		ans += 1000;
		X -= 500;
	}

	while (X >= 5) {
		ans += 5;
		X -= 5;
	}

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

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA

main = do
    [k, n] <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    a:as' <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine
    let as = a:as'
    let bs = as' ++ [a]
    putStrLn $ show (k - maximum (fmap (\(a, b) -> if abs (a - b) > k `div` 2 then k - abs (a - b) else abs (a - b)) $ zip as bs))


Measured memory_bytes: 4348
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  string A, B, C;
  cin >> A >> B >> C;
  cout << A.front() << B.front() << C.front() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	cout<<(n>=30? "Yes" : "No")<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3648
def main():
    x_max, y_max, n = map(int, input().split())
    x_min, y_min = 0, 0

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

        if a == 1:
            x_min = max(x_min, x)
        elif a == 2:
            x_max = min(x_max, x)
        elif a == 3:
            y_min = max(y_min, y)
        elif a == 4:
            y_max = min(y_max, y)

    print(max(0, x_max - x_min) * max(0, y_max - y_min))

        # if (a == 1) and (x > x_min):
        #     x_min = x
        # elif (a == 2) and (x < x_max):
        #     x_max = x
        # elif (a == 3) and (y > y_min):
        #     y_min = y
        # elif (a == 4) and (y < y_max):
        #     y_max = y
        # 
        # if (x_max <= x_min) or (y_max <= y_min):
        #     print(0)
        #     return

    # print((x_max - x_min) * (y_max - y_min))

if __name__ == "__main__":

    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    lint N;
    cin >> N;   
    lint K;
    cin >> K;            
    string S;
    cin >> S;
     
     int ret = 0;
     REP(i,N-1){
         if(S[i] == S[i+1]){
             ++ret;
         }
     }

     cout << min(ret + 2*K,N-1) << endl;   //(upper limit is set for the answer as N-1).
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main(){
    ll n,sum  = 0;
    cin>>n;
    for(int i = 1; i<= n ;i++ ){
        if(i%3==0||i%5==0)
            sum+=0;
        else
            sum +=i;
    }
    cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

int dx[4] = {1, -1, 4, -4}; // when moving happened, there are 4 possibility
map<string, int> res;

void Solution()
{
    queue<string> que;
    
    que.push("01234567");
    
    while(!que.empty())
    {
        
        string v = que.front();
        
        que.pop();
        
        int pos = 0;
        
        for(int i = 0; i < 8; i++)
        {
            if(v[i] == '0')
            {
                pos = i;
            }
        }
        
        for(int i = 0; i < 4; i++)
        {
            if(0 <= pos + dx[i] && pos + dx[i] < 8 && !(pos == 3 && i == 0) && !(pos == 4 && i == 1))
            {
                string u = v;
                
                swap(u[pos], u[pos + dx[i]]);
                
                if(res[u] == 0)
                {
                    que.push(u);
                    res[u] = res[v] + 1;
                }
            }
        }
    }
}

int main()
{
    int in;
    
    res["01234567"] = 1;
    
    Solution();
    
    while(true)
    {
        string s;
        
        for(int i = 0; i < 8; i++)
        {
            if(!(cin>>in))
            {
                return 0;
            }
            
            s+=in+'0';
        }
        
        cout<<res[s] - 1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3460
import java.util.Scanner;

class Main{
	static final int hash = 1000000007;

	static int H;
	static int W;
	static boolean[][] a;
	static int[][] memo;
	static boolean[][] memoflag;

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

		H = sc.nextInt();
		W = sc.nextInt();

		a = new boolean[H + 1][W + 1];
		memo = new int[H][W];
		memoflag = new boolean[H][W];
		for(int h = 0; h < H; h++) {
			String input = sc.next();
			for(int w = 0; w < W; w++) {
				memoflag[h][w] = false;
				if(input.charAt(w) == '.')
					a[h][w] = true;
				else
					a[h][w] = false;
			}
		}
		for(int h = 0; h <= H; h++) {
			a[h][W] = false;
		}
		for(int w = 0; w < W; w++) {
			a[H][W] = false;
		}

		int ans = dp(0, 0);
		System.out.println(ans);
		sc.close();
	}
	static int dp(int y, int x) {
		if(!a[y][x])
			return 0;
		else if(x == W - 1&& y == H - 1)
			return 1;
		if(!memoflag[y][x]) {
			memoflag[y][x] = true;
			memo[y][x] = dp(y + 1, x) + dp(y, x + 1);
			if(memo[y][x] > 1e+9) {
				memo[y][x] %= hash;
			}
		}
		return memo[y][x];
	}
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, x;
    cin >> n >> x;
    ll t = 0; 
    ll p;
    cin >> p;
    if (p > x) {
        t += p - x;
        p = x;
    }
    ll c;
    for (int i = 1; i < n; i++) {
        cin >> c;
        if (p + c > x) {
            t += (p + c) - x;
            c -= (p + c) - x;
        }
        p = c;
    }

    cout << t << endl;
}


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

int main() {
  long long n;
  string s = "abcdefghijklmnopqrstuvwxyz";
  vector <long long> x(11);
  cin >> n;
  string ans;
  
  x.at(0) = 1;
  for(int i = 1;i<11;i++){
    x.at(i) = x.at(i-1) + pow(26,i);
  }
  for(long long i = 10;i >=0;i--){
    if(n >= x.at(i)){
      ans = ans + s.at(int((n - x.at(i)) / pow(26,i)));
      n = n - (int((n - x.at(i)) / pow(26,i))+1) * pow(26,i);
    }
  }
  cout << ans << endl;
  
}


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

int main() {
	int a[3];
	bool v=false,w=false,x=false,y=false;
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	for(int i=0;i<4;i++){
		if(a[i]==1){
			v=true;
		}
		if(a[i]==7){
			w=true;
		}
		if(a[i]==9){
			x=true;
		}
		if(a[i]==4){
			y=true;
		}
	}
	if(v&&w&&x&&y){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<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;

int main(){
  int n;
  cin >>n;
  string s;
  cin >>s;
  ll r=0, g=0, b=0;
  rep(i,n){
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }
  ll rgb = r*g*b;
  for(int i = 0; i<n-2; i++){
    for(int j = i+1; j<n-1; j++){
      int k = 2*j-i;
      if(k<n && s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]) rgb--;
    }
  }
  cout << rgb << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,k,i;
  cin>>k>>n;
  ll arr[n];
  for(i=0;i<n;i++)
   {
       cin>>arr[i];
      
   }
  vector<ll>ans;
  ll x;
  for(i=0;i<n;i++)
  {
      if(i==n-1)
      {
          x=k-arr[i]+arr[0];
          ans.push_back(x);
          
      }
      else
      {
          x=arr[i+1]-arr[i];
          ans.push_back(x);
      }
  }
  sort(ans.begin(),ans.end());
  x=0;
  for(i=0;i<ans.size()-1;i++)
  x+=ans[i];
  cout<<x;

}

Measured memory_bytes: 3956
#include <cstring>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;

const int MAXN = 100010;
int N, A[MAXN];

int main() {
    int i;
    scanf("%d", &N);
    for(i = 1; i <= N; i++) scanf("%d", &A[i]);

    ll L = 2, R = 2;
    for(i = N; i >= 1; i--) {
        ll m = A[i], lb = L / m, rb = R / m;
        if(lb * m < L) lb++;
        //fail
        if(lb > rb) { printf("-1"); return 0; }
        L = lb * m, R = (rb + 1) * m - 1;
    }
    printf("%lld %lld", L, R);
}

Measured memory_bytes: 512