akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 5e5 + 10;
int N;
LL A[500], S, X, D, ANS;
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%lld", &A[i]);
        if(i <= 2)
            S += A[i];
        else
            X ^= A[i];
    }
    if(S - X < 0 || (S - X) % 2 != 0)
    {
        printf("-1\n");
        return 0;
    }
    else
        D = (S - X) / 2;
    LL ANS = D;
    for(int i = 60; i >= 0; i--)
    {
        int x = ((X >> i) & 1LL), d = ((D >> i) & 1LL);
        if(d && x)
        {
            printf("-1\n");
            return 0;
        }
        if(!d && x && (ANS | (1LL << i)) <= A[1])
            ANS |= (1LL << i);
    }
    if(ANS == 0 || ANS > A[1])
        printf("-1\n");
    else
        printf("%lld\n", A[1] - ANS);
    return 0;
}


Measured memory_bytes: 3792
n = int(input())
s = [input().split() for _ in range(n)]
m = int(input())
t = [input().split() for _ in range(m)]
ans = -100
for i in s:
    ans = max(ans,s.count(i) - t.count(i))
if ans < 0:
    ans = 0
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    set<int> s;
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.merge(x, y);
    }
    rep(i, n) {
        s.insert(uf.root(i));
    }
    printf("%d\n", sz(s));
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int mx = 0;
  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    int p;
    cin >> p;
    ans += p;
    if ( p > mx ) { mx = p;} 
  }
  cout << ans - (mx/2) << endl;
  return 0;
}


Measured memory_bytes: 256
s =list(map(int, list(input())))
INF = 1001001001001
dp1=[INF]*1001001
dp2=[INF]*1001001
n=len(s)
dp1[n-1]=s[n-1]
dp2[n-1]=10-s[n-1]
for i in reversed(range(n-1)):
    if s[i]<9:
        dp1[i] = min(dp1[i+1]+s[i],dp2[i+1]+s[i]+1)
    dp2[i] = min(dp1[i+1]+10-s[i], dp2[i+1]+10-s[i]-1)
    
dp2[0]+=1
print(min(dp1[0], dp2[0]))



Measured memory_bytes: 141500
#134c
N = int(input())
list_A=[]
for i in range(N):
    list_A.append(int(input()))
    
# 1 以上 N 以下の各整数 iに対し、数列中の Aiを除く N−1 個の要素のうちの最大の値を求めよ。

max_1st_value_in_list_A = max(list_A)
max_1st_index_in_list_A = list_A.index(max(list_A))

list_A.pop(max_1st_index_in_list_A)

max_2nd_value_in_list_A = max(list_A)
#2番目に大きいもののインデックスは使わないのでコメントアウト
#max_2nd_index_in_list_A = list_A.index(max(list_A))
#
#if max_2nd_index_in_list_A>=max_1st_index_in_list_A:
#    max_2nd_index_in_list_A += 1  
#print(max_1st_index_in_list_A,max_1st_value_in_list_A)
#print(max_2nd_index_in_list_A,max_2nd_value_in_list_A)

for i in range(N):
    if i!=max_1st_index_in_list_A:
        print(max_1st_value_in_list_A)
    else:
        print(max_2nd_value_in_list_A)

Measured memory_bytes: 12520
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if 2*A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

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

long long N;
long long A[200005];

int main(){
	cin >> N;

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

	long long ans = 0;
	map<long long, long long> zero;
	for(long long i = 0; i < N; i++) {
		long long leftzero = i - A[i];
		long long rightzero = i + A[i];

		if(zero.count(leftzero))
			ans += zero[leftzero];

		zero[rightzero] += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 17640
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b;
  int i;
  char c[7]={};
  int d;
  scanf("%d%d",&a,&b);
  sprintf(c,"%d%d",a,b);
  d=atoi(c);
  // printf("%d\n",d);
  for(i=0;i*i<=d;i++){
    if(d==i*i){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


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

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

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

int main(){
  string s[3],ABC="ABC";
  REP(i,3){
    cin >> s[i];
  }
  int t=0;
  while(true){
    if (s[t]=="") {
      cout << ABC[t];
      return 0;
    } else if(s[t][0]=='a'){
      s[t]=s[t].substr(1);
      t=0;
    } else if(s[t][0]=='b'){
      s[t]=s[t].substr(1);
      t=1;
    } else if(s[t][0]=='c'){
      s[t]=s[t].substr(1);
      t=2;
    }
  }
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

#define T tuple<int, int, int, int>
const int MAX_N = 100000;
int N, X;
T data[MAX_N];
int S[MAX_N + 1];
int threshold = 0;

bool f(int x) {
    int full = min(N - 1, x / X); // いくつfullで選ぶか
    int remain = min(X, x - X * full); // 中途半端に選ぶのはいくつか

    for (int i = 0; i < N; i++) {
        int b = get<1>(data[i]);
        int l = get<2>(data[i]);
        int u = get<3>(data[i]);

        int remain_point = min(b, remain) * l + max(0LL, min(remain - b, X - b)) * u;
        int full_point;
        if (i + 1 > full) {
            full_point = S[full];
        } else {
            full_point = S[i] + (S[full + 1] - S[i + 1]);
        }

        if (remain_point + full_point >= threshold) return true;
    }

    return false;
}

signed main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        int b, l, u;
        cin >> b >> l >> u;
        int s = b * l + (X - b) * u;
        data[i] = T(s, b, l, u);
        threshold += l * b;
    }
    sort(data, data + N, greater<>());
    for (int i = 0; i < N; i++) {
        S[i+1] = S[i];
        S[i+1] += get<0>(data[i]);
    }

    int lb = -1;
    int ub = X * N + 1;
    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (f(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
    return 0;
}

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

signed main(){
    string s,n;
    cin >> s;

    if(s == "Sunny") {
      n = "Cloudy";
    }else if(s == "Cloudy"){
      n = "Rainy";
    }else if(s == "Rainy"){
      n = "Sunny";
    }
    
    cout << n << endl;
    return 0;
}
  

Measured memory_bytes: 256
//
// 二部グラフ判定 (by DFS)
//
// cf.
//   深さ優先探索 (DFS) による各種グラフ探索特集 (執筆予定)
//
//
// verified:
//   ARC 099 E - Independence
//     https://beta.atcoder.jp/contests/arc099/tasks/arc099_c
//


/*
    二部グラフかどうかを判定する
    また、各連結成分ごとに、(左ノード数, 右ノード数) を求める
 */


#include <iostream>
#include <vector>
using namespace std;


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



// nums[i] := i 番目の連結成分の {左ノード数, 右ノード数}, 「dir = 1: 左、-1: 右」
using pint = pair<int,int>;
using Graph = vector<vector<int> >;

bool dfs(const Graph &G, int v, int vdir, pint &num, vector<int> &dir) {
    bool res = true;
    dir[v] = vdir;
    if (vdir == 1) ++num.first;
    else if (vdir == -1) ++num.second;
    for (auto nv : G[v]) {
        if (dir[nv] == 0) {
            if (!dfs(G, nv, -vdir, num, dir)) res = false;
        }
        else if (dir[nv] != -vdir) res = false;
    }
    return res;
}

bool isbipartite(const Graph &G, vector<pint> &nums) {
    bool res = true;
    int N = (int)G.size();
    vector<int> dir(N, 0);
    for (int v = 0; v < N; ++v) {
        if (dir[v] != 0) continue;
        pint num = {0, 0};
        if (!dfs(G, v, 1, num, dir)) res = false;
        nums.push_back(num);
    }
    return res;
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int> > isexistedge(N, vector<int>(N, 1));
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b; --a, --b;
        isexistedge[a][b] = isexistedge[b][a] = 0;
    }
    Graph G(N);
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j)
        if (isexistedge[i][j] && i != j)
            G[i].push_back(j);
    
    // 二部グラフの構成
    vector<pint> nums;
    if (!isbipartite(G, nums)) {
        cout << -1 << endl;
        return 0;
    }
    
    // ナップサック DP
    vector<int> dp(N+10, 0);
    dp[0] = 1;
    for (int i = 0; i < (int)nums.size(); ++i) {
        for (int j = N; j >= 0; --j) {
            if (!dp[j]) continue;
            dp[j] = 0;
            dp[j + nums[i].first] = 1;
            dp[j + nums[i].second] = 1;
        }
    }
    
    long long a = -1;
    long long mindif = N;
    for (int i = 0; i <= N; ++i) {
        if (!dp[i]) continue;
        if (mindif > abs(i - N/2)) mindif = abs(i - N/2), a = i;
    }
    long long b = N-a;
    cout << a*(a-1)/2 + b*(b-1)/2 << endl;
}

Measured memory_bytes: 5120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 1e5 + 10;
vector<pii> za[nax];
int res[nax];
int maxKol;
int n;

void go(int vert, int parKol, int parent) {
	// printf("%d %d %d\n", vert, parKol, parent);
	int newCol = 0;
	for (auto v : za[vert]) {
		if (v.st == parent) {
			continue;
		}
		++newCol;
		if (newCol == parKol) {
			++newCol;
		}
		maxKol = max(maxKol, newCol);
		res[v.nd] = newCol;
		go(v.st, newCol, vert);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	rep(i,0,n-1) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		za[x].pb({y, i});
		za[y].pb({x, i});
	}
	go(0, -1, -1);
	cout << maxKol << endl;
	rep(i,0,n-1) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 8448
def solve():
	N, M = map(int, input().split())

	dp = [0]*(N+1)
	for _ in range(M):
		a = int(input())
		dp[a] = -1

	dp[0] = 1
	if dp[1]==-1:
		dp[1] = 0
	else:
		dp[1] = 1

	for i in range(2, N+1):
		if dp[i]==-1:
			dp[i] = 0
		else:
			dp[i] = dp[i-1] + dp[i-2]

	print(dp[N]%1000000007)

solve()


Measured memory_bytes: 460020
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll MOD=2019;
    ll l,r;
    cin>>l>>r;
    ll ans=(l*r)%MOD;
    for(ll i=l;i<min(r,l+MOD*2);i++){
        for(ll j=i+1;j<=min(i+2*MOD,r);j++){
            ans=min(ans,i*j%MOD);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#ifdef LOCAL
    #include "trace.h"
#else
    #define trace(args...)
#endif
 
ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int n; cin>>n;
	int cntr = 0;
	int ans = 0;
	for(int i = 0; i<n; i++){
		int x, y;
		cin>>x>>y;
		if(x==y) cntr++; else cntr = 0;
		ans = max(ans, cntr);
	}
	if(ans>=3)
		cout<<"Yes";
	else
		cout<<"No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3620
# Aizu Problem 0084: Search Engine
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")

letters = [chr(_) for _ in range(65, 91)] + [chr(_) for _ in range(97, 123)]

def search_engine(string):
    for char in ['.', ',']:
        string = string.replace(char, ' ')
    words = [word for word in string.split() if 3 <= len(word) <= 6 and word.isalpha]
    print(' '.join(words))

    
for line in sys.stdin:
    search_engine(line.strip())

Measured memory_bytes: 7568
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

const int MAX = 101;
const int INF = (1<<20);
int bill[2][MAX];
int T[2][MAX];
int n,ans;

void print(){

  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++)
      cout << T[i][j] << " ";
    cout << endl;
  }

}

void init(){

  for(int i = 0; i < 2; i++)
    for(int j = 0; j < MAX; j++)
      T[i][j] = INF;

}

int getpos(int pos,int sto,int add){
  pos = !pos;
  sto += add;
  
  int state = bill[pos][sto];

  //cout << "state " << state << endl;
  if(state == 0) return sto;

  if(state == 2){ while(bill[pos][sto] == 2 && sto > 0) sto--;}
  else if(state == 1){ while(bill[pos][sto+1] == 1 && sto < n-1) sto++;}

  return sto;
}

int solve(int start){
  init();

  int stasto = getpos(!start,0,0);

  //  T[start][0] = 0;
  T[start][stasto] = 0;

  priority_queue<PP,vector<PP>, greater<PP> > Q;

  //  Q.push(PP(0,P(start,0)));

  Q.push(PP(0,P(start,stasto)));

  while(!Q.empty()){
    PP pp = Q.top();
    Q.pop();

    int pos = pp.second.first;
    int sto = pp.second.second;

    if(pp.first > T[pos][sto]) continue;


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

      if(sto+i >= n) break;

      int movepos = getpos(pos,sto,i);

      //  cout << "from " << sto << " to " << bill[!pos][movepos] << endl;
      if(T[!pos][movepos] > pp.first+1){
	T[!pos][movepos] = pp.first+1;
	Q.push(PP(pp.first+1,P(!pos,movepos)));
      }
    }
  }
  //print();
  return min(T[0][n-1],T[1][n-1]);
}

int main(){

  while(cin >> n && n){

    for(int i = 0; i < 2; i++)
      for(int j = 0; j < n; j++)
	cin >> bill[i][j];

    ans = min(solve(0),solve(1));

    if(ans == INF) cout << "NA" << endl;
    else cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1196
import sys
from collections import defaultdict

N = int(sys.stdin.readline().rstrip())

d = defaultdict(int)

for _ in range(N):
    s = sys.stdin.readline().rstrip()
    d[s] += 1

# print(d)
d2 = sorted([(v, k) for k, v in d.items()])
m = max(d2)[0]  # v の回数で max を拾う
# print(m)
for v, k in d2:
    if v == m:
        print(k)


Measured memory_bytes: 48904
#include <stdio.h>

int main(){
	
	int n, k;
	
	scanf("%d", &n);
	scanf("%d", &k);
	int matrix[n];
	
	for(int i=0; i<n; i++){
		scanf("%d", &matrix[i]);
	}
	
	for(int i=0; i<n-k; i++){
		if(matrix[i]<matrix[i+k]){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	
	return 0;
}

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

	
int main(){
	const int N_MAX = 100000;
	const int BigNumber = 1000000007;	
	long long* RevFactrial = new long long[N_MAX];
	int number[N_MAX], counter[N_MAX];
	int N,R;
	
	RevFactrial[N_MAX-1] = 1;
	for(int i=N_MAX-2; i>=0; i--){
		RevFactrial[i] =  ((long long) RevFactrial[i+1] * (N_MAX -i-1)) % BigNumber;
	}
	while(true){
		cin >> N;
		if(N==0) break;
		cin >> R;
	
		for(int n=0; n<N; n++){
			number[n] = n;
			counter[n] = 0;
		}
		
		for(int r=0; r<R; r++){
			int s, t;
			cin >> s >> t;
			s--; t--;
			int ns = number[s];
			int nt = number[t];
			int cs = counter[t];
			int ct = counter[s];
				
			if(ns<nt)	cs++;
			else		ct--;
			for(int i=s+1; i<t; i++){
				int ni = number[i];
				if(ni < nt){
					cs++;
					if(ns<ni) counter[i]++;
				}
				if(ni < ns){
					ct--;
					if(nt<ni) counter[i]--;
				}
			}

			counter[s] = cs;
			counter[t] = ct;
			number[s] = nt;
			number[t] = ns;
		}

		long long  index = 0;
		for(int i=0; i<N-1; i++){
			index  +=  counter[i]*RevFactrial[N_MAX-N+i]%BigNumber;
		}
		cout << index%BigNumber << endl;
		
	}

	delete[] RevFactrial;
	return 0;
}

Measured memory_bytes: 2592
def main():
    s = input()
    ans = 0
    if s[0] == 'R' and s[0] == s[1] and s[1] == s[2]:
        ans = 3
    elif s[0] == 'R' and s[0] == s[1]:
        ans = 2
    elif s[1] == 'R' and s[1] == s[2]:
        ans = 2
    elif 'R' in s:
        ans = 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <unistd.h>
#include <stdio.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}

int main()
{
   int n,k,c;
   cin>>n>>k>>c;
   string inp;
   cin>>inp;
   vector<int> dpl(n+2,0);
   vector<int> dpr(n+2, 0);
//    dpl[0]=(inp[0]=='o') ? 1 : 0;
//    dpr[0] = (inp[n-1] == 'o') ? 1 : 0;
   
   int prev=-10000000;
   for(int i=1;i<=n;i++){
       if(inp[i-1]=='x') dpl[i]=dpl[i-1];
       else if(prev+c<i){
           prev=i;
           dpl[i]=dpl[i-1]+1;

       }
       else{
           dpl[i]=dpl[i-1];
       }

   }
   prev=-10000000;
   for (int i = 1; i<=n; i++)
   {
       if (inp[n-i] == 'x')
           dpr[i] = dpr[i - 1];
       else if (prev + c < i)
       {
           prev = i;
           dpr[i] = dpr[i - 1] + 1;
       }
       else
       {
           dpr[i] = dpr[i - 1];
       }
   }
   //printvec(dpl);
   //printvec(dpr);
   bool con=true;
   vector<int> ans;
   for(int i=1;i<=n;i++){
       if(dpl[i-1]+dpr[n-i]==k-1 && inp[i-1]=='o'){
           ans.pb(i);
       }
    //    else if (dpl[i-1] + dpr[n  - i] <k-1){
    //        //cout<<" oit "<<i<<endl;
    //        con=false;
    //        break;
    //    }
   }
   if(con) {
       fori(ans.size()) cout<<ans[i]<<endl;
   }
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  bool ans=false;
  for (int i=0; i<=(S.size()-1)/2; i++) {
    if (S.at(i)!=S.at(S.size()-1-i)) {
      ans = true;
      break;
    }
  }
  
  for (int i=0; i<=((S.size()-1)/2)-1; i++) {
    if (S.at(i)!=S.at((S.size()-1)/2-i-1)) {
      ans = true;
      break;
    }
  }
  
    for (int i=0; i<=((S.size()-1)/2)-1; i++) {
    if (S.at((S.size()+3)/2-1+i)!=S.at(S.size()-i-1)) {
      ans = true;
      break;
    }
  }
  
  if (ans==true) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,k,ans=0;cin>>n>>k;
    for(ll i=k;i<=n+1;++i)
    {
        ans=ans+((n-i+1)*i+1)%mod;
    }
    cout<<ans%mod;
    return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int cnt = 0;
        while (true) {
            String str = br.readLine();
            if (str.equals("0")) {
                break;
            }
            for (int i = 0; i < str.length(); i++) {
                cnt += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(cnt);
            cnt = 0;
        }
    }
}

Measured memory_bytes: 24188
/* Minimum Spanning Tree */
#include <stdio.h>
#include <limits.h>

#define MAX_N 100
#define INF INT_MAX/2
#define min(a,b) (a < b ? a : b)

int prim(int, int[MAX_N][MAX_N]);

int main()
{
    int n, i, j, a[MAX_N][MAX_N];
    scanf("%d", &n);
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            scanf("%d", &a[i][j]);
        }
    }
    printf("%d\n", prim(n,a));
    return 0;
}

int prim(int n, int a[MAX_N][MAX_N])
{
    int i, v, cost[MAX_N], used[MAX_N], res = 0;
    for(i=0; i<n; i++){
        cost[i] = INF;
        used[i] = 0;
    }

    cost[0] = 0;
    while(1){
        v = -1;
        for(i=0; i<n; i++){
            if(!used[i] && (v == -1 || cost[i] < cost[v])){
                v = i;
            }
        }
        if(v == -1){
            break;
        }
        used[v] = 1;
        res += cost[v];
        for(i=0; i<n; i++){
            if(a[v][i] == -1){
                continue;
            }
            cost[i] = min(cost[i], a[v][i]);
        }
    }
    return res;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    vi p(n);
    rep(i, n){
        cin >> p[i];
    }
    int ans = 0;
    rep(i, n-1){
        if(p[i] == i+1){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[n-1] == n) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
int gcd(int X,int Y){
  if(X<Y)
    swap(X,Y);
  while(1){
    if(X%Y==0){
      return Y;
      break;
      }
    int Z=X%Y;
    X=Y;
    Y=Z;
    }
  }
int can(int X,int Y){
  return X/gcd(X,Y)*Y;
  }
signed main(){
  int N;
  cin>>N;
  int ans;
  cin>>ans;
  rep(i,0,N-1){
    int X;
    cin>>X;
    if(X>=500000000000000000){
      ans=X;
      break;
      }
    ans=can(ans,X);
    }
  cout<<ans;
  }


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  rep (i, n) {
    cin >> w[i];
  }
  rep (i, n-1) {
    int l = w[i].length();
    if (w[i][l-1] == w[i+1][0]) {
      continue;
    } else {
      printf("No\n");
      return 0;
    }
  }
  rep (i, n) {
    FOR (j, i+1, n) {
      if (w[i] == w[j]) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,num[100005],pre[100005],suf[100005];
string st;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++) cin>>num[i];
	for (i=1;i<=n;i++) pre[i]=pre[i-1]+abs(num[i]-num[i-1]);
	for (i=n;i;i--) suf[i]=suf[i+1]+abs(num[i]-num[i+1]);
	for (i=1;i<=n;i++) cout<<pre[i-1]+suf[i+1]+abs(num[i-1]-num[i+1])<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        double a1, a2, b1, b2, c1, c2;
        a1 = (x2 - x1) * 2;
        b1 = (y2 - y1) * 2;
        c1 = x2 * x2  + y2 * y2 - x1 * x1 - y1 * y1;
        a2 = (x3 - x1) * 2;
        b2 = (y3 - y1) * 2;
        c2 = x3 * x3  + y3 * y3 - x1 * x1 - y1 * y1;
        
        double x, y, r;
        x = ((c1 * b2) - (c2 * b1)) / ((a1 * b2) - (a2 * b1));
        y = ((a1 * c2) - (a2 * c1)) / ((a1 * b2) - (a2 * b1));
        r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
        
        cout << setprecision(3) << fixed << x << " " << y << " " << r << endl;
    }
    
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  string ans = "Good";
  for(int i = 0; i < 3; i++){
    if(s[i] == s[i+1]) ans = "Bad";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#define N 200005
using namespace std;

typedef long long ll;
ll n, k, mx, s0, s1, s2, ans, l, r, md;
map<ll, ll> c1, c2;
vector<ll> a1, a2;

ll f12(ll p) {
	ll re = 0, i, j;
	j = 0;
	for (i = s1 - 1; i >= 0; i--) {
		for (; j < s2; j++) {
			if (a1[i] * a2[j] <= p) break;
		}
		re += (s2 - j);
	}
	return re;
}

ll com(ll p) {return p * (p - 1) / 2;}
ll f1(ll p) {
	ll t, re = 0, i, j, cut = 2e9, po, sq = sqrt(p);
//	re += com(c1[sq]);
//	cut = sq;
//	for (i = 0; i < s1 && a1[i] != cut; i++) {
//		po = p / (-a1[i]);
//		po *= -1;
//		if (po <= a1[i]) break;
//		t = upper_bound(a1.begin(), a1.end(), po) - a1.begin();
//		re += t;
//	}

	j = s1 - 1;
	for (i =0; i < s1; i++) {
		for (; j > i; j--) {
			if (a1[i] * a1[j] <= p) break;
		}
		re += max((j - i), 0ll);
	}
	return re;
}

ll f2(ll p) {
	ll re = 0, i, j, cut = 2e9, sq = sqrt(p);
//	if (sq * sq == p) {
//		re += com(c2[sq]);
//		cut = sq;
//	}
	j = s2 - 1;
	for (i =0; i < s2; i++) {
		for (; j > i; j--) {
			if (a2[i] * a2[j] <= p) break;
		}
		re += max((j - i), 0ll);
	}
	return re;
}

int main()
{
	ll i, t, cnt;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &t);
		if (t < 0) {
			a1.push_back(t);
			c1[-t]++;
		} else if (t == 0) {
			s0++;
		} else {
			c2[t]++;
			a2.push_back(t);
		}
	}
	s1 = a1.size();
	s2 = a2.size();
	if (!a1.empty()) sort(a1.begin(), a1.end(), greater<ll>());
	if (!a2.empty()) sort(a2.begin(), a2.end());
	l = -1e18;
	r = 1e18 + 1;
	while (r - l > 2) {
		md = (l + r) / 2;
		cnt = 0;
		if (md < 0) cnt += f12(md);
		else {
			cnt += s1 * s2;
			cnt += s0 * (s0 - 1) / 2;
			cnt += (s0) * (s1 + s2);
			if (md > 0) cnt += f1(md);
			if (md > 0) cnt += f2(md);
		}
		if (cnt >= k) {ans = md; r = md;}
		else l = md + 1;
	}
	for (i = r - 1; i >= l; i--) {
		md = i;
		cnt = 0;
		if (md < 0) cnt += f12(md);
		else {
			cnt += s1 * s2;
			cnt += s0 * (s0 - 1) / 2;
			cnt += (s0) * (s1 + s2);
			if (md > 0) cnt += f1(md);
			if (md > 0) cnt += f2(md);
		}
		if (cnt >= k) ans = md;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12904
#include <stdio.h>
using namespace std;
 
int main()
{
  long long int i,j,k,l;
  long long int A,B;
  A=0.0;
  B=0.0;
  double b;
  scanf("%lld %lf",&A,&b);
  b *= 100.0;
  b = b+0.5;
  B = (long long int)(b);
  
  A *= B;
  A /= 100;
  //i = (long long int)(A);
  i = A;
  
  printf("%lld\n",i);
    
  return 0; 
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int n, m, s[2000], t[2000], dp[2001][2001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    for (int i = 0; i < m; ++i)
        cin >> t[i];

    for (int j = m - 1; j >= 0; --j)
    {
        int dq = 0;
        for (int i = n - 1; i >= 0; --i)
        {
            dp[i][j] = dp[i][j + 1];
            if (s[i] == t[j])
            {
                adds(dp[i][j], 1);
                adds(dp[i][j], dq);
            }
            adds(dq, dp[i][j + 1]);
        }
    }
    int sol = 1;
    for (int i = 0; i < n; ++i)
        adds(sol, dp[i][0]);
    cout << sol;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
typedef long long i64;
i64 a[100],n;
void mins(i64&a,i64 b){if(a>b)a=b;}
int main(){
	for(int i=0;i<4;++i)scanf("%lld",a+i);
	scanf("%lld",&n);
	n*=4;
	for(int i=0;i<3;++i){
		for(int j=1;j<4;++j){
			mins(a[j],a[i]<<(j-i));
		}
	}
	printf("%lld",n/8*a[3]+n/4%2*a[2]+n/2%2*a[1]+n%2*a[0]);
	return 0;
}

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

if n == 1 and m == 1:
    print(1)
    exit()

if n == 1 or m == 1:
    if n > 1:
        ans = max(0,n-2)
    else:
        ans = max(0,m-2)
else:
    ans = n*m - (n*2 + m*2 - 4)

print(ans)

Measured memory_bytes: 3060
<?php
while(true)
{
    $stdin = trim(fgets(STDIN));
    if ($stdin === '')
    {
        break;
    }  
    $stdins[] = $stdin;
}
$shain = (int)$stdins[0];
$manageListTmp = explode(' ', $stdins[1]);
$manageListResult = [];
foreach ($manageListTmp as $manageTmp) {
    if(!isset($manageListResult[$manageTmp])) {
        $manageListResult[$manageTmp] = 0;
    }
    ++$manageListResult[$manageTmp];
}

for ($i = 1; $i <= $shain; $i++) {
    if (isset($manageListResult[$i])) {
        echo $manageListResult[$i];
    } else {
        echo '0';
    }
    if ($i != $shain) {
        echo "\n";
    }
} 

Measured memory_bytes: 38016
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <vector>
using namespace std;

int a[5], k;
string ans = "Yay!";

int main() {

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

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (a[j] - a[i] > k) ans = ":(";
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}




Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    clock_t start, end;
    start = clock();
    vite;
    char n;
    cin >> n;
    if(isupper(n))
        cout << "A";
    else
        cout << "a";
    end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    // cout<<fixed << time_taken << setprecision(5);
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	int card_A,card_B;
	int ans_A,ans_B;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
			
		ans_A=ans_B=0;
		
		for(i=0;i<n;i++)
		{
			cin >> card_A >> card_B ;
			if(card_A>card_B)
				ans_A+=card_A+card_B;
			else if(card_A == card_B)
			{
				ans_A+=card_A;
				ans_B+=card_B;
			}
			else
				ans_B+=card_A+card_B;
		}
		
		cout << ans_A << " " << ans_B << endl;
	}
}

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

int main() {
  int D, G;
  int p[10], c[10];
  vector< vector <int> > cand;
  vector<int> solve_all;
  vector<int> nums;
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
    solve_all.push_back(i);
  }
  for (int bit = 0; bit < (1<<D); bit++) {
    vector<int> tmp;
    for (int i = 0; i < D; i++) {
      if((bit & 1<<i)) tmp.push_back(solve_all[i]);
    }
    cand.push_back(tmp);
  }
  /*
  for (vector<int>  index_v : cand) {
    for (int  i : index_v) {
      cout << i;
    }
    cout << endl;
  }
  */
  vector<int> not_solve;
  cand.push_back(not_solve);
  for (vector<int> index_v : cand) {
    int sum_point = 0, sum_num = 0;
    for (int i: index_v) {
      sum_point += 100 * p[i] * (i+1) + c[i];
      sum_num += p[i];
    }
    vector<int> not_solve_all;
    for(int i = 0; i < D; i++) {
      if(binary_search(index_v.begin(), index_v.end(), i)) continue;
      not_solve_all.push_back(i);
    }
    // sort(not_solve_all.begin(), not_solve_all.rend());
    reverse(not_solve_all.begin(), not_solve_all.end());
    for(int i: not_solve_all) {
      for(int j = 0; j < p[i]; j++) {
        if (sum_point >= G) break; 
        sum_point += 100 * (i+1);
        sum_num++;
      }
    }
    nums.push_back(sum_num);
  }
  sort(nums.begin(), nums.end());
  cout << nums[0];
  return 0;
}

Measured memory_bytes: 504
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    int x,y;
    while (cin>>x>>y&&(x!=0||y!=0)) {
        for(int i=1;i<=x;i++)
            for(int j=1;j<=y;j++)
            {
                printf("#");
                if(j==y)printf("\n");
            }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>

int main()
{
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);
    if((N*A) < B) {
        printf("%d\n", N*A);
    }
    else if((N*A) > B) {
        printf("%d\n", B);
    }
    else {
        printf("%d\n", B);
    }
    return 0;
}


Measured memory_bytes: 128
s = gets.chomp
t = gets.chomp
ss = s.size
ts = t.size
ans = Float::INFINITY

0.upto(ss - ts) do |i|
  count = 0
  s[i, ts].each_char.with_index { |c, idx| count += 1 if c != t[idx] }
  ans = [ans, count].min
end

puts ans

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

int main(void){
    vector<int>X(26,0);
    string S;cin>>S;
    for(long long i=0;i<S.size();i++){
        X[(int)S[i]-97]++;
    }
    for(long long i=0;i<26;i++){
        if(X[i]==0){
            int ans=i+97;
            cout<<(char)ans<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 


int main(){
	ios_base::sync_with_stdio(false);
	ll n,h,w;cin>>n>>h>>w;
	ll x = max((ll)0,n-h+1);
	ll y = max((ll)0,n-w+1);
	cout<<x*y<<endl;
	
}

Measured memory_bytes: 256
# 配る DP
N = int(input())

INF = 1<<60
dp = [INF]*(N+1)
dp[0] = 0

# 配る DP --- dp[n] から遷移を出して行く
for i in range(N):
  pow6 = 1
  while pow6+i <= N:
    dp[i+pow6] = min(dp[i]+1, dp[i+pow6])
    pow6 *= 6
    
  pow9 = 1
  while pow9+i <= N:
    dp[i+pow9] = min(dp[i]+1, dp[i+pow9])
    pow9 *= 9

print(dp[N])

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S,T;
    cin >> S>> T;
    ll s = S.size();
    ll t = T.size();
    sort(all(S));
    sort(all(T));
    bool ans = false;
    bool chanse = true;
    rep(i,min(s,t)){
        if(S[i] < T[t - 1 - i]){
            ans = true;
            break;
        }
        else if(S[i] > T[t - 1 - i]){
            chanse = false;
            break;
        }
    }
    if(ans)cout << "Yes" << endl;
    else if(chanse && s < t)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef unsigned long long ll;
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 main(){

    ll a, h=100;
    double b;

    cin >> a >> b;
    b*=100.000000;
    ll c= b+0.1;
    ll ans = (a*c)/h;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n;cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  ll ans=0;
  for(int i=0;i<n-1;i++){
    ans+=a[n-1-(i+1)/2];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4848
(function(input) {
  'use strict';
  input.split("\n").some(function(line) {
    var number = parseInt(line, 10)
    while (number <= 999) {
      if (number % 111 == 0) {
        console.log(number)
        break
      } else {
        number += 1
      }
    }
  })
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[1]>s[0]||(s[1]==s[0]&&s[2]>s[0]))
		printf("%c%c%c",s[0]+1,s[0]+1,s[0]+1);
	else 
		printf("%c%c%c",s[0],s[0],s[0]);
}

Measured memory_bytes: 256