akhauriyash/Code-Regression huggingface dataset:
program bounding
  implicit none
  integer :: n, x, ans, i, d
  integer,allocatable :: l(:)
  read *, n, x
  allocate(l(n))
  read *, l
  ans = 0
  d = 0
  do i = 1, n
    d = d + l(i)
    ans = ans + 1
    if (d > x) exit
    if (i == n) ans = ans + 1
  end do
  print '(i0)', ans
  stop
end program bounding


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

int g_count = 0;
void InsertionSort(std::vector<int> *a, const int g){
    const int n = a->size();
    for(int i=g; i<n; i++){
        int v = a->at(i);
        int j = i - g;
        while(j >= 0 && a->at(j) > v){
            a->at(j + g) = a->at(j);
            j -= g;
            g_count += 1;
        }
        a->at(j + g) = v;
    }
}

void ShellSort(std::vector<int> *a){

    const int n = a->size();
    std::vector<int> g;
    g.reserve(100);
    int m = 0;
    int t = 1;
    while(m < 100 && t <= n){
        g.emplace_back(t);
        t += 6;
        m += 1;
    }
    std::reverse(g.begin(), g.end());
    for(const int tg : g){
        InsertionSort(a, tg);
    }
    std::cout << m << std::endl;
    for(int i=0; i<m; i++)
        std::cout << g.at(i) << ((i == m - 1) ? "\n" : " ");
    std::cout << g_count << std::endl;
    for(int i=0; i<n; i++)
        std::cout << a->at(i) << std::endl;
}

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(auto &&i : a)
        std::cin >> i;
    ShellSort(&a);
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
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 (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e3+5;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a,b;
    cin >> a >> b;

    auto f = [](char c, int n) {
        string x;
        while(n) {
            x += c;
            n--;
        }
        return x;
    };

    string s1 = f('0'+a, b);
    string s2 = f('0'+b, a);

    cout << min(s1,s2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    double den=-1.0;
    P ans;
    for(int i=0; i*a*100<=f; i++){
        for(int j=0; (i+a+j*b)*100<=f; j++){
            if(i+j){
                int water=(i*a+j*b)*100;
                int maxsugar=min(f-water,e*water/100);
                for(int k=0; k*c<=maxsugar; k++){
                    int l=(maxsugar-k*c)/d;
                    int sugar=k*c+l*d;
                    if(chmax<double>(den, 100.0*sugar/(sugar+water))){
                        ans = P(sugar+water,sugar);
                    }
                }
            }
        }
    }
    cout<<ans.F<<' '<<ans.S<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            double r = double.Parse(ss[0]);
            double x = (double)r * r * Math.PI;
            double y = (double)r * 2 * Math.PI;
            Console.WriteLine("{0:f6} {1:f6}", x, y);
        }
    }
}

Measured memory_bytes: 9152
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk){
    var s =chunk.toString().trim() *1;
    var s1 = s%60;
    var m = Math.floor(s/60)%60;
    var h = Math.floor(s/60)/60; 
    console.log(Math.floor(h) +":"+ m +":"+ s1);
});

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int a, b, k;
    cin >> a >> b >> k;
    if (k > a) {
        cout << 0 << " " << max(b - (k - a), 0ll) << endl;
    } else {
        cout << a - k << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,a,b;
    cin>>n>>a>>b;
    cout<<((a-b)%2?"Borys":"Alice");
    
   
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> v(s.size() + 1);
  for (int i = 0; i < s.size(); i++) v[i + 1] = s[i] == 'R' ? v[i] + 1 : 0;
  cout << *max_element(v.begin(), v.end()) << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;


int main() {
	int a,b,c;
  	cin >> a>> b>> c;
  	if(b-a == c-b) cout << "YES" << endl;
  	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w=mp()
s=["#"*(w+2)]
for i in range(h):
    s.append("#"+input()+"#")
s.append("#"*(w+2))
ans=[[0]*(w+2) for i in range(h+2)]

for i in range(h+2):
    ran=[]
    c=1
    for j in range(1,w+2):
        if s[i][j]==s[i][j-1]:
            c+=1
        else:
            ran.append(c)
            c=1
    ran.append(c)
    p=0
    for j in range(len(ran)):
        for k in range(ran[j]):
            if j%2==1:
                ans[i][p]+=ran[j]
            p+=1

for i in range(w+2):
    ran=[]
    c=1
    for j in range(1,h+2):
        if s[j][i]==s[j-1][i]:
            c+=1
        else:
            ran.append(c)
            c=1
    ran.append(c)
    p=0
    for j in range(len(ran)):
        for k in range(ran[j]):
            if j%2==1:
                ans[p][i]+=ran[j]
            p+=1
x=0
for i in range(h+2):
    for j in range(w+2):
        x=max(x,ans[i][j]-1)
print(x)

Measured memory_bytes: 115500
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int number[n+1][3]={0};
    for(int i=0; i<=n; i++)number[i][0]=1;
    int x,y,z,temp;
    cin >> x;
    for(int i=0; i<x; i++){
        cin >> temp;
        number[temp][0]=0;
    }cin >> y;
    for(int i=0; i<y; i++){
        cin >> temp;
        number[temp][1]=1;
    }cin >> z;
    for(int i=0; i<z; i++){
        cin >> temp;
        number[temp][2]=1;
    }
    int count=0;
    for(int i=1; i<=n; i++){
        if((number[i][0]||number[i][1])&&number[i][2])count++;
    }
    cout << count << endl;
    return 0;
}


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

Aset = set(A)
lst = {}
for i in Aset:
    lst[i] = 0
    
for i in range(N):
    lst[A[i]] += 1

c = dict(lst) # c は keyの値である場合の組み合わせの数。
              # c = dict(lst)で異なるオブジェクトとして等価なcを定義
              # c = lst だと、同一のオブジェクトとなってしまう？
c_all = 0
for j in lst:
    c_all += lst[j]*(lst[j]-1)//2

for i in lst:
    c[i] = c_all
    c[i] = c[i] - lst[i]*(lst[i]-1)//2 + (lst[i]-1)*(lst[i]-2)//2
        
for i in range(N):
    print(c[A[i]])

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

int main() {
   string N ;
  cin >> N ;
  
 char a = N[0] ;
 char b = N[1] ;
 char c = N[2] ;
 char d = N[3] ;
  
  if(a==b && b==c || b==c && c==d) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
x = int(input())
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**0.5) + 1):
        # 既にfalseになってたらスキップ
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
prime_ls = primes(10**5 + 3)

r = len(prime_ls)- 1
l = -1
while r - l > 1:
    m = (r + l) // 2
    if prime_ls[m] >= x:
        r = m
    else:
        l = m
print(prime_ls[r])

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
int v[200];
int main(void){
    IOS;
    int n, k; cin >> n >> k;
    for (int i = 1; i <= k; ++i){
        int d; cin >> d;
        for (int j = 0; j < d; ++j){
            int id; cin >> id;
            v[id]++;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        if (v[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    char a[11],b[11],c[11];
    scanf("%s%s%s",a,b,c);
    int suma=0,sumb=0;
    for(int i=0;a[i]!='\0';++i)
    ++suma;
    for(int i=0;b[i]!='\0';++i)
    ++sumb;
    if(a[suma-1]==b[0]&&b[sumb-1]==c[0])
    printf("YES");
    else
    {
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[200010];
bool ok(int mid) {
	long long ans=0;
	for(int i=0; i<n; i++)ans+=(a[i]+mid-1)/mid-1;
	return ans<=k;
}
int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	int mx=0;
	for(int i=0; i<n; i++) {
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	int l=0,r=mx;
	int mid;
	while(l+1<r) {
		mid=(l+r)/2;
		if(ok(mid))r=mid;
		else l=mid;
		//cout<<mid<<' '<<l<<' '<<r<<endl;
	}
	cout<<r<<endl;
	return 0;
}/*
*/

Measured memory_bytes: 4252
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if(M - N == K - M) {
    cout << "YES\n";
  }
  else {
    cout << "NO\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M >> K;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = []
for i in range(4):
    ans.append(0)
for n in range(N):
    S = input()
    if(S == 'AC'):
        ans[0] += 1
    elif(S == 'WA'):
        ans[1] += 1
    elif(S == 'TLE'):
        ans[2] += 1
    elif(S == 'RE'):
        ans[3] += 1

print('AC x ' + str(ans[0]))
print('WA x '+ str(ans[1]))
print('TLE x '+ str(ans[2]))
print('RE x '+ str(ans[3]))


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

using namespace std;

int main(void)
{
	string s,t;
	cin >> s >> t;
	for(int i=1;i<=s.size();i++)
	{
		cout << s[i-1];
		if(i<=t.size())cout << t[i-1];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ld long double
#define F first
#define S second
//
#define int long long
#define ll long long
#define db(x)                cerr<<#x<<": "<<x<<endl
#define db2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define db3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define db5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define db6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
//
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcount
//
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
//
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define vi vector<int>
#define vvi vector< vector<int> >
#define si set<int>
#define pb push_back
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define mk make_pair
const int N=50;
const int mod=1e9+7;
const int mod1=998244353;
const int inf=1e16+7;
using namespace std;

void solve(){
    int n;
    cin>>n;
    int n1=n/5;
    int n2=n/3;
    int n3=n/15;
    int ans=n1*(n1+1)/2*5+n2*(n2+1)/2*3-n3*(n3+1)/2*15;
    cout<<n*(n+1)/2-ans;
}


int32_t main() {
    IOS;
    int t;
//    cin>>t;
    t=1;
    for(int i=1;i<=t;i++){
        solve();
       // cout<<endl;
    }
   
}

















Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll a,b,c,d,l,x1,y1,x2,y2,x3,y3;
	cin>>a>>b>>c>>d;
	l=(c*d)/__gcd(c,d);
	x1=a/c;
	if(a%c)
	x1+=1;
	y1=b/c;
	x2=a/d;
	if(a%d)
	x2+=1;
	y2=b/d;
	x3=a/l;
	if(a%l)
	x3+=1;
	y3=b/l;
	cout<<b-a+1-(y1-x1+1)-(y2-x2+1)+(y3-x3+1)<<endl;



	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int A = int.Parse(Console.ReadLine());
        
        Console.WriteLine(N * N - A);
        
    }
}



Measured memory_bytes: 13140
#include <iostream>
using namespace std;
 
int main() {
  int n,q;
 
  cin >> n;
  int S[n+1];
  for(int k=0;k<n;k++){
    cin >> S[k];
  }
  cin >> q;
  int T[q];
  for(int l=0;l<q;l++){
    cin >> T[l];
  }
 
  int count=0;
  for(int j=0;j<q;j++){
    int i=0;
    S[n] = T[j];
    while(S[i] != T[j]){
      i++;
    }
    if(i != n) count += 1;
  }
 
  cout << count << endl;
     
  return 0;
}

Measured memory_bytes: 3116
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
	return f*x;
}
int r;
int main(){
	cin>>r;
	if(r<1200){
		printf("ABC");
		return 0;
	}
	if(r<2800){
		printf("ARC");
		return 0;
	}
	printf("AGC");
	return 0;
}

Measured memory_bytes: 256
import math


def is_integer_num(r):
    if isinstance(r, int):
        return True
    if isinstance(r, float):
        return r.is_integer()
    return False


n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for k in range(n):
        if i < k:
            dis = 0
            for j in range(d):
                dis += abs(x[i][j] - x[k][j])**2
            jud = math.sqrt(dis)
            if is_integer_num(jud):
                cnt += 1
print(cnt)

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

int main(){
  int N;
  int H[25];
  cin >> N;
  for(int i=0; i <N ;i++) cin >> H[i] ;
  
  int HMAX=0;
  int count=0;
  for(int i=0; i <N ;i++){
    if(HMAX <= H[i]){
      HMAX=H[i];
      count++;
    }
  }
    
  cout<< count<< endl;
  }
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <set>
#include <map>
#include <random>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<P> ans;
  int num = 0;
  vector<int> vec;
  if (s[N-1] == '1') {
    cout << -1 << endl;
    return 0;
  }
  if (s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N-1; i++) {
    if (s[i] != s[(N-2)-i]) {
      cout << -1 << endl;
      return 0;
    }
    if ((N/2) <= i) {
      break;
    }
    if (s[i] == '1') {
      vec.push_back(i+1);
    }
  }
  for (int i = 0; i < (int)vec.size(); i++) {
    ans.emplace_back(i+1,i+2);
  }
  num = (int)vec.size() + 2;
  for (int i = 1; i < (int)vec.size(); i++) {
    int d = vec[i] - vec[i-1];
    for (int j = 0; j < d-1; j++) {
      ans.emplace_back(i+1,num);
      num++;
    }
  }
  for (num; num <= N; num++) {
    ans.emplace_back((int)vec.size()+1,num);
  }

  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i].F << " " << ans[i].S << endl;
  }
  return 0;
}

Measured memory_bytes: 4616
import std.stdio;
import std.string;
import std.conv;

void main() {
    int n;

    while ((n = readln.chomp.to!int) != 0) {
        int count = 0;
        while ((n /= 5) != 0) {
            count += n;
        }
        writeln(count);
    }
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


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

	vector<int> ans(n);
	rep(i, n-1) {
		ans[a[i]-1]++;
	}
	rep(i, n)
		cout << ans[i] << endl;


}

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

int main() {
	int i;
	double ans;

	cin >> i;

	if (i % 2 == 0) {
		ans = 0.5;
	}
	else {
		ans = ((double)i / 2 + 0.5) / (double)i;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int H = 1, W = 1;

int main()
{
    while (H != 0 && W != 0)
    {
        scanf("%d %d", &H, &W);
        for (int i = 1; i <= H; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if ((i + j) % 2 == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
                
            }
            printf("\n");
        }
        if (H != 0 && W != 0)
        {
            printf("\n");
        }
    }
    return 0;
}




Measured memory_bytes: 2052
def func(n):
    return n//2 if n%2==0 else 3*n+1

s = int(input())

i=0
sl = [s]
while True:
    n = func(sl[-1])
    if( n  in sl):
        print(i+2)
        exit()
    sl.append(n)
    #sl = list(set(sl))
    i+=1


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
  string str1;
  getline(cin,str1);
  if(str1.compare("Rainy")==0)
    cout<<"Sunny"<<endl;
  else if(str1.compare("Sunny")==0)
    cout<<"Cloudy"<<endl;
    else
    {
            cout<<"Rainy"<<endl;
    }
    
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int head[100010],nxt[100010],mark[100010],cnt;
int dp[100010],in[100010];
int m,n,x,y,ans;
void add(int u,int v){
	nxt[++cnt]=head[u],mark[cnt]=v,head[u]=cnt;
}
int dfs(int k){
	if(dp[k])return dp[k];
	for(int i=head[k];i;i=nxt[i])dp[k]=max(dp[k],dfs(mark[i])+1);
	return dp[k];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&x,&y),add(x,y),in[y]++;
	for(int i=1;i<=n;i++)if(in[i]==0)ans=max(ans,dfs(i));
	printf("%d",ans);
}

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

int main()
{
    int a[] = {64,32,16,8,4,2,1};
    int n;
    cin >> n;

    for(int i=0; i<7; i++)
    {
        if(a[i] <= n)
        {
            cout << a[i];
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second




int main() {
	int n;
	cin >> n;
	map<ll, ll> c;

	c[0] = 1;

	ll s = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		s += a;
		++c[s];
	}
	ll ret = 0;
	for (auto&p : c) {
		ret += p.sc * (p.sc - 1) / 2;
	}
	cout << ret << endl;



	
}

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

const int MAX_N=51;

int n,l,r,ans,ok;
vector<int> A(MAX_N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> l >> r,n){
        for (int i=0;i<n;++i) cin >> A[i];
        ans=0;
        for (int x=l;x<=r;++x){
            ok=-1;
            for (int i=0;i<n;++i){
                if (x%A[i]==0){ok=i+1; break;}
            }
            if (ok<0&&!(n&1)) ++ans;
            if (ok>=0&&(ok&1)) ++ans;
        }
        cout << ans << '\n';
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

//Write From this Line

const ll mod = 1e9+7;
ll dp[100010][13];
int main()
{
	string s;
	cin >> s;
	REV(s);

	ll ten = 1;
	dp[0][0] = 1;
	rep(i,s.size()){
		if (s[i] == '?') {
			rep(k,10){
				ll tmp = (ten * k) % 13;
				rep(j,13){
					ll next = (j + tmp) % 13;
					dp[i+1][next] += dp[i][j];
					dp[i+1][next] %= mod;
				}
			}
		}	else {
			int num = s[i] - '0';
			ll tmp = (ten * num) % 13;
			rep(j,13){
				ll next = (j + tmp) % 13;
				dp[i+1][next] += dp[i][j];
				dp[i+1][next] %= mod;
			}
		}
		ten *= 10; ten %= 13;
	}
	ll sum = 0;
	rep(i,13){
		sum += dp[s.size()][i];
	}
	cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 13868
# Problem D - Double Dots

from collections import deque

# input
N, M = map(int, input().split())

# initialization
nodes = [0] * N
visit = [0] * N
edges_dic = {}
for i in range(M):
    A, B = map(int, input().split())
    if A in edges_dic:
        edges_dic[A].append(B)
    else:
        edges_dic[A] = [B]

    if B in edges_dic:
        edges_dic[B].append(A)
    else:
        edges_dic[B] = [A]
queue = deque([1])

# search
while len(queue)>=1:
    q = queue.popleft()
    visit[q-1] = 1
    next_n = edges_dic[q]
    for n in next_n:
        if visit[n-1]==0:
            nodes[n-1] = q
            visit[n-1] = 1
            queue.append(n)

# output
print("Yes")
for i in range(1, N):
    print(nodes[i])


Measured memory_bytes: 40716
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
  string s;
  cin >> s;
  int size=s.size();
  int l=0;int r=size-1;
  int cnt=0;
  if(size==1){
    cout<<"0"<<endl;
    return 0;
  }
  while(l<=r){
    if(s[l]==s[r]){
      l++;r--;
      continue;
    }else if(s[l]=='x'){
      cnt++;
      l++;
    }else if(s[r]=='x'){
      cnt++;
      r--;
    }else{
      cout<<"-1"<<endl;
      return 0;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 512
import sys


def main():
  input = sys.stdin.readline
  S = str(input().strip())
  K = int(input())
  max = min(5, len(S))
  sub = []
  for i in range(len(S)):
    for j in range(1, max+1):
      if i+j > len(S):
        continue
      sub.append(S[i:i+j])
  sub = sorted(list(set(sub)))
  print(sub[K-1])


if __name__ == '__main__':
  main()

Measured memory_bytes: 5068
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main(void) {
    while(1) {
        int n;
        char s[70][70]={};
        string code[70];
        scanf("%d",&n);
        if(!n) break;
        for(int i=0; i<n; i++)
            scanf("%s",s[i]);
        for(int i=0; i<n; i++) {
            code[i] = s[i][0];
            for(int j=0; j<strlen(s[i])-1; j++) {
                switch(s[i][j]) {
                    case 'a': case 'i': case 'u': case 'e': case 'o':
                        code[i] += s[i][j+1];
                        break;
                }
            }
        }
        sort(code, code+n);
        for(int k=1; k<53; k++) {
            for(int i=0; i<n-1; i++)
                if(!strncmp(code[i].c_str(), code[i+1].c_str(), k)) goto next;
            printf("%d\n",k);
            goto end;
next:
            ;
        }
        printf("-1\n");
end:
        ;
    }
    return 0;
}

Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114C
{
    class Program
    {
        static long n = -1;
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            int length = N.Length;
            n = int.Parse(N);

            for(int i = length; i >= 3; i--)
            {
                Ans(i, new List<int>(), 0);
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static long ans = 0;
        static void Ans(int repeat, List<int> now, long nowNumber)
        {
            if (repeat == 0)
            {
                if (nowNumber <= n && now.Distinct().ToArray().Length == 3) ans++;
                return;
            }
            for (int i = 0; i < 3; i++)
            {
                List<int> next = new List<int>(now);
                if (i == 0) next.Add(3);
                else if (i == 1) next.Add(5);
                else if (i == 2) next.Add(7);
                
                long nextNumber = 0;
                if (i == 0) nextNumber = nowNumber + 3 * (int)Math.Pow(10, repeat-1);
                else if (i == 1) nextNumber = nowNumber + 5 * (int)Math.Pow(10, repeat-1);
                else if (i == 2) nextNumber = nowNumber + 7 * (int)Math.Pow(10, repeat-1);
                Ans(repeat - 1, next, nextNumber);
            }
        }
    }
}


Measured memory_bytes: 17480
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int X[7],Y[7];
ll f[2000005],inv[2000005],ans;
ll C(int n,int m){
	return f[n+m]*inv[n]%mod*inv[m]%mod;
}
ll calc0(int x,int y){
	ll ans=0;
	ans+=C(x-X[2],y-Y[2]);
	ans+=C(x-X[1]+1,y-Y[1]+1);
	ans-=C(x-X[1]+1,y-Y[2]);
	ans-=C(x-X[2],y-Y[1]+1);
	return (ans%mod+mod)%mod;
}
ll calc1(int x,int y){
	ll ans=0;
	ans+=C(X[5]-x,Y[5]-y);
	ans+=C(X[6]-x+1,Y[6]-y+1);
	ans-=C(X[5]-x,Y[6]-y+1);
	ans-=C(X[6]-x+1,Y[5]-y);
	return (ans%mod+mod)%mod;
}
int main(){
	f[0]=f[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=2000002;i++) f[i]=f[i-1]*i%mod,inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	for(int i=2;i<=2000002;i++) inv[i]=inv[i]*inv[i-1]%mod;
	for(int i=1;i<=6;i++) scanf("%d",&X[i]);
	for(int i=1;i<=6;i++) scanf("%d",&Y[i]);
	for(int i=X[3];i<=X[4];i++){
		ans=(ans+1LL*(mod-(i+Y[3])+1)*calc0(i,Y[3]-1)%mod*calc1(i,Y[3]))%mod;
		ans=(ans+1LL*(i+Y[4])*calc0(i,Y[4])%mod*calc1(i,Y[4]+1));
	}
	for(int i=Y[3];i<=Y[4];i++){
		ans=(ans+1LL*(mod-(i+X[3])+1)*calc0(X[3]-1,i)%mod*calc1(X[3],i))%mod;
		ans=(ans+1LL*(X[4]+i)*calc0(X[4],i)%mod*calc1(X[4]+1,i))%mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n; int k;
  cin >> n >> k;
  int ans = 0;
  while(n) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	vector<tuple<string, int, int>> vc;
	
	rep(i,N){
		string S;
		int P;
		cin>>S>>P;
		vc.emplace_back( S, -P, i );
	}
	sort( begin( vc ), end( vc ) );
	
	rep(i,N){
    //位置を指定する場合(I番目の引数)
    int k=get<2>( vc[i] );
    cout<<k+1<<endl;
	}
}

Measured memory_bytes: 256
program thumbnail
  implicit none
  integer              :: n, i, idx
  integer, allocatable :: a(:)
  real(8)              :: ave, rsd
  read(*,*) n
  allocate(a(n))
  read(*,*) a(:)
  if (n .eq. 1) then
     write(*,'(i0)') 0
     stop
  end if
  
  ave = sum(a)/real(n,8)
  rsd = abs(a(1)-ave)
  idx = 1
  
  do i = 2, n
     if (abs(a(i)-ave) .lt. rsd) then
        rsd = abs(a(i)-ave)
        idx = i
     end if
  end do
  deallocate(a)
  write(*,'(i0)') idx-1
  stop
end program thumbnail

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

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

	vector<vector<bool>>did(h, vector<bool>(w));
	queue<vector<int>>next;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (ban[i][j] == '#') {
				did[i][j] = true;
				next.push({ i,j });
			}
		}
	}

	int depth = 0;
	next.push({ -1,-1 });
	vector<int>movex{ 1,-1,0,0 };
	vector<int>movey{ 0,0,1,-1 };
	while (true) {
		vector<int>now = next.front();
		next.pop();
		if (now[0] == -1) {
			if (next.empty())break;
			depth++;
			next.push({ -1,-1 });
		}
		else {
			for (int i = 0; i < 4; i++) {
				int ax = now[0] + movex[i];
				int ay = now[1] + movey[i];
				if (0 <= ax && ax < h && 0 <= ay && ay < w && !did[ax][ay]) {
					did[ax][ay] = true;
					next.push({ ax,ay });
				}
			}
		}
	}

	cout << depth << endl;
	return 0;
}

Measured memory_bytes: 56884
str = input().split()
A = int(str[0])
B = int(str[1])
ans = 0
 
if A> B:
  ans = ans + A
  A = A-1
else :
  ans = ans + B
  B = B-1
if A> B:
  ans = ans + A
else :
  ans = ans + B
  
print(ans)

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

using  namespace std;

int main()
{
    int N;
    cin >> N;
    vector<pair<long double,long double>>v;
    v.resize(N);
    for(int i = 0; i < N; i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());
    long double sum = 0;
    do 
    {
        for(int i = 0; i < N - 1; i++)
        {
            sum += sqrt(pow((v[i+1].first - v[i].first),2.0) + pow((v[i+1].second - v[i].second),2.0));
        }
    }while(next_permutation(v.begin(),v.end()));
    long double ans = sum;
    for(int i = 1; i <= N; i++)
    {
        ans = ans / i;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
N = input()
N = int(N)
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

sortedarray = sorted(array)

be = sortedarray[(N//2-1)]
af = sortedarray[N//2]
for flag in array:
    if flag <= be:
        print(af)
    else: print(be)

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s;
  cin >> s;
  vector<ll> mod(2019, 0);

  ll pow10 = 1;
  ll v = 0;

  reverse(ALL(s));

  for (char i : s) {
    ll n = i - '0';
    v = (v + (n * pow10) % 2019) % 2019;
    mod[v]++;
    pow10 = (pow10 * 10) % 2019;
  }

  ll res = mod[0];
  repz(i, 0, 2019) { res += mod[i] * (mod[i] - 1) / 2; }
  cout << res << endl;
  ret;
}


Measured memory_bytes: 3776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAttackSurvival solver = new CAttackSurvival();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAttackSurvival {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int q = in.nextInt();
            int a = k - q;
            int[] arr = new int[n];
            Arrays.fill(arr, a);
            for (int i = 0; i < q; i++) {
                int b = in.nextInt() - 1;
                arr[b]++;
            }
            for (int i = 0; i < n; i++) {
                if (arr[i] > 0)
                    out.println("Yes");
                else
                    out.println("No");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 36520
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
t, a = rm()
ansv = inf
ansi = 0
for i, v in enumerate(rl()):
  if abs(a-t+v*0.006) < ansv:
    ansv = abs(a-t+v*0.006)
    ansi = i+1
print(ansi)
  
    










Measured memory_bytes: 27092
#include<iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N, K;
    cin >> N >> K;
    if(K != 1){
        cout << (N - (K - 1))-1 << endl;
    }else{
        cout << 0 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def main():
    n,m,q=map(int,input().split())
    # print(n,m,q)
    a = [ [int(x) for x in input().split()] for _ in range(q) ]
    # print(a)
    ans=0

    import itertools
    for b in itertools.combinations_with_replacement([i for i in range(1,m+1)],n):
        cnt=0
        for v in a:
            if b[v[1]-1]-b[v[0]-1]==v[2]:
                cnt+=v[3]
        ans=max(ans,cnt)

    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 67668
#include <iostream>
#include <algorithm>
#include <ostream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cmath>
#include <cstring>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using ll = long long;

template <typename T, typename U>
std::ostream &operator<<(std::ostream &out, std::pair<T, U> p)
{
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T>
std::ostream &operator<<(std::ostream &out, std::vector<T> v)
{
  out << "[";
  for (int i = 0; i < v.size(); ++i)
  {
    out << v[i] << (i == (v.size() - 1) ? "" : ", ");
  }
  out << "]";
  return out;
}

int n;
std::vector<int> a;

int main()
{
  cin >> n;
  a.resize(n);

  int n_minus = 0, a_min = int(1e9) + 1;
  ll sum = 0LL;

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

    sum += abs(a[i]);
    a_min = std::min(a_min, abs(a[i]));

    if (a[i] < 0)
    {
      n_minus++;
    }
  }

  if (n_minus % 2 == 0)
  {
    cout << sum << endl;
  }
  else
  {
    cout << sum - 2 * a_min << endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
    int n; std::cin >> n;
    int x[100100];
    for (int i = 0; i < n; i++) std::cin >> x[i];
    long long ans = 1;
    int prev = 1, j = 1;
    const int M = 1000000007;
    for (int i = 1; i < n; i++) {
        j++;
        if (prev + 1 == x[i]) { ans = ans * j % M; j--; }
        else {
            prev += 2;
        }
    }
    while (j > 0) ans = ans * j % M, j--;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string ab = Console.ReadLine();

            int takahashiMonsHP = int.Parse(ab.Split(' ')[0]);
            int takahashiMonsATK = int.Parse(ab.Split(' ')[1]);
            int aokiMonsHP = int.Parse(ab.Split(' ')[2]);
            int aokiMonsATK = int.Parse(ab.Split(' ')[3]);

            bool takahashiWin = false;

            do
            {
                aokiMonsHP = aokiMonsHP - takahashiMonsATK;
                if (aokiMonsHP <= 0)
                {
                    takahashiWin = true;
                    break;
                }

                takahashiMonsHP = takahashiMonsHP - aokiMonsATK;
                if (takahashiMonsHP <= 0)
                {
                    takahashiWin = false;
                    break;
                }


            } while (true);

            if (takahashiWin)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}


Measured memory_bytes: 27380