akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef pair<ll,pair<ll,ll> > p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
const int MAX = 510000;

ll fac[MAX],finv[MAX],inv[MAX];
//http://drken1215.hatenablog.com/entry/2018/06/08/210000
//テーブルを作る前処理　O(n)
//pが素数でなくてはならない
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
//二項係数計算
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    //前処理
    COMinit();

    int H,W,A,B;
    ll ans=0;
    cin>>H>>W>>A>>B;

    for(int i=0;i<=H-1-A;i++){
        ans+=COM(i+B-1,B-1)*COM(H-1-i+W-1-B,W-1-B);
        ans%=MOD;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    for(int i=1;i<=9;i++){
        if(N > i*111){continue;}
        cout << i*111 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
signed main() {
    int a, b, m;
    cin >> a >> b >> m;
    int sa[a];
    int sb[b];
    int x[m];
    int y[m];
    int c[m];
    int ans = 10000000000;
    int mina = 10000000000;
    int minb = 10000000000;
    rep(i, a) {
        cin >> sa[i];
        if(mina > sa[i]) mina = sa[i];
    }
    rep(i, b) {
        cin >> sb[i];
        if(minb > sb[i]) minb = sb[i];
    }
    rep(i, m) cin >> x[i] >> y[i] >> c[i];
    rep(i, m) {
        if(ans > sa[x[i] - 1] + sb[y[i] - 1] - c[i]) ans = sa[x[i] - 1] + sb[y[i] - 1] - c[i];
    }
    cout << min(mina + minb, ans) << endl;
    return 0;
}

Measured memory_bytes: 4096
///***###                               بسم الله الرحمن الرحيم                            ###***///


/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 31 May,2020;
*/

///************************Start Of Template*************************///


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
const int N=2e5+5;
int main()
{
    Read_Fast
    long long a;
    long double b;
    cin>>a>>b;
    long long ans=ll(a*b);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3768
#include<stdio.h>

int main(void)
{
   int n,i,max,min;

   scanf("%d",&n);

   int a[n];

   for(i=0;i<n;i++){
     scanf("%d",&a[i]);
   }

   max=a[0];
   min=a[0];
   for(i=1;i<n;i++){
     if(max<a[i])
       max = a[i];
     if(min>a[i])
       min = a[i];
   }
   max = max - min;

   printf("%d\n",max);

   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  string s;
  cin >> s;

  int n = s.size();
  ll ans = 0;
  rep(b,1<<(n-1)) {
    ll sum = 0;
    ll x = s[0]-'0';
    rep(i,n-1) {
      if ((b>>i)&1) {
        sum += x;
        x = s[i+1]-'0';
      }
      else {
        x = 10*x + s[i+1]-'0';
      }
    }
    sum += x;
    ans += sum;
  }

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

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
map<int, int> cnter;
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	long long ans = 1;
	if (inputs[0] != 0) {
		ans = 0;
	}
	for (int i = 1; i < inputs.size(); ++i) {
		if (inputs[i] == 0) {
			ans = 0;
		}
	}
	REP(i, inputs.size()) {
		cnter[inputs[i]]++;
	}
	vector<pair<long long, long long>> now_go;
	for (auto i = cnter.begin(); i != cnter.end(); ++i) {
		now_go.push_back(*i);
	}
	sort(now_go.begin(), now_go.end());
	for (int q = 1; q < now_go.size(); ++q) {
		if (now_go[q].first != now_go[q - 1].first+1) {
			ans = 0;
		}
		REP(t, now_go[q].second) {
			ans *= now_go[q - 1].second;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long int n,a,b,c,d,x;
cin >> n;
  a=n%15;

  c=n/15;
  x=0;

if(c==0){
  x=0;
}else if(c==1){
  x=60;
}else{
  x=60*c+60*((c-1)*c);
}
    if(a==0){
  b=0;
  }
  if(a==1){
  b=15*1*c+1;
  }
  if(a==2){
  b=15*2*c+3;
  }
  if(a==3){
  b=15*2*c+3;
  }
  if(a==4){
  b=15*3*c+7;
  }
  if(a==5){
  b=15*3*c+7;
  }
  if(a==6){
  b=15*3*c+7;
  }
  if(a==7){
  b=15*4*c+14;
  }
  if(a==8){
  b=15*5*c+22;
  }
  if(a==9){
  b=15*5*c+22;
  }
  if(a==10){
  b=15*5*c+22;
  }
  if(a==11){
  b=15*6*c+33;
  }
  if(a==12){
  b=15*6*c+33;
  }
  if(a==13){
  b=15*7*c+46;
  }
  if(a==14){
  b=15*8*c+60;
  }
    
    cout << x+b;
    
    
    
    
}

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

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

int main(){
  string S, T;

  cin >> S >> T;
  bool flag = true;

  for (int i = 0; i < S.length(); i++) {
      if (S.at(i) != T.at(i)) flag = false;
  }
  if (S.length() + 1 != T.length()) flag = false;

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

int main(void)
{
	long long a, b, c;
	long long m, j, k;
	long long count = 0;

	cin >> a >> b >> c;

	if (a == b && b == c && c == a && (c % 2 == 0)) {
		cout << -1 << endl;
		return (0);
	}

	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {

		

		m = a / 2;
		j = b / 2;
		k = c / 2;

		a = j + k;
		b = m + k;
		c = m + j;

		count++;

	}

	cout << count << endl;

	return (0);

}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
int main(void){
    int a,b,k;
    int f = 0;
    std::cin>>a>>b;
    std::cin>>k;
    for (int i = 100;i>=0;--i){
        if((a%i==0)*(b%i==0)){
            f++;
        }
        if(f==k){
            std::cout<<i<<std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mincost(int a[],int n,int k){
    int dp[n+1];
    int i,mini=INT_MAX,j,c;
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[1]-a[0]);
    for(i=2;i<n;i++){
        for(j=1;j<=k;j++){
            if(i-j>=0){
                c=(abs(a[i]-a[i-j])+dp[i-j+1]);
            }
            if(c<mini){
                mini=c;
            }
        }
        dp[i+1]=mini;
        mini=INT_MAX;
    }
    return dp[n];
}
int main(){
    int n,k,i,d;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    d=mincost(a,n,k);
    cout<<d;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	//ll n, m, h, w;
	//cin >> x;
	string s;
	cin >> a;
	cin >> b;
	ll x[100005] = {};
	c = 1;
	//if (b >= 500000000 * a)
	//{
	//	for (ll i = b; i > 0; i--)
	//	{

	//		if (b%i == 0&&b>=i)
	//		{
	//			c = i;
	//			cout << c << endl;
	//			return 0;
	//		}
	//	}

	//}
	if (a == 1)
	{
		cout << b << endl;
		return 0;
	}
	else
	{

		for (ll i = 1; i <= b; i++)
		{

			if (i*a > b)
			{
				break;
			}
			if (b%i == 0)
			{
				c = i;
			}
		}
	}
	cout << c << endl;


	//cout << sum << endl;
	//cout <<  endl;
	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




//
//ll insuusyurui[1000] = {};
//ll insuukazu[1000] = {};
//ll memo[4000] = {};
//ll memo2[4000] = {};
//cin >> n;
//cin >> m;
//a = 2;
//// √n ≧ a ( n ≧ a * a ) の間ループ処理
//while (n >= a * a) {
//	// a で割り切れたら、a は素因数
//	// そして、割られる数を a で割る
//	// a で割り切れなかったら、 a を 1 増加させる
//	if (n % a == 0) {
//		printf("%lld * ", a);
//		insuukazu[c]++;
//		n /= a;
//	}
//	else {
//		a++;
//		//if (insuukazu[c] != 0)
//		{
//			c++;
//			//cout << c << endl;
//
//		}
//	}
//}
//printf("%lld\n", n);
//for (int i = 0; i < c; i++)
//{
//	//cout << insuukazu[i] << endl;
//}
//
//cout << "Yes" << endl;

Measured memory_bytes: 256
#include "iostream"

using namespace std;

int return_multiple(int i, int j){
    return i * j;
}

int main(){
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            int k = return_multiple(i, j);
            cout << i << "x" << j << "=" << k << endl;
//            printf("%dx%d=%d\n", i, j, k);
        }
    }
    return 0;
}

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

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

  vector<int> Vec;
  for (int i = 0; i < N; i++) {
    int command;
    int ele;

    cin >> command;
    if (command == 0) {
      cin >> ele;
      Vec.push_back(ele);
    } else if (command == 1) {
      cin >> ele;
      cout << Vec.at(ele) << endl;
    } else if (command == 2) {
      Vec.pop_back();
    }
  }
}


Measured memory_bytes: 3844
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
static const LL INF = 1LL << 60;

void solve(std::string S, std::string T) {
	LL ans = INF;
	for (LL i = 0; i + T.length() <= S.length(); ++i) {
		LL cnt = 0;
		for (int j = 0; j < T.length(); ++j) {
			cnt += S[i + j] != T[j];
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

int main() {
    std::string S;
	std::cin >> S;
	std::string T;
	std::cin >> T;
	solve(S, T);
	return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define N 1002
#define INF 1e9+1
string s1,s2;
int dp[N][N];


int main(){
	FOR(i,0,N)FOR(j,0,N)dp[i][j]=-1;
	cin>>s1>>s2;
	FOR(i,0,s1.size()+1){
		dp[i][0]=i;
	}
	FOR(i,0,s2.size()+1){
		dp[0][i]=i;
	}
	FOR(i,1,s1.size()+1){
		FOR(j,1,s2.size()+1){
			int a,b=1;
			if(s1[i-1]==s2[j-1])b=0;
			a=min(dp[i-1][j]+1,dp[i][j-1]+1);
			a=min(a,dp[i-1][j-1]+b);
			dp[i][j]=a;
		}
	}
	cout<<dp[s1.size()][s2.size()]<<endl;
	return 0;
}


Measured memory_bytes: 7140
// B - Go to Jail
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n;
	int c = 0;
	while(n--){
		int x, y; cin>>x>>y;
		if(x == y) c++;
		else c = 0;
		if(c == 3) break;
	}
	puts(c < 3? "No":"Yes");
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int t;
string s;
int main()
{
	cin>>t;
	cin>>s;
	if(t%2)
	{
		cout<<"No\n";
		return 0;
	}
	if(s.substr(t/2)==s.substr(0,t/2))
	{
		cout<<"Yes\n";
	}
	else
	cout<<"No\n";
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = y1 - y2 + x1
y4 = y1 - x1 + x2

print(x3, y3, x4, y4)

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

using namespace std;

#define ll long long
#define vi vector<int>

ll N, M, X, Y;
int buff;
bool flag = true;
vi Xs, Ys;

void solve(){
    int maxX = Xs.back();
    int minY = Ys.front();

    if(minY > maxX && minY > X && maxX < Y) flag = false;

    if(flag)
        cout << "War" << endl;
    else
        cout << "No War" << endl;
}

int main(){
    cin >> N >> M >> X >> Y;

    for(int i = 0; i < N; i++) {
        cin >>  buff;
        Xs.push_back(buff);
    }
    sort(Xs.begin(),Xs.end());

    for(int i = 0; i < M; i++) {
        cin >>  buff;
        Ys.push_back(buff);
    }
    sort(Ys.begin(),Ys.end());

    solve();
}


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

flag = 1
counter = 0
while flag:
  flag = 0
  for j in range(n-1, 0, -1):
    if A[j] < A[j-1]:
      A[j], A[j-1] = A[j-1], A[j]
      flag = 1
      counter += 1
print(*A, sep=" ")
print(counter)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;long long a[n];
   for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);int c=0;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           for(int k=j+1;k<n;k++)
           {if(a[i]!=a[j]&&a[j]!=a[k]){
               if((a[i]+a[j])>a[k]){c++;}
           }
           }
       }
   }
   cout<<c;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int cnt[10][10];

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
        string s = to_string(i);
        cnt[s[0]-'0'][s.back()-'0']++;
    }
    int ans = 0;
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            if(i!=j)
                ans += cnt[i][j] * cnt[j][i];
    for(int i=0; i<10; i++)
        ans += cnt[i][i]*cnt[i][i];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 768
#include <stdio.h>

int main(void){
    int N,X,T;
    int tmp;
    int ans;
    scanf("%d %d %d", &N, &X, &T);

    tmp = N / X;

    if ( N % X != 0 ) {
        tmp += 1;
    }

    ans = tmp * T;
    printf("%d\n", ans);
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// vi[i-1]?????°???i??????????????°
bool isCompleted(vector<int> vi) {
    //?????????2??? && ??????????????°??????????????§true??????????????????
    int zero = std::count(vi.begin(), vi.end(), 0);
    if(zero == 8) return true;

    //??????
    for(int i=1; i<=9; ++i) {
        if(vi[i-1] >= 3) {
            vi[i-1] -= 3;
            if(isCompleted(vi)) return true;
            vi[i-1] += 3;
        }
    }
    //??????
    for(int i=1; i<=7; ++i) {
        if(vi[i-1] >= 1 && vi[i] >= 1 && vi[i+1] >= 1) {
            --vi[i-1]; --vi[i]; --vi[i+1];
            if(isCompleted(vi)) return true;
            ++vi[i-1]; ++vi[i]; ++vi[i+1];
        }
    }
    return false;
}

int main(int argc, char** argv) {
    vector<int> vi; // vi[i-1]?????°???i??????????????°
    string str;
    while(cin >> str) {
        vi.assign(9, 0);
        for(unsigned int i=0; i<str.size(); ++i) {
            ++vi[str[i]-'0'-1];
        }
        bool isFound = false;
        for(int i=1; i<=9; ++i) {
            if(vi[i-1] == 4) continue;
            ++vi[i-1];
            if(isCompleted(vi)) {
                if(isFound) cout << " ";
                isFound = true;
                cout << i;
            }
            --vi[i-1];
        }
        if(!isFound) cout << "0";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3008
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    from collections import Counter

    ball_count, kind_count = map(int, input().split())
    ball_numbers = Counter(list(map(int, input().split())))
    sorted_ball_numbers = sorted(ball_numbers.items(), key=lambda x: x[1])
    ball_number_key_count = len(ball_numbers.keys())

    need_rewritten_count = 0
    diff_count = ball_number_key_count - kind_count

    if diff_count > 0:
        for i, (key, value) in enumerate(sorted_ball_numbers):
            if diff_count > i:
                need_rewritten_count += value

    print(need_rewritten_count)


Measured memory_bytes: 37776
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
mv=((0,1),(0,-1),(1,0),(-1,0))

def dfs(y,x):
    global cnt
    L[y][x]=""
    cnt+=1
    for i,j in mv:
        mx=x+i
        my=y+j
        if 0<=mx<W and 0<=my<H and L[my][mx]==".":
            dfs(my,mx)

while True:
    W,H=map(int,raw_input().split())
    if W==H==0:break
    cnt=0
    L=[list(raw_input()) for i in range(H)]
    for i in range(H):
        for j in range(W):
            if L[i][j]=="@":
                x,y=j,i
    dfs(y,x)
    print cnt

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

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

    cout << min(a,b) << " " << max(0,a+b-n) << endl;

    return 0;
}


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

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

  int fx = 0;
  int t = n;
  while(t > 0) {
    fx += t % 10;
    t /= 10;
  }

  if((n % fx) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
h,w = map(int, input().split())
sf = [input() for _ in range(h)]

def candidate(hi,wi):
    for d in [[1,0],[0,1],[-1,0],[0,-1]]:
        dh = hi+d[0]
        dw = wi+d[1]
        if h>dh>=0 and w>dw>=0 and sf[hi][wi]!=sf[dh][dw]:
            return True
    return False

csf = [[False for _ in range(w)] for _ in range(h)]
for hi in range(h):
    for wi in range(w):
        csf[hi][wi] = candidate(hi,wi)
res = 0
used = [[False for _ in range(w)] for _ in range(h)]
for hi in range(h):
    for wi in range(w):
        if used[hi][wi]:
            continue
        st = [(hi,wi,sf[hi][wi])]
        nb = 0
        nw = 0
        # print("===")
        while len(st)>0:
            s = st.pop()
            # print(s)
            if csf[s[0]][s[1]] and not used[s[0]][s[1]]:
                used[s[0]][s[1]] = True
                if s[2] == "#":
                    nb += 1
                else:
                    nw += 1
                for d in [[1,0],[0,1],[-1,0],[0,-1]]:
                    dh = s[0]+d[0]
                    dw = s[1]+d[1]
                    if h>dh>=0 and w>dw>=0 and csf[dh][dw] and not used[dh][dw] and sf[s[0]][s[1]]!=sf[dh][dw]:
                        st.append((dh,dw,sf[dh][dw]))
        res += nb*nw
print(res)


Measured memory_bytes: 22140
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		long s = sc.nextLong();
		long x1 = 1000000000;
		long y2 = (s + x1 - 1) / x1;
		long x2 = x1 * y2 - s;
		System.out.println("0 0 " + x1 + " 1 " + x2 + " " + y2);
	}
}


Measured memory_bytes: 23764
import numpy as np
import copy

if __name__ == '__main__':
    H, W, K = map(int, input().split(' '))
    C = np.zeros([H, W], dtype=bool)
    for i in range(H):
        tmp = input()
        for j in range(W):
            if tmp[j] == ".":
                C[i][j] = False
            if tmp[j] == "#":
                C[i][j] = True

    count = 0
    for i in range(2**H):
        tmp1 = copy.copy(C)
        for j in range(H):
            if ((i>>j) & 1):
                tmp1[j,:] = False

        for ii in range(2**W):
            tmp2 = copy.copy(tmp1)
            for jj in range(W):
                if ((ii>>jj) & 1):
                    tmp2[:, jj] = False

            if np.count_nonzero(tmp2) == K:
                count += 1

    print(count)

Measured memory_bytes: 26992
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

int main(){
    int N;
    int c=0;

    cin>>N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i*j>=N) break;
            c++;
        }
    }

    cout<<c<<endl;
}


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

int main() {
 ll x,y;
  cin >> x >> y;
  if(x==y)cout<< 0<<endl;
  else if(y>0){
   if(x>y)cout<<x-y+2<<endl;
    else if(x<0&&abs(x)<=y)cout<<x+y+1<<endl;
    else if(x<0&&abs(x)>y)cout<< abs(x)-y+1<<endl;
    else cout<<y-x<<endl;
  }
  else if(y==0){
    if(x<=0)cout<<abs(x)<<endl;
    else cout<< x+1<<endl;
  }
  else{
    if(y>=x)cout<< y-x<<endl;
    else if(0>x&&x>y)cout<< abs(y)-abs(x)+2<<endl;
    else if(x>abs(y))cout<<x-abs(y)+1<<endl;
    else cout<<abs(y)-x+1<<endl;
  }
}

Measured memory_bytes: 256
M = 50100
p = [1]*M; p[0],p[1]=0,0;
pm = [0]*M; pM = [0]*M;
for i in range(2,M):
    if p[i]:
        for j in range(i*i,M,i): p[j] = 0
num = -1
for i in range(1,M):
    pm[i] = num
    if p[i]: num = i
num = -1
for i in range(M-1,2,-1):
    pM[i] = num
    if p[i]: num = i
while 1:
    try:
        n = input()
        print pm[n],pM[n]
    except EOFError:
        break

Measured memory_bytes: 7640
# include <iostream>
# include <cstdio>
# include <algorithm>

using namespace std ;

int n ;
int a[200005] , b[200005] ;

int main()
{
	scanf("%d" , &n) ;
	for ( int i = 1 ; i <= n ; i++ )
		scanf("%d%d" , &a[i] , &b[i]) ;
	sort( a + 1 , a + n + 1 ) ;
	sort( b + 1 , b + n + 1 ) ;
	if ( n % 2 == 1 )
	{
		int val1 = a[( n + 1 ) / 2] ;
		int val2 = b[( n + 1 ) / 2] ;
		printf("%d\n" , val2 - val1 + 1) ;
	}
	else
	{
		int val1 = a[n / 2] + a[n / 2 + 1] ;
		int val2 = b[n / 2] + b[n / 2 + 1] ;
		printf("%d\n" , val2 - val1 + 1) ;
	}
	return 0 ;
}

Measured memory_bytes: 5328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        String ans = "";
        if(N==0) ans = "0";
        while( N != 0 ){
            
            if( N % 2 != 0 ){
                N--;
                ans = "1" + ans;
            } else {
                ans = "0" + ans;
            }
            
            N /= -2;
        }

        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){

  int n;
  cin>>n;
  int m = 0;

  string ans = "No";
  REP(i,1000){
    if(2*n == i*(i+1)){
      ans = "Yes";
      m = i;
    }
  }
  cout<<ans<<endl;
  if(ans == "No"){
    return 0;
  }

  cout<<m+1<<endl;

  cout<<m;
  REP(i,m){
    cout<<" "<<i+1;
  }
  cout<<endl;

  //ここから0番目を１とする
  int s[m][n];
  REP(i,m){
    REP(j,n){
      s[i][j] = 0;
      if(i==j){
        s[i][j] = 1;
      }
    }
  }

  int a = 0;
  int b = 1;
  REP(i,n-m){
    s[a][m+i] = 1;
    s[b][m+i] = 1;
    if(b==m-1){
      a++;
      b = a+1;
    }else{
      b++;
    }
  }

  REP(i,m){
    cout<<m;
    REP(j,n){
      if(s[i][j]==1){
        cout<<" "<<j+1;
      }
    }
    cout<<endl;
  }

    return 0;
}

Measured memory_bytes: 175104
#include <iostream>

using namespace std;

int main(){
  int n;
  std::cin >> n;
  for(int i=1; i<=50000; i++){
    if( n == int( i * 1.08) ){
      std::cout << i << '\n';
      return 0;
    }
  }
  std::cout << ":(" << '\n';

  return 0;
}


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

struct NODE{
	int key;
	int inserted = 0;
	NODE* parent = nullptr;
	NODE* left = nullptr;
	NODE* right = nullptr;
};

void show_key(NODE *node){
	cout << " " << node->key;
}

void show_preorder(NODE *node){
	show_key(node);
	if(node->left != nullptr)
		show_preorder(node->left);
	if(node->right != nullptr)
		show_preorder(node->right);
}

void show_inorder(NODE *node){
	if(node->left != nullptr)
		show_inorder(node->left);

	show_key(node);

	if(node->right != nullptr)
		show_inorder(node->right);
}

void print(NODE *node){
	show_inorder(node);
	cout << endl;
	show_preorder(node);
	cout << endl;
}

void insert(NODE *node, int &insert_key){
	if(!node->inserted){ // If not inserted
		node->key = insert_key;
		node->inserted = 1;
		return;
	}else if(node->key < insert_key){
		if(node->right == nullptr){
			NODE *new_node = new NODE; 
			node->right = new_node;
		}
		insert(node->right, insert_key);
		return;
	}else{
		if(node->left == nullptr){
			NODE *new_node = new NODE;
			node->left = new_node;
		}
		insert(node->left, insert_key);
		return;
	}

}

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

	char command[8];
	int insert_key;
	NODE* root_node = new NODE;
	for(int i=0; i<m; ++i){
		cin >> command;
		if(command[0] == 'i'){
			cin >> insert_key;
			insert(root_node, insert_key);
		}else if(command[0] == 'p'){
			print(root_node);
		}
	}
}


Measured memory_bytes: 26476
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    div4 = len(list(filter(lambda x: x % 4 == 0, a)))
    div2 = len(list(filter(lambda x: (x % 2 == 0 and x % 4 != 0), a)))
    div1 = n - div4 - div2
    if(div4 + 1 < div1 + bool(div2)):
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

const int INF=INT_MAX/3;
const int LIMIT=200;

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};

int h,w;
int c[10][10];
int a[LIMIT][LIMIT];
int mi[10];
string s;
int ans;

int main(){
    cin>>h>>w;
    rep(i,10){
        rep(j,10){
            cin>>c[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    rep(i,10)mi[i]=c[i][1];
    rep(i,h){
        rep(j,w){
            if(a[i][j]==-1)continue;
            ans+=mi[a[i][j]];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct nvec : public vector<int>
{
  int base;
  nvec(int len, int base) : vector<int>(len), base(base) {}
  nvec& operator=(ll in)
  {
    for (int i = 0; i < size(); i++) {
      if (in == 0)
        break;
      at(i) = in % base;
      in /= base;
    }
    return *this;
  };
  operator ll() const noexcept
  {
    ll out, b;
    out = 0;
    b = 1;
    for (int i = 0; i < size(); i++) {
      if (at(i))
        out += at(i) * b;
      b *= base;
    }
    return out;
  };
  nvec& operator++()
  {
    for (int i = 0; i < size(); i++) {
      at(i)++;
      if (at(i) < base)
        break;
      at(i) = 0;
    }
    return *this;
  };
  nvec& operator--()
  {
    for (int i = 0; i < size(); i++) {
      if (0 < at(i)) {
        at(i)--;
        break;
      }
      at(i) = base - 1;
    }
    return *this;
  };
  nvec& operator++(int dummy) { return operator++(); }; // 後置(a++)のoverload
  nvec& operator--(int dummy) { return operator--(); }; // 後置(a--)のoverload
};
nvec& operator+=(nvec& a, int b)
{
  for (int i = 0; i < a.size(); i++) {
    if (b == 0)
      break;
    a.at(i) += (b % a.base);
    if (0 < b) {
      b /= a.base;
      if (a.base <= a.at(i)) {
        a.at(i) -= a.base;
        b++;
      }
    } else {
      b /= a.base;
      if (a.at(i) < 0) {
        a.at(i) += a.base;
        b--;
      }
    }
  }
  return a;
}
nvec& operator-=(nvec& a, int b) { return a += -b; }
nvec operator+(nvec a, int b) { return a += b; }
nvec operator-(nvec a, int b) { return a += -b; }
ostream& operator<<(ostream& os, const nvec& a)
{
  string s;
  for (int i = a.size() - 1; 0 <= i; i--) {
    s += to_string(a.at(i));
  }
  return (os << s);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  ll N;
  cin >> N;
  nvec nv(10, 10);
  nv = N;
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += nv[i];
  }
  if (N % ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    x = [0] * n
    for i in range(n):
        x[i] = x[i - 1] + (1 if s[i] == "I" else -1)
    print(max(0, max(x)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
S=input().upper()

if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
    print('Yes')
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
    print('Yes')
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	int s;
	std::cin >> s;
	mint ans=0;
	for(int i=1;i<=s/3;i++) {
		int x=s-i*3;
		ans+=mint::comb(x+i-1,i-1);
	}
	print(ans);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
int main()
{
    string s;
    cin>>s;
    int a[2019]={0};
    int b[2019]={0};
    int n=s.length();
    lli ans=0;
    rep(i,n){
        rep(j,2019){
            b[(j*10+(s[i]-'0'))%2019]+=a[j];
        }
        b[s[i]-'0']++;
        ans+=b[0];
        rep(j,2019) a[j]=b[j],b[j]=0;//,cout<<b[j]<<" ";
        //nline;
    }
    cout<<ans;
    nline;
}


Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	char str[21]={0};
	char result[21]={0};
	int offset;
	cin >> str;
	for (int i=20; i>=0; i--)
	{
		if (str[i]!=0)
		{
			offset = i;
			break;
		}
	}
	for (int i=0; i<=offset; i++)
	{
		result[i] = str[offset-i];
	}
	cout << result << endl;
}

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int left,right;
	left=a+b;
    right=c+d;
	if(left>right) cout<<"Left";
	else if(left<right) cout<<"Right";
	else cout<<"Balanced";
	return 0;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int Signum(double x){
	return x<-EPS?-1:x>EPS?1:0;
}

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
	Point& operator+=(Point p){
		x+=p.x,y+=p.y;
		return *this;
	}
	Point& operator-=(Point p){
		x-=p.x,y-=p.y;
		return *this;
	}
	Point& operator*=(double c){
		x*=c,y*=c;
		return *this;
	}
	Point& operator/=(double c){
		x/=c,y/=c;
		return *this;
	}
};
Point operator+(Point a,Point b){
	return a+=b;
}
Point operator-(Point a,Point b){
	return a-=b;
}
Point operator*(Point a,double c){
	return a*=c;
}
Point operator*(double c,Point a){
	return a*=c;
}
Point operator/(Point a,double c){
	return a/=c;
}
bool operator==(Point a,Point b){
	return abs(a.x-b.x)<EPS && abs(a.y-b.y)<EPS;
}
bool operator!=(Point a,Point b){
	return !(a==b);
}

double Abs(Point p){
	return sqrt(p.x*p.x+p.y*p.y);
}
double Abs2(Point p){
	return p.x*p.x+p.y*p.y;
}
double Arg(Point p){
	return atan2(p.y,p.x);
}
double Dot(Point a,Point b){
	return a.x*b.x+a.y*b.y;
}
double Cross(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}
Point Rot(Point p,double t){
	return Point(cos(t)*p.x-sin(t)*p.y,sin(t)*p.x+cos(t)*p.y);
}

int CCW(Point a,Point b,Point c){
	b-=a,c-=a;
	if(int sign=Signum(Cross(b,c)))
		return sign; // 1:ccw,-1:cw
	if(Dot(b,c)<-EPS)
		return -2;   // c-a-b
	if(Abs2(b)<Abs2(c)-EPS)
		return 2;    // a-b-c
	return 0;        // a-c-b (inclusive)
}

bool IsConvex(const vector<Point>& ps)
{
	int n=ps.size(),res=true;
	rep(i,n) res&=CCW(ps[i],ps[(i+1)%n],ps[(i+2)%n])!=-1;
	return res;
}

int main()
{
	for(int n;cin>>n && n;){
		vector<Point> ps(n);
		for(auto& p:ps) cin>>p.x>>p.y;
		cout<<IsConvex(ps)<<endl;
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


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

    int ans = 0;
    for(int bit1 = 0; bit1 < (1 << h); bit1++){
        for(int bit2 = 0; bit2 < (1 << w); bit2++){
            int cnt = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if((bit1 & (1 << i)) == 0 && (bit2 & (1 << j)) == 0){
                        if(v[i][j] == '#') cnt++;
                    }
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string solve(string S) {
    string res;
    rep(i, len(S)) {
        if (S[i] == '0') res.push_back('0');
        else if (S[i] == '1') res.push_back('1');
        else {
            if (len(res) != 0) res.pop_back();
        }
    }
    return res;
}

int main() {
    string S; cin >> S;
    cout << solve(S) << endl;
}

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

int main() {
    int h, w;

    while(true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;

        rep(i,h) {
            rep(j,w) {
                if ((i+j) % 2 == 0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }

        cout << endl;
    }
}


Measured memory_bytes: 3116
#include<string>
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
typedef pair<int,int> P;
int n,m;
vector<vector<int> > trans(vector<vector<int> > s){
	vector<vector<int> > t(m,vector<int>(m));
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			t[i][j]=s[j][m-i-1];
		}
	}
	
	return t;
	
}
int main(){
	while(cin>>n>>m,n||m){
		vector<vector<int> > s(n,vector<int>(n)),t(m,vector<int>(m));
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)
				cin>>s[i][j];
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++)
				cin>>t[i][j];
		}
		vector<P> ans;
		for(int k=0;k<4;k++){
			for(int i=0;i<=n-m;i++){
				for(int j=0;j<=n-m;j++){
					bool flag=true;
					for(int y=0;y<m;y++){
						for(int x=0;x<m;x++){
							if(t[y][x]!=-1&&s[i+y][j+x]!=t[y][x]){
								flag=false;
								goto con;
							}
						}
					}
					if(flag){
						//cout<<"-------"<<endl;
						for(int a=0;a<m;a++){
							for(int b=0;b<m;b++){
								if(t[a][b]!=-1){
									ans.pb(P(a+i+1,b+j+1));
									//cout<<b+j+1<<" "<<a+i+1<<endl;
									goto end;
								}
							}
						}
						
						
					}
					con:;
				}
			}
			end:;
			/*cout<<endl;
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++)
				cout<<t[i][j]<<' ';
				cout<<endl;
			}*/
			t=trans(t);
		}
		if(!ans.size())
			cout<<"NA"<<endl;
		else{
			sort(all(ans));
			cout<<ans[0].second<<" "<<ans[0].first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 968
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll l, r, d, ans = 0;

int main() {
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++) {
		if (i % d == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int sum = 0;

		for (int a = 1; a <= k; a++) {
			for (int b = 1; b <= k; b++) {
				for (int c = 1; c <= k; c++) {
					sum += gcd(gcd(a,b),c);
				}
			}
		}
		
		System.out.println(sum);
	}

	public static int gcd(int p, int q) {
		if (p % q == 0) {
			return q;
		}
			return gcd(q, p % q);
	}

}


Measured memory_bytes: 36136