akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
//#define ForJ(n) for(int j=0;j<n;j++)
//#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

int Product_set_min(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= lb;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= la;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= la;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
int Product_set_max(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= rb;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
string min (string m){
    transform(m.begin(), m.end(), m.begin(),towlower);
    return m;
}
signed  main(){
    int x,y,z;
    cin >> x>>y>>z;
    if (x%(y+z)<z) {
        cout<<x/(y+z)-1<<endl;
    }else{
        cout<<x/(y+z)<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case #%d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
 
using namespace std;
 
 
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
const int N = 1e5 + 5;
#define piii pair<int, pair<int,int> >
 
int arr[N*2],n;
int f(int x){
  int mx = 0,i;
  loop1(i,n)mx = max(mx, x^arr[i]);
  return mx;
}
int main()
{
  char a;
  cin >> a;
  cout << (char)(a+1) << endl;
}

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

signed main() {
  string S;
  cin >> S;
  reverse( S.begin(), S.end() );
  
  vector<string> T(4);
  T = { "dream", "dreamer", "erase", "eraser" };
  for( int i = 0; i < 4; i++ ){
    reverse( T.at(i).begin(), T.at(i).end() );
  }
  
  bool ok;
  for( int i = 0; i < S.size(); i++ ){
    ok = false;
    for( int j = 0; j < 4; j++ ){
      if( S.substr(i, T.at(j).size()) == T.at(j) ){
        ok = true;
        i += T.at(j).size()-1;
        break;
      }
    }
    if( ok == false ){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,c,b,d;
	int x,y;
	cin>>a>>c>>b>>d;
	x=max(a,b);
	y=min(c,d);
	if(x>y){
		cout<<0<<endl;
	}
	else{
		cout<<y-x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b+c || b==a+c || c==a+b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,R;
    cin >> N >> R;
    cout << R + 100 * max(0,10 - N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
int main(){
  int N; cin>>N;
  string s,t;
  cin>>s>>t;
  int ans = 2*N;
  rep(i,N){
    string ss = s.substr(i,N-i);
    string tt = t.substr(0,N-i);
    if(ss == tt){
      ans = N+i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  Dijkstra<long> D1(N), D2(N);
  for (int i = 0; i < M; i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    D1.add(--u, --v, a);
    D2.add(u, v, b);
  }
  D1.solve(--S);
  D2.solve(--T);
  vector<long> sum(N);
  for (int i = 0; i < N; i++) {
    sum.at(i) = D1.dist.at(i) + D2.dist.at(i);
  }
  for (long i = N - 1, mi = LONG_MAX; i >= 0; i--) {
    sum.at(i) = (mi = min(mi, sum.at(i)));
  }
  for (int i = 0; i < N; i++) {
    cout << (long) 1e15 - sum.at(i) << "\n";
  }
}

Measured memory_bytes: 19012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		String T = scanner.nextLine();
		scanner.close();

		boolean flag = false;

		for (int n = 0; n < S.length(); n++) {
			if (S.equals(T)) {
				flag = true;
				break;
			}

			String s = S.substring(S.length() - 1, S.length());
			S = S.substring(0, S.length() - 1);
			S = s + S;
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
array=[]
while gets
    win="d"
    p=0
    array=$_.chomp
    0.step(8,3) do |i|
        if((array[0+i]==array[1+i]) && (array[1+i]==array[2+i]) && (array[0+i]!="s"))#?¨?
            win=array[0+i]
            break
        end
        if((array[3*0+p]==array[3*1+p]) && (array[3*1+p]==array[3*2+p]) && (array[3*0+p]!="s"))#???
            win=array[3*0+p]
            break
        end
        p+=1
    end
    win=array[0] if(array[0]==array[4]&&array[4]==array[8]&&array[0]!="s")#??????
    win=array[2] if(array[2]==array[4]&&array[4]==array[6]&&array[2]!="s")#??????
    puts win
end

Measured memory_bytes: 6104
/* 
    Author : Jeff Ahn
    Sat 27 Jun 2020 05:01:34 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

signed main() {
  fastio;
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int res = 0;
  for (int i = 0; i< n; i++) {
    if (s[i] != t[i]) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum3;
    char name[5];
    cin>>name;
    int j,k=0;
    for(i=0;i<4;i++)
    {
        for(j=i+1;j<4;j++)
        {
            if(name[i]==name[j])
            {
                k++;
            }
        }
    }
    if(k==2)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim()
{
  int i, u, v, minv, sum;
  int d[MAX], p[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFINITY;
      p[i] = -1;
      color[i] = WHITE;
    }

  d[0] = 0;

  while(1)
    {
      minv = INFINITY;
      u = -1;
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( u == -1 ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFINITY )
	    {
	      if( d[v] > M[u][v] )
		{
		  d[v] = M[u][v];
		  p[v] = u;
		  color[v] = GRAY;
		}
	    }
	}
    }

  sum = 0;
  for( i=0; i<n; i++ )
    {
      if( p[i] != -1 ) sum += M[i][p[i]];
    }

  return sum;
}


int main()
{
  int i, j, x;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  scanf("%d", &x);
	  if( x == -1 )
	    {
	      M[i][j] = INFINITY;
	      continue;
	    }
	  M[i][j] = x;
	}
    }

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

  return 0;
}





Measured memory_bytes: 2128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '1') {
			cout << 9;
		}
		else if (N[i] == '9') {
			cout << 1;
		}
	}

	cout << endl;

}






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


int main() {
  ll A, B, C, D, E, F;
  cin >> A >> B >> C;
  ll a = A, b = B, c = C;
  ll result = 0;
  if (A == B && A == C && B == C && A % 2 == 0) {
    result = -1;
  } else {
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
      D = A / 2 + B / 2;
      E = B / 2 + C / 2;
      F = A / 2 + C / 2;
      A = D;
      B = E;
      C = F;
      ++result;
      if ((A == a || A == b || A == c) && (B == a || B == b || B == c)) {
        result = -1;
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
n = int(input())
Ss = []
for i in range(n):
    Ss.append(input())

minfreq = dict()
for i in range(ord('a'), ord('z')+1):
    minfreq[chr(i)] = 500000

for S in Ss:
    freq = dict()
    for i in range(ord('a'), ord('z')+1):
        freq[chr(i)] = 0

    for c in S:
        freq[c] += 1

    for c in freq:
        minfreq[c] = min(minfreq[c], freq[c])

out = ""
l = list(minfreq.items())
l.sort()
for c,x in l:
    out += c*x
print(out)

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

string S; int K;
vector<int64_t> v;
vector<int64_t> s;    //v[i]の文字の連続数

int ctoi(char c){  return (c - '0'); }

int main(){
  cin >> S >> K;

  int i = 0; int j = 0;
  while(i < S.size()){
    while(S[i] == S[i+j]) j++;
    v.push_back(ctoi(S[i]));
    s.push_back(j);
    i += j; j = 0;
  }

  /*最初の文字が1だったら、1の連続(他の数がでないまで)がK以下なら、遷移後のK番目の文字は1である。一方で、最初の文字が1でない、乃至は1であるが連続数がKを下回っている場合2以上の数字との関わりが確定。2^5000兆はKの最大値のはるか上なので、その値を表示？*/
  if(v[0] == 1){
    if(s[0] >= K) cout << v[0] << endl;
    else cout << v[1] << endl;
  }else cout << v[0] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N,Q,a[100010],b[100010],n[100010],w[100010],ed[100010];

int main()
{
	scanf ("%d %d",&N,&Q);
	for (int i=1;i<=Q;i++) scanf ("%d %d",&a[i],&b[i]);

	w[0] = 1;
	for (int i=1;i<=Q;i++){
		if (w[i-1] == a[i]) w[i] = b[i];
		else if (w[i-1] == b[i]) w[i] = a[i];
		else w[i] = w[i-1];
	}

	ed[w[Q]] = 1;
	for (int i=1;i<=N;i++) n[i] = i;
	for (int i=Q;i>=0;i--){
		if (w[i] > 1) ed[n[w[i]-1]] = 1;
		if (w[i] < N) ed[n[w[i]+1]] = 1;
		int t = n[a[i]];
		n[a[i]] = n[b[i]];
		n[b[i]] = t;
	}

	int ans = 0;
	for (int i=1;i<=N;i++) if (ed[i]) ans++;
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++)
        {
            int j;
            cin >> j;
            j--;
            v[j]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if(v[i]==0)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

#define N 101
#define Black 2
#define White 0
#define Gray  1

int z=0;
int n=0;
int G[N][N];
int d[N];
int f[N];
int color[N];


void DFS_Visit(int u){
  int t;
  color[u] = Gray;
  d[u] = ++z;
  for(t=0;t<n;t++){
    if(G[u][t] == 1 && color[t] == White){
      DFS_Visit(t);
    }
  }
  color[u] = Black;
  f[u] = ++z;
}


void DFS(){
  int u;
  z = 0;
  for(u=0;u<n;u++){
    color[u] = White;
  }
  for(u=0;u<n;u++){
    if(color[u] == White){
      DFS_Visit(u);
     }
  }
}  
  
  


main(){
  int i,j,s,v,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0; j<n;j++){
      G[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d", &v,&r);
    for(j=0;j<r;j++){
      scanf("%d",&s);
      G[i][s-1] = 1;
    }
  }
  DFS();
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1, d[i], f[i]);
  }
  return 0;
}
 

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
	cin >> a.at(i);    
  }
  sort(a.begin(), a.end());
  
  int count = 0;
  for(int i = 0; i < N; i++){
    if(i > 0 && a.at(i) == a.at(i-1))
      continue;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/04/27
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t;

long long int A[100001] = {0};

int main()
{
	int N = 0, i = 0;
	int minus_count = 0, zero_count=0;
	long long int min = 1000000000;
	uint64_t sum = 0;
	scanf("%d",&N);
	for(i = 0; i < N; i++) {
		scanf("%lld",&A[i]);
		if(A[i] < 0) {
			minus_count++;
		}
		if(A[i] == 0){
			zero_count++;
		}
		if(abs(A[i]) < min) {
			min = abs(A[i]);
		}
		sum += abs(A[i]);
	}
	//printf("sum=%llu minus=%d zero=%d min=%d\n", sum, minus_count, zero_count, min);


	if(((minus_count%2) != 0) && (zero_count == 0)) {
		sum -= (min*2);
	}
	printf("%llu", sum);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long int M;
  cin >> M;
  //--M;
  cout << ((M-1)*M)/2 << '\n';
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char map[105][105];
int n,m,dx[]={0,0,-1,1},dy[]={1,-1,0,0},ans;
void dfs(int x,int y,char ch)
{
	map[x][y]=0;
	for(int i=0;i<4;++i)
	{
		int tx=x+dx[i],ty=y+dy[i];
		if(tx<0||tx>=n||ty<0||ty>=m||map[tx][ty]!=ch)
		{
			continue;
		}
		dfs(tx,ty,ch);
	}
}
int main()
{
	while(scanf("%d%d",&n,&m),n|m)
	{
		for(int i=0;i<n;++i)
		{
			scanf("%s",&map[i]);
		}
		ans=0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<m;++j)
			{
				if(map[i][j])
				{
					++ans;
					dfs(i,j,map[i][j]);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  int _d = pow(100, d);
  int cnt = 0;
  REP(i, 1, 10000000) {
    if (i % _d == 0) {
      int tmp = i / _d;
      if (tmp % 100 != 0) {
        cnt++;
        if (cnt == n) {
          cout << i << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  a = list(map(int,input().split()))
  x = c
  for j in range(m):
    x += a[j]*b[j]
  if x > 0:
    ans += 1
print(ans)

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, m, ans = 0;
    cin >> n >> m;
    vll a(m);
    cin >> a;
    ans = sum(a);
    if(n<ans) cout << -1 << endl;
    else cout << n-ans << endl;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
    using namespace std;
    void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
        }

    int main(){
       init();
       string s,t;
       cin>>s>>t;
       string x=t.substr(0,t.length()-1);
       if(x==s){
        if(t.length()-s.length()==1)cout<<"Yes";
        else cout<<"No";
       }else cout<<"No";




              return 0;}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int W, a, b;
  cin >> W >> a >> b;

  if(a <= b){
    if(b <= a+W){
      cout << 0 << endl;
    }
    else{
      cout << b - (a+W) << endl;
    }
  }
  else{
    if(a < b+W){
      cout << 0 << endl;
    }
    else{
      cout << a - (b+W) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    ll N, K;
    cin >> N >> K;
    ll a, b;
    map<ll, ll> m;
    map<ll, ll>::iterator ite;
    rep(i, N) {
        cin >> a >> b;
        ite = m.find(a);
        if (ite == m.end()) m.insert(make_pair(a, b));
        else {
            m[a] += b;
        };
    }

    ll c = 0;
    for (ite = m.begin(); ite != m.end(); ite++) {
        ll a = ite->second;
        if (c + a >= K) {
            cout << ite->first << endl;
            return 0;
        } else {
            c += ite->second;
        }
    }


}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll x;
    cin >> x;
    ll tmp;
    vector<ll>v;
    FOR(i,1,33){
        tmp = i*i;
        FOR(j,1,10){
            if(tmp <= x){
                v.push_back(tmp);
                tmp*=i;
            }
            else{
                break;
            }
        }
    }
    sort(ALL(v));
    reverse(ALL(v));

    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = `dd`.split.map &:to_i
p (K..N+1).map{ |k|
  f = (0+k-1)*k / 2
  t = (N-k+1+N)*k / 2
#  p [k,f,t]
  t - f + 1
}.inject(0,:+) % 1000000007


Measured memory_bytes: 16028
import itertools


n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

permu_dict = list(itertools.permutations([i for i in range(1, n+1)]))
permu_dict = sorted(permu_dict)

print(abs(permu_dict.index(p)-permu_dict.index(q)))


Measured memory_bytes: 8308
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
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); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

void Main()
{
    int n, m;
    cin >> n >> m;

    vector<int> list;
    rep(i, n) list.pb(0);
    rep(i, m) list.pb(1);

    int ans = 0;
    rep(i, list.size())
    {
        rep(j, list.size())
        {
            if (i == j)
                break;

            if ((list[i] + list[j]) % 2 == 0)
                ++ans;
        }
    }

    cout << ans << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    double a;
    double sum=0;
    String str;
    for(int i=0;i<n;i++){
      a=scan.nextDouble();
      str=scan.next();
      if(str.equals("BTC")) a=a*380000;
      sum=sum+a;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

int h,w,n;
set<pair<int,int>> se;

int check(int x,int y){
  int cnt = 0;
  for(int i=0;i<=2;i++){
    for(int j=0;j<=2;j++){
      if(x+i>=1&&x+i<=h&&y+j>=1&&y+j<=w) cnt+=se.count({x+i,y+j});
      else return 0;
    }
  }
  return cnt;
}

int32_t main(){
    
  fast;
  cin >> h >> w >> n;


  for(int i=1;i<=n;i++){
    int x,y; cin >> x >> y;
    se.insert({x,y});
  }

  vector<pair<int,int>> vp(all(se));
  int ans[10]={0};
  set<pair<int,int>> used;

  for(int idx=0;idx<vp.size();idx++){
    int x = vp[idx].f , y = vp[idx].s;
    for(int i=-2;i<1;i++){
      for(int j=-2;j<1;j++){
        if(!used.count({x+i,y+j})){
          ans[check(x+i,y+j)]++;
          used.insert({x+i,y+j});
        }
      }
    }
  }

  int sum = 0;
  for(int k=1;k<10;k++) sum+=ans[k];
  ans[0] = (h-2)*(w-2) - sum;
  for(int k : ans) cout << k << '\n';
  return 0;
}

Measured memory_bytes: 64384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    string s;
    
    cin >> s;

    unordered_map<char,int>mp;
    

    for(int i = 0;i < 4;i++)
    {
        mp[s[i]]+=1;
    }

    int count=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr)
    {
        if(itr->second==2){
        count++;
        }
    }

    if(count==2)
    {
        cout << "Yes"<<endl;
    }else{
        
        cout << "No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int n = Integer.parseInt(tokens[0]);
		int m = Integer.parseInt(tokens[1]);
		int[] a = new int[n];
		tokens = in.nextLine().split(" ");
		for (int i = 0; i < n; ++i) {
			a[i] = Integer.parseInt(tokens[i]) % m;
		}

		long[] b = new long[n + 1];
		b[0] = 0;
		long sum = 0;
		for (int i = 0; i < n; ++i) {
			sum += a[i];
			b[i + 1] = sum;
		}
		Map<Integer, List<Integer>> map = new TreeMap<>();
		for (int i = 0; i <= n; ++i) {
			int mod = (int) (b[i] % m);
			if (!map.containsKey(mod)) {
				map.put(mod, new ArrayList<Integer>());
			}
			map.get(mod).add(i);
		}

		long result = 0;
		for (List<Integer> list : map.values()) {
			result += getKaijo(list.size() - 1);
		}
		System.out.println(result);
		in.close();
	}

	public static long getKaijo(long v) {
		long result = 0;
		for (long i = v; i >= 1; --i) {
			result += i;
		}
		return result;
	}
}

Measured memory_bytes: 60304
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)

	cnt := 0
	for i := 1; i <= N; i++ {
		if i%2 == 1 && a[i-1]%2 == 1 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int min = 10;
		int ans = 0;
		for (int i = 0; i < 5; i++) {
			int a = sc.nextInt();
			int temp = a % 10;
			if (temp == 0) {
				ans += a;
				continue;
			} else if (temp < min) {
				min = temp;
			}
			ans += a - temp + 10;
		}
		ans -= 10 - min;
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

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

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

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

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

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

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

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

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	int mx = (n-1)*(n-2)/2;
	if (mx < k) {
		puts("-1");
		return 0;
	}

	vector<P> ans;
	rep(i,n-1){
		//nを真ん中にする
		ans.push_back({i+1,n});
	}
	int add = mx-k;
	// 辺の候補を列挙しとく
	vector<P> edge;
	rep(i,n-1) rep(j,i) {
		edge.push_back({i+1,j+1});
	}

	rep(i,add) ans.push_back(edge[i]);

	cout << ans.size() << endl;
	rep(i,ans.size()){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream> 
#include <string>
#include <map>
#include <math.h>
using namespace std; 
int main(){
	double  N, A, B, C ,D;
	cin >> N >> A >> B >> C >> D;
	double X = ceil(N/A);
	double Y = ceil(N/C);
	if(X*B <= Y*D){
		cout << X*B << endl;
	}
	else{
		cout << Y*D << endl;
	}
	return 0;
}

//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. 
	
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.

//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.






//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.


Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main(){
char s[4];
cin>>s[0]>>s[1]>>s[2]>>s[3];
bool x=0;
if(s[0]==s[1]&&s[2]==s[3]){
    x=1;}
if(s[0]==s[2]&&s[1]==s[3]){
    x=1;}

if(s[0]==s[3]&&s[1]==s[2]){
    x=1;}
if(s[0] == s[1] && s[0] == s[2]){
    x = 0;
  }
if(x==1)
    cout<<"Yes";
else cout<<"No";
return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    priority_queue<ll> q;
    rep(i, n) {
        ll a;
        cin>>a;
        q.push(a);
    }
    ll a = -1;
    while (!q.empty()) {
        ll h = q.top(); q.pop();
        if (q.empty()) break;

        ll n = q.top();
        if (h == n && a == -1) {
            a = h;
            q.pop();
        }
        else if (h == n) {
            cout<<a * h<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
}

Measured memory_bytes: 1400
// 2014/09/08 Tazoe

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

int main()
{
	while(true){
		unsigned n;
		cin >> n;

		if(n==0)
			break;

		unsigned sum = 0;
		for(int i=0; i<n; i++){
			unsigned p;
			cin >> p;

			sum += p;
		}

		unsigned j[65000];
		for(int i=0; i<n-1; i++){
			cin >> j[i];
		}

		sort(j, j+(n-1));

		unsigned sal_max = n*sum;

		for(unsigned i=n-1; i>=1; i--){
			sum += j[i-1];

			sal_max = max(sal_max, i*sum);
		}

		cout << sal_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1420
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      a: i32,
      b: i32,
      h: i32,
      m: i32,
   }
   let th = (h as f64/12.0 + m as f64/60.0/12.0)*2.0*std::f64::consts::PI;
   let tm = (m as f64/60.0)*2.0*std::f64::consts::PI;
   let hx = th.cos()*a as f64;
   let hy = th.sin()*a as f64;
   let mx = tm.cos()*b as f64;
   let my = tm.sin()*b as f64;
   let r = ((hx-mx)*(hx-mx) + (hy-my)*(hy-my)).sqrt();
   println!("{0:.10}", r);
}


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

int main(){
    
    string str[10];
    
    while(cin >> str[0]){
        
        for(int i=1;i<8;i++){
            cin >> str[i];
        }
        
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                
                if(i < 7 && j < 7){
                    if(str[i][j] == '1' && str[i][j+1] == '1' && str[i+1][j] == '1' && str[i+1][j+1] == '1'){
                        cout << 'A' << endl;
                    }
                }
                
                if(i < 5){
                    if(str[i][j] == '1' && str[i+1][j] == '1' && str[i+2][j] == '1'&& str[i+3][j] == '1'){
                        cout << 'B' << endl;
                    }
                }
                
                if(j == 0 && str[i].find("1111") != string::npos){
                    cout << 'C' << endl;
                }
                
                if(i < 6 && 0 < j){
                    if(str[i][j] == '1' && str[i+1][j-1] == '1' && str[i+1][j] == '1'&& str[i+2][j-1] == '1'){
                        cout << 'D' << endl;
                    }
                }
                
                if(i < 7 && j < 6){
                    if(str[i][j] == '1' && str[i][j+1] == '1' && str[i+1][j+1] == '1'&& str[i+1][j+2] == '1'){
                        cout << 'E' << endl;
                    }
                }
                
                if(i < 6 && j < 7){
                    if(str[i][j] == '1' && str[i+1][j] == '1' && str[i+1][j+1] == '1'&& str[i+2][j+1] == '1'){
                        cout << 'F' << endl;
                    }
                }
                
                if(i < 7 && 0 < j && j < 7){
                    if(str[i][j] == '1' && str[i][j+1] == '1' && str[i+1][j-1] == '1'&& str[i+1][j] == '1'){
                        cout << 'G' << endl;
                    }
                }
                
            }
        }
        
        
    }
    
    return(0);
}


Measured memory_bytes: 3228
#! /usr/bin/env python3

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import string
S = input()

c = Counter(S)

for i in string.ascii_lowercase:
    if(not c[i]):
        print(i)
        exit()
print("None")

Measured memory_bytes: 10308
#include <stdio.h>

int main(){
    int S[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int H[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int C[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int D[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int N;
    char c;
    int x;
    scanf("%d\n",&N);
    for(int i=0;i<N;i++){
        scanf("\n%c %d",&c,&x);
        if(c=='S')
            S[x-1]=0;
        if(c=='H')
            H[x-1]=0;
        if(c=='C')
            C[x-1]=0;
        if(c=='D')
            D[x-1]=0;
    }

    for(int i=0;i<13;i++)
        if(S[i]!=0)
            printf("S %d\n",S[i]);
    for(int i=0;i<13;i++)
        if(H[i]!=0)
            printf("H %d\n",H[i]);
    for(int i=0;i<13;i++)
        if(C[i]!=0)
            printf("C %d\n",C[i]);
    for(int i=0;i<13;i++)
        if(D[i]!=0)
            printf("D %d\n",D[i]);
    
}


Measured memory_bytes: 2040
#include <stdio.h>

int main(void)
{
  int la,lb,lc,arc,ll,m1,m2,num=0,tria=0,trib=0,tric=0;

  for(;;){
    scanf("%d %d %d", &la, &lb, &lc);
    if(la>lb&&la>lc){
      ll=la;
      m1=lb;
      m2=lc;
    } else if(lb>la&&lb>lc){
      ll=lb;
      m1=la;
      m2=lc;
    } else if(lc>la&&lc>lb){
      ll=lc;
      m1=la;
      m2=lb;
    } else {
      trib++;
      num++;
      continue;
    }
    if(ll>=m1+m2) break;
    num++;
    arc=m1*m1+m2*m2-ll*ll;
    if(arc==0) tria++;
    if(arc>0) trib++;
    if(arc<0) tric++;
  }
  printf("%d %d %d %d\n", num, tria, trib, tric);

  return 0;
}


Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(){
int n,b,f,r,i,b1,f1,r1,v,tmp;
int House[4][3][10];
cin>>n;
for (b=0;b<4;b++){
    for (f=0;f<3;f++){
        for (r=0;r<10;r++){
        House[b][f][r]=0;
        }
    }
}

for (i=0;i<n;i++){
    cin>>b1>>f1>>r1>>v;
    House[b1-1][f1-1][r1-1]+=v;
}
for (b=0;b<4;b++){
    for (f=0;f<3;f++){
        for (r=0;r<10;r++){
        cout<<" "<<House[b][f][r];
        }
        cout<<endl;
        if ((b<3) and (f==2)){
            cout<<"####################"<<endl;
        }
    }
}
return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

    vector<int> s(n);
    ll sum = 0;
    rep(i, n){
        cin >> s[i];
        sum += s[i];
    }

    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    sort(ALL(s));

    int i = 0;
    int ans;
    while(i < s.size()){
        ans = sum - s[i++];
        if(ans % 10 != 0){
            cout << ans << endl;
            return 0;
        }
    }

    cout << 0 << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

counter = Counter(D)
for t_i in T:
    if t_i in counter and 0 < counter[t_i]:
        counter[t_i] -= 1
    else:
        print("NO")
        sys.exit()

print("YES")

Measured memory_bytes: 44684
#include <iostream>

using namespace std;
long N,a[100001],b[100001],c[100001],i;
int main()
{
    cin >> N;
    for (i=1;i<=N;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    long A[N],B[N],C[N];
    A[1]=a[1];
    B[1]=b[1];
    C[1]=c[1];
    for (i=2;i<=N;i++)
    {
        A[i]=max(B[i-1],C[i-1])+a[i];
        B[i]=max(A[i-1],C[i-1])+b[i];
        C[i]=max(A[i-1],B[i-1])+c[i];
    }
    cout << max(A[N],max(B[N],C[N]));
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n+1];
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }
    int ans[n+1];
    ans[1] = 0;
    for(int i=2;i<=n;i++){

        if(i>2){
            ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
        }else{
            ans[i] = ans[i-1] + abs(h[i] - h[i-1]);
        }
    }
    cout << ans[n];
    return 0;
}

Measured memory_bytes: 4352
def gcd(a, b):
	if a > b:
		a, b = b, a
	while a:
		a, b = b%a, a
	return b

n, x = map(int, input().split(" "))
y = list(map(int, input().split(" ")))

y = [abs(y_i-x) for y_i in y]
m = y[0]
for y_i in y[1:]:
	m = gcd(m, y_i)
print(m)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m, t; cin >> n >> m >> t;

    vi event(t+1);
    REP(i, n) {
        int a; cin >> a;
        ++event[a - m];
        --event[min(a + m, t)];
    }
    REP(i, t) event[i+1] += event[i];

    int ans = 0;
    REP(i, t) {
        if (event[i] == 0) {
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a; cin>>b;
    if(a==1)
        a=14;
    if(b==1)
        b=14;
    if(a>b)
        cout<<"Alice";
    else if (a==b)
        cout<<"Draw";
    else
        cout<<"Bob";
}

Measured memory_bytes: 256