akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define MAX 100

main(){
  char input[MAX], output[MAX];
  int i, j, k, input_max;
  int res, flag = 0;
  int inputnum;


  while(1){
    /* read */
    for(i = 0 ; i < MAX ; i++){
      res = scanf("%c", &input[i]);

      if(res == EOF){
	flag = 1;
        break;
      }

      if(input[i] == '\n'){
        input[i] = '\0';
        input_max = i;
        break;
      }
    }

    if (flag == 1)break;

    /* analyze */
    j = 0;
    k = 0;
    for(i = 0 ; i < input_max ; i++){
      if(input[i] == '@'){
	inputnum = input[i+1];
	while(k < atoi(&inputnum)){
	  output[j] = input[i + 2];
	  j++;
	  k++;
	}
	k = 0;
	i += 2;
      }
      else{
	output[j] = input[i];
	j++;
      }
    }
    
    output[j] = '\0';
    
    /* output */
    for(i = 0 ; output[i] != '\0' ; i++){
      printf("%c", output[i]);
    }
    printf("\n");
  }

  return 0;
}

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

class Program
{
	static int N,M;
	static int maxPt;
	static int[][] abcd;

	//全探索関数
	static void Depth(int[] arr, int ind, int Ai){
			//最終インデックスの場合
			if(ind == N-1){
					//全探索
					for(int i=Ai; i<=M; i++){
							int[] newArr = new int[N];
							Array.Copy(arr, newArr, N);
							newArr[ind] = i;
							ScoreCheck(newArr);
					}
			}
			//最後ではない場合
			else{
					//全探索
					for(int i=Ai; i<=M; i++){
							int[] newArr = new int[N];
							Array.Copy(arr, newArr, N);
							newArr[ind] = i;
							Depth(newArr, ind+1, i);
					}
			}
	}

	//得点をチェックする関数
	static void ScoreCheck(int[] arr){
			int score = 0;

			foreach(int[] nums in abcd){
					if(arr[nums[1]-1] - arr[nums[0]-1] == nums[2]){
								score += nums[3];
					}
			}

			//Console.WriteLine(score);

			if(score > maxPt){
					maxPt = score;
			}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		N = int.Parse(line[0]);
		M = int.Parse(line[1]);
		int Q = int.Parse(line[2]);

		abcd = new int[Q][];
		for(int i=0; i<Q; i++){
				abcd[i] = new int[4];
				abcd[i] = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
		}

		//An格納する配列
		int[] An = new int[N];

		//全探索を開始
		for(int i=1; i<=M; i++){
				int[] newArr = new int[N];
				Array.Copy(An, newArr, N);
				newArr[0] = i;
				Depth(newArr, 1, i);
		}

		Console.WriteLine(maxPt);

	}
}



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

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

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

    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                sum = sum + gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int y, m , d;
    char c, e;
    cin >> y >> c >> m >> e >> d;
    if(m < 5)
    cout << "Heisei" << endl;
    else
    {
        cout << "TBD" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[200010];/*
signed main(){
  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;
  return 0;
}*/
signed main(){
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  int i=0,j=0;
  while(1){
    if(i*r>n) break;
    j=0;
    while(1){
      if(i*r+j*g>n) break;
      if((n-i*r-j*g)%b==0) ans++;
      j++;
    }
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

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


int main() {
    int K,A,B;
    cin >> K >> A >> B;
    string ans ="NG";
    for(int i=A;i<=B;i++){
        if(i%K==0){
            ans = "OK";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;

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

void testcase(){
    ll d,n;
    cin>>d>>n;
    if(d == 0){
        if(n == 100){
            cout << n + 1<< "\n";
            return;
        }
        cout << n << "\n";
    }
    else if(d == 1){
        if(n == 100){
            cout << n + 1<< "00\n";
            return;
        }
        cout << n << "00\n";
    }
    else{
        if(n == 100){
            cout << n + 1 << "0000\n";
            return;
        }
        cout << n << "0000\n";
    }
}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    testcase();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (auto &&e : l)
        cin >> e;
    int ans = 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 (l[i] == l[j] || l[j] == l[k] || l[k] == l[i])
                    continue;
                if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
                    ++ans;
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
	
int N ,M=0;
int X=0;
string S;
cin>>N>>S;
if(N>=1&&N<=100){

for(int i=0;i<N;i++){

	
	if(S[i]=='I')
		X++;
		else if(S[i]=='D'){
		X--;}
		if(M<X)
		M=X;
}

}
cout<<M;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  long long count=0;
  for(int  i=0;i<N;i++){
    cin >> L.at(i);
  }
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        int A=L.at(i);
        int B=L.at(j);
        int C=L.at(k);
        if(A==B || B==C || C==A){
          continue;
        }
        if(A<B+C && B<C+A && C<A+B){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}
        

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int main(){
    int N; cin >> N;
    vector<vector<int>> dist(N, vector<int>(N));
    vector<vector<int>> c(N, vector<int>(N, 1));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dist[i][j] = min(min(i, N-1-i), min(j, N-1-j));
        }
    }
    int res = 0;
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};
    for(int p=0;p<N*N;p++){
        int P; cin >> P;
        int a = (P-1)%N;
        int b = (P-1)/N;
        c[a][b] = 0;
        res += dist[a][b];
        for(int i=0;i<4;i++){
            int na = a + dx[i];
            int nb = b + dy[i];
            if(na < 0 || N <= na || nb < 0 || N <= nb) continue;
            dist[a][b] = min(dist[a][b], dist[na][nb] + c[na][nb]);
        }
        deque<pair<int, int>> qu; qu.emplace_back(a, b);
        while(!qu.empty()){
            auto pr = qu.front(); qu.pop_front();
            int a = pr.first;
            int b = pr.second;
            for(int i=0;i<4;i++){
                int na = a + dx[i];
                int nb = b + dy[i];
                if(na < 0 || N <= na || nb < 0 || N <= nb) continue;
                if(dist[na][nb] <= dist[a][b] + c[a][b]) continue;
                dist[na][nb] = dist[a][b] + c[a][b];
                if(c[na][nb]) qu.emplace_back(na, nb);
                else qu.emplace_front(na, nb);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6520
n = int(input())
a = list(map(int, input().split( )))
mx = max(a)
#+4は配列外とかの対応
l = [0 for _ in range(mx+4)]

#a[i]=0の処理が面倒なので+1,+2にずらす
for i in range(n):
    l[a[i]] += 1
    l[a[i]+1] += 1
    l[a[i]+2] += 1
#print(l)
lmax = max(l)

print(lmax)

Measured memory_bytes: 13964
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const S = arg[1].split("");
    
    if(S.length <= K) {
        console.log(S.join(""));
    } else {
        console.log(S.slice(0, K).join("") + "...");   
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  int k;
  int q;
  cin >> n;
  cin >> k;
  cin >> q;
  int a[q];
  int nc[n];
  rep(i,q)
  {
    cin >> a[i];
  }
  rep(i,n)
  {
    nc[i] = 0;
  }
  rep(i,q)
  {
    nc[a[i] - 1]++;
  }
  rep(i,n)
  {
    if(q - nc[i] >= k)
    {
      cout << "No" << endl;
    }
    else
    {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 1408
a = int(input())
b = int(input())
c = int(input())
x = int(input())

comb = 0

for i in range(0,a+1):
  for j in range(0,b+1):
    for k in range(0,c+1):
      total = int(500 * i + 100 * j + 50 * k)
      if total == x:
        comb += 1
print(comb)

Measured memory_bytes: 3064
from bisect import bisect_right, bisect_left
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for j in range(N):
    b = B[j]
    i = bisect_left(A, b)
    k = bisect_right(C, b)
    ans += i * (N - k)
print(ans)


Measured memory_bytes: 22720
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;

int main() {
	int n, x, t;
	cin>>n>>x>>t;
	int ans = n / x * t;
	if(n % x) ans += t;
	cout<<ans<<"\n";
	return 0;
} 

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int n; cin >> n && n; )
	{
		vector<vint> time(32);
		vector<pair<int, string> > scores(n, mp(0, ""));
		
		rep(i, n)
		{
			int times;
			cin >> scores[i].second >> times;
			
			rep(j, times)
			{
				int t;
				cin >> t;
				time[t].push_back(i);
			}
		}
		
		rep(i, 30)
		{
			int p = n - time[i].size() + 1;
			rep(j, time[i].size()) scores[time[i][j]].first += p;
		}
		
		sort(ALL(scores));
		cout << scores[0].first << " " << scores[0].second << endl;
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,alice=0,bob=0;
cin >> n;
vector <int> a(n);
rep(i,n){
    cin >> a[i];
} 

sort(a.begin(),a.end());

rep(i,n){
    if ((n%2 == 0 && i%2 != 0)||(n%2 != 0 && i%2 == 0))
    {
        alice += a[i];
    }else
    {
        bob += a[i];
    }
}
  
cout << alice-bob << endl;


//////////////////////////////////////////////////////
return 0;}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int root(int *u,int x){
  if(u[x]==x) return x;
  return u[x]=root(u,u[x]);
}

int same(int *u,int x,int y){
  return root(u,x)==root(u,y);
}

void unite(int *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  u[x]=y;
}

typedef struct mnode{
  int x,y;
  int index;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  if(p->x!=q->x) return p->x-q->x;
  return p->y-q->y;
}

void run(void){
  int n,k,l;
  scanf("%d%d%d",&n,&k,&l);
  int *road=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) road[i]=i;
  for(i=0;i<k;i++){
    int p,q;
    scanf("%d%d",&p,&q);
    unite(road,p-1,q-1);
  }
  int *rail=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) rail[i]=i;
  for(i=0;i<l;i++){
    int r,s;
    scanf("%d%d",&r,&s);
    unite(rail,r-1,s-1);
  }
  node *array=(node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    array[i].x=root(road,i);
    array[i].y=root(rail,i);
    array[i].index=i;
  }
  qsort(array,n,sizeof(node),cmp);
  int *ans=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    int j=i;
    while(j<n && cmp((void *)(array+i),(void *)(array+j))==0) j++;
    int k;
    for(k=i;k<j;k++) ans[array[k].index]=j-i;
    i=j-1;
  }
  for(i=0;i<n;i++) printf("%d ",ans[i]);
  printf("\n");
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MINUS(a) memset(a,0xff,sizeof(a))

long long N, K;
vector<long long> A;

long long dp[44][2];

long long rec(int digit, bool strict) {

  if (digit < 0) return 0;

  auto& ret = dp[digit][strict];
  if (ret != -1) return ret;

  long long mask = 1LL << digit;

  int cnt = 0;
  for (auto& e: A) if (e & mask) ++cnt;
  long long score0 = mask * cnt, score1 = mask * (N - cnt);

  if (strict) {
    if (K & mask) {
      // 1に遷移した場合, strict = true
      // 0に遷移した場合, strict = false
      return ret = max(rec(digit - 1, true) + score1, rec(digit - 1, false) + score0);
    } else {
      // 0にしか遷移できず, strict = true
      return ret = rec(digit - 1, true) + score0;
    }
  } else {
      // 0と1どちらに遷移しても良い (strict = false)
      return ret = rec(digit - 1, false) + max(score1, score0);
  }

}

signed main() {

  cin >> N >> K;
  A.resize(N); for (auto& e: A) cin >> e;

  MINUS(dp);

  cout << rec(43, true) << endl;

}


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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e5 + 5;

int n, m;
int a[300300];
ll l[300300], r[300300];
multiset <int> s;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	m = 3 * n;
	for(int i = 1; i <= m; ++i) {
		cin >> a[i];
		if(i <= n) {
			l[i] = l[i-1] + a[i];
			s.insert(a[i]);
		}
		else {
			l[i] = l[i-1];
			int mn = *s.begin();
			if(a[i] > mn) {
				l[i] -= mn;
				l[i] += a[i];
				s.erase(s.find(mn));
				s.insert(a[i]);
			}
		}
	}
	s.clear();
	for(int i = m; i >= 1; --i) {
		if(i >= m - n + 1) {
			r[i] = r[i+1] + a[i];
			s.insert(a[i]);
		}
		else {
			r[i] = r[i+1];
			int mx = *s.rbegin();
			if(a[i] < mx) {
				r[i] -= mx;
				r[i] += a[i];
				s.erase(s.find(mx));
				s.insert(a[i]);
			}
		}
	}

	ll ans = -9e18L;
	for(int i = n; i <= m - n; ++i) {
		ans = max(ans, l[i] - r[i+1]);
	}

	cout << ans;
	return 0;
}


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

int main(){
  char a;
  cin >> a;
  if(a=='A'){
    cout << "T";
  }
  else if(a=='C'){
    cout << "G ";
  }
  else if(a=='G'){
    cout << "C ";
  }
  else if (a== 'T'){
    cout << "A";
  }
}

    


Measured memory_bytes: 256
import math
N,K = map(int,input().split())
numGames = 1000
win = 0

probSum=0
for diceNum in range(1,N+1):
    if (diceNum<K):
        numHeadNeeded = math.ceil(math.log(K/diceNum,2))
    else:
        numHeadNeeded=0
    
    prob = (1/N)*((1/2)**(numHeadNeeded))
    probSum = probSum+prob

print(probSum)

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


int search_maxi(int array[26]){
  int maxi=0;
  for(int i=0;i<26;i++){
    if(array[maxi] < array[i]){
      maxi=i;
    }
  }
  return maxi;
}


bool check(int count[26],int maxi,int x){
  
  for(int j=0;j<26;j++){
    if( maxi!=j && count[j]+x >= count[maxi] ){
      return false;
    }
  }

  return true;
}


int main(){
  
  while(1){
    int n;
    int count[26]={};
    
    cin>>n;
    if(n==0)break;

    char ansC;
    int ansI=n+1;
    
    for(int i=0;i<n;i++){
      char ch;
      cin>>ch;

      int id=ch-'A';
      count[id]++;

      int maxi=search_maxi(count);
      
      if( check( count , maxi, n-1-i ) ){
        ansC=('A' + maxi);
        ansI=min(ansI,i+1);
      }
    }

    if(ansI==n+1){
      cout<<"TIE"<<endl;
    }else{
      cout<<ansC<<' '<<ansI<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    return [YES, NO][not (2*X <= Y <= 4*X and Y % 2 == 0)]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    print(solve(X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75332
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int count=0;
		for(int i=1;i<=n;i+=d*2+1)count++;
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ld> sd;
typedef set<ll> sl;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define Plabs     ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    Plabs;
    char c;
    cin>>c;
    if(c>=65 && c<=90)
    {
        cout<<"A";
    }else
    {
        cout<<"a";
    }
}











Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i <= n; i++)

int n, m, ans = 0;
bool flg[100100];
vi a[100100];
void nya(int n){
    flg[n] = true;
    for(int i : a[n]){
        if(!flg[i])
        nya(i);
    }
    return;
}
int main(){
    cin >> n >> m;
    rep(i, m){
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    rep(i, n){
        if(!flg[i]){
            nya(i);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12212
#include<cstdio>
#include<algorithm>

using int64=long long;

constexpr int Maxn(100000);

template<class _Tp>
	inline void chkMin(_Tp&x,const _Tp&y)
		{(x>y)&&(x=y);}

namespace IOManager{
	constexpr int FILESZ(131072);
	char buf[FILESZ];
	const char*ibuf=buf,*tbuf=buf;

	struct IOManager{
		inline char gc()
			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}

		template<class _Tp>
			inline operator _Tp(){
				_Tp s=0u;char c=gc();
				for(;c<48;c=gc());
				for(;c>47;c=gc())
					s=(_Tp)(s*10u+c-48u);
				return s;
			}
	};
}IOManager::IOManager io;

int lis[(Maxn<<1)+1],
	a[Maxn+1],
	b[Maxn+1];

int main(){
	const int n=io;
	int*const llis=lis+n;

	int64 ans=0,ts=0;
	for(int i=1;i<=n;++i)
		ans+=(lis[i]=a[i]=io),
		ts+=(llis[i]=b[i]=io);
	(ans>ts)&&(ans=ts);

	std::sort(lis+1,lis+n+n+1);

	int64 s[]={0,0,0};

	for(int i=1;i+1<n;++i)
		*s+=lis[i];
	s[1]=*s+lis[n-1];
	s[2]=s[1]+lis[n];

	for(int i=1,idx;i<=n;++i){
		ts=0;idx=n;

		if(a[i]<=lis[idx-1])
			++idx;
		else ts+=a[i];
		if(b[i]<=lis[idx-1])
			++idx;
		else ts+=b[i];

		chkMin(ans,s[idx-n]+ts);
	}

	return printf("%lld",ans),0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <utility>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    int g[110][110];
    int i, j;
    int u, k, v;
    int p;
    int dist[110];
    bool visited[110];
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            g[i][j] = 0;
        }
    }
    
    for(i = 0; i < n; i++){
        dist[i] = -1;
        visited[i] = false;
    }
    
    for(i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(j = 0; j < k; j++){
            cin >> v;
            v--;
            g[u][v] = 1;
        }
    }
    
    queue<int> q1, q2;
    q1.push(0);
    
    for(i = 0; q1.size(); i++){
        while(!q1.empty()){
            p = q1.front();
            q1.pop();
            
            if(visited[p]) continue;
            visited[p] = true;
            
            dist[p] = i;
            
            for(j = 0; j < n; j++){
                if(g[p][j]){
                    q2.push(j);
                }
            }
        }
        q1 = q2;
        while(!q2.empty()){
            q2.pop();
        }
    }
    
    for(i = 0; i < n; i++){
        printf("%d %d\n", i+1, dist[i]);
    }
}



Measured memory_bytes: 3264
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn next_animal(cond: char, a0: char, a1: char) -> char {
    if cond == 'o' {
        if a1 == 'S' && a0 == 'S' {
            'S'
        } else if a1 == 'S' && a0 == 'W' {
            'W'
        } else if a1 == 'W' && a0 == 'S' {
            'W'
        } else  {
            'S'
        }
    } else {
        if a1 == 'S' && a0 == 'S' {
            'W'
        } else if a1 == 'S' && a0 == 'W' {
            'S'
        } else if a1 == 'W' && a0 == 'S' {
            'S'
        } else  {
            'W'
        }
    }
}



fn solve(s: Vec<char>) -> Vec<char> {
    let s1 = vec!['S', 'S'];
    let s2 = vec!['W', 'W'];
    let s3 = vec!['W', 'S'];
    let s4 = vec!['S', 'W'];
    let mut results = vec![s1, s2, s3, s4];

    for i in 2..s.len() {
        let cond = s[i-1];
        for j in 0..4 {
            let a0 = results[j][i-2];
            let a1 = results[j][i-1];
            let next = next_animal(cond, a0, a1);
            results[j].push(next)
        }
    }


    let len = s.len();
    for r in results {
        let cond = s[len-1];
        let a0 = r[len-2];
        let a1 = r[len-1];

        let cond2 = s[0];
        let a02 = r[len-1];
        let a12 = r[0];
        if next_animal(cond, a0, a1) == r[0] && next_animal(cond2, a02, a12) == r[1] {
            return r
        }

    }
    return vec![];


}


fn main() {
    input! {
        n: i64,
        s: chars,
    }
    let result = solve(s);
    if result.is_empty() {
        println!("-1");
    }
    for c in result {
        print!("{}", c);
    }
    println!("");
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int& a : A) cin >> a;
  sort(A.begin(), A.end());

  if (N % 2 && A[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 1, now = N % 2 + 1;
  for (int i = N % 2; i < N; i += 2) {
    if (A[i] != now || A[i+1] != now) {
      cout << 0 << endl;
      return 0;
    }
    ans *= 2; ans %= 1000000007;
    now += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    lint X;
    cin >> X;
    lint a=100;
    lint ans =0;
    while(a<X){
        a*=1.01;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#define ll long long int

using namespace std;

int main(){

    int n;

    cin >> n;

    int y,m,d;

    ll ans=0;

    for(int i=0;i<n;i++){

        cin >> y >> m >> d;

        ans = 0;
        if(y%3==1){
            ans += (((1000-y-1)/3)+1)*200 + ((1000-y-1)-((1000-y-1)/3)-1) * 195;
        }
        else if(y%3==2){
            ans += (((1000 - y - 2) / 3) + 1) * 200 + ((1000 - y-2) - ((1000 - y-2) / 3)) * 195;
        }
        else{
            ans += ((1000-y-1)/3)*200 + ((1000-y-1) - (1000-y-1)/3) * 195;
        }
        if(y%3!=0){
            ans += (10-m)/2 * 20 + ((10-m-(10-m)/2)) * 19 + (19+m%2) - d + 1;
        }
        else {
            ans += (10-m) * 20 + 20 - d + 1;
        }

        cout << ans << endl;
    }

    return 0;
}


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

//main関数
int main() {
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> A(N),B(M),C(M);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    vector<pair<long,long>> charge(0);
    for(int i=0;i<M;i++){
        cin>>B.at(i)>>C.at(i);
        charge.push_back(make_pair(C.at(i),B.at(i)));
    }
    //計算
    sort(A.begin(),A.end());
    sort(charge.begin(),charge.end());
    vector<long> hyp(N,0);
    long g=M-1,count=0;
    for(int i=0;i<N;i++){
        if(g<0) break;
        
        hyp.at(i)=charge.at(g).first;
        count++;
        if(count>=charge.at(g).second){
            count=0;
            g--;
        }
    }
    long ans=0;
    for(int i=0;i<N;i++){
        //cout<<hyp.at(i)<<" "<<A.at(i)<<endl;
        ans+=max(hyp.at(i),A.at(i));
    }
    
    //出力
    cout<<ans<<endl;
    
    //cout<<endl<<charge.at(0).first;
}

Measured memory_bytes: 4976
n = int(input())
prime_list = []
result = []
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
for i in range(2,55556):
  if is_prime(i) == True and i % 5 ==1:
    prime_list.append(i)
    
for p in range(n):
  result.append(prime_list[p])
  
print(*result)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

vector<vector<ll>> e(100001,vector<ll>(0));


signed main(){
  ll n,b=0,w=0;
  cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    e[a].pb(b);
    e[b].pb(a);
  }

  vector<int> f(n+1,0);//1-black 2-white

  queue<ll> q;
  q.push(1);
  q.push(-n);
  f[1]=1;
  f[n]=1;
  while(!q.empty()){

    while(!q.empty() && q.front()>0){
      ll now=q.front();q.pop();
      rep(i,siz(e[now])){
        if(f[e[now][i]]==0){
          q.push(e[now][i]);
          f[e[now][i]]=1;
          b++;
        }
      }
    }


  while(!q.empty() && q.front()<0){
      ll now=q.front();q.pop();
      now*=-1;
      rep(i,siz(e[now])){
        if(f[e[now][i]]==0){
          q.push(-e[now][i]);
          f[e[now][i]]=1;
          w++;
        }
      }
    }
    

  }

  if(b>w)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vv vector<ll>
#define pp pair<ll,ll>
#define ff first
#define ss second
#define vp vector<pp>
#define ld long double
#define pb push_back
#define mp make_pair
const ll mod=7+1e9;
ll power(ll a,ll n)
{
	ll ans=1;
	a=a%mod;
	while(n>0)
	{
		if(n&1)
		{
			ans=(ans*a)%mod;
		}
		n=n>>1;
		a=(a*a)%mod;
	}
	return ans;
}
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r,d,x;
    cin>>r>>d>>x;
    ll n=10;
    while(n--)
    {
    	x=x*r-d;
    	cout<<x<<endl;
	}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  }


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int A;
	int B;

	scanf("%d", &A);
	scanf("%d", &B);

	int num1 = A + B;
	int num2 = A - B;
	int num3 = A * B;

	if (num1 > num2 && num1 > num3) {
		printf("%d", num1);
	}
	else if (num2 > num1 && num2 > num3) {
		printf("%d", num2);
	}
	else if (num3 > num1 && num3 > num2) {
		printf("%d", num3);
	}
    else if (num1 == num2 || num1 == num3){
        printf("%d",num1);    
    }
    else if (num2 == num3)
        printf("%d",num2);
      
      

	return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(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() {
  ll a;
  cin>>a;
  co(3*a*a);
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline



N, W = map(int, input().split())                                # N: 品物の種類 W: 重量制限

price_list = []
weight_list = []
for _ in range(N):
    weight, price = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)


################################################################################################################################################

def max2(x,y):
    """ pythonの組み込み関数 max は２変数に対しては遅い！！ """
    if x>y:
        return x
    else:
        return y


dp_min = 0                                                      # 総和価値の最小値

""" dp[weight <= W] = 重さ上限を固定した時の"最大"価値 """
dp = [dp_min] * (W + 1)

for item in range(N):
    for weight in reversed(range(weight_list[item], W + 1)):
        dp[weight] = max2(dp[weight], dp[weight - weight_list[item]] + price_list[item])


print(dp[W])

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

int main(){
    ll n;cin>>n;
    ll arr[n],s=0;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i+=2) 
        s+=(arr[i]&1); 
    cout<<s<<"\n";
}

Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = readLine()?.split(" ")?.map { it.toLong() } ?: return

    // ここで、操作制限があるのは 2で割る ことであることに着目すると,
    // 配列中の偶数要素の個数が問題になる.
    // n = x * 2^i という n を整数の範囲で 3倍、1/2、3倍、1/2...
    // と操作できる回数は i　回である.
    // 上記 n については、最初に何回3倍してもこの性質は崩れない
    // 戦略としては任意の2の倍数 n についてまず1/2操作、それ以外の要素にたいして3倍操作を行い
    // nが2の倍数ではなくなったら、別の2の倍数を選んで同じことを繰り返すのが最適
    // よって、n = x * 2^i の i を合計したものが、操作回数の最大値となる

    val result = aList.filter { it % 2L == 0L }
        .map {
            var i = 0
            var half = it
            while (half % 2L == 0L) {
                half /= 2
                i++
            }
            i
        }
        .sum()

    println(result)
}

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

using namespace std;

int main(void)
{
  int n;
  int result = 0;
  
  cin >> n;
  
  result = 1000 - n;
  
  while (result < 0) {
    result += 1000;
  }

  cout << result << endl;
}

Measured memory_bytes: 3632
//4
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	int a, b, n;
	cin >> a >> b >> n;
	bool ans = false;
	loop(i, n)
	{
		int s, f;
		cin >> s >> f;
		if (!(f <= a || b <= s))ans = true;
	}
	cout << ans << endl;
}


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

 int main() {

int N, T, A;
cin >> N >> T >> A ;
vector<double>H(N);

for(int i=0;i<N;i++) cin >> H.at(i);
for(int i=0;i<N;i++){
      H.at(i) = double(T) - 0.006*H.at(i);
      H.at(i) = abs(H.at(i) - double(A));
}
double diff = 100000 ;
double kai;
for (int i=0;i<N;i++){
       if(H.at(i)<diff){
                diff = H.at(i);
                kai = i+1;
        }
}
cout << kai << endl;

}



Measured memory_bytes: 256
X,Y,Z = gets.split.map(&:to_i)  # スペースで区切られた複数の整数
X.freeze
Y.freeze
Z.freeze
#配列生成
ary = Array.new(3, 0)

ary[0] = Z
ary[1] = X
ary[2] = Y

ans = ary[0].to_s + " " + ary[1].to_s + " " + ary[2].to_s
puts ans

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main() {
	int N = 0, M = 0, q = 0;
	int a[100000] = { 0 };
	long long int dp[100000] = { 0 };
	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		cin >> a[i];
		
	}
	if (a[0] == 1) {
		dp[0] = 0;
		q++;
		if (a[1] == 2) {
			dp[1] = 0;
		}
		else {
			dp[1] = 1;
		}
	}
	else {
		if (a[0] == 2 || a[1] == 2) {
			dp[1] = 0;
			q++;
		}
		else {
			dp[1] = 2;
		}
		dp[0] = 1;
	}
	
	for (int i = 2; i < N; i++) {
		if (a[q]-1 == i) {
			dp[i] = 0;
			q++;
		}
		else {
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= 1000000007;
		}
	}
	cout << dp[N - 1];
}
 

Measured memory_bytes: 1408
ans=0
s=input()
n=len(s)
# print((n-1)**2)
for i in range(2**(n-1)):
    # print(i)
    tmp=[]
    for k in range(n-1):
        # print("".join(tmp))
        tmp.append(s[k])
        if i>>k & 1:
            # print(114514)
            tmp.append("+")
    tmp.append(s[-1])
    # print("".join(tmp))
    ans+=eval("".join(tmp))
print(ans)
    




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

int main() {
  int N;
  set<string> S = {};
  string s;
  char c;
  
  cin >> N >> s;
  c = s[0];
    
  for(int i=0; i<N; i++) {
    if(S.end()==S.find(s) && c==s[0]) {
      S.insert(s);
    } else {
      cout << "No" << endl;
      break;
    }
    c = s[s.size()-1];
    cin >> s;
  }
  
  if(N==S.size()) {
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import collections
from scipy.misc import comb
n = int(input())
l = []
for i in range(n):
    s = input()
    s = ''.join(sorted(s))
    l.append(s)
c = collections.Counter(l)
r = 0
for i in list(c.values()):
    if i > 1:
        r += comb(i, 2, exact=True)
print(r)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m;
  cin>>n>>m;
  vll h(n);
  vvll edge(n);

  REP(i,n)cin>>h[i];
  REP(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }


  vector<bool> v(n,true);
  REP(i,n){
    for(auto e:edge[i]){
      if(h[i]<=h[e])
        v[i]=false;
    }
  }

  ll ans=0;
  REP(i,n){
    if(v[i])
      ans++;
  }

  cout<<ans<<endl;
}



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

const int MAX = 2001;
const int MOD = 1000000007;

void    ComInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
    fac.at(0) = 1;
    fac.at(1) = 1;
    finv.at(0) = 1;
    finv.at(1) = 1;
    inv.at(1) = 1;
    for (int i=2; i<MAX; i++) {
        fac.at(i) = (fac.at(i-1)*i) %MOD;
        inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
        finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD;
    }
}

long    COM(int N, int K, vector<long> &fac, vector<long> &finv) {
    if (N<K)
        return 0;
    if ((N<0)||(K<0))
        return 0;
    return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int main() {
    // Array
    vector<long> fac(MAX);
    vector<long> finv(MAX);
    vector<long> inv(MAX);
    // Initialize
    ComInit(fac, finv, inv);
    int n, k;
    cin >>n >>k;
    cout <<COM(n+k-1, k-1, fac, finv) <<endl;
    return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int output = 0;
		for(int i = 0;i<x;i++) {
			int temp = sc.nextInt();
			if(temp>=y)output++;
		}
		System.out.println(output);

	}

}


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

int main(){
int a,b,c,k;
cin >> a >> b >> c >> k;
if(a-k >= 0){
	cout << k <<endl;
}
else if(a+b-k >= 0){
	cout << a <<endl;
}
else{
	cout << 2*a +b-k <<endl;
}
}

Measured memory_bytes: 3632
#include<stdio.h>
int a[20];
int m[200];
void recursion(int,int);
int p;
int h = 0;
main(){
  int i;
  int q;
  scanf("%d", &p);
  for(i=0;i<p;i++)
    {
    scanf("%d", &a[i]);
    }
  scanf("%d", &q);
  for(i=0;i<q;i++)
    {
    scanf("%d", &m[i]);
    }
  for(i=0;i<q;i++)
    {
      h = 0;
      recursion(0,m[i]);
      if(h == 0) 
        printf("no\n");
      else
        printf("yes\n");
    } 
 return 0;
}
  
void recursion(int j, int k)
  {
    if(k == 0)
      h = 1;
    else if(p > j)
    {
     recursion(j + 1, k - a[j]);
     recursion(j + 1, k);
    }
  }

Measured memory_bytes: 580
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}


const ll N=2e5+5;



int main()
{ 

IOS;


ll l,r;
cin>>l>>r;

ll x=min(l+2030,r);

ll ans=2020;

for(ll i=l;i<=x;i++){
  for(ll j=i+1;j<=x;j++){
chmin(ans,(i*j)%2019);
  }
}

cout<<ans;


//end_routine();

return 0;
 
 }


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int s[11][11];
int k[11];
int p[11];
ll n,m,ans;

int l_ch(int d,int kk){
    if(d>=n){
        int f=1;
        rep(i,m){
            int ks=0;
            rep(j,k[i]){
                if(kk&(1<<(s[i][j]-1))) ks++;
            }
            if(ks%2!=p[i]){
                f=0;
                break;
            }
        }
        return f;
    }else{
        ll l1=l_ch(d+1,kk|(1<<d));
        ll l2=l_ch(d+1,kk);
        return l1+l2;
    }
}
int main(){
    cin>>n>>m;
    rep(i,m){
        cin>>k[i];
        rep(j,k[i]) cin>>s[i][j];
    }
    rep(i,m) cin>>p[i];
    ans = l_ch(0,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        while (!(line = br.readLine()).equals("-1")) {
            int q = Integer.parseInt(line);
            double x = q / 2.0;

            while (Math.abs(Math.pow(x, 3.0) - q) >= 0.00001 * q) {
                x = x - (Math.pow(x, 3.0) - q) / 3 / Math.pow(x, 2.0);
            }

            System.out.printf("%.6f%n", x);
        }
    }
}


Measured memory_bytes: 24724