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

void input(int& rnMaxNum, int& rnBase)
{
  cin >> rnMaxNum >> rnBase;
}

llong calcNumOfCases(int nMaxNum, int nBase)
{
  llong nNumOfCases = 0;
  int nTerm;

  if (nBase % 2 == 0)
  {
//    an = a1 + (n - 1)d
//    nMaxNum = (nBase / 2) + (n - 1)nBase  
     if ( nMaxNum - (nBase / 2) >= 0 )
     {
       nTerm = ( nMaxNum - (nBase / 2) ) / nBase + 1;
       nNumOfCases += (llong)nTerm * nTerm * nTerm;
     }
  }
  nTerm = nMaxNum / nBase;
  nNumOfCases += (llong)nTerm * nTerm * nTerm;

  return nNumOfCases;
}
  
int main()
{
  int nMaxNum, nBase;
  
  input(nMaxNum, nBase);
  cout << calcNumOfCases(nMaxNum, nBase) << endl;

  return 0;
}

Measured memory_bytes: 3496
#include<iostream>
main(){int n,m,i,a,c[1<<20];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m;
	int64_t k;
	cin >> n >> m >> k;
	vector<int64_t> a(n + 1), b(m + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}

	for (int i = 0; i < m; i++) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}

    int64_t ans = 0;
    for (int64_t i = 0, j = m; i <= n; i++) {
    	if (a[i] > k) break;

    	while (a[i] + b[j] > k) j--;
    	ans = max(ans, i + j);

    }
    cout << ans;
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int l=s.size();
  for(int i=0;i<l;i++){
    if(s.at(i)!=t.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char N[3]; 
  cin >> N;
  int A;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
    if(N[i] == N[j]) A++;  
    }
  }
  if(A == 8) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("ARC80F.in","r",stdin);
	freopen("ARC80F.out","w",stdout);
}

const int maxn=500+10;
int n,a[maxn],pos[maxn],tot,cnt,ans;
int be[maxn],cnte,to[maxn*maxn],las[maxn*maxn],beg[maxn];
bool vis[maxn];

void add(int u,int v){
	las[++cnte]=beg[u];
	beg[u]=cnte;
	to[cnte]=v;
}

bool pd(int x){
	if(x==1 || x==2)return false;
	int y=sqrt(x);
	REP(i,2,y)if(x%i==0)return false;
	return true;
}

bool Hungary(int u){
	for(int i=beg[u];i;i=las[i]){
		if(vis[to[i]])continue;
		vis[to[i]]=1;
		if(!be[to[i]] || Hungary(be[to[i]])){
			be[to[i]]=u;
			return true;
		}
	}
	return false;
}

int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n){
		scanf("%d",&a[i]);
		if(i==1 || a[i-1]<a[i]-1)pos[++tot]=a[i];
		if(i!=1 && a[i]>a[i-1]+1)pos[++tot]=a[i-1]+1;
	}
	pos[++tot]=a[n]+1;
	REP(i,1,tot)if(pos[i]%2)++cnt;
	REP(i,1,tot)if(pos[i]%2==0){
		REP(j,1,tot)if(pos[j]%2==1 && pd(abs(pos[j]-pos[i])))
			add(i,j);
	}
	REP(i,1,tot)if(pos[i]%2==0){
		memset(vis,0,sizeof(vis));
		ans+=Hungary(i);
	}
	printf("%d\n",ans+(tot-ans*2)+(cnt-ans)%2);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int times(long long A){
  int count=0;
  bool flag=true;
  while(flag){
    if(A/2==0){
      flag=false;
    }
    else{
      count=count+1;
      A=A/2;
    }
  }
  return count;
}
long long Rui(int a){
  if(a==0){
    return 1;
  }
  else{
    long long C=1;
    for(int i=0;i<a;i++){
      C=C*2;
    }
    return C;
  }
}      
int main(){
  long long H;
  cin>>H;
  int N=times(H);
  cout<<Rui(N+1)-1<<endl;
}
  

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

//ABC115D
int main(void) {
  long long n, x, k, i, cou=0, pcu=0, tmp;
  scanf("%lld %lld", &n, &x);
  long long thi[n+1], p[n+1];
  thi[0]=1, p[0]=1;
  for(i=1; i<=n; i++){
    thi[i]=thi[i-1]*2+3, p[i]=p[i-1]*2+1;
  }
  i=n;
  while(cou<x&&i>=0){
    if(x>=cou+thi[i]){

      cou+=thi[i];
      pcu+=p[i];
      if(x>=cou+1) cou++, pcu++;
      //printf("thi[%lld]=%lld p[%lld]=%lld", i, thi[i], i, p[i]);
      //printf(" cou=%lld pcu=%lld\n", cou, pcu);
    }else{
      cou++;
      //printf("thi[%lld]=%lld p[%lld]=%lld", i, thi[i], i, p[i]);
      //printf(" cou=%lld pcu=%lld\n", cou, pcu);
      i--;
    }
  }
  printf("%lld", pcu);
}

Measured memory_bytes: 128
public class Main {
	public static void main(String[] args) {
	for(java.util.Scanner scan:new java.util.Scanner[] {new java.util.Scanner(System.in)}) {
	for(int i:new int[] {0}) {
	for(int a:new int[] {scan.nextInt()}) {		
	for(long sum:new long[] {0}) {
	for(int cnt:new int[] {0}) {
	for(long min:new long[] {Long.MAX_VALUE}) { 
		while(i<a) {
			for(long x:new long[] {scan.nextLong()}) {
				if(System.out.printf("", i++)==null) {}
				if(x<0) {
					if(System.out.printf("", sum+=(x*-1))==null) {}
					if(System.out.printf("", cnt++)==null) {}
					if(System.out.printf("", min=Long.min(min, x*-1))==null) {}
				}
				else {
					if(System.out.printf("", sum+=x)==null) {}
					if(System.out.printf("", min=Long.min(min, x))==null) {}
				}
			}
		}
		if(cnt%2==0) {
			if(System.out.printf("%d\n", sum)==null) {}
		}
		else {
			if(System.out.printf("%d\n", sum-min*2)==null) {}
		}
	}}}}}}}}

Measured memory_bytes: 83368
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

a = STR()
if a == a.upper():
    print('A')
else:
    print('a')

Measured memory_bytes: 72636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int cnt[100010][26];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<string>a(n); rep(i, n)cin >> a[i];
	map<string, int>mp;
	rep(i, n) {
		sort(ALL(a[i])); mp[a[i]]++;
	}
	int ans = 0;
	for (auto m : mp) {
		int tmp = m.second;
		ans += tmp * (tmp - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16640
#include <stdio.h>

#define N 10

int main(void){
    int len[N], totalLn;
    int v1, v2;
    double joinTm, joinPt;
    
    while(1){
        if (scanf("%d,", &len[0]) ==EOF) break;
        totalLn = len[0];
        for (int i=1; i<N; i++){
            scanf("%d,", &len[i]);
            totalLn += len[i];
        }
        scanf("%d,%d", &v1, &v2);
        joinTm = (double)totalLn / (v1 + v2);
        joinPt = joinTm * v1;
        for (int i=0; i<N; i++){
            joinPt-=len[i];
            if (joinPt <= 0){
                printf("%d\n", i+1);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1020
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 100000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 300005

int cnt[maxn],l[maxn],r[maxn];
int main()
{
    boost1;boost2;
    int i,j,n,m,x,y,z,val,l1,r1,l2,r2;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    cin>>l[i]>>r[i];
    for(i=1;i<=n;i++)
    {
        j=1;
        while(j*j<=r[i])
        {
            val=j;
            y=r[i]/val;
            x=1+(r[i]/(val+1));
            y=min(y,m);
            if(x>y)
            continue;
            //cout<<x<<" "<<y<<" "<<val<<endl;
            z=(l[i]+val-1)/val;
            z=max(z,x);
            l1=inf;
            r1=-inf;
            l2=inf;
            r2=-inf;
            if(z<=y)
            {
                l1=z;
                r1=y;
            }
            if((r[i]/j)!=j)
            {
                val=r[i]/j;
                y=r[i]/val;
                x=1+(r[i]/(val+1));
                y=min(y,m);
                if(x>y)
                continue;
              //  cout<<x<<" "<<y<<" "<<val<<endl;
                z=(l[i]+val-1)/val;
                z=max(z,x);

                if(z<=y)
                {
                    l2=z;
                    r2=y;
                }
            }
            if(l2>r1)
            {
                if(l1<=r1){
                cnt[l1]++;
                cnt[r1+1]--;}
                if(l2<=r2){
                cnt[l2]++;
                cnt[r2+1]--;}
            }
            else if(r2<l1)
            {
                if(l1<=r1){
                cnt[l1]++;
                cnt[r1+1]--;}
                if(l2<=r2){
                cnt[l2]++;
                cnt[r2+1]--;}
            }
            else{
            x=min(l1,l2);
            y=max(r1,r2);
            if(x<=y)
            {
                cnt[x]++;
                cnt[y+1]--;
            }}
            j++;
        }
    }
    for(i=1;i<=m;i++)
    {
        cnt[i]+=cnt[i-1];
        cout<<cnt[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
import java.io.IOException;

public class Main {
    static class Edge {
        int to;
        boolean odd;

        Edge(int to, boolean odd) {
            this.to = to;
            this.odd = odd;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        List<List<Edge>> edges = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            edges.add(new ArrayList<>());
        }
        for(int i = 0; i < n - 1; i++) {
            String[] in = br.readLine().split(" ");
            int u = Integer.parseInt(in[0]) - 1;
            int v = Integer.parseInt(in[1]) - 1;
            int w = Integer.parseInt(in[2]);
            boolean odd = w % 2 == 1;
            edges.get(u).add(new Edge(v, odd));
            edges.get(v).add(new Edge(u, odd));
        }

        boolean[] odd = new boolean[n];
        Stack<Integer> stack = new Stack<>();
        stack.push(0);
        boolean[] checked = new boolean[n];
        checked[0] = true;
        while(!stack.isEmpty()) {
            int s = stack.pop();
            for(Edge e : edges.get(s)) {
                if(!checked[e.to]) {
                    odd[e.to] = odd[s] ^ e.odd;
                    stack.push(e.to);
                    checked[e.to] = true;
                }
            }
        }


        for(int i = 0; i < n; i++) {
            System.out.println(odd[i]? '1': '0');
        }

        br.close();
    }
}

Measured memory_bytes: 71336
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();   //基準となる合計額
        int q = X / 100;    //商
        int d = X % 100;    //余り

        for (int i = 0; i < q; ++i){
            if (d >= 5){
                d -= 5;
            } else if (d >= 4){
                d -=4;
            } else if (d >= 3){
                d -=3;
            } else if (d >= 2){
                d -=2;
            } else if (d >= 1){
                d -=1;
            }
        }
        
        //出力
        if (d == 0){
            System.out.println(1);
        } else{
            System.out.println(0);
        }
    }
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll k;
	cin >> k;
	ll start = k;
	ll div = 0, count = 0;
	while (start) {
		div *= 10;
		div += 7;
		count++;
		start /= 10;
	}
	div = div % k;
	vector<bool> found(10 * (k + 1), false);
	while (!found[div]) {
		if (div % k == 0) {
			cout << count << endl;
			return 0;
		}
		found[div] = true;
		div = div % k;
		div *= 10;
		div += 7;
		count++;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 4468
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_C&lang=ja

def partition(A, p, r):
    x = A[r][0]
    i = p - 1
    for j in range(p, r):
        if A[j][0] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q - 1)
        quicksort(A, q + 1, r)

n = int(input())
A = []
valset = set({})
for i in range(n):
    c, d = input().split()
    A.append((int(d), i, c))
    valset.add(int(d))

quicksort(A, 0, n - 1)

# flag
is_stable = True
for val in valset:
    tp = [A[j][1] for j in range(n) if A[j][0] == val]
    flag = False
    for j in range(len(tp) - 1):
        if tp[j] > tp[j + 1]:
            flag = True
            break
    # print(val, tp, flag)
    if flag:
        is_stable = False
        break
    
if is_stable:
    print("Stable")
else:
    print("Not stable")

for tp in A:
    print("{} {}".format(tp[2], tp[0]))


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

int main()
{
    int n,ans;

    cin >> n; 
    vector<int> b(n-1);
    rep(i, n-1) {
        cin >> b[i];
    }

    ans = b[0];
    for (int i = 1;i < n - 1;++i) {
        ans += min(b[i-1], b[i]);
    }
    ans += b[n-2];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int m;
  cin >> m;
  int ans = 24;
  ans += 24-m;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

long long gcd ( int a, int b )
{
	if ( b == 0 ) {
		return a;
	}
	
	return gcd (b, a%b);
		
}
	

int main() {
    
    long long k;
	long long a, b, c;
	long long ret = 0;
	
	cin >> k;
	for ( a = 1; a <= k; a++ ) {
		for ( b = 1; b <= k; b++ ) {
			for ( c = 1; c <= k; c++ ) {
				ret += gcd(a, gcd(b, c));
			}
		}
	}
	cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3628
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* }}} */

int main(){
  string s;
  cin >> s;
  int a = 0, b = 0;
  each(c, s) (c == 'g' ? a : b)++;
  if (s.size() & 1) a--;
  cout << (a - b) / 2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

ll d;
vector<ll> c(26);
vector<vector<ll>> s(365, vector<ll>(26));
vector<ll> t(365);
vector<ll> last(26, -1);

ll score(ll type, ll day, ll sc) {
  ll s_now = sc + s[day][type];
  REP(i, 26) { s_now -= c[i] * (day - last[i]); }
  return s_now;
}

ll sim(vector<ll> yotei) {
  ll ss = 0;
  REP(i, d) {
    last[yotei[i]] = i;
    ss = score(yotei[i], i, ss);
  }
  return ss;
}

int main() {
  cin >> d;
  REP(i, 26) { cin >> c[i]; }
  REP(i, d) {
    REP(j, 26) { cin >> s[i][j]; }
  }

  REP(i, d) {
    ll tmp = 0, m = 0;
    REP(j, 26) {
      if (m < s[i][j]) {
        m = s[i][j];
        tmp = j;
      }
    }
    t[i] = tmp;
  }

  vector<ll> ch(10), tmp(10);
  REP(j, 100000) {
    ll ss = sim(t);
    REP(i, 10) { ch[i] = rand() % 26; }
    REP(i, 10) {
      tmp[i] = t[i];
      t[i] = ch[i];
    }

    if (sim(t) < ss) {
      REP(i, 10) { t[i] = tmp[i]; }
    }
  }
  // DEBUGS(t);
  //cout << sim(t) << "\n";
   REP(i, d) { cout << t[i]+1 << "\n"; }
  return 0;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x, y;
  x = (c + b - 1) / b;
  y = (a + d - 1) / d;
  if(x > y)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}

void dfs(int G[100][100], int n, int *d, int *f, int u) {
    static int t = 0;
    d[u] = ++t;
    for(int i = 0; i < n; ++i) {
        if(!G[u][i] || d[i]) continue;
        dfs(G, n, d, f, i);
    }
    f[u] = ++t;
}
int main(int argc, char **argv) {
    int n = get_uint();
    int G[100][100] = {};
    for(int i = 0; i < n; ++i) {
        int u = get_uint() - 1;
        int k = get_uint();
        for(int j = 0; j < k; ++j) G[u][get_uint() - 1] = 1;
    }
    int d[100], f[100] = {};
    for(int i = 0; i < n; ++i)
        if(!f[i]) dfs(G, n, d, f, i);
    for(int i = 0; i < n; ++i) {
        put_uint(i + 1), putchar_unlocked(' ');
        put_uint(d[i]), putchar_unlocked(' ');
        put_uint(f[i]), putchar_unlocked('\n');
    }
    return 0;
}



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n,a;
  char l;
  cin >> n;
  bool s[13] = { false };
	bool h[13] = { false };
	bool c[13] = { false };
	bool d[13] = { false };
  rep(i,n){
    cin >> l >> a;
    if(l=='S')s[a-1]=true;
    else if(l=='H')h[a-1]=true;
    else if(l=='C')c[a-1]=true;
    else if(l=='D')d[a-1]=true;
  }
  rep(i,13){
    if(s[i]==false)cout << 'S' << ' ' << i+1 << endl;
  }
  rep(i,13){
    if(h[i]==false)cout << 'H' << ' ' << i+1 << endl;
  }
  rep(i,13){
    if(c[i]==false)cout << 'C' << ' ' << i+1 << endl;
  }
  rep(i,13){
    if(d[i]==false)cout << 'D' << ' ' << i+1 << endl;
  }
}



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

int main() {
	int n, k;
	cin >> n >> k;
	int numer = 0, denom = n;
	if (n >= k) {
		numer += n - k + 1;
		n = k - 1;
	}
	while (n > 0) {
		k = (k + 1) / 2;
		numer <<= 1;
		denom <<= 1;
		if (n >= k) {
			numer += n - k + 1;
			n = k - 1;
		}
	}

	cout << setprecision(9) << (double) numer / denom << endl;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  StdIn.readLine()
  val nums = StdIn.readLine().split(' ').map(BigInt(_))

  val sum = nums.sum

  val tmp1 = sum*sum - nums.map(n=>n*n).sum

  val ans = (tmp1/2) % (BigInt((math.pow(10L,9L)+7).toLong))

  println(ans)
}









Measured memory_bytes: 113684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 2];
        int sum = 0;
        arr[n] = 0;
        arr[n + 1] = 0;

        for (int i = 1; i < n + 1; i++) {
            arr[i] = sc.nextInt();
            sum += Math.abs(arr[i - 1] - arr[i]);
        }
        sc.close();

        sum += Math.abs(arr[n]);

        for (int i = 1; i <= n; i++) {
            System.out.println(sum - Math.abs(arr[i - 1] - arr[i]) - Math.abs(arr[i] - arr[i + 1])
                    + Math.abs(arr[i - 1] - arr[i + 1]));
        }
    }
}

Measured memory_bytes: 69500
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int gcd(int a, int b) {
	if (b == 0)return a;
	int tmp = a%b;
	a = b;
	b = tmp;
	return gcd(a, b);
}

int main() {
	ll n,m;
	scanf("%lld%lld", &n,&m);

	char s[100001], t[100001];
	scanf("%s", s);
	scanf("%s", t);

	ll x = n / gcd(n, m)*m;
	int dfn = x / m;
	int dfm = x / n;
	REP(i, gcd(n, m)) {
		if (s[dfn*i] != t[dfm*i]) {
			puts("-1");
			return 0;
		}
	}
	PRINTL(x);
}

Measured memory_bytes: 384
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

N = NI()
ans = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        d = math.gcd(a,b)
        if d == 1:
            ans += N
        else:
            for c in range(1,N+1):
                ans += math.gcd(d,c)
print (ans)

Measured memory_bytes: 70416
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<char> vec(n);
  REP(i,n) {
    cin >> vec[i];
    if(vec[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,i,a[10000][4],b[2];

	while(1){
		scanf("%d",&n)!=0;
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
			a[i][3]=a[i][1]+a[i][2];
		}
		b[0]=a[0][0];
		b[1]=a[0][3];
		for(i=1;i<n;i++){
			if(b[1]<a[i][3]){
				b[0]=a[i][0];
				b[1]=a[i][3];
			}
		}
		printf("%d %d\n",b[0],b[1]);		
	}
	return 0;
}

Measured memory_bytes: 756
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int op(int a, int b){
    return max(a, b);
}
int e() { return -1;}

int target;

bool op2(int v){
    return v < target;
}

int main() {
    int N, Q; 
    cin>> N >> Q;
    segtree<int, op, e> Seg(N);
    REP(i, 0, N){
        int a;
        cin >> a;
        Seg.set(i, a);
    }
    vi Query(3, 0);
    REP(i, 0, Q){
    }
    REP(i, 0, Q){
        REP(j, 0, 3) cin >> Query[j]; 
        if(Query[0] == 1){
            Seg.set(Query[1] - 1, Query[2]);
        }
        if(Query[0] == 2){
            int max = Seg.prod(Query[1] - 1, Query[2]);
            cout << max << endl;
        }
        if(Query[0] == 3){
            target = Query[2];
            int res = Seg.max_right<op2>(Query[1]-1) + 1;
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 6204
// ProblemURL : https://atcoder.jp/contests/abc072/tasks/arc082_b
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]int, n)
	for i := range ps {
		fmt.Scan(&ps[i])
		ps[i]--
	}

	as := make([]int, 0, n)
	for i := range ps {
		if i == ps[i] {
			as = append(as, i)
		}
	}

	ct := 0
	for i := 0; i < len(as); i++ {
		if i+1 < len(as) && as[i]+1 == as[i+1] {
			i++
			ct++
		} else {
			ct++
		}
	}
	fmt.Println(ct)
}


Measured memory_bytes: 5504
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d", &a, &b);

    if (a==b) {
        puts("a == b");
    }else{
        if (a<b) {
            puts("a < b");
        }else{
            puts("a > b");
        }
    }

    return 0;
}

Measured memory_bytes: 580
# encoding:utf-8
 
def main():
	N = int(input())
	nums = list(map(int, input().split()))
	l_div4 = len([x for x in nums if x % 4 == 0])
	l_div2 = len([x for x in nums if x % 2 == 0])
	l_div0 = len(nums) - l_div2

	main_checker(l_div4, l_div2, l_div0)

def main_checker(l_div4, l_div2, l_div0):
	#print(l_div4, (l_div2 - l_div4), l_div0)
	if l_div0 == 0:
		print("Yes")
	elif l_div4 >= l_div0 + ((l_div2 - l_div4) > 0) - 1:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()


Measured memory_bytes: 14252
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = {0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = {0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}

int main() {
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int b = 1; b < N + 1; b++) {
		int r = N % b;
		int p = (N - r) / b;
		ans += max(0, b - K)*p + max(0, r - K + 1);
	}
	if (K == 0)ans -= N;
	print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[220000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>m>>n;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	a=t[0]+m-t[n-1];
	for(i=1;i<n;i++){
		a=max(a,t[i]-t[i-1]);
	}
	cout<<m-a<<endl;
}

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


int main(){
  vector<int> pop_num;
  string str;
  priority_queue<int> que;
  int num;
  int pop;
  int i;
  
  while(true){
    cin >>str;
    if(str == "insert"){
      cin >>num; 
      que.push(num);
    }else if(str == "extract"){

      pop_num.push_back(que.top());
      que.pop();
    }else if(str == "end"){
      break;
    }
  }

  for(int i = 0;i < pop_num.size();i++){
    cout << pop_num[i]<<endl;
  }

  
  /* while(!que.empty()){
    cout <<que.top()<<endl;
    que.pop();
  }
  */
  return 0;
}



Measured memory_bytes: 10692
#include <iostream>
#include <queue>
#include <vector>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> hint(N);
  std::vector<int> lut(N);

  for (int i = 0; i < M; ++i) {
    int x, y, z;
    std::cin >> x >> y >> z;
    hint[x - 1].push_back(y - 1);
    hint[y - 1].push_back(x - 1);
  }

  std::queue<int> chain;
  int num = 0;

  for (int i = 0; i < N; ++i) {
    int table;
    if (lut[i] == 0) {
      ++num;
      lut[i] = num;
    } else {
      continue;
    }

    // for (auto &h : hint[i]) {
    // lut[h] = table;
    // chain.push_back(h);
    // }
    // hint[i].clear();
    chain.push(i);

    while (!chain.empty()) {
      auto c = chain.front();
      for (auto &h : hint[c]) {
        if (lut[h] == 0) {
          lut[h] = num;
          chain.push(h);
        }
      }
      hint[c].clear();
      chain.pop();
    }
  }

  int result = num;

  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 6904
#include <iostream>
#include<vector>
#include<map>
#include<cctype>
#include<algorithm>
#define ll long long int
//using namespace std;

inline bool check_int(std::string s,int n){
	if(isdigit(static_cast<unsigned char>(s[n]))){
		return true;
	}else{
		return false;
	}
}

int main() {
	std::string s;
	ll a,b;
	std::cin>>a>>b;
	std::cin>>s;
	ll k=0;
	for(int i=0;i<a;i++)if(!check_int(s,i))k++;
	if(s[a]!='-')k++;
	for(int i=a+1;i<a+b+1;i++)if(!check_int(s,i))k++;
	if(k!=0){
		std::cout<<"No"<<std::endl;
	}else{
		std::cout<<"Yes"<<std::endl;
	}
	//std::cout<<s[1]<<std::endl;
	return 0;
}


Measured memory_bytes: 256
read n k

for i in `seq "$k"`
do
	read "d_$i"
    read -a "a${i}s"
done

result=(`seq "$n"`)

for i in `seq "$k"`
do
	temp=a${i}s[@]
    
	# ${result[@]} \= ${!temp}
    for j in "${!temp}"
    do
    	for k in "${!result[@]}"
        do
        	if [[ "${result[k]}" = "$j" ]]; then
            	unset result[k]
            fi
        done
    done
done

echo "${#result[@]}"

Measured memory_bytes: 4500
# ABC 121: B – Can you solve this?
n, m, c = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]

a = []
for _ in range(n):
    a.append([int(s) for s in input().split()])

counter = 0

for i in range(n):
    answer = c
    
    for j in range(m):
        answer += a[i][j] * b[j]

    if answer > 0:
        counter += 1

print(counter)

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

using namespace std;
using ll = long long;

int main() {
    int a,b,h,m = 0;
    cin >> a >> b >> h >>m;

    double aDeg = (((double)h + (double)m / 60) / 12) * 360;
    double bDeg = ((double)m / 60) * 360;
    double deg = max(aDeg,bDeg) - min(aDeg,bDeg);
    if(deg > 180){
        deg = 360 - deg;
    }
    deg = (deg / 180) * M_PI;

    double C = 0;
    double c = 0;
    double A = (double)a;
    double B = (double)b;

    C = A * A + B * B - 2 * A * B * cos(deg);
    c = sqrt(C);
    cout << fixed << setprecision(10) << c << endl;
    
    return 0;
}

Measured memory_bytes: 4184
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if (M2 - M1 == 1 && D2 == 1) cout << 1 << endl;
    else cout << 0 << endl;
}


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


int main(void) {

  string s, p;
  cin >> s >> p;
  s += s;

  for(int i=0; i<s.size(); i++){
    bool f = true;
    for(int j=0; j<p.size(); j++){
      if( i+j >= s.size() ){
        f = false;
        break;
      }
      if( s[i+j] != p[j] ){
        f = false;
        break;
      }
      // cerr << s[i+j] << " " << p[j] << endl;
    }
    if( f ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3216
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int n;
	int a[100];
	int t = 0;

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

	for (int i = 0; i < n - 1; i++)
	{
		int mini = i;
		for (int j = i + 1; j < n; j++)
		{
			if (a[j] < a[mini])
			{
				mini = j;
			}
		}
		if (mini != i)
		{
			int temp = a[i];
			a[i] = a[mini];
			a[mini] = temp;
			t++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << a[i];
		if (i < (n - 1))
		{
			cout << " ";
		}
	}
	cout << endl;
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  REP1(k, 1000) {
    if (k * (k - 1) / 2 == n) {
      cout << "Yes" << endl;
      cout << k << endl;
      vector<int> vc[k];
      int num = 1;
      REP(i, k) {
        for (int j = i + 1; j < k; ++j) {
          vc[i].push_back(num);
          vc[j].push_back(num);
          num++;
        }
      }
      REP(i, k) {
        cout << vc[i].size();
        REP(j, vc[i].size()) cout << " " << vc[i][j];
        cout << "\n";
      }
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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


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

    ll N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];

    ll nmax = 0;
    ll ans = 0;
    for(ll i=0; i<N; i++){
      if(A[i] <= nmax) continue;
      if(A[i] > nmax+1){
        int tmp = ans;
        int a = A[i];
        //while(A[i] > nmax+1){
        //  A[i] -= (nmax+1);
        //  ans++;
        //}
        //cout << (ans-tmp) << " " << floor((double)(a-1)/(double)(nmax+1)) << endl;
        ans += floor((double)(a-1)/(double)(nmax+1));
        A[i] = 1;
        if(nmax == 0){
          nmax = 1;
        }
      }else{
        nmax++;
      }
    }
    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0; i<n; i++)
#define DEBUG(x) cerr << #x << ": " << (x) << endl

using ll = __int128_t;
using ll64 = long long;

int n;
int p[252], q[252];
int rev[252];
bool used[252];

void extgcd(ll p, ll q, ll& x, ll& y, ll& g){
  if(q==0){
    g = p;
    x = 1;
    y = 0;
    return;
  }
  extgcd(q, p%q, y, x, g);
  y -= p / q * x;
  return;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",p+i),p[i]--;
  REP(i,n)scanf("%d",q+i),q[i]--;
  REP(i,n)rev[p[i]] = i;
  fill(used, used+n, false);
  ll M = 1;
  ll R = 0;
  REP(i,n)if(!used[i]){
    vector<int> ids;
    int cur = i;
    do{
      ids.push_back(cur);
      cur = rev[q[p[cur]]];
    }while(cur != i);
    for(int x : ids){
      used[x] = true;
    }
    sort(ids.begin(), ids.end());
    vector<int> vals;
    for(int x : ids){
      vals.push_back(p[x]);
    }
    sort(vals.begin(), vals.end());
    if(ids != vals){
      puts("-1");
      return 0;
    }
    vals.clear();
    for(int x : ids){
      vals.push_back(p[x]);
    }
    ll m = ids.size();
    ll r = 0;
    while(r<m){
      if(vals == ids)break;
      // step
      REP(j,m)vals[j] = q[vals[j]];
      r++;
    }
    if(r==m){
      puts("-1");
      return 0;
    }
    ll x, y, g;
    extgcd(M, -m, x, y, g);

    if(abs((ll64)(R-r)) % __gcd((ll64)M,(ll64)m) != 0){
      puts("-1");
      return 0;
    }
    ll mul = (r-R) / g;

    ll nxtM = M/__gcd((ll64)M,(ll64)m)*m;
    x = (x * mul) % nxtM;
    R = M * x + R;
    M = nxtM;
    R %= M;
    if(R<0)R+=M;
  }

  printf("%lld\n",(ll)R);
  return 0;
}



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

using namespace std;

int dp[101][4][4][4];

int main(){
    int N;
    cin >> N;
    int mod = 1e9 + 7;

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

    for (int len = 0; len < N; len++){
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    if (dp[len][c1][c2][c3] == 0) continue;

                    for (int cn = 0; cn < 4; cn++) {
                        if (c2 == 0 && c1 == 1 && cn == 2) continue;
                        if (c2 == 1 && c1 == 0 && cn == 2) continue;
                        if (c2 == 0 && c1 == 2 && cn == 1) continue;
                        if (c3 == 0 && c1 == 1 && cn == 2) continue;
                        if (c3 == 0 && c2 == 1 && cn == 2) continue;

                        dp[len+1][cn][c1][c2] += dp[len][c1][c2][c3];
                        dp[len+1][cn][c1][c2] %= mod;

                    }
                }
            }
        }
    }

    int res = 0;
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                res += dp[N][c1][c2][c3];
                res %= mod;
            }
        }
    }
    cout << res << endl;

}


Measured memory_bytes: 256