akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vector<string> G(0);

void p4(int s){
    rep(i,4){
        int k = i/2;
        rep(j,2) G[s + i][s + j + k*2] = char('a' + i);
    }
    rep(i,4){
        int k = 1 - (i / 2);
        rep(j,2) G[s + j + k*2][s + i] = char('e' + i);
    }
}
const vector<string> cop5 = {"aabbc",
                             "hii.c",
                             "h..jd",
                             "g..jd",
                             "gffee"};
const vector<string> cop7 = {".aa.bcc",
                             "d..eb..",
                             "d..ef..",
                             ".gg.fhh",
                             "iijj.kk",
                             "l..mn..",
                             "l..mn.."};
void p5(int s){
    rep(i,5) rep(j,5) G[s+i][s+j] = cop5[i][j];
}
void p7(int s){
    rep(i,7) rep(j,7) G[s+i][s+j] = cop7[i][j];
}
int main(){
    cin>>N;
    S = "";
    rep(i,N) S.push_back('.');
    rep(i,N) G.push_back(S);
    if(N == 2){
        cout<<-1<<endl;
        return 0;
    }else if(N == 3){
        G[0][0] = G[0][1] = G[1][2] = G[2][2] = 'a';
    }else if(N == 6){
        G[0][0] = G[0][1] = G[1][2] = G[2][2] = 'a';
        G[3][3] = G[3][4] = G[4][5] = G[5][5] = 'a';
    }else{
        if(N%4 == 0){
            rep(i,N/4) p4(i * 4);
        }else if(N%4 == 1){
            rep(i, (N/4) - 1) p4(i*4);
            p5(N - 5);
        }else if(N%4 == 2){
            rep(i, (N/4) - 2) p4(i*4);
            p5(N - 10);
            p5(N - 5);
        }else if(N%4 == 3){
            rep(i,(N/4) - 1) p4(i * 4);
            p7(N - 7);
        }
    }
    rep(i,N){
        rep(j,N) cout<<G[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 2304
n, m, c = list(map(int, input().split()))
b_list = list(map(int, input().split()))
a_lists = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for a_list in a_lists:

    v = c
    for i in range(len(a_list)):
        v += a_list[i] * b_list[i]

    if v > 0:
        ans += 1

print(ans)


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;

    ll d = abs(A-B);
    if (d<=(V-W)*T) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3560
#coding: utf-8

def main():
    N = int(input())
    t = list(map(int, input().split()))
    a = list(reversed(list(map(int, input().split()))))

    m = [0] * N

    b = 0
    for i,h in enumerate(t):
        if b != h:
            m[i] = h#確定
            if a[N-i-1] < h:
                print(0)
                return
        b = h
    b = 0
    for j,h in enumerate(a):
        p = N-j-1
        if b != h:
            if m[p] != 0 and m[p] != h:
                print(0)
                return
            else:
                m[p] = h#確定
                if t[p] < h:
                    print(0)
                    return
        b = h
    res = 1
    for k,h in enumerate(m):
        if h == 0:
            res = res * min(a[N-k-1], t[k]) % (pow(10, 9) + 7)
    print(res)
    return

main()


Measured memory_bytes: 19136
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

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

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

int main() {
	int N;
	int A[100100] = {0};
	int B[100100] = {0};
	multimap<long long int, int> mp;
	long long int taka_sum =0, aoki_sum  =0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];

		mp.insert(pair<const long long int, int>((A[i]+ B[i])*(-1), i));
	}

	long long int flg = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (flg % 2 == 0) {
			taka_sum += A[itr->second];

		}
		else {
			aoki_sum += B[itr->second];
		}
		flg++;
	}

	cout << taka_sum - aoki_sum << endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a,b;
  cin>>a>>b;
  int ans=1;
  for(int i=1; i<=a; i++){
    if(i==1)
      ans*=b;
    else
      ans*=(b-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  //数＋1 ＊＊＊＊owari
  ll n;
  cin>>n;
  string s;
  cin>>s;
  map<char,ll> cnt;
  rep(i,0,n){
     cnt[s[i]]++;
  }
  ll ans=1;
  for(auto v:cnt){
    ans*=(v.second+1);
    ans%=inf;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 3732
#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int parent; int left, right; } TREE;
TREE tree[30];

void preorder(int node)
{
	printf(" %d", node);
	if (tree[node].left  >= 0) preorder(tree[node].left);
	if (tree[node].right >= 0) preorder(tree[node].right);
}

void inorder(int node)
{
	if (tree[node].left  >= 0) inorder(tree[node].left);
	printf(" %d", node);
	if (tree[node].right >= 0) inorder(tree[node].right);
}

void postorder(int node)
{
	if (tree[node].left  >= 0) postorder(tree[node].left);
	if (tree[node].right >= 0) postorder(tree[node].right);
	printf(" %d", node);
}

int main()
{
	int n, i, id;
	int root, left, right;

	n = in();
	for (i = 0; i < n; i++) {
		id = in();
		tree[id].left  = left =  in();
		tree[id].right = right = in();
		if (tree[id].left  >= 0) tree[left ].parent = id+1;
		if (tree[id].right >= 0) tree[right].parent = id+1;
	}
	for (root = 0; root < n; root++) {
		if (tree[root].parent == 0) break;
	}

	puts("Preorder");
	preorder(root); putchar('\n');
	puts("Inorder");
	inorder(root); putchar('\n');
	puts("Postorder");
	postorder(root); putchar('\n');
	return 0;
}



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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; s.at(i) != 'A';++i){
    count++;
  }
  int zcount = s.size();
 for(int i = s.size()-1; s.at(i) != 'Z'; --i){
   zcount--;
 }
  
  cout << zcount - count<< endl;
}



Measured memory_bytes: 640
n = int(input())
a = 0
w = 0
t = 0
r = 0
for i in range(n):
    result = input()
    if result == "AC":
        a += 1
    elif result == "WA":
        w += 1
    elif result == "TLE":
        t += 1
print ("AC x "+ str(a))
print ("WA x "+ str(w))
print ("TLE x "+ str(t))
print ("RE x "+ str(n -(a + w + t)))

Measured memory_bytes: 9204
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



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

	int tmp = 0;
	int ans = 0;

	while (tmp < x)
	{
		tmp += ++ans;
	}

	cout << ans << endl;
}


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

const int N = 36;

struct Card{
	char suit;
	int value;
};

void bubbleSort(Card [], int);

void selectionSort(Card [], int);

bool isStable(Card [], Card [], int);

void print(Card [], Card [], int);

int main(){
	Card cBub[N], cSel[N];
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> cBub[i].suit >> cBub[i].value;
		cSel[i] = cBub[i];
	}
	bubbleSort(cBub, n);
	selectionSort(cSel, n);
	print(cBub, cSel , n);
	return 0;
}

void bubbleSort(Card c[], int n){
	for(int i = 0; i < n; i++){
		for(int j = n-1; j > i; j--){
			if(c[j].value < c[j-1].value)
				swap(c[j], c[j-1]);
		}
	}
}

void selectionSort(Card c[], int n){
	for(int i = 0; i < n; i++){
		int minJ = i;
		for(int j = i+1; j < n; j++){
			if(c[j].value < c[minJ].value)
				minJ = j;
		}
		swap(c[i], c[minJ]);
	}
}

bool isStable(Card cIn[], Card cOut[], int n){
	for(int i = 0; i < n; i++){
		if(cIn[i].suit != cOut[i].suit || cIn[i].value != cOut[i].value){
			return false;
		}
	}
	return true;
}

void print(Card cBub[], Card cSel[] , int n){
	for(int i = 0; i < n; i++){
		if(i)
			cout << ' ';
		cout << cBub[i].suit << cBub[i].value;
	}
	cout << endl << "Stable" << endl;
	for(int i = 0; i < n; i++){
		if(i)
			cout << ' ';
		cout << cSel[i].suit << cSel[i].value;
	}
	if(isStable(cBub, cSel, n))
		cout << endl << "Stable" << endl;
	else
		cout << endl << "Not stable" << endl;
}


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

using namespace std;



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

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

    int n;
    cin >> n;

    int OneLiterPrice = min({price[0] * 4, price[1] * 2, price[2]});
    int TwoLiterPrice = price[3];

    long long bestPrice = min(OneLiterPrice * 1LL * n, TwoLiterPrice * 1LL * (n / 2) + OneLiterPrice * 1LL * (n % 2));

    cout << bestPrice;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
using ll = long long;
using ld = long double;
mt19937 rng(time(0));

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
int a[3]; cin >> a[0] >> a[1] >> a[2];
sort(a, a+3);
if (a[0] == a[1] && a[1] != a[2]) {
    puts("Yes");
    return 0;
}
if (a[1] == a[2] && a[1] != a[0]) {
  puts("Yes");
  return 0;
}
puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<int> a(3);
  rep(i,3){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if(a[0]==a[1]&&a[1]!=a[2]){
    cout << "Yes" << "\n";
  }
  else if(a[0]!=a[1]&&a[1]==a[2]){
    cout << "Yes" << "\n";
  }
  else{
    cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    long A, B;
    int K;
    cin >> A >> B >> K;

    if (B - A + 1 > 2 * K) {
        rep(i,K) {
            cout << A + i << endl;
        }
        repr(i,1,K+1) {
            cout << B - (K - i) << endl;
        }
    }
    else {
        repr(i,A,B+1) {
            cout << i << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<string>
#include<map>
#include<vector>
using namespace std;
map<string,int> mp;
vector<string> v;
vector<string> ans;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(!mp[s]){
			v.push_back(s);
		}
		mp[s]++;
	}
	int MAX=0;
	for(int i=0;i<v.size();i++){
		if(mp[v[i]]>MAX){
			MAX=mp[v[i]];
		}
	}
	for(int i=0;i<v.size();i++){
		if(mp[v[i]]==MAX){
			ans.push_back(v[i]);
		}
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 28400
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}


// vector<long long> enumDivisor(long long n) {
//     vector<long long> res;
//     for (long long i = 1; i*i <= n; i++) {
//         if (n%i) continue;
//         res.push_back(i);
//         if (i*i != n) res.push_back(n/i);
//     }
//     sort(res.begin(), res.end());
//     return res;
// }

// ll calc(ll a, ll b) {
//     return a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b;
// }

ll calc(ll a) {
    return a*a*a*a*a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x;
    cin >> x;
    // auto f = enumDivisor(x);
    // int n = sz(f);
    // rep(i, n) {
    //     if (i > n-1-i) break;
    //     ll b = f[i];
    //     ll a = f[n-1-i];
    //     if ((a - b) * calc(a, b) == x) {
    //         cout << a << " " << b << endl;
    //         return 0;
    //     }
    // }
    for (ll a = 1; a <= 1000; ++a) {
        for (ll b = -1000; b <= 1000; ++b) {
            if (calc(a) - calc(b) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char a[100];
int main()
{
 string s;
  cin>>s;
  int t=s.length();
  char a[100];
  for(int i=1;i<=t;i++)
  {
    a[i]='x';
  }
   for(int i=1;i<=t;i++)
  {
    cout<<a[i];
  }
  
 
  
  return 0;
}
  
 

  
  

  

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>

using namespace std; using ll=long long; const int INF=1e2; using P=pair<ll,ll>;

int main() {
  ll h,w; cin>>h>>w; ll an=1e18;
  if (h%3 == 0 || w%3 == 0) {
    cout<<0<<endl;
    return 0;
  } else {
    an = min(an, min(w,h));
  }

  for(int i=1;i<h;i++) {
    ll s1 = i*w;
    ll s2 = (h-i) * (w/2);
    ll s3 = (h-i) * (w-w/2);
    ll mx = max(s1, max(s2, s3));
    ll mn = min(s1, min(s2, s3));
    an = min(an, mx - mn);
  }

  for(int i=1;i<w;i++) {
    ll s1 = i*h;
    ll s2 = (w-i) * (h/2);
    ll s3 = (w-i) * (h-h/2);
    ll mx = max(s1, max(s2, s3));
    ll mn = min(s1, min(s2, s3));
    an = min(an, mx - mn);
  }
  cout<<an<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string Ns; int Ni[15], used[10];
int dfs(int n, bool smaller) {
  if(n >= Ns.size()) return (used[3] > 0 && used[5] > 0 && used[7] > 0);
  int cnt = 0;
  for(int i = 0; i <= (smaller?9:Ni[n]); ++i) {
    if(i != 0 && i != 3 && i != 5 && i != 7) continue;
    if(i == 0 && used[0] < n) continue;
    ++used[i];
    cnt += dfs(n+1, (smaller || i < Ni[n]));
    --used[i];
  }
  return cnt;
}
int main() {
  cin >> Ns;
  for(int i = 0; i < Ns.size(); ++i) Ni[i] = Ns.at(i)-'0';
  cout << dfs(0, false) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mk make_pair
#define pb push_back
#define mod 1000000007
int p[200005];
int sz[200005];
void initialize(int  n){
    for(int i=1;i<=n;i++){p[i]=i;sz[i]=1;}
}
int find(int x){
if(x==p[x])return x;
else return p[x]=find(p[x]);
}
void _union(int x,int y){
    x=find(x);
    y=find(y);
    if(sz[x]>sz[y]){
    sz[x]+=sz[y];
    sz[y]=0;
    p[y]=x;
    }
    else{
    sz[y]+=sz[x];
    sz[x]=0;
    p[x]=y;
    }
}

int main(){
    int n,m;
    cin>>n>>m;
    initialize(n);
    for(int i=0;i<m;i++){
    int x,y;cin>>x>>y;
    if(find(x)==find(y))continue;
    else _union(x,y);
    }
    vector<int> v;
    for(int i=1;i<=n;i++){
        if(sz[i]!=0)v.pb(sz[i]);
    }
    sort(v.begin(),v.end());
    int ans=v[0];
    int sum=v[0];
    //cout<<v[0]<<endl;
    for(int i=1;i<v.size();i++){
        if(v[i]-sum>0){
            ans+=v[i]-sum;
            sum=v[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5780
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(u == s){
		cout << a-1 << " " << b << endl;
	} else{
		cout << a << " " << b-1 << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
//a.c A-Favorite Sound
#include<stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(b/a>=c){
        printf("%d\n",c);
    }else{
        printf("%d\n",b/a);
    }
    return 0;
}

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    X, Y, Z = map(lambda x: int(x)-1, input().split())
    uf.union(X, Y)
print(uf.group_count())

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

int main() {
    int N, T; cin >> N >> T;
    int ans = 1001;
    for (int i = 0; i < N; i++) {
        int c, t; cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == 1001) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  vector<vector<ll>> v;
  for(int i=1;i<=n;i++){
    ll a;
    cin >> a;
    v.push_back({a,i});
  }
  sort(v.begin(),v.end());

  for(int i=0;i<n;i++){
    cout << v[i][1] << endl;
  }


}

Measured memory_bytes: 8620
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
 
 
int main() 
{
 
	int n; cin>>n;
	ll a[n], b[n];
	for(int i = 0; i<n; i++) 
	{
		int x, y; cin>>x>>y;
		a[i] = x+y;
		b[i] = x-y;
	}
	sort(a, a+n);
	sort(b, b+n);
	ll res = abs( a[n-1]-a[0] );
	res = max(res, abs( b[n-1]-b[0] ) );
	cout<<res<<endl;
}

Measured memory_bytes: 6772
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

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

  int n, k;

  std::cin >> n >> k;

  int ki[10];
  for (int i = 0; i < 10; ++i) {
    ki[i] = 0;
  }

  int t;
  for (int i = 0; i < k; ++i) {
    std::cin >> t;
    ki[t] = 1;
  }

  int res = n;
  for (;;) {
    if (ki[res % 10]) {
      ++res;
      continue;
    }

    int val = res / 10;
    bool is_ng = false;
    while (val != 0) {
      if (ki[val % 10]) {
        ++res;
        is_ng = true;
        break;
      }
      val /= 10;
    }
    if (!is_ng) {
      break;
    }
  }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

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

  if (x >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    ll n,k;
    cin >> n >> k;

    vector<ll> a;
    vector<ll> f;

    rep(i,n){
        ll tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    rep(i,n){
        ll tmp;
        cin >> tmp;
        f.pback(tmp);
    }

    sort(ALL(a));
    sort(ALL(f));

    vector<pair<ll, pair<ll,ll>>> v;

    rep(i,n){
        v.pback(mpair(a[i] * f[n - 1 - i], mpair(a[i], f[n - 1 -i])));
    }

    sort(ALL(v));
    reverse(ALL(v));

    ll ok = LLONG_MAX - 3;
    ll ng = -1;

    while(abs(ok - ng) > 1){

        cerr << ok << " " << ng << endl;

        ll tmp = (ok + ng) / 2;
        bool able = true;
        vector<pair<ll, pair<ll,ll>>> tmpv;
        ll tmpk = k;

        rep(i,n){
            tmpv.pback(v[i]);
        }

        rep(i,n){
            if(tmpk > 0){
                if(tmpv[i].first > tmp){
                    ll obj = tmp / tmpv[i].second.second;

                    obj = tmpv[i].second.first - obj;

                    if(obj <= tmpk){
                        tmpk = tmpk - obj;
                    }else{
                        able = false;
                        break;
                    }
                }
            }else{
                if(tmpv[i].first > tmp){
                    able = false;
                    break;
                }
            }
        }

        if(able){
            ok = tmp;
        }else{
            ng = tmp;
        }

    }

    cout << ok << endl;

}


Measured memory_bytes: 21916
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
//using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up) for (auto countName = left; countName < right; countName += up)
#define REP(countName, end) for (auto countName = 0; countName < end; countName++)
#define rev(countName, right, left, down) for (auto countName = right; countName >= left; countName -= down)
#define REV(countName, end) for (auto countName = end; countName >= 0; countName--)

auto solve1(int n, std::vector<int> &&a)
{
    std::vector<int> v(n);
    REP(i, n)
    {
        if (a[i] % 2 == 0)
        {
            while (a[i] % 2 == 0)
            {
                v[i]++;
                a[i] /= 2;
                //cout << a[i] << " ";
            }
            //cout << endl;
        }
        else
        {
            v[i] = 0;
        }
    }
    return *std::min_element(v.begin(), v.end());
}

int main(void)
{
    int n;
    cin >> n;
    std::vector<int> a(n);
    REP(i, n) { cin >> a[i]; }
    cout << solve1(n, std::move(a)) << endl;
    return 0;
}

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

using namespace std;

int main(void){
  int n,a[101];
  long long dp[101][21];

  while(cin >> n){
    for(int i=0;i<n;i++)
      cin >> a[i];
    
    for(int i=0;i<101;i++)
      for(int j=0;j<21;j++)
	dp[i][j]=0;

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

    for(int i=0;i<n-1;i++){
      for(int j=0;j<21;j++){
	if(j+a[i+1]<21)dp[i+1][j+a[i+1]]+=dp[i][j];
	if(j-a[i+1]>=0)dp[i+1][j-a[i+1]]+=dp[i][j];
      }
    }

    cout << dp[n-2][a[n-1]] << endl;
  }

  return 0;
}

Measured memory_bytes: 1172
import itertools

N, K = map(int, input().split())
S = input()
assert len(S) == N

# list of run-length
runlen = [len(list(g)) for k, g in itertools.groupby(S)]

# runlen starts and ends with the length of a run of '1'
if S[0] == '0':
    runlen = [0] + runlen
if S[-1] == '0':
    runlen = runlen + [0]

# list of sum of runlen[i : i + k]
k = 2 * K + 1
s = sum(runlen[:k])
sublen = [s]
for i in range(2, N - k, 2):
    s -= sum(runlen[i - 2 : i])
    s += sum(runlen[i - 2 + k : i + k])
    sublen.append(s)

print(max(sublen))


Measured memory_bytes: 5456
n,m=map(int,input().split())
l=[]

for i in range(m):
        l.append(list(map(int,input().split())))
p=list(map(int,input().split()))

t=[]
for i in range(2**n):
        t.append(format(i,'b').zfill(n))
z=[]
p=p*(2**n)
for i in range(2**n):
        for j in range(len(l)):
                count=0
                for k in range(1,len(l[j])):
                        count+=int((t[i][l[j][k]-1]))
                z.append(count%2)
y=[]
u=[]
ans=0
for i in range(2**n):
        y.append(p[i*m:i*m+m])
        u.append(z[i*m:i*m+m])
        
for l in range(len(y)):
        if y[l]==u[l]:
                ans+=1
print(ans)


Measured memory_bytes: 3572
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 100000;
int ans,n,k;
int main()
{
    scanf("%d",&n);
    scanf("%d",&k);
    ans = 1;
    for (int i = 1; i <= n; i++)
    {
        if(ans * 2 <= ans + k)
            ans *= 2;
        else
            ans += k;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define int long long
#define ll long long
using namespace std;
signed main() {
	int a, b, c,d;
	cin >> a >> b;
	if (b < 10)c = a * 10 + b;
	else if (b < 100)c = a * 100 + b;
	else c = a * 1000 + b;
	d = sqrt(c);
	if (d*d==c)cout << "Yes" << endl;
	else cout << "No" << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
//過去AC
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
#define double long double
using namespace std;
typedef pair<int, int> P;
 
int sx, sy, gx, gy;
int n;
int x[200000], y[200000];
vector<P> p;
int dp[200002];		//dp[length] = min(max)
const double PAI = 3.141592653589793238;
 
signed main()
{
	int i;
	
	cin >> sx >> sy >> gx >> gy;
	cin >> n;
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	
	if (sx > gx) { swap(sx, gx); swap(sy, gy); }
	if (sy > gy) {
		sy *= -1;
		gy *= -1;
		for (i = 0; i < n; i++) { y[i] *= -1; }
	}
	
	for (i = 0; i < n; i++) {
		if (sx <= x[i] && x[i] <= gx && sy <= y[i] && y[i] <= gy) {
			p.push_back(P(x[i], y[i]));
		}
	}
	sort(p.begin(), p.end());
	
	//LIS
	int INF = 1145141919810;
	for (i = 0; i <= n + 1; i++) dp[i] = INF;
	dp[0] = -INF;
	for (i = 0; i < p.size(); i++) {
		dp[upper_bound(dp, dp + n + 1, p[i].second) - dp] = p[i].second;
	}
	for (i = n; i > 0; i--) {
		if (dp[i] < INF) break;
	}
	
	//LISの長さ
	int Count = i;
	
	//場合分け
	double ans;
	
	if (min(gx - sx, gy - sy) + 1 > Count) {
		ans = (gy - sy + gx - sx) * 100 - Count * (20.0 - PAI * 5.0);
	}
	else {
		ans = (gy - sy + gx - sx) * 100 - (Count - 1.0) * (20 - PAI * 5) + (PAI * 10 - 20);
	}
	
	printf("%.20Lf\n", ans);
	return 0;
}

Measured memory_bytes: 10608
#include <iostream>

int main(){
    int T,h,m,s;
    std::cin >> T;
    s = T % 60;
    T /= 60;
    m = T % 60;
    h = T / 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int lim = 300;
const int lim_ = 1000001;
int tri[lim];
int tetra[lim];
int n;
int table[lim_];
int odd[lim_];
int main() {
    tri[1] = 1;
    rrep(i, 2, lim) {
        tri[i] = tri[i - 1];
        tri[i] += i;
    }
    //cout << tri[lim - 1] << endl;
    tetra[1] = 1;
    rrep(i, 2, lim) {
        tetra[i] = tetra[i - 1];
        tetra[i] += tri[i];
    }
    //rep(i, 5) cout << tetra[i] << " "; cout << endl;
    //cout << tetra[lim - 1] << endl;
    rep(i, lim_) table[i] = odd[i] = inf;
    table[0] = odd[0] = 0;
    rep(i, lim) {
        rep(j, lim_) {
            if (table[j] != inf && j + tetra[i] < lim_) {
                chmin(table[j + tetra[i]], table[j] + 1);
            }
        }
        if (tetra[i] % 2 == 0) continue;
        rep(j, lim_) {
            if (odd[j] != inf && j + tetra[i] < lim_) {
                chmin(odd[j + tetra[i]], odd[j] + 1);
            }
        }
    }
    
    while (cin >> n && n) {
        cout << table[n] << " " << odd[n] << endl;
    }
    
}



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

int main() {
  int W, n;
  for (int Case = 1; cin >> W, W; ++Case) {
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
      scanf("%d,%d", &v[i], &w[i]);
    }

    vector<int> d(W + 1, -1);
    d[0] = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = W - w[i]; j >= 0; --j) {
        if (d[j] == -1) continue;
        d[j + w[i]] = max(d[j + w[i]], d[j] + v[i]);
      }
    }

    int ans_v = 0, ans_w = 0;
    for (int i = 0; i <= W; ++i) {
      if (ans_v < d[i]) {
        ans_v = d[i];
        ans_w = i;
      }
    }

    cout << "Case " << Case << ":" << endl;
    cout << ans_v << endl;
    cout << ans_w << endl;
  }
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int N,Q;
int C[334334];
int Qa;
int X[334334];
int T[334334];
int main()
{
	scanf("%d%d",&N,&Q);
	for(int i=0;i<N;i++){
		scanf("%d",&C[i]);
		X[C[i]]=1;
	}
	for(int i=0;i<334333;i++){
		if(X[i]==1){
			T[i+1]=i;
		}
		else T[i+1]=T[i];
	}
	for(int i=0;i<Q;i++){
		scanf("%d",&Qa);
		int ans=0;
		int now=T[334333];
		ans=max(ans,now%Qa);
		while(now>0){
			now-=now%Qa;
			now=T[now];
			ans=max(ans,now%Qa);
		}
		printf("%d\n",ans);
	}
	
}

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

typedef pair<int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<P> que;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(P(a, 1));
    }
    for (int i = 0; i < M; i++) {
        int b, c;
        cin >> b >> c;
        que.push(P(c, b));
    }

    long long res = 0;
    int cnt = 0;
    while (cnt < N) {
        P p = que.top();
        que.pop();
        res += p.first;
        cnt++;
        p.second--;
        if (p.second) que.push(p);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n;
		cin >> n;
		
		ll i = 1;
		ll ans =0;
		while((i*i)<n)
		{
			ll lol = (n/i) - 1;
			if((n%lol)==(n/lol))
			ans += lol;
			
			i++;
			
		}
		cout << ans << endl;
		
	}
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define br cout << endl ;
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
		 int n , m ;
		 cin >> n >> m ;
		 int res =  m *(m-1)/2 + n * (n-1)/2 ;
		 cout << res ;
		  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x,y;
		int copy = 0;
		
			for(int i=1; true; i++){
				x = sc.nextInt();
				y = sc.nextInt();
				if(x == 0 && y == 0) break;
				
				else if(x > y){
					copy = x;
					x = y;
					y = copy;
				}
				System.out.println(x + " " + y);
			}
			sc.close();
	}
}


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

const int M = 1000000007;

class unionfind {
    public:
    int n;
    vector<int> par;
    unionfind(int m) {
        n = m;
        par.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int find(int x) { return par[x] == x ? x : (par[x] = find(par[x])); }
    int isunion(int x, int y) { return find(x) == find(y); }
    int tounion(int x, int y) {
        int p = find(x), q = find(y);
        if (p == q) return 0;
        par[q] = p;
        return 1;
    }
};

int main() {
    while (1) {
        int n, q;
        cin >> n >> q;
        if (!n) return 0;

        vector<int> par(n);
        for (int i = 1; i < n; ++i) {
            cin >> par[i];
            --par[i];
        }
        vector<pair<char, int>> inp(q);
        vector<int> cnt(n, 0);
        for (int i = q - 1; i >= 0; --i) {
            cin >> inp[i].first >> inp[i].second;
            --inp[i].second;
            if (inp[i].first == 'M')
                ++cnt[inp[i].second];
        }
        unionfind uf(n);
        for (int i = 1; i < n; ++i)
            if (!cnt[i])
                uf.tounion(par[i], i);

        long long sum = 0;
        for (auto i : inp) {
            if (i.first == 'M' && !--cnt[i.second])
                uf.tounion(par[i.second], i.second);
            else if (i.first == 'Q')
                sum += uf.find(i.second) + 1;
        }
        cout << sum << "\n";
    }
}

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


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

    string s;
    cin >> s;
    int ans=0;
    rep(i, s.size()) {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int a_pos = -1;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A' && a_pos == -1) {
      a_pos = i;
    } else if (s[i] != 'A' && a_pos != -1) {
      if (s[i] == 'B' && i+1 < n && s[i+1] == 'C') {
        ans += i - a_pos;
        a_pos += 2;
        i++;
      } else {
        a_pos = -1;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        sc.close();
        String[] arr1 =  s.split("");
        String[] arr2 =  t.split("");
//        List<String> list1 = Arrays.asList(s.split(""));
        List list1 = new LinkedList(Arrays.asList(s.split("")));
//        List<String> list2 = Arrays.asList(t.split(""));
        List list2 = new LinkedList(Arrays.asList(t.split("")));
//        int num = Integer.parseInt(arr[arr.length - 1]);
        list2.remove(arr2.length - 1);
//        System.out.println(list1);
//        System.out.println(list2);
         if(list1.toString().contentEquals(list2.toString())){
             System.out.println("Yes");
         }else{
             System.out.println("No");
         }
//        switch(num){
//            case 3:
//                System.out.println("bon");
//                break;
//            case 0:
//            case 1:
//            case 6:
//            case 8:
//                System.out.println("pon");
//                break;
//            default:
//                System.out.println("hon");
//                break;
//        }
//        String[] array = str.split(" ");
//        int sum = 0;
//        for(int i=0; i<array.length; i++) {
//            int num = Integer.parseInt(array[i]);
//            sum += num;
//        }
//        System.out.println(15-sum);
    }
}

Measured memory_bytes: 35592
X, K, D = map(int, input().split())

if abs(X) >= K*D:
    print(abs(X) - K*D)
else:
    n = abs(X) // D
    A = abs(X) - n * D
    if K % 2 == n % 2:
        print(A)
    else:
        print(abs(D-A))


Measured memory_bytes: 9144
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<map>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;

int main(){
	int n,ans=0;
	char s[55];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			i+=3;
			ans++;
		}else{
			i++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char c[500010];
int now;
int main(){
	scanf("%s",c+1);int n=strlen(c+1);ll ans=0;
	for(int i=1;i<=n;){
		int j=i;
		while(c[j]==c[i]&&j<=n)j++;
		if(c[i]=='>'){
			int gnow=j-i;
			ans+=1ll*now*(now+1)/2+1ll*gnow*(gnow+1)/2;
			ans-=min(now,gnow);
			now=0;
		}
		else now=j-i;
		i=j;
	}
	if(now)ans+=1ll*now*(now+1)/2;
	cout<<ans;
	return 0;
}


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

using namespace std;

int main(){
    vector<int> A(3);
    int sum=0;
    for(int i=0;i<3;++i){
        cin >> A[i];
        sum += A[i];
    }
    if(sum<22){
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }

    return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ma=0;
  string s;
  map<string,int> mp;
  vector<string> vec;
  queue<string> que;
  cin>>n;

  for(int i=0; i<n; i++){
    cin>>s;
    vec.push_back(s);
    mp[s]++;
  }

  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  ma=mp[vec[0]];
  que.push(vec[0]);
  for(int i=1; i<vec.size(); i++){
    if(mp[vec[i]]>ma){
      while(!que.empty())que.pop();
      que.push(vec[i]);
      ma=mp[vec[i]];
    }else if(mp[vec[i]]==ma){
      que.push(vec[i]);
    }

  }

  while(!que.empty()){
    cout<<que.front()<<'\n';
    que.pop();
  }   
  
  return 0;
}


Measured memory_bytes: 28400
#include <iostream>

using namespace std;

int main() {
	long long int k, s;
	cin >> k >> s;
	long long int ss = 0;
	for (long long int i = 0; i <= k; i++) {
		for (long long int j = 0; j <= k; j++) {
			if (s-i-j >= 0 && s-i-j <= k) {
				ss++;
			}
		}
	}
	cout << ss << endl;
	return 0;
}

Measured memory_bytes: 256
/*

by.YXH_XianYu
   2018.6.15
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>

int a,b;

int main(){
	//freopen("mothergoose.in","r",stdin);
	//freopen("mothergoose.out","w",stdout);

	scanf("%d%d",&a,&b);
	if(a>8 || b>8)
		printf(":(\n");
	else
		printf("Yay!\n");

	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
	if a%b==0:
		return b
	else:
		r=a%b
		return gcd(b,r)

def lcm(a,b):
	return a*b/gcd(a,b)


while True:
	try:
		a,b=map( int, raw_input().split() )
		print gcd(a,b),lcm(a,b)

	except EOFError:
		break


Measured memory_bytes: 4640
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	t := getString()

	if len(t) == len(s)+1 {
		x := t[:len(s)]
		// out(x, s)
		if x == s {
			out("Yes")
			return
		}
	}
	out("No")
}


Measured memory_bytes: 1756
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = "No";
		if (A % 2 == 1 && B % 2 ==1) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21204
#include<iostream>
using namespace std;
double abs(double x){
  return (x<0)?x*-1:x;  
}
int main(){
  int n,t,a,h,num;
  double b,most=0;
  cin >> n >> t >> a;
  for(int i=0;i<n;i++){
    cin >> h;
    if(i==0){
      num=1;
      most=t-h*0.006;
    }else{
      b=t-h*0.006;
      if(abs(a-b)<abs(a-most)){
        most=b;
        num=i+1;
      }
    }
  }
  cout << num <<endl;
}


Measured memory_bytes: 256