akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
  // ビンゴカードをロード
  int a0, a1, a2;
  vector<vector<int>> card(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    cin >> a0 >> a1 >> a2;
    card.at(i).at(0) = a0;
    card.at(i).at(1) = a1;
    card.at(i).at(2) = a2;
  }
  
  int N;
  cin >> N;
  
  // 判定用の配列
  vector<vector<bool>> judge(3, vector<bool>(3, false));
  
  // 穴あけ
  int b;
  for (int i = 0; i < N; i++) {
    cin >> b;
    for (int m = 0; m < 3; m++) {
      for (int n = 0; n < 3; n++) {
        if (card.at(m).at(n) == b) {
          judge.at(m).at(n) = true;
        }
      }
    }
  }
  
  // ビンゴ判定
  bool result = false;
  if (
    (judge.at(0).at(0) && judge.at(0).at(1) && judge.at(0).at(2))
    || (judge.at(1).at(0) && judge.at(1).at(1) && judge.at(1).at(2))
    || (judge.at(2).at(0) && judge.at(2).at(1) && judge.at(2).at(2))
    || (judge.at(0).at(0) && judge.at(1).at(0) && judge.at(2).at(0))
    || (judge.at(0).at(1) && judge.at(1).at(1) && judge.at(2).at(1))
    || (judge.at(0).at(2) && judge.at(1).at(2) && judge.at(2).at(2))
    || (judge.at(0).at(0) && judge.at(1).at(1) && judge.at(2).at(2))
    || (judge.at(0).at(2) && judge.at(1).at(1) && judge.at(2).at(0)) ) {
    result = true;
  }
  
  cout << (result ? "Yes" : "No");
   
  return 0;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int a,b,c;
LL k;
int main()
{
	cin>>a>>b>>c>>k;
	if(k%2==0)cout<<a-b;
	else cout<<b-a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  for(int i=0;i<H;i++){
    cin>>S[i];
  }
  
  vector<int>dx={0,0,1,-1};
  vector<int>dy={1,-1,0,0};
  queue<pair<int,int>>q;
  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#'){continue;}
      vector<vector<int>>cost(H,vector<int>(W,-1));
      cost[i][j]=0;
      q.push(make_pair(i,j)); 
      while(!q.empty()){
        auto p=q.front();q.pop();
        int y=p.first,x=p.second;
        
        for(int d=0;d<4;d++){
          if(y+dy[d]>=H||x+dx[d]>=W||y+dy[d]<0||x+dx[d]<0){continue;}
          if(cost[y+dy[d]][x+dx[d]]!=-1){continue;}
          if(S[y+dy[d]][x+dx[d]]=='#'){continue;}
          cost[y+dy[d]][x+dx[d]]=cost[y][x]+1;
          q.push(make_pair(y+dy[d],x+dx[d]));  
        }
        ans=max(ans,cost[y][x]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
def resolve():
    S = input()
    comp = "".join([ str(i % 2) for i in range(len(S))])
    cnt = 0
    for i in range(len(S)):
        if S[i] == comp[i]:
            cnt = cnt + 1
    return min(cnt, len(S)-cnt)

if '__main__' == __name__:
    print(resolve())

Measured memory_bytes: 9460
k = int(input())
if k < 11:
    print(k)
else:
    s = [None] * 20
    target = k
    target -= 10
    s[1] = 1
    for i in range(target):
        # print(s[::-1])
        for j in range(20):
            if s[j] is None:
                s[j] = 0
            # print("add try j=",j, "s[j]",s[j], "->", s[j] + 1)
            s[j] += 1  # その桁を足す

            if s[j] > 9:  # もし10になったら
                # print("reach 10")
                s[j] = 0
                continue  # 続ける

            if j != 0:
                # print(" j!=1")
                for k in range(j, -1, -1):
                    if s[k] == 0:
                        s[k - 1] = 0
                    else:
                        s[k - 1] = s[k] - 1

            if s[j + 1] != None and abs(s[j] - s[j + 1]) > 1:
                # print(" over")
                continue
            # print(" pass")
            break
    #print(s)
    res = ""
    for i in range(20):
        if s[i] != None:
            res = str(s[i]) + res
        else:
            break
    print(int(res))

Measured memory_bytes: 42352
# ABC052 B - Increment Decrement
N = int(input())
S = input()
L = []

t = 0
ans = 0

for s in S:
    if s == 'I':
        t += 1
        ans = max(ans,t)
        L.append(ans)
        continue

    if s == 'D':
        t -= 1
        ans = max(ans,t)
        L.append(ans)
        continue

print(max(L))


Measured memory_bytes: 3060
n = int(input())
n_s = []
for c in str(n):
    n_s.append(c)
n_l = [int(s) for s in n_s]
c = 0
for i in n_l:
    c = i + c

if n % c == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
let () =
  let a = Scanf.scanf "%d " (fun a -> a) in
  let b = Scanf.scanf "%d " (fun a -> a) in
  let c = Scanf.scanf "%d " (fun a -> a) in
  let x = Scanf.scanf "%d " (fun a -> a) in

  let res = ref 0 in

  for i = 0 to a do
    for j = 0 to b do
      for k = 0 to c do
        if 500*i + 100*j + 50*k = x then res := !res + 1 else ()
      done;
    done;
  done;

  Printf.printf "%d\n" !res


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll mod = 1000000007;

ll modpow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ans += modpow(10, n, mod);
    ans %= mod;
    ans -= 2 * modpow(9, n, mod);
    ans %= mod;
    ans += modpow(8, n, mod);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
n=int(input())
a,b,c=list(map(int,input().split())),0,[]
for i in range(n):
    if i!=n-1:
        if a[i]==a[i+1]:
            b+=1
        else:
            c.append(b+1)
            b=0
    else:
        c.append(b+1)
        b=0
for i in range(len(c)):
    b+=c[i]//2
print(b)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
using namespace std;

int arr[123456*2];

bool sosu(int n){
    bool s = 1;
    for(int i=2;i<n;i++){
        if((n%i)==0) s = 0;
    }
    return s;
}

void Eratosthenes(){
	for(int i = 0; i < 123456*2; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(123456*2); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < 123456*2; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	// for(int i = 2; i < N; i++){
	// 	if(arr[i]){
	// 		//cout << i << endl;
	// 	}
	// }
}

int main(){
    int n;
    int i,j,k,l;
    int cnt;
    bool table[123456*2];
    // for(i=0;i<123456*2;i++){
    //     table[i] = sosu(i);
    // }
	for(i = 0; i < 123456*2; i++){
		arr[i] = 1;
	}
	for(i = 2; i < sqrt(123456*2); i++){
		if(arr[i]){
			for(j = 0; i * (j + 2) < 123456*2; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}    
    while(1){
        cin >> n;
        if(n==0) break;
        cnt = 0;
        
        for(i=n+1;i<=2*n;i++){
            //iが素数か
            if(arr[i]) cnt++;
        }
        cout << cnt << endl;
    }
    // cout << endl;
}
/*
1
10
13
100
1000
10000
100000
0
 */





Measured memory_bytes: 4052
#include<cstdio>
#include<algorithm>
using namespace std;

int a[100009],b[100009],c[100009],fa[100009],va[100009]={0},cva[100009]={0},cvb[100009]={0},xore=0;
bool is[100009]={0},vis=0;

int gf(int u){
	if(fa[u]==u){return u;}
	va[fa[u]]+=va[u];va[u]=0;
	return fa[u]=gf(fa[u]);
}

int main(){
	int n,res=0,tot,apos,bpos;
	scanf("%d",&n);
	for(int i=1;i<=n;i=-(~i)){scanf("%d",&a[i]);c[i]=a[i];xore^=a[i];}	
	sort(c+1,c+1+n);tot=unique(c+1,c+1+n)-c-1;
	for(int i=1;i<=tot;i=-(~i)){fa[i]=i;}fa[tot+1]=tot+1;
	for(int i=1;i<=n;i=-(~i)){
		scanf("%d",&b[i]);
		if(a[i]==b[i]){continue;}
		apos=lower_bound(c+1,c+1+tot,a[i])-c;
		bpos=lower_bound(c+1,c+1+tot,b[i])-c;
		if(c[bpos]!=b[i]){
			if(vis||b[i]!=xore){printf("-1\n");return 0;}
			else{vis=true;res--;bpos=tot+1;}//本质 xore 不参与离散化，也不参与并查集统计
		}
		cva[apos]++;cvb[bpos]++;
//		fprintf(stdout,"%d[%d:%d %d[%d:%d %d %d\n",a[i],c[apos],apos,b[i],c[bpos],bpos,tot,xore);
		if(gf(apos)!=gf(bpos)){va[fa[apos]]+=va[fa[bpos]];va[fa[bpos]]=0;fa[fa[bpos]]=fa[apos];}//注意顺序
		va[fa[bpos]]++;
	}
	for(int i=1;i<=tot;i=-(~i)){
		gf(i);
		if(c[i]==xore&&cvb[i]){vis=true;res--;cvb[i]--;}
		//不能直接用vis判断
		if(cva[i]<cvb[i]){printf("-1\n");return 0;}
	}
	for(int i=1;i<=tot;i=-(~i)){
		if(va[i]){res+=va[i]+1;}//fprintf(stdout,"%d:%d\n",c[i],va[i]+1);}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n, m;   cin >> n >> m;
    vector<int>dic(n+2);
    rep(i, m){
        int l,r;    cin >> l >> r;
        dic[l]++;
        dic[r+1]--;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        dic[i] += dic[i-1];
        if(dic[i] == m) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<map>

using namespace std;

main(){

  map<char, string> e;
  
  e['A'] = "00000"; 
  e['B'] = "00001";
  e['C'] = "00010";
  e['D'] = "00011";
  e['E'] = "00100";
  e['F'] = "00101";
  e['G'] = "00110"; 
  e['H'] = "00111"; 
  e['I'] = "01000";
  e['J'] = "01001";
  e['K'] = "01010";
  e['L'] = "01011";
  e['M'] = "01100";
  e['N'] = "01101";
  e['O'] = "01110"; 
  e['P'] = "01111";
  e['Q'] = "10000";
  e['R'] = "10001";
  e['S'] = "10010";
  e['T'] = "10011";
  e['U'] = "10100"; 
  e['V'] = "10101";
  e['W'] = "10110";
  e['X'] = "10111";
  e['Y'] = "11000";
  e['Z'] = "11001";
  e[' '] = "11010"; 
  e['.'] = "11011";
  e[','] = "11100";
  e['-'] = "11101";
  e['\'']= "11110";
  e['?'] = "11111";

  map<string, char> d;
  d["101"] = ' ';
  d["000000"] = '\'';
  d["000011"] = ','; 
  d["10010001"] = '-'; 
  d["010001"] = '.';
  d["000001"] = '?'; 
  d["100101"] = 'A'; 
  d["10011010"] = 'B'; 
  d["0101"] = 'C';
  d["0001"] = 'D'; 
  d["110"] = 'E'; 
  d["01001"] = 'F'; 
  d["10011011"] = 'G';
  d["010000"] = 'H'; 
  d["0111"] = 'I'; 
  d["10011000"] = 'J'; 
  d["0110"] = 'K';
  d["00100"] = 'L'; 
  d["10011001"] = 'M'; 
  d["10011110"] = 'N';
  d["00101"] = 'O';
  d["111"] = 'P'; 
  d["10011111"] = 'Q'; 
  d["1000"] = 'R'; 
  d["00110"] = 'S'; 
  d["00111"] = 'T'; 
  d["10011100"] = 'U';  
  d["10011101"] = 'V'; 
  d["000010"] = 'W'; 
  d["10010010"] = 'X'; 
  d["10010011"] = 'Y'; 
  d["10010000"] = 'Z'; 

  string s;
  while(getline(cin, s)){
    string t = "";
    for(int i=0; i<s.length(); i++){
      t += e[s[i]];
    }
    
    string ans = "";
    
    for(int i=0; i<t.length(); i++){
      string tmp = "";
      for(int j=i; j<t.length(); j++){
	tmp += t[j];	  
	i = j;
	if(d[tmp] != 0){
	  ans += d[tmp];
	  break;
	}
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
	int a,b,x;
	cin >> a >> b >> x;
if((x >= a)&&(a+b >= x))cout <<"YES";
else cout<<"NO";

	return		(0);
}


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int m, k;
    cin >> m >> k;
    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << "-1" << endl;
        }
        return 0;
    }
    
    int mx = (1 << m) - 1;
    if (k > mx) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i <= mx; i++) {
        if (i == k)continue;
        cout << i << " ";
    }

    cout << k << " ";
    for (int i = mx; i >= 0; i--) {
        if (i == k)continue;
        cout << i << " ";
    }

    cout << k << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
    int n;
    int a[10];

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

    int ex = 1, ans = 1;

    for (int i = 0; i < n; i++){
        if (a[i] % 2 == 0){
            ex *= 2;
        }
        ans *= 3;
    }

    cout << ans - ex << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) { cout << 'x';}
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int n,k,d[10];
  cin >> n >> k;
  REP(i,k){
    cin >> d[i];
  }
  FOR(i,n,100000){
    REP(j,k){
      REP(l,5){
        if (dig(i,l)==d[j]&&l<dignum(i)) {
          j=k;
          l=5;
          break;
        }
        if (j==k-1&&l==4) {
          cout << i;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	scanf("%d %d %d",&a,&b,&c);
	if(20>=a && a>=b && b >=0 && 20 >= c &&c >= 0)
	{
		d = a - b;
		if(d >= c)
		{
			printf("0\n");
		}
		else
		{
			printf("%d\n",c - d);
		}
	}
	else
	{
		printf("エラー\n");
	}
return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  ll ans = 0;
  cin >> n ;
  vector<int> v(n);
  rep(i,n){
    cin >> v[i];
  }
  sort(all(v));
  rep(i,n-1){
    ans += v[i+1] - v[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < (n); i++)

int main(void) 
{
    int h, w;
    while(1) {
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        REP(i, h) {
            REP(j, w) {
	      if((i + j)%2 == 0 ) {
                    cout << "#" ;
                } else {
                    cout << "." ;
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main(){
    int S,h,m,s;
    cin >> S;
    s = S%60;
    m = ((S-s)/60)%60;
    h = (((S-s-(m*60))/60)/60)%24;
    cout << h << ":" << m << ":" << s << "\n";
    return  0;
}


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

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int oo = 0x3f3f3f3f;
const double pi = acos(-1);
const double eps = 1e-9;

#define endl '\n'

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

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

	int ans = 0;

	vi V(n);
	for (int i = 0; i < n; ++i){
		cin >> V[i];
		if (V[i] >= k)
			ans++;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int Q;
	cin>>Q;
	
	for(int i=0;i<Q;i++){
		long long A,B;
		cin>>A>>B;
		
		long long C = A*B;
		long long D = sqrt(C);
		
		while(D*D>=C)D--;
		
		while((D+1)*(D+1)<C)D++;
		
		long long ans = 2*D;
		
		if(D*(D+1)>=C)ans--;
		
		set<long long> S;
		S.insert(A);S.insert(B);
		S.insert(C/A);S.insert(C/B);
		

		
		if(A<=D)ans--;
		if(B<=D)ans--;
		
		/*
		for(auto a:S){
			if(a<=D)ans--;
		}
		*/
		
		
		
		
		cout<<ans<<endl;
	}
		
	
	return 0;
}


Measured memory_bytes: 256
s=gets.chomp
a=s[0..s.length/2-1]
b=s[s.length/2..-1].reverse
c=[?b,?d,?p,?q]
b.length.times do |i|
  g=c.index(b[i])
  b[i]=c[g/2*2+g%2^1]
end
puts a==b ? :Yes : :No

Measured memory_bytes: 2044
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            int cnt = 0;

            while (true)
            {
                string t = Console.ReadLine();
                if (t == "END_OF_TEXT")
                    break;
                t = t.ToLower();
                string[] word = t.Split(' ');

                for (int i = 0; i < word.Length; i++)
                {
                    if (word[i] == w)
                    {
                        cnt++;
                    }
                }
            }

            Console.WriteLine(cnt);
            
        }
    }
}

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
		ll n;
		cin>>n;
		ll sum=0;
		for(int i=1;i<=n;i++)
		{
			if(i%15==0)continue;
			else if(i%3==0)continue;
			else if(i%5==0)continue;
			else sum+=i;

		}
			cout<<sum<<endl;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 1000000000
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

int main(void){
	ll n, k, s; cin >> n >> k >> s;
	vint ans(n);
	if(s == SIZE) fill(all(ans), 1);
	else fill(all(ans), SIZE);
	rep(i, k){
		ans[i] = s;
	}

	voutput(ans);
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;

  char next_top;
  set<string> pool;
  string w;

  cin >> w;
  next_top = w.back();
  pool.insert(w);

  for(int i  = 1; i < n; ++i)
  {
    cin >> w;
    if(w[0] != next_top || pool.find(w) != pool.end())
    {
      cout << "No";
      return;
    }
    next_top = w.back();
    pool.insert(w);
  }
  cout << "Yes";
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	A := sc.nextInt()
	B := sc.nextInt()
	C := sc.nextInt()
	D := sc.nextInt()

	if A*B >= C*D {
		fmt.Println(A * B)
	} else {
		fmt.Println(C * D)
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

bool prime (int N){
    if(N==1){
        return false;
    }
    for(int i=2;i<1+N/2;i++){
        if(N%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    int x;
    cin>>x;
    while(!prime(x)){
        x++;
    }
    cout<<x;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int s = scan.nextInt();
		int h = s / (60*60);
		s = s % (60*60);
		int m = s / 60;
		s = s % 60;
		System.out.printf("%d:%d:%d\n", h, m, s);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26368
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,  = get_nums_l()
abc = list(map(lambda s: list(map(int, s.split())), sys.stdin.readlines()))

dp_a = [0] * (n)
dp_b = [0] * (n)
dp_c = [0] * (n)

dp_a[0] = abc[0][0]
dp_b[0] = abc[0][1]
dp_c[0] = abc[0][2]

for i in range(1,n):
    dp_a[i] = max(dp_b[i-1], dp_c[i-1]) + abc[i][0]
    dp_b[i] = max(dp_a[i-1], dp_c[i-1]) + abc[i][1]
    dp_c[i] = max(dp_a[i-1], dp_b[i-1]) + abc[i][2]

print(max(dp_a[n-1], dp_b[n-1], dp_c[n-1]))

Measured memory_bytes: 75356
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		long long ans=1;
		for(int i=1;i<=n;i++)
		{
			ans=(ans*i)%1000000007;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define F first
#define S second
using namespace std;
typedef pair<int,int> Po; //Po(tID,pID)
typedef pair<Po,int> PP; //PP(Po(ID,solved),time)

bool cmp(const PP &p,const PP &q){
  if(p.F.S != q.F.S)return p.F.S > q.F.S;
  if(p.S != q.S)return p.S < q.S;
  return p.F.F < q.F.F;
}


int main(){
  int T,P,R,tID,pID,time;
  string message;

  while(true){
    scanf("%d%d%d",&T,&P,&R);
    if(T+P+R == 0)break;
    vector<PP> total;
    for(int i=0;i<T;i++)total.push_back(PP(Po(i+1,0),0));
    map<Po,int> info;
    for(int i=0;i<R;i++){
      scanf("%d %d %d",&tID,&pID,&time);
      tID--;
      cin >> message;
      if(message[0] == 'W'){
	info[Po(tID,pID)]++;
      }
      else {
	total[tID].S+=+info[Po(tID,pID)]*1200+time;
	total[tID].F.S+=1;
      }
    }

    sort(total.begin(),total.end(),cmp);
  
    for(int i=0;i<total.size();i++){
      printf("%d %d %d\n",total[i].F.F,total[i].F.S,total[i].S);
    }  

  
  }
  return 0;
}

Measured memory_bytes: 1268
import java.util.Scanner;
 
class Main {
 
    public static void main(String args[]){ 
        Scanner scan = new Scanner(System.in);
 
        int m, n;
         
        n = scan.nextInt();
        String[] c ={"S", "H", "C", "D"}; 
         
        int a[][];
        a = new int[4][13];
         
        for(int i = 0;i < n;i++){
            String s = scan.next();
            m = scan.nextInt();
             
            for(int j = 0; j < 4; j++) {
                if(c[j].equals(s)) a[j][m - 1] = 1;
            }
        }
             
        for(int i = 0;i < 4;i++){
            for(int j = 0; j < 13;j++){
                if(a[i][j] == 0){
                    System.out.println(c[i] + " " + (j + 1));
                }
            }
        }
    }   
}




Measured memory_bytes: 26332
#include<cstdio>
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a>b||(n==1&&a!=b))printf("0\n");
	else if(a==b)printf("1\n");
	else printf("%lld\n",(1ll*b*(n-1)+a)-(1ll*a*(n-1)+b)+1);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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;}
 
const ll INF=1e9+7;

int main(){
    vector<ll> a(4);
    rep(i,4){
        char u;
        cin >> u;
        ll v=(ll)(u-'0');
        a[i]=v;
    }
    
    char s[2]={'+','-'};
    rep(i,2){
        vector<char> p(3);
        p[0]=s[i];
        rep(j,2){
            p[1]=s[j];
            rep(k,2){
                p[2]=s[k];
                ll sum=a[0];
                rep(t,3){
                    if(p[t]=='+'){
                        sum+=a[t+1];
                    }
                    else{
                        sum-=a[t+1];
                    }
                }
                if(sum==7){
                    cout << a[0];
                    rep(t,3){
                        cout << p[t];
                        cout << a[t+1];
                    }
                    cout << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
} 

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

#define fi first
#define se second

const int N = 550;
const int mod = 1e9 + 7;

using namespace std;

int n;
int res[N * N];

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        vector < pair < int, int > > v;
        for(int i = 1; i <= n; i++){
                int x;
                cin >> x;
                res[x] = i;
                for(int j = 1; j < i; j++){
                        v.push_back({x, i});
                }
        }
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        vector < int > A;
        for(int i = 1; i <= n * n; i++){
                if(res[i]){
                        for(int j = 1; j <= n - res[i]; j++){
                                A.push_back(res[i]);
                        }
                        continue;
                }
                if(!v.empty()){
                        if(v.back().fi < i){
                                cout << "No" << "\n";
                                return 0;
                        }
                        res[i] = v.back().se;
                        v.pop_back();
                } else{
                        if(A.empty()){
                                cout << "No" << "\n";
                                return 0;
                        }
                        res[i] = A.back();
                        A.pop_back();
                }
        }
        cout << "Yes" << "\n";
        for(int i = 1; i <= n * n; i++){
                cout << res[i] << ' ';
        }
}


Measured memory_bytes: 4084
#include <stdio.h>

int main(void){
	char string[1201];
	int i, count[26];
	for (i = 0; i < 26; i++) count[i] = 0;
	while(1){
		if (scanf("%s", string) == EOF) break;
		for (i = 0; i < 1201; i++){
			if (string[i] == '\0') break;
			if ('A' <= string[i] && string[i] <= 'Z') string[i] += 'a' - 'A';
			if ('a' <= string[i] && string[i] <= 'z') count[string[i] - 'a']++;
		}
	}
	for (i = 0; i < 26; i++){
		printf("%c : %d\n", 'a' + i, count[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[300],b[300],c[300];
bool vis[300];

signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<n;i++) cin>>c[i];
	int sum=0;
	sum+=b[a[1]];
	vis[a[1]]=1;
	for(int i=2;i<=n;i++)
	{
		sum+=b[a[i]];
		vis[a[i]]=1;
		if(vis[a[i]-1]&&a[i-1]==a[i]-1) sum+=c[a[i]-1];
//		cout<<sum<<endl;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        string t = sc.Next();

        Console.WriteLine(t + s);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int sp=0,stack[101];
    char temp[8];
    while (scanf(" %s",temp)!=EOF) {
        if (temp[0]=='+') {
            sp--;
            stack[sp-1]+=stack[sp];
        } else if (temp[0]=='-') {
            sp--;
            stack[sp-1]-=stack[sp];
        } else if (temp[0]=='*') {
            sp--;
            stack[sp-1]*=stack[sp];
        } else {
            stack[sp]=atoi(temp);
            sp++;
        }
    }
    printf("%d\n",stack[0]);
    return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[7][7];
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>a[i][j];

    int sol=0;
    for(int i=0;i<(1<<h);i++)
    {
        for(int j=0;j<(1<<w);j++)
        {
            int black=0;
            for(int r=0;r<h;r++)
            {
                for(int c=0;c<w;c++)
                {
                    if( ((i>>r)&1)==0 && ((j>>c)&1)==0 && a[r][c]=='#')
                    {
                        black++;
                    }
                }
            }
            if(black==k)
                            sol++;
        }
    }
    cout<<sol;
}


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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[2010], ans = 0;
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	sort(arr, arr + n);
	
	for(int i = n - 1; i >= 1; i--){
		int l = 0, r = i - 1;
		while(l < r){
			
			if(arr[l] + arr[r] > arr[i]){
				ans += r - l;
				r--;
			}
			else{
				l++;
			}
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
} 

Measured memory_bytes: 256
s = list(str(input()))
import sys

if s[0] == 'R' and s[1] == 'R' and s[2] == 'R':
  print("3")

if s[0] == 'S' and s[1] == 'S' and s[2] == 'S':
  print("0")

sum = 0
for i in range(3):
  if s[i] == "R":
    sum += 1
if sum == 1:
  print("1")
elif sum == 2:
  for i in range(2):
    if s[i] == "R" and s[i+1] == "R":
      print("2")
      sys.exit()
  print("1")
    

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

int main(){
  int a,b;
  cin>>a>>b;
  string stra,strb;
 
  
  if(a<=b){
    for(int i=0;i<b;i++)cout<<a;
  }else{
    for(int i=0;i<a;i++)cout<<b;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

// Convex Hull Trick for min query
template<typename T, typename U=__int128>
class ConvexHullTrick {
private:
  deque<pair<T,T>> data;
  bool check(pair<T,T> &p){
    int s = data.size();
    return (U)(data[s-1].fi-data[s-2].fi)*(p.se-data[s-1].se) < (U)(data[s-1].se-data[s-2].se)*(p.fi-data[s-1].fi);
  }
public:
  ConvexHullTrick(){ }
  // additions of 'a' shold be NON-INCREASING
  void add(T a, T b){
    auto p = mp(a,b);
    while(data.size()>=2 && !check(p)) data.pop_back();
    data.push_back(p);
  }
  inline T val(int i, T x) {
    return data[i].fi*x + data[i].se;
  }
  // queries shold be NON-DECREASING
  T query(T x){
    while(data.size()>=2 && val(0, x) >= val(1, x)) data.pop_front();
    return val(0, x);
  }
  inline bool empty(){
    return data.empty();
  }
};

int main(){
  int n,T;
  cin>>n>>T;
  vector<pair<int, pair<int,int>>> v(n);
  rep(i,n) cin>>v[i].se.fi>>v[i].se.se>>v[i].fi;
  // <f,<t,p>>
  sort(all(v));

  vector<vector<long>> dp(n, vector<long>(T+1,0));
  vector<ConvexHullTrick<long>> cht(T+1);

  rep(i,n){
    long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
    for(int j=T; j>=t; j--){
      if(j == t) dp[i][j] = p;
      else if(cht[j-t].empty()) continue;
      else dp[i][j] = -cht[j-t].query(f) + p - f*f;
      cht[j].add(-2*f, -(dp[i][j] - f*f));
    }
  }

  // rep(i,n){
  //   long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
  //   for(int j=T; j>t; j--){
  //     for(int k=0; k<i; k++)
  //       dp[i][j] = max(dp[i][j], dp[k][j-t] + p - (f-v[k].fi)*(f-v[k].fi));
  //   }
  //   dp[i][t] = p;
  // }

  long ans = 0;
  rep(i,n) rep(j,T+1) ans = max(ans, dp[i][j]);

  cout << ans << endl;

  return 0;
}

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

digitlist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for d in D:
    digitlist.remove(d)

Keta = len(str(N))
Ans = ''


def clear(X):
    if len(X) == Keta:
        if int(X) >= N:
            print(X)
            exit()
    else:
        for i in digitlist:
            X = X + str(i)
            clear(X)
            X = X[:-1]


def clear2(X):
    if len(X) == Keta+1:
        if int(X) >= N:
            print(X)
            exit()
    else:
        for i in digitlist:
            X = X + str(i)
            clear2(X)
            X = X[:-1]



clear(Ans)
clear2(Ans)

Measured memory_bytes: 3064
s = input()
n = 0
ans = 0
mods = [0]*2019
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, 2019)
  n %= 2019
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

int getroot(std::vector<int> &root, int i)
{
    if (root[i] != root[root[i]]) {
        root[i] = getroot(root, root[i]);
    }
    return root[i];
}

int main(int argc, char *argv[])
{
    int n, m, k;

    std::vector<int> root;
    std::vector<std::pair<int,int>> relFriend;
    std::vector<std::pair<int,int>> relBlock;

    std::cin >> n >> m >> k;

    root.resize(n + 1);
    relFriend.reserve(m);
    relBlock.reserve(k);

    for (int i = 0; i <= n; i++) {
        root[i] = i;
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;

        if (a > b) {std::swap(a, b);}

        relFriend.push_back(std::pair<int,int>(a, b));
    }

    for (int i = 0; i < k; i++) {
        int c, d;
        std::cin >> c >> d;

        if (c > d) {std::swap(c, d);}

        relBlock.push_back(std::pair<int,int>(c, d));
    }

    std::sort(relFriend.begin(), relFriend.end());
    std::sort(relBlock.begin(), relBlock.end());

    for (const auto& it: relFriend) {
        const auto a = it.first;
        const auto b = it.second;

        const auto ra = getroot(root, a);
        const auto rb = getroot(root, b);
        root[a] = std::min(ra, rb);
        root[b] = root[a];
        root[ra] = root[a];
        root[rb] = root[a];
    }

    for (int i = 1; i <= n; i++) {
        getroot(root, i);
    }

    std::vector<int> rootCount(n + 1);
    for (const auto &it: root) {
        rootCount[it]++;
    }

#ifdef _DEBUG

    std::cout << "Root: ";
    for (int i = 1; i <= n; i++) {
        std::cout << root[i] << " ";
    }
    std::cout << std::endl;
    std::cout << "Root count: ";
    for (int i = 1; i <= n; i++) {
        std::cout << rootCount[i] << " ";
    }
    std::cout << std::endl;
#endif
    
    std::vector<int> canFriend(n + 1);
    for (int i = 1; i <= n; i++) {
        canFriend[i] = rootCount[root[i]] - 1;
    }

    for (const auto& it: relFriend) {
        const auto a = it.first;
        const auto b = it.second;

        if (root[a] != root[b]) {continue;}
        canFriend[a]--;
        canFriend[b]--;
    }

    for (const auto& it: relBlock) {
        const auto c = it.first;
        const auto d = it.second;

        if (root[c] != root[d]) {continue;}
        canFriend[c]--;
        canFriend[d]--;
    }

    for (int i = 1; i <= n; i++) {
        std::cout << canFriend[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3584
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll& r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll& r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll& r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll& r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll& r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

vector<modll> fact, inv;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1;
		cin >> n;
		if (n < 0) return 0;
		vector<LL> x(n);
		for (int i = 0; i < n; ++i) {
			cin >> x[i];
		}

		LL m = n - 1;
		fact.resize(m + 1);
		inv.resize(m + 1);
		fact[0] = 1;
		for (int i = 1; i <= m; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		for (int i = 1; i <= m; ++i) {
			inv[i] = fact[m] * modll::modinv(i);
		}

		modll prev = fact[m];
		modll ans = prev;
		ans *= (x[1] - x[0]);
		for (int i = 1; i < m; ++i) {
			prev += inv[i + 1];
			modll a = prev;
			a *= (x[i + 1] - x[i]);
			ans += a;
		}

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


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
std::string s;

int main(){
	std::cin >> s;
	n = s.length();
	long bc = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'B'){
			bc++;
		}
	}
	long ans = 0;
	int b = 0;//bth black
	for(int i = 0; i < n; i++){
		if(s[i] == 'B'){
			ans += n-(bc-b) - i;
			b++;
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
vector<vector<int>> dir{{1,0},{0,1},{-1,0},{0,-1}};
ll h,w;
void dfs(int x,int y,int cnt,vector<ll> &tmp,vector<vector<ll>> &a){
    bool f=false;
    
    rep(i,4){
      if(x+dir[i][0]>=0&&x+dir[i][0]<h&&y+dir[i][1]>=0&&y+dir[i][1]<w){
        if(a[x+dir[i][0]][y+dir[i][1]]>a[x][y]){
          f=true;
          cnt++;
          dfs(x+dir[i][0],y+dir[i][1],cnt,tmp,a);
          cnt--;
        }
      }
    }
    if(!f){
      tmp.push_back(cnt);
      op(cnt);
      cout<<":"<<endl;
    }
  }

void setup(){
  
  cin>>h>>w;
  ll last=0;
  vec(ans,0);
  mat(a,h,w);
  rep(i,h){
    rep(j,w){
      
      cin>>a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      rep(k,4){
        if(i+dir[k][0]>=0&&i+dir[k][0]<h&&j+dir[k][1]>=0&&j+dir[k][1]<w){
          if(a[i+dir[k][0]][j+dir[k][1]]<=a[i][j]){
            break;
          }
        }
        if(k==3){
          op(i);
          op(j);
          dfs(i,j,1,ans,a);
        }
      }
    }
  }
  cout<<endl;
  rep(i,ans.size()){
    last+=(ans[i]-1)*(ans[i])/2;
    last%=MOD;
  }
  op((last+(h*w))%MOD);
}

int main(){
  ll n;
  cin>>n;
  vec(v,n);
  vec(c,n);
  rep(i,n){
    cin>>v[i];
  }
  ll ans=0;
  rep(i,n){
    cin>>c[i];
    if(v[i]>c[i])ans+=(v[i]-c[i]);
  }
  op(ans);
  return 0;

}

Measured memory_bytes: 256
def f(a):
	s=0;q=a[:n];s=sum(q);heapify(q);r=[s]
	for e in a[n:2*n]:s+=e-heappushpop(q,e);r+=[s]
	return r
import sys;from heapq import*;n,*a=map(int,sys.stdin.read().split());print(max(map(sum,zip(f(a),reversed(f([-e for e in reversed(a)]))))))

Measured memory_bytes: 127704