akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int a,b,c,temp;
  scanf("%d%d",&a,&b);
  if(a<b){
    temp=a;
    a=b;
    b=temp;
  }
  c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  printf("%d\n",b);
  return 0;
}



Measured memory_bytes: 2084
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



vll edge[MAX], node;
bool visited[MAX];
map<pll, ll> mp;
ll par[MAX], deg[MAX];

void dfs(ll cur, ll pre) {
  par[cur] = pre;
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i];
    if (visited[to]) continue;
    visited[to] = true;
    mp[pll(cur, to)]++;
    mp[pll(to, cur)]++;
    dfs(to, cur);
  }
  node.pb(cur);
}

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



  cin >> n >> m;
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  if (m % 2) {
    cout << "-1" << endl;
    return 0;
  }
  visited[1] = true;
  dfs(1, -1);
  vpll an;
  FOR(i, 1, n + 1) {
    rep(j, edge[i].size()) {
      ll to = edge[i][j];
      if (mp[pll(i, to)]) continue;
      an.pb(pll(i, to));
      deg[i]++;
      mp[pll(i, to)]++;
      mp[pll(to, i)]++;
    }
  }

  rep(i, n - 1) {
    ll cur = node[i];
    if (deg[cur] % 2) an.pb(pll(cur, par[cur]));
    else {
      deg[par[cur]]++;
      an.pb(pll(par[cur], cur));
    }
  }
  
  rep(i, an.size()) cout << an[i].first << " " << an[i].second << endl;


  return 0;
}


Measured memory_bytes: 38388
n, m = map(int, input().split())
a = [ i  for i in map(int, input().split())]

# print(n, m)
# print(a)

a.sort(reverse=True)
# print(a)

last = a[m-1]
# print(last)
total = sum(a)

if (last >= (total / (4 * m))):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 39860
#include <iostream>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if (c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }else if (c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }else if (c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }else if (c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }else if (c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
  int top(){
    return s[0];
  }
  int front(){
    return s[1];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
};

bool diceCheck(Dice diceA,Dice diceB){
  int i;

  if (diceA.right()==diceB.top())diceA.roll('W');
  else if (diceA.left()==diceB.top())diceA.roll('E');
  else {
    for (i=0;i<3;i++){
      if (diceA.top()==diceB.top())break;
      diceA.roll('N');
    }
    if (diceA.top()!=diceB.top())return false;
  }
  for (i=0;i<3;i++){
    if (diceA.front()==diceB.front())break;
    diceA.roll('R');
  }
  if (diceA.front()!=diceB.front())return false;
  for (i=2;i<6;i++){
    if (diceA.s[i]!=diceB.s[i])return false;
  }
  return true;
}
int main(){
  Dice diceA,diceB;
  int i;
  bool b=true;
  for (i=0;i<6;i++)cin>>diceA.s[i];
  for (i=0;i<6;i++)cin>>diceB.s[i];
  if (diceCheck(diceA,diceB))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned 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 (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,W;
  cin>>n>>W;
  
  int v[100],w[100];
  rep(i,n){
    cin>>v[i]>>w[i];
  }
  
  // dp[i+1][j]:=i番目の品物の中から重さの総和がj以下となるように選んだ時の価値の総和の最大値
  // ただし、同じ品物を選択可能である
  int dp[101][10001]={0};
  
  rep(i,n){ // 品物i
    for(int j=0;j<=W;++j){ // ナップサックの容量j
      if(j<w[i]){ // 入らない
        dp[i+1][j]=dp[i][j];
      }else{ // 入る
        // ”i-1番目までの品物から重さj以下となるように選んだ価値の総和”
        // VS
        // ”i番目の品物と、重複を許しi番目までの品物から重さがj-w[i]以下となるように選んだ価値の総和、の和”
        
        // 普通のナップサックと異なり、遷移前で品物iを含んでいる可能性があるため(同一の品物で2周目以降)、「品物iまでから重さj-w[i]以下で」となる
        dp[i+1][j]=max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
      }
    }
  }
  
  cout(dp[n][W]);
}


Measured memory_bytes: 7116
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
using ll = long long;

using namespace std;




int main()
{/*六日目*/
//少数も使いたい割り算はしない方がいい
// 数値の大きさ
//for文で0代入する場所はforの一文下
//オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
//for文いつも間違える/ i<nなら最後はa[n-1]

	int n; cin >> n;
	vector<ll> sur(n);
	bool ok = true;
	for (int i = 0;i < n;i++)
		cin >> sur[i];
	sort(sur.begin(), sur.end());
	for (int i = 1;i < n;i++) {
		if (sur[i - 1] == sur[i]) {
			ok = false;
			break;
		}
	}if (ok)
		cout << "YES";
	else
		cout << "NO";
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mpr            make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    int n,p=360;
    cin>>n;
    while(p%n!=0){
        p+=360;
    }
    cout<<p/n<<endl;
}



Measured memory_bytes: 3628
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L = map(int, readline().split())
    S = []
    for _ in range(N):
        S.append(input())
    S.sort()
    ans = ''
    for i in range(N):
        ans += S[i]
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a, b;
	char op;
	int ans;

	scanf("%d %c %d", &a, &op, &b);
	
	while(op != '?'){
		switch(op){
			case '+':
				ans = a + b;
				break;
			case '-':
				ans = a - b;
				break;
			case '*':
				ans = a * b;
				break;
			case '/':
				ans = a / b;
				break;
		}

		printf("%d\n", ans);
		scanf("%d %c %d", &a, &op, &b);
	}

	return 0;
}

Measured memory_bytes: 1028
a,b,c,d,e,f=map(int,input().split())
maxsugar=0
maxwater=100*a
for i in range(31):
    for j in range(31):
        for k in range(3001):
            water=100*a*i+100*b*j
            sugar=c*k
            if water+sugar>f:
                continue
            if sugar>(a*i+b*j)*e:
                continue
            sugar+=min((f-(water+sugar))//d*d,((a*i+b*j)*e-c*k)//d*d)
            if 100*maxsugar*(water+sugar)<100*sugar*(maxsugar+maxwater):
                maxsugar=sugar
                maxwater=water
print(maxsugar+maxwater,maxsugar)

Measured memory_bytes: 9156
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> v;
  double sum =0;
  int a;
  for(int i=0; i<n; i++){
    cin >>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  sum =v[0];
  for(int i=1; i<n; i++){
    sum=(sum+v[i])/2;
  }
  cout <<sum;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int MAX = 310;
vector<vector<char> > cake(MAX,vector<char> (MAX));
vector<vector<int> > ans(MAX,vector<int> (MAX,0));
int num = 1;

void dfs(int x_l, int x_h, int y_l, int y_h, int K){
  if(K==1){
    repp(y,y_l,y_h) repp(x,x_l,x_h) ans[x][y] = num;
    ++num;
    return;
  }

  vector<int> W_count(MAX,0);
  vector<int> H_count(MAX,0);
  repp(y,y_l,y_h) repp(x,x_l,x_h) if(cake[x][y] == '#'){
    ++W_count[x];
    ++H_count[y];
  }

  repp(x,x_l,x_h){
    if(W_count[x] ==K)break;
    if(W_count[x] >= 1){
      dfs(x_l,x+1,y_l,y_h,W_count[x]);
      dfs(x+1,x_h,y_l,y_h,K-W_count[x]);
      return;
    }
  }

  repp(y,y_l,y_h){
    if(H_count[y] >= 1){
      dfs(x_l,x_h,y_l,y+1,H_count[y]);
      dfs(x_l,x_h,y+1,y_h,K-H_count[y]);
      return;
    }
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W,K;cin >> H >> W >> K;
  rep(y,H)rep(x,W)cin >> cake[x][y];
  dfs(0,W,0,H,K);
  rep(y,H){
    rep(x,W) cout << ans[x][y] SPF;
    cout << endl;
  }
  return 0;

}


Measured memory_bytes: 2308
#include<iostream>

using namespace std;

int main() {
     int x ;
     int y ;
     char a ;
     char b ;
     cin >> x >> y;
   if (x < y ) {
     cout << "a < b" << endl;
  }
   else if (x == y ){
      cout << "a == b" << endl;
  }
   else if (x > y ){
       cout << "a > b" << endl;
  }
     return 0;
}  


Measured memory_bytes: 3084
/* All rights reserved.
* Author : yeguosheng
* FileName:
* Date : 2019-09-20-19.46.15
* Description : c
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#define lop(i,s,e)  for(int i = s;i <= e;i++)
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define inf 0x7fffffff
#define ll long long
#define esp 1e-9
using namespace std;
const int maxn = 1e5+5;
int n,k,q;
int arr[maxn];
int score[maxn];
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    for(int i = 1;i <= n;i++)
        arr[i] = k;//init
    int total = 0;
    int x;
    for(int i = 1;i <= q;i++)
    {
        cin>>x;
        score[x]++;
        total += 1;
    }
    for(int i = 1;i <= n;i++)
    {
        arr[i] -= (total - score[i]);
        if(arr[i] <= 0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int num = 100 * r + 10 * g + b;
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,X,i ;
  cin>>A>>B>>X ;
  if(A<=X&&B+A>=X){
    cout <<"YES"<<endl ;
  }else{
    cout <<"NO"<<endl ;
  }
  //cout <<(min(A,B)+min(C,D))<<endl ;
  return 0 ;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw" << endl;
  }
  else if(a == 1){
    cout << "Alice" << endl;
  }
  else if(b == 1){
    cout << "Bob" << endl;
  }
  else if(a > b){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll m = a + b;
  ll t = n / m;
  ll r = n % m;
  ll ans = t * a + min(r,a);
  cout << ans;

}


Measured memory_bytes: 256
package main
 
import (
  "fmt"
)
 
func main() {
  var a,b int
  fmt.Scanf("%d %d", &a, &b)
  
  if (a == 0) {
    fmt.Println("Even")
    return
  } else if (b ==0) {
    fmt.Println("Even")
    return
  } else {
    product := a * b
 
    if product % 2 == 0 {
      fmt.Println("Even")
      return
    } else {
      fmt.Println("Odd")
      return
    }
  }
}



Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAXE = 2020;
const int MAXV = 1010;
struct edge {
  int from;
  int to;
  int cost;
};
edge es[MAXE];
int d[MAXV];
int V, E;
void shortest_path(int s){
  for(int i=0;i<=V;i++) d[i]=1e9;
  d[s]=0;
  int cnt=0;
  while(true){
    bool update=false;
    for(int i=0;i<E;i++){
      if(d[es[i].from]!=1e9&&d[es[i].to]>d[es[i].from]+es[i].cost){
        d[es[i].to]=d[es[i].from]+es[i].cost;
        update=true;
      }
    }
    if(!update)break;
    cnt++;
    if(cnt > E) {
        cout<<"NEGATIVE CYCLE"<<endl;
        exit(0);
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin>>V>>E>>r;
  FOR(i,0,E){
      cin>>es[i].from>>es[i].to>>es[i].cost;
  }
  shortest_path(r);
  FOR(i,0,V){
      if(d[i] == 1e9) cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
  }
}


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

int n,ww;
int w[105],v[105];

int dp[105][105][305];

int w1;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n>>ww;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	w1=w[1];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			for(int mov=0;mov<=3*i;mov++)
			{
				if(j>=1&&mov>=w[i]-w[1])dp[i][j][mov]=max(dp[i-1][j][mov],dp[i-1][j-1][mov-w[i]+w[1]]+v[i]);
				else dp[i][j][mov]=dp[i-1][j][mov];
			}
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=3*n;j++)
		{
			long long we=(long long)i*w[1]+j;
			if(we<=ww)ans=max(ans,dp[n][i][j]);
		}
	}
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 11136
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}
int main(){
	//File();
	int a[4];
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	int z=a[3]-a[2];
	a[2]+=z;a[1]+=z;
	int q=a[3]-a[1];
	if(q&1)printf("%d\n",q/2+z+2);
	else printf("%d\n",q/2+z);
	return 0;
}

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

void solve()
{
	string s, t;
	cin >> s >> t;
	
	int sn = s.length(), tn = t.length();
	
	int mn = tn;
	for(int i = 0; i<=sn-tn; i++)
	{
		int curr = 0;
		for(int j = 0; j<tn; j++)
		{
			if(s[i+j] != t[j]) curr++;
		}
		mn = min(mn, curr);
	}
	cout << mn << "\n";
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#define MAX 100000

int main(void){
  int S[MAX],T[MAX],n,q,count=0,i,left,mid,right;
  
  scanf("%d",&n);

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

  scanf("%d",&q);

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

  /* for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	count++;
	break;            //codesA.c で用いたプログラム
      }
    }
  }
  printf("%d\n",count);
  */
  for(i=0;i<q;i++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right-1) / 2;
      if(S[mid] == T[i]){
	count++;
	break;
      }
      else if(T[i] < S[mid]){
	right = mid;
      } else{
	left = mid + 1;
      }
    }
  }
  printf("%d\n",count);
  return 0;  
}

Measured memory_bytes: 1192
// AOJ 2335: 10-Year-Old Dynamic Programming
// 2017.11.27 bal4u@uu

#include <stdio.h>

#define M 1000000007

int fact[2020001];

int extended_gcd(int a, int b, int *x, int *y)
{
	int d;

	if (b == 0) { *x = 1; *y = 0; return a; }
	d = extended_gcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

int inverse(int a)
{
    int x, y;
    if (extended_gcd(a, M, &x, &y) == 1) return (x + M) % M;
    return 0;
}

int comb(int n, int k)
{
    if (n < 0 || k < 0 || n < k) return 0;
	if (k == 0) return 1;
    return (long long)fact[n] * inverse(((long long)fact[k]*fact[n-k]) % M) % M;
}

int main()
{
	int n, m, k, i, j, ii, jj, kk;
	int ans, r, c;

	for (fact[0] = 1, i = 1; i < 2020001; i++) fact[i] = ((long long)fact[i-1]*i) % M;

	scanf("%d%d%d", &n, &m, &k);

    ans = 0; kk = n + m + (k << 1);
    for (i = 0; i <= k; i++){
        j = k-i, ii = n + (i << 1), jj = m + (j << 1);
        r = (comb(ii, i) - comb(ii, i-1) + M) % M;
        c = (comb(jj, j) - comb(jj, j-1) + M) % M;
        ans = (ans + ((long long)r*c) % M * (long long)comb(kk, ii)) % M;
    }
    printf("%d\n", ans);
}

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


int main() {
    int n, k; cin >> n;
    vector<int> a(n),b(n);

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

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

    for (int i = 0; i < (n); i++){
        if (a[i] == b[n - 1]) cout << b[n - 2] << endl;
        else cout << b[n - 1] << endl;
    }
}

Measured memory_bytes: 3200
#include <stdio.h> 

int main() {
  int n,x;
  int b,i,j,k,a;

  while(1) {
    scanf("%d %d",&n,&x);   
    b = 0;
    if( n == 0 && x == 0){
      break;
    }
    for(k = 1; k <= n ; k++) {


      for(j = 1; j <= n ; j++) {

	for(i = 1; i <= n; i++) {
	  
	  if(i == j || j == k || i ==k) {
	    
	  }else{
	    a = i + j + k;
	    if(a == x) {
	     
	      b += 1;
 
	    }
	  }
	  
	}//i
	
      }//j

    }//k
    printf("%d\n",b/6);
  }


  return 0;
}  
      

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



int main(){
	int x,y;
	cin >> x >> y;
	if(4*x - y >= 0 && y - 2* x >= 0 && y%2 ==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s=="Sunny")
    cout<<"Cloudy"<<endl;
  if (s=="Cloudy")
    cout<<"Rainy"<<endl;
  if (s=="Rainy")
    cout<<"Sunny"<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,k,x,y;
  int sum=0;
  scanf("%d %d %d %d",&n,&k,&x,&y);
  if(n<=k) sum=x*n;
  else sum=x*k+y*(n-k);
  printf("%d\n",sum);
  return(0);
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s,t;
  int n;
  cin>>n>>s>>t;
  string ret = string(n+n,' ');
  int cur = 0;
  for(int i=0;i<n;i++){
    ret[cur++] = s[i];
    ret[cur++] = t[i];
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,K,cnt,ans,tmp;
string S;

int main(){
    cin>>N>>K>>S;
    vector<int> z,o,vec;
    bool zeorone = (S[0]=='1');
    cnt=1;
    repi(i,1,N-1){
        if(S[i]=='0'){
            if(!zeorone)cnt++;
            else {
                o.push_back(cnt);
                cnt=1;
                zeorone = false;
            }
        }
        else{
            if(zeorone)cnt++;
            else {
                z.push_back(cnt);
                cnt=1;
                zeorone = true;
            }
        }
    }
    if(S[N-1]=='0'){
            if(!zeorone){
                cnt++;
                z.push_back(cnt);
            }
            else {
                z.push_back(cnt);
                o.push_back(1);
            }
    }
    else{
            if(zeorone){
                cnt++;
                o.push_back(cnt);
            }
            else {
                o.push_back(cnt);
                z.push_back(1);
            }
    }
    o.push_back(0);

    if(z.size()<=K)ans=N;
    else{  
        if(S[0]=='0'){
            rep(i,z.size()-K+1){
                rep(j,K){
                    tmp+=o[i+j]+z[i+j];
                }
                if(i)tmp+=o[i-1];
                vec.push_back(tmp);
                tmp=0;
            }
        }
        else{
            rep(i,z.size()-K+1){
                rep(j,K){
                    tmp+=o[i+j]+z[i+j];
                }
                tmp+=o[i+K];
                vec.push_back(tmp);
                tmp=0;
            }
        }
        rep(i,vec.size()){
            ans=max(ans,vec[i]);
        }
    }
    out(ans);

}


Measured memory_bytes: 1212
n = int(input())
evidences = [[] for _ in range(n)]
for i in range(n):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x-1, y))
result = 0
for i in range(1, 2**n):
    consistent = True 
    for j in range(n):
        if (i>>j) & 1 == 0:
            continue 
        for x, y in evidences[j]:
            if (i>>x)&1 != y:
                consistent = False 
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)



Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    ll n, k; cin >> n >> k;
    ll a = n%k;
    cout << min(a, k-a) << endl;
}

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

int a[15][15];

int main()
{
    int ans=0;
    //入力
    int n;
    cin>>n;
    rep(i,n) rep(j,n) a[i][j]=-1;   //a[i][j] = iの、kに対する証言
    rep(i,n){
        int num;
        cin>>num;
        rep(j,num){
            int x,y;
            cin>>x>>y;
            x--;
            a[i][x]=y;
        }
    }
    
    //bit全探索
    rep(i,1<<n){
        //正直者は誰か？
        vector<int> d(n);
        rep(j,n){
            if(i>>j&1){
                d[j]=1;
            }
        }
        //正直者なら、証言を照らし合わせる
        bool hantei=true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(a[j][k]==-1) continue; //証言していないなら、continue;
                    if(a[j][k]!=d[k]){
                        hantei=false;
                        break;
                    }
                }
            }
        }
        if(hantei) ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans;
}

Measured memory_bytes: 3620
import sys

NUM=3000
table = [""]*NUM

while True:
    T=str(input())
    if T == '-':
        break

    left=0
    right=0
    for i in range(len(T)):
        table[left+right] = T[right]
        right += 1
    num_shuffle = int(input())

    for loop in range(num_shuffle):
        pick_num = int(input())
        for i in range(pick_num):
            table[right+i]=table[left+i]
        left += pick_num
        right += pick_num

    for i in range(left,right):
        print("%s"%(table[i]),end="")
    print()



Measured memory_bytes: 5640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int r;

	cin >> r;

	cout << r*r << endl;

	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
 
mono = list(map(int,input().split()))
 
l =[0] * N
for i in range(N):
  if mono[i] >= sum(mono)/(4*M):
    l[i] = 1
    
if l.count(1) >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9132
import java.util.Scanner;

// Main
class Main {
	static final int INIT = 8;
	static int[] grow(int[] s) {
		int[] d = new int[s.length * 2];
		System.arraycopy(s, 0, d, 0, s.length);
		return d;
	}

	static class PrioQue {
		private int[] data;
		public PrioQue() {
			data = new int[INIT];
			// data[0] を項目数にする
		}
		public boolean isEmpty() {
			return data[0] == 0;
		}
		public void insert(int x) {
			int next = data[0] + 1;
			if (next >= data.length) {
				data = grow(data);
			}
			data[next] = x;
			data[0] = next;
			// up-heap
			int i = next;
			while (i >= 2) {
				int p = i / 2;
				if (data[p] < data[i]) {
					// 入れ替えて続行
					int t = data[p];
					data[p] = data[i];
					data[i] = t;
					i = p;
				} else {
					// ここで終わり
					break;
				}
			}
		}
		public int getMax() {
			return data[1];
		}
		public void deleteMax() {
			if (!isEmpty()) {
				// top へ入れ替え
				data[1] = data[data[0]];
				int size = data[0] - 1;
				data[0] = size;
				// down-heap
				for (int i = 1; ; ) {
					int c0 = i * 2;
					int c1 = i * 2 + 1;
					int c;
					if (c0 <= size && c1 <= size) {
						if (data[c1] > data[c0]) {
							c = c1;
						} else {
							c = c0;
						}
					} else if (c0 <= size) {
						c = c0;
					} else {
						break;
					}
					if (data[i] < data[c]) {
						// 入れ替えて続行
						int t = data[c];
						data[c] = data[i];
						data[i] = t;
						i = c;
					} else {
						// ここで終わり
						break;
					}
				}
			}
		}
	}

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			PrioQue[] qq = new PrioQue[n];
			for (int i = 0; i < n; i++) {
				qq[i] = new PrioQue();
			}
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int c = sc.nextInt();
				int t = sc.nextInt();
				switch (c) {
				case 0:
					int x = sc.nextInt();
					qq[t].insert(x);
					break;
				case 1:
					if (!qq[t].isEmpty()) {
						System.out.println(Integer.toString(qq[t].getMax()));
					}
					break;
				case 2:
					qq[t].deleteMax();
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 165448
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define 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; }

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

int main(){
    int n; cin >> n;
    int ac=0, wa=0, tle=0, re=0;
    rep(i, n){
        string s; cin >> s;
        if(s=="AC"){ac++;}
        else if(s=="WA"){wa++;}
        else if(s=="TLE"){tle++;}
        else if(s=="RE"){re++;}
    }
    cout<<"AC x "<< ac << endl;
    cout<< "WA x "<< wa << endl;
    cout<< "TLE x "<< tle << endl;
    cout<< "RE x "<< re << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> m;
  rep(i, n){
    int in;
    cin >> in;
    a.at(i) = in;
    m[in]++;
  }
  ll ans = 0;
  for(auto p : m){
    ans += (ll)p.second * (p.second-1) / 2;
  }
  rep(i, n){
    int now = a.at(i);
    ll tmp = ans;
    tmp -= (ll)m[now] * (m[now]-1) / 2;
    tmp += (ll)(m[now]-1)*(m[now]-2)/2;
    cout << tmp << endl;
  }
  return 0;
}

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

ll mod=1e9+7;
const ll Ma=1e7;

ll fact[Ma],inv[Ma],finv[Ma];

void setup(){
    fact[0]=fact[1]=finv[0]=finv[1]=inv[1]=1;
    for(int i=2;i<Ma;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
    

ll h(ll n,ll r){
    //n+r-1Cr
    ll x=n+r-1;
    //xCr
    return fact[x]*(finv[r]*finv[x-r]%mod)%mod;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    setup();
    
    ll n,m,x,f=2,ans=1;
    cin>>n>>m;
    x=m;
    
    map<ll,ll>mp;
    
    while(x>1){
        if(x%f==0){
            mp[f]++;
            x/=f;
        }
        else f++;
    }
    
    for(auto i:mp){
        ans*=h(n,i.second);
        ans%=mod;
    }
    
    if(m==1)ans=1;
    
    cout<<ans%mod<<endl;
    
    return 0;
}


Measured memory_bytes: 234624
#include <stdio.h>

int main(void) {
	int r,c,i,j;
	int box[101][101];
	scanf("%d %d",&r,&c);
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			box[i][j]=0;
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&box[i][j]);
			printf("%d ",box[i][j]);
			box[i][c] += box[i][j];
			box[r][j] += box[i][j];
		}
		printf("%d\n",box[i][c]);
	}
	for(j=0;j<c;j++){
		printf("%d ",box[r][j]);
		box[r][c] += box[r][j];
	}
	printf("%d\n",box[r][c]);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
			while(array[i] % 2 == 0) {
				count++;
				array[i] = array[i] / 2;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 34516
#!/usr/bin/env python3
N,M = map(int,input().split())

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

F = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            F = 1
            for k in range(M):
                for l in range(M):
                    if B[k][l] != A[i+k][j+l]:
                        F = 0
            if F:
                print('Yes')
                quit()
print('No')


Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,k=map(int, input().split())
    num=0
    if b-a>10**18:
        num='Unfair'
    else:
        if k%2==0:
            num=a-b
        else:
            num=b-a
    print(num)
resolve()

Measured memory_bytes: 3060
Module Module1
    Sub Main(ByVal args() As String)
        Dim a$ = Console.ReadLine()
        Dim ans% = 0
    	For i as integer = 1 To 4
            If Mid(a$, i, 1) = "2" Then ans% += 1
        Next
        Console.WriteLine(ans%)
  End Sub
End Module

Measured memory_bytes: 19792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m,k;
vector< pair<PII, PII> > v;
int res=0;
vector< vector<int> > vi[15];
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<k;i++)
	{
		int a,b,c,d;
		cin >>a>>b>>c>>d;
		a--,b--;
		v.push_back(MP(MP(a,b),MP(c,d)));
	}
	for (int i=0;i<m;i++) vi[1].push_back(vector<int>(1,i));
	for (int i=2;i<=n;i++)
	{
		for (int j=0;j<vi[i-1].size();j++)
		{
			for (int t=vi[i-1][j].back();t<m;t++)
			{
				vector<int> vt=vi[i-1][j];
				vt.push_back(t);
				vi[i].push_back(vt);
			}
		}
	}
	for (int i=0;i<vi[n].size();i++)
	{
		vector<int> vt=vi[n][i];
		int r=0;
		//for (int j=0;j<n;j++) cout <<vt[j]<<" ";
		//cout <<"\n";
		for (int j=0;j<k;j++)
		{
			if (vt[v[j].Fst.Snd]-vt[v[j].Fst.Fst]==v[j].Snd.Fst)
				r+=v[j].Snd.Snd;
		}
		res=max(res,r);
	}
	cout <<res;
	return 0;
} 

Measured memory_bytes: 16220
# https://atcoder.jp/contests/abc114/submissions/6262572

from itertools import product
N = input()
n = int(N)
ans = 0
for i in range(1,len(N)+1):
    for s in product(["3","5","7"],repeat=i):
        if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
            ans += 1
print(ans)


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

signed main() {
	int r, c;
	cin >> r >> c;

	vector<vector<int>> fig(r, vector<int>(c));

	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			cin >> fig[i][j];
		}
	}

	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			cout << fig[i][j] << ' ';
		}
		cout << accumulate(fig[i].begin(), fig[i].end(), 0) << endl;
	}

	int ssum = 0;

	for (int i = 0; i < c; ++i) {
		int sum = 0;
		for (int j = 0; j < r; ++j) {
			sum += fig[j][i];
		}
		cout << sum << ' ';
		ssum += sum;
	}
	
	cout << ssum << endl;
}
			





Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
using namespace std;
int a[300000];

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

    int n;cin>>n;

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

	int r_or=1,ans=0;

	for(int i=2;i<=n;i++)
	{
		if(a[i]>a[i-1])
			r_or++;
		else
		{
			ans=max(ans,r_or);
			r_or=1;
		}
	}
	ans=max(ans,r_or);
	cout<<n-ans<<"\n";
    return 0;
}


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

class Baseball{
private:
  int point;
  int runner;
  int out_count;
  void hit();
  void homerun();
  void out();
public:
  Baseball(){
    point = 0;
    runner = 0;
    out_count = 0;
  }
  ~Baseball(){}
  
  void show_point(){ std::cout << point << std::endl;}
  void start();
};

void Baseball::hit(){
  ++runner;
  if(runner == 4){
    ++point;
    --runner;
  }
}

void Baseball::homerun(){
  point += runner + 1;
  runner = 0;
}

void Baseball::out(){
  ++out_count;
}

void Baseball::start(){
  while(out_count < 3){
    std::string event;
    std::cin >> event;
    if(event == "HIT"){ hit(); }
    else if(event == "HOMERUN"){ homerun(); }
    else if(event == "OUT"){ out(); }
  }
}
 
int main(){
  int data_num;
  std::cin >> data_num;

  for(int i = 0; i < data_num; ++i){
    Baseball baseball;
    baseball.start();
    baseball.show_point();
  }
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int maxa = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    maxa = max(maxa, A[i]);
  }
  vector<int> B(maxa + 1, 0);
  for (int i = 0; i < N; i++) {
    int a = A[i];
    for (int k = 1; a * k < maxa + 1; k++) {
      B[a * k]++;
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (B[A[i]] == 1) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 7948
lists = {"a": 0, "b": 1, "c": 2}
a_list = list(input())
b_list = list(input())
c_list = list(input())
list_all = [a_list, b_list, c_list]
number=0
while list_all:
  if list_all[number] == []:
    break
  x = list_all[number].pop(0)
  number = lists[x]
print(x.upper())

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

int main(){
	int A, B, C, D, E, t = 0;
	cin>>A>>B>>C>>D>>E;
	
	if (B < 0){
		t +=  (B - A) * C * -1;
		cout<<t<<endl;
		return 0;
	} else if(A < 0) {
		t += A * C * -1;
		A = 0;
	}
	if(B == 0){
		t += D;
		cout<<t<<endl;
		return 0;
	}else if (A == 0){
		t += D;
	}

	t += E * (B - A);
	
	cout<<t<<endl;
			
	
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#define int long long
using namespace std;
const int MOD = 1e9+7;
 
int pot(int x, int p) {
if (p == 0) return 1;
int z = pot(x, p/2);
z = (z*z)%MOD;
if (p%2) z = (z*x) % MOD;
return z;
}
 
int inv(int x) {
return pot(x, MOD-2);
}
 const int MAX = 100000;
int pows[2*MAX + 10];
int powsinv[2*MAX + 10];
 
int calc(int a, int b) {
int x = pows[a+b-2] * powsinv[a-1] % MOD;
x = x * powsinv[b-1] % MOD;
return x;
}
 int a,b,w,h;
signed main(){
cin >> h >> w >> a >> b;
pows[0] = 1; powsinv[0] = 1;
for (int i = 1; i < 2*MAX + 10; i++) {
pows[i] = (pows[i-1] * i) % MOD;
powsinv[i] = inv(pows[i]);
}
 
int res = 0;
for (int i = b+1; i <= w; i++) {
  int x = calc(h - a, i) * calc(a, w-i+1) % MOD; 
  res = (res + x) % MOD;
}
 
cout << res << "\n";
return 0;
}

Measured memory_bytes: 3328
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if (a + b) == c || (b + c) == a || (a + c) == b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif


const LL INF = 1e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N;
    cin >> N;
    LL res = 1;
    for (int i = 0; i < N; i++) {
        LL A;
        cin >> A;
        if (A == 0) {
            cout << 0 << "\n";
            return 0;
        }
        if (res > 2*INF/A) res = INF+1;
        else res *= A;
    }
    if (res > INF) {
        cout << -1 << "\n";
    }
    else cout << res << "\n";
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   
    ll h,w;
    cin >> h >> w;
    ll num[26] = {};
    for (ll i=0;i<h;i++){
        string s;
        cin >> s;
        for (ll j=0;j<w;j++){
            num[s[j] - 'a']++;
        }
    }
    int flag = 0;
    if(h%2 == 0 and w%2 == 0){
        for (ll i=0;i<26;i++){
            if(num[i]%4 != 0){
                cout << "No" << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cout << "Yes" << endl;
        }
    }else if(h%2 == 0){
        ll num2 = 0;
        for (ll i=0;i<26;i++){
            if(num[i] % 2 != 0){
                cout << "No" << endl;
                flag = 1;
                break;
            }
            if(num[i]%4 != 0){
                num2++;
            }
        }
        if(flag == 0 and num2 <= h/2){
            cout << "Yes" << endl;
        }else if(flag == 0){
            cout << "No" << endl;
        }
    }else if(w%2 == 0){
        ll num2 = 0;
        for (ll i=0;i<26;i++){
            if(num[i] % 2 != 0){
                cout << "No" << endl;
                flag = 1;
                break;
            }
            if(num[i]%4 != 0){
                num2++;
            }
        }
        if(flag == 0 and num2 <= w/2){
            cout << "Yes" << endl;
        }else if(flag == 0){
            cout << "No" << endl;
        }

    }else{
        ll num1 = 0;
        ll num2 = 0;
        for (ll i=0;i<26;i++){
            if(num[i] % 2 != 0){
                num1++;
                if(num1 > 1){
                    cout << "No" << endl;
                    flag = 1;
                    break;
                }
            }else if(num[i]%4 != 0){
                num2++;
            }
        }
        if(flag == 0 and num2 <= w/2 + h/2){
            cout << "Yes" << endl;
        }else if(flag == 0){
            cout << "No" << endl;
        }

    }
}




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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n){
        cin >> s[i];
    }
    bool dp[101][10001];
    dp[0][0] = true;
    REP(i, 1, n+1){
        rep(j, 10001){
            if(j >= s[i-1]){
                dp[i][j] = dp[i-1][j] || dp[i-1][j-s[i-1]];
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    int ans = 0;
    repr(j, 10001){
        if(j % 10 == 0){
            continue;
        }
        if(dp[n][j]){
            ans = j;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	ans = 1;
	for (int i = 0; i < a; i++)
	{
		cin >> b;
		x[b]++;
	}
	if (a%2==0)
	{
		for (int i = 1; i < a; i+=2)
		{
			if (x[i]!=2)
			{
				cout << 0 << endl;
				return 0;
			}
			ans *= 2;
			ans %= 1000000007;
		}
	}
	else
	{
		if (x[0]!=1)
		{
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < a; i += 2)
		{
			if (x[i] != 2)
			{
				cout << 0 << endl;
				return 0;
			}
			ans *= 2;
			ans %= 1000000007;

		}
	}
	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

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

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 8064
#include <stdio.h>

int main(void){
  int N,M,X;
  int A[100];
  int count1=0;
  int count2=0;
  scanf("%d%d%d",&N,&M,&X);
  for(int i=0;i<M;i++){
   scanf("%d",&A[i]);
    if(A[i]<X){
      count1++;
    }else if(A[i]>X){
      count2++;
    }
    
    
  }
  
  if(count1>=count2){
    printf("%d",count2);
  }else{
    printf("%d",count1);
  }
  
  
  return 0;
}

Measured memory_bytes: 128