akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  
  if(a%2==0 || b%2 == 0 || c%2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  
  cout << min(a*b, min(a*c, c*b)) << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

l = [0]*(N+1)
l[0] = 1
j = 0
for i in range(1, N+1):
  if j < M and i == a[j]:
    j += 1
  else:
    if i == 1:
      l[1] = 1
    else:
      l[i] = (l[i-1] + l[i-2]) % (10**9+7)

print(l[N])

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

int main(){
     int N,M,P;
     while(cin>>N>>M>>P,N||M||P){
	  int win=0,sum=0;
	  for(int i=0;i<N;i++){
	       int num;
	       cin>>num;
	       if(i==M-1) win=num;
	       sum+=num;
	  }
	  if(win==0){
	       cout<<0<<endl;
	  }else{
	       cout<<sum*(100-P)/win<<endl;
	       //cout<<sum<<" "<<P<<" "<<win<<endl;
	  }
     }
}

Measured memory_bytes: 0
/*
 * D.cpp
 *
 *  Created on: 2016/07/25
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

const int MAX_H=1e5,MAX_W=1e5,MOD=1e9+7;

int H,W,A,B;

ll fact[MAX_H*2+1];

ll pow(ll a,ll b){
	ll res=1;
	while (b){
		if (b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(int a,int b){
	ll num=fact[a],deno=(fact[b]*fact[a-b])%MOD;
	return num*pow(deno,(ll)MOD-2)%MOD;
}

int main(){
	cin>>H>>W>>A>>B;
	fact[0]=1;
	FOR(i,1,MAX_W*2+1){
		fact[i]=fact[i-1]*i%MOD;
	}
	ll res=0;
	REP(i,H-A){
		res+=comb(B+i-1,B-1)*comb(H-1-i+W-B-1,H-1-i)%MOD;
		res%=MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MAX 2000005
typedef unsigned long long ll;
ll mod=1e9+7;

bool isNum(char ch){
  return ('0'<=ch&&ch<='9');
}

bool check(char ch){
  return (ch=='\0'||ch=='>');
}

int n,a;
int p;

char t[MAX];


ll solve();

ll getNum(){
  if(t[p]=='S'){
    p+=2;
    ll res=solve();
    p++;
    return (res*res)%mod; 
  }
  ll res=0;
  while(isNum(t[p])){
    res=res*10LL+(t[p]-'0');
    p++;
  }
  return res;
}

ll solve(){
  ll res=getNum();
  while(1){
    if(check(t[p])&&check(t[p+1])&&check(t[p+2])){
      break;
    }
    p+=2;
    ll num=min(63ULL,getNum());

    res=(res>>num);
    //cout<<res<<endl;
  }
  return res;
}

int main(){
  while(1){
    n=0;
    while(1){
      scanf("%c",&t[n]);
      if(t[n]==' ')continue;
      if(t[n]=='\n')break;
      n++;
    }
    if(t[0]=='#')break;

    while(n<MAX){
      t[n]='\0';
      n++;
    }
    // printf("%s\n",t);
    p=0;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
      ll n,x,t;
      cin>>n>>x>>t;
      int ans=ceil((double)n/x);
      ans=ans*t;
      cout<<ans;
      return 0;
   }



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

#define m 1000000007

long long int binpow(long long int a, long long int b, long long int mm) {
    a %= mm;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mm;
        a = a * a % mm;
        b >>= 1;
    }
    return res;
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    long long int s1=0,s2=0;
    while(n--){
    	long long int x;
    	cin>>x;
    	s1=(s1+x)%m;
    	long long int val=(x%m)*(x%m);
    	s2=(s2+val)%m;
	}
	s1=(s1*s1)%m;
	long long int sum=((s1-s2)%m +m)%m;
	long long int tp=binpow(2,1000000005,m);
	long long int ans=((sum%m)*(tp%m))%m;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  while (x->left != NIL)
    x = x->left;

  return x;
}

Node treeMaximum(Node x){
  while (x->right != NIL)
    x = x->right;

  return x;
}

Node treeSearch(Node u, int k){
  if (u == NIL || k == u->key)
    return u;

  if (k < u->key)
    return treeSearch(u->left,k);

  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  
  if (x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while (y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node x,y;
  
  if (z->left == NIL || z ->right == NIL)
    y = z;

  else
    y = treeSuccessor(z);

  if (y->left != NIL)
    x = y->left;

  else
    x = y->right;

  if (x != NIL)
    x->parent = y->parent;

  if (y->parent == NIL)
    root = x;

  else if (y == y->parent->left)
    y->parent->left = x;

  else
    y->parent->right = x;

  if (y != z)
    z->key = y->key;
}

void insert(int k){
 Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;

    if (z->key < x->key)
      x = x->left;

    else
      x = x->right;
  }

  z->parent = y;

  if (y == NIL)
    root = z;

  else if(z->key < y->key)
    y->left = z;

  else
    y->right = z;
}

void inorder(Node u){
  if (u == NIL)
    return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
 if (u == NIL)
    return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int a,b;
  cin >> a >> b;
  if(a+b < 10)cout << a+b;
  else cout << "error" << endl;
  





  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x;
	cin>>x;
	ll y,z;
	ll ans=0;
	y=x/500;
	x=x-500*y;
	z=x/5;
	ans=1000*y+5*z;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define mod 998244353
#define ll long long
int main(){
    ll n, s, i, j, ans = 0;
    scanf("%lld %lld" ,&n ,&s);
    ll a[n], dp[3000][3001];
    for(i = 0; i < n; i++)
        scanf("%lld" ,&a[i]);
    for(i = 0; i <= s; i++){
        dp[0][i] = 0;
        if(a[0] == i)
            dp[0][i] = 1;
    }
    for(i = 0; i < n; i++)
        dp[i][0] = i + 2;
    for(i = 1; i < n; i++){
        for(j = 1; j < a[i]; j++)
            dp[i][j] = dp[i - 1][j];
        for(j = a[i]; j <= s; j++)
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i]]) % mod;
    }
    for(i = 0; i < n; i++)
        ans = (ans + dp[i][s]) % mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 70528
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 1e5 + 5;
int n, m;
vector<int> g[maxn];
int dp[maxn], in[maxn];
int main() {
    IO;
    cin >> n >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        in[y]++;
    }
    queue<int> q;
    rep(i, 1, n) if (!in[i]) q.push(i);
    int ans = 0, sz = q.size();
    while (q.size()) {
        int now = q.front();
        q.pop();
        for (auto nex : g[now]) {
            in[nex]--;
            if (!in[nex])
                q.push(nex);
        }
        --sz;
        if (!sz) {
            sz = q.size();
            ans++;
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 8996
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt1=0
cnt2=0
ma=sum(b)-sum(a)
if ma<0:
    print("No")
    exit()

for i in range(n):
    if b[i]<=a[i]:
        cnt1+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==0:
            cnt2+=(b[i]-a[i]+1)//2
        else:
            cnt2+=(b[i]-a[i]+1)//2
            cnt1+=1
#print(cnt1,cnt2)
if cnt1>ma or cnt2>ma:
    print("No")
else:
    print("Yes" if (ma-cnt2)*2==ma-cnt1 else "No")


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

char x[3];

int main(){
	for (int i = 0; i < 3; ++i)cin >> x[i];
	for (int i = 0; i < 3; ++i){
		cout << ((x[i] == '1') ? '9' : ((x[i] == '9') ? '1' : x[i]));
	}
}

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

int main() {
    string s;
    cin >> s;
    int w;
    cin >> w;
    string ans = "";
    for (int i = 0; i < s.size(); i += w) {
        ans += s[i];
    }
    cout << ans << endl;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	int n,W;
	cin>>n>>W;
	vi weight(n),val(n);
	ll dp[W+1];
	memset(dp,0,sizeof(dp));
	rep(i,0,n)cin>>weight[i]>>val[i];
	for (int i=0;i<n;i++){
		for (int w=W;w>=weight[i];w--){
			dp[w]=max(dp[w],dp[w-weight[i]]+val[i]);
		}
	}
	cout<<dp[W]<<endl;
	return 0;
}

Measured memory_bytes: 1024
exception Hoge
let calc x = 
  match x with
  | a::b::c::[] -> a + b = c
  | _ -> raise Hoge

let () =
  Scanf.scanf "%d %d %d\n" (fun a b c -> [a; b; c])
  |> List.sort compare
  |> calc
  |> fun b -> if b then print_endline "Yes"
  else print_endline "No"

Measured memory_bytes: 384
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

targets = {}
for i in range(N):
    if P[i] != i+1:
        targets[i] = P[i]

# print(targets)
if not targets:
    print("YES")
elif len(targets) == 2:
    for i, v in targets.items():
        if v-1 in targets and targets[v-1] == i+1:
            print("YES")
        else:
            print("NO")
        break
else:
    print("NO")

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    char c;
    cin>>c;
    if(c=='A'){
        cout<<'T'<<endl;
    }else if(c=='T'){
        cout<<'A'<<endl;
    }else if(c=='C'){
        cout<<'G'<<endl;
    }else if(c=='G'){
        cout<<'C'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next();
		int len = s.length();
		String ans = "";
		for(int i=0;i<len;i++) {
			ans += "x";
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 22992
#include<stdio.h>
  
#define AMAX 20
#define MMAX 2000
 
int n, q;
int isExist[ MMAX+1 ] = {0};

int main( void ) 
{
    int i, j;
    int num;
    int sum;

    scanf( "%d", &n );
    sum = 0;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num );
        sum += num;
        for( j=sum-num; 0<j; j-- ) {
        	if( isExist[ j ] ) {
        		isExist[ j+num ] = 1;
        	}
        }
        isExist[ num ] = 1;        
    }
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
    	if( isExist[ num ] ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define DEBUG

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = (2 * 1e6) + 10, maxm = (1 << 18);
const double PI = acos(-1);
ll fat[maxn], inv[maxn];

ll fexp(ll a, ll b){
    ll ans= 1;

    while (b){
        if (b&1) {
            ans = (ans * a) % mod;
        }
        a = (a * a ) % mod;
        b = (b >> 1);
    }
    return ans;
}

void init(){
    fat[0] = 1;
    for (int i=1; i<maxn; i++){
        fat[i] = (fat[i-1] * i) % mod;
    }
    inv[maxn-1] = fexp(fat[maxn-1], mod - 2);
    for (int i=maxn-2; i>=0; i--){
        inv[i] = (inv[i+1] * (i+1))%mod;
    }
}

ll C(ll n, ll a){
    if (n == a || a == 0)  return 1;
    if (a > n) return 0;
    return ((fat[n] * inv[a]) % mod * inv[n - a]) % mod;
}

int main (){
    init();

    ll xi, xf, yi, yf;
    cin >> xi >> yi >> xf >> yf;

    ll ans = C(xf + yf + 2, xf + 1);
    ans = (ans - C(yi + xf + 1, yi) + mod) % mod;
    ans = (ans - C(xi + yf + 1, xi) + mod) % mod;
    ans = (ans + C(xi + yi, xi) + mod) % mod;

    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 34896
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)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)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  string a, b, c;
  cin >> a >> b >> c ;
  int ans = 0 ;
  
  REP(i,n){
    int cnt = 0 ;
    if(a.at(i)!=b.at(i)){
      cnt++ ;
    }
    if(b.at(i)!=c.at(i)){
      cnt++ ;
    }
    if(c.at(i)!=a.at(i)){
      cnt++ ;
    }
    if(cnt==3){
      ans += 2 ;
    }
    else if(cnt==2){
      ans += 1 ;
    }
  }
  
  cout << ans <<endl ;
    
    


  return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;


int main() {
	lli N;
	cin >> N;
	map<lli, lli> m;
	vector<lli> v(N);
	vector<pair<lli, lli>> ans(N-1);
	int plus = 0, minus = 0, zero = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		m[v[i]]++;
		if (v[i] >= 1)plus++;
		if (v[i] < 0)minus++;
		if (v[i] == 0)zero++;
	}
	int now = 0;
	while (m.size() != 1 || (*m.begin()).second!=1) {
		lli ma = (*m.begin()).first; m[ma]--;
		auto it = m.end(); it--;
		lli mb = (*it).first; m[mb]--;
		if (m[ma] <= 0) {
			m.erase(ma);
		}
		if (m[mb] <= 0) {
			m.erase(mb);
		}
		if (ma >= 1)plus--;
		if (ma < 0)minus--;
		if (ma == 0)zero--;
		if (mb >= 1)plus--;
		if (mb < 0)minus--;
		if (mb == 0)zero--;

		//debug(ma);
		//debug(mb);
		//debug(plus + minus + zero);
		if (plus < minus || plus+minus+zero == 0) {
			m[mb-ma]++;
			if (mb - ma >= 1)plus++;
			if (mb - ma < 0)minus++;
			if (mb - ma == 0)zero++;
			//cout << mb << " " << ma << endl;
			ans[now] = { mb,ma };
		}
		else {
			m[ma - mb]++;
			if (ma - mb >= 1)plus++;
			if (ma - mb < 0)minus++;
			if (ma - mb == 0)zero++;
			//cout << ma << " " << mb << endl;
			ans[now] = { ma,mb };
		}
		now++;
	}
	cout << (*m.begin()).first << endl;
	for (auto i : ans) {
		cout << i.first << " " << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for (int i = 0; i <   n; ++i) cin >> a[i];
    for (int i = 0; i <   n; ++i) cin >> b[i];
    for (int i = 0; i < n-1; ++i) cin >> c[i];

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        sum +=  b[a[i] - 1];
        if (i != 0 && (a[i-1] + 1) == a[i]) {
            sum += c[a[i - 1] - 1];
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
# N, K = map(int, input().split())
# a = map(int, input().split())

R,G,B,N = map(int, input().split())
count = 0
for i in range(0, N + 1, R):
    K = N - i

    for j in range(0, K + 1, G):
        J = K - j

        if J % B == 0:
            count += 1

print(count)

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	sort(a.begin(), a.end());
	cout << a[0] << " " << a[n-1] << " " << sum << endl;
	return 0;
}


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

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> a(n);
    set<int> occ;
    for(int &temp:a){
        cin>>temp;
        occ.insert(temp);
    }
    for(int i=0;i<100;i++){
        if(x-i>=0 && occ.find(x-i)==occ.end()){
            cout<<x-i<<"\n";
            return 0;
        }
        if(occ.find(x+i)==occ.end()){
            cout<<x+i<<"\n";
            return 0;
        }
    }    
}

Measured memory_bytes: 3624
#0-indexed
n = int(input())
L = [[]*n for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        x-=1
        L[i].append((x,y))
#print(L)
ans = 0
for i in range(1<<n):
    bit = [(i>>j)&1 for j in range(n)]
    #print(bit)
    flag = True
    for j in range(n):
        if bit[j]:
            for x,y in L[j]:
                if bit[x] != y:
                    flag = False
                    break
            if not flag:
                break
    if flag:
        ans = max(ans,sum(bit))
print(ans)


Measured memory_bytes: 69236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main {
 
    public static void main(String[] args) throws IOException {
 
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 
        String[] abc = in.readLine().split(" ");
 
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);
 
        if (a <= b && b <= c) {
            System.out.println(a + " " + b + " " + c);
        } else if (a <= c && c <= b) {
            System.out.println(a + " " + c + " " + b);
        } else if (b <= a && a <= c) {
            System.out.println(b + " " + a + " " + c);
        } else if (b <= c && c <= a) {
            System.out.println(b + " " + c + " " + a);
        } else if (c <= a && a <= b) {
            System.out.println(c + " " + a + " " + b);
        } else if (c <= b && b <= a) {
            System.out.println(c + " " + b + " " + a);
        }
    }
}

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

using namespace std;

const int vy[] = {-1, 0, 1, 0}, vx[] = {0, 1, 0, -1};

const string p = "^v<>";

int H, W;
string S[50], P;
int x, y, dir;
int nxt[1001];
int step;

bool check(int &idx)
{
  bool flip = false;
  if(P[idx] == '~') flip = true, ++idx;
  switch(P[idx++]) {
    case 'N':
      return (dir == 0) ^ flip;
    case 'E':
      return (dir == 1) ^ flip;
    case 'S':
      return (dir == 2) ^ flip;
    case 'W':
      return (dir == 3) ^ flip;
    case 'C':
      return (S[y + vy[dir]][x + vx[dir]] == '#') ^ flip;
    default:
      return !flip;
  }
}


void ai(int &idx)
{
  if(step == 11451419) {
    cout << -1 << endl;
    exit(0);
  }
  int nowidx = idx;
  if(p.find(P[idx]) != string::npos) {
    ++step;
    if(P[idx] == '^') {
      if(S[y + vy[dir]][x + vx[dir]] != '#') {
        y += vy[dir], x += vx[dir];
      }
    } else if(P[idx] == 'v') {
      if(S[y - vy[dir]][x - vx[dir]] != '#') {
        y -= vy[dir], x -= vx[dir];
      }
    } else if(P[idx] == '<') {
      (dir += 3) %= 4;
    } else {
      (dir += 1) %= 4;
    }

    if(S[y][x] == 'g') {
      cout << step << endl;
      exit(0);
    }
    ++idx;
  } else if(P[idx] == '[') {
    if(check(++idx)) {
      while(P[idx] != ']') ai(idx);
    }
    idx = nxt[nowidx];
  } else if(P[idx] == '{') {
    int proc = 0;
    while(check(++idx)) {
      if(proc++ >= 11451419) {
        cout << -1 << endl;
        exit(0);
      }
      while(P[idx] != '}') ai(idx);
      idx = nowidx;
    }
    idx = nxt[nowidx];
  }
}

int main()
{
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
    for(int j = 0; j < W; j++) {
      if(S[i][j] == 's') x = j, y = i;
    }
  }
  cin >> P;
  P += "$";

  for(int i = 0; i < P.size(); i++) {
    if(P[i] == '[' || P[i] == '{') {
      int sum = 0;
      for(int j = i; j < P.size(); j++) {
        if(P[j] == '[' || P[j] == '{') ++sum;
        else if(P[j] == ']' || P[j] == '}') --sum;
        if(sum == 0) {
          nxt[i] = j + 1;
          break;
        }
      }
    }
  }

  int ptr = 0;
  while(P[ptr] != '$') ai(ptr);
  cout << -1 << endl;
}

Measured memory_bytes: 3224
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

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

using namespace std;
int main(){
  long n,k,ret;
  long ii;
  double sum = 0,one,div;
  long base,sum1;
  sum1 = 0;
  cin >> n >> k;
  for(ii=1;ii<=n;ii++){
    one = 1.0/n;
    ret = ii;
    div = 1;
    while(ret < k){
      ret *= 2;
      //one /= 2.0;
      div *= 2;
    }
    if(ii==1){
      base = div * n;
    }

    sum1 += base/(div*n);
    
  }
  //cout << sum << endl;
  one = sum1;
  sum = one/base;
  //cout << sum1 << endl;
  printf("%.12lf\n",sum);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dic = dict()
ans = 0
for i in range(n):
    k = i + 1 - a[i]
    if k in dic:
        ans += dic[k]
    k = a[i] + i + 1
    if k in dic:
        dic[k] += 1
    else:
        dic[k] = 1
print(ans)


Measured memory_bytes: 111572
nm=list(map(int,input().split()))
n=nm[0]
m=nm[1]

inp=[]
if m==0:
    inp=[n+1]
    dis=[n+1]
else:
    for inpset in range(m):
        inp.append(int(input()))
    

    dis=[max(inp[0],1)]
    p=0
    for i in inp[:-1]:
        dis.append(inp[p+1]-inp[p]-1)
        p+=1
    dis.append(max(n-inp[-1],1))
    #print (dis)

def fib(x):
    a=0
    b=1
    for step in range(x):
        c=a+b
        a=b
        b=c
    return a


def counting(x):
    if x==1:
        return 1
    else:
        
        res=0
        for a in range(x-1):
            if x-1-a>=a:
                res+=combinations_count(x-1-a,a)
                # print(x-1-a,a)
            else:
                break
        res=res%1000000007
        return res

if 0 in dis:
    print(0)
else:
    ans=1
    dis.sort()
    for d in dis:
        ans*=fib(d)%1000000007
        ans=ans%1000000007
    print(ans)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++)
        cin >> l[i];

    int ret = 0;
    for (int i=0; i<n; i++)
        for (int j=i+1; j<n; j++)
            for (int k=j+1; k<n; k++)
                if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k] && l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])
                    ret++;
    cout << ret << "\n";

    return 0;
}


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

string s[100004];
int trie[500005][27];
int d[500005];
string p[100004];

int main()
{
    int n;
    cin >> n;
    int m = 1;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        int c = 0;
        for(int j = 0; j < (int)s[i].size(); j++){
            if(trie[c][s[i][j] - 'a'] == 0){
                trie[c][s[i][j] - 'a'] = m++;
            }
            c = trie[c][s[i][j] - 'a'];
            d[c]++;
        }
        d[m]++;
        trie[c][26] = m++;
    }
    int q;
    cin >> q;
    vector<int> v[100005];
    for(int i = 0; i < q; i++){
        int k;
        cin >> k >> p[i];
        k--;
        v[k].push_back(i);
    }
    int ans[100002];
    fill(ans, ans + q, 1);
    for(int i = 0; i < n; i++){
        if(v[i].size() == 0) continue;
        int r[27][27];
        for(int j = 0; j < 27; j++){
            for(int k = 0; k < 27; k++) r[j][k] = 0;
        }
        int c = 0;
        for(int j = 0; j < (int)s[i].size(); j++){
            for(int k = 0; k < 27; k++){
                if(k == s[i][j] - 'a') continue;
                r[k][s[i][j] - 'a'] += d[trie[c][k]];
            }
            c = trie[c][s[i][j] - 'a'];
        }
        for(int k = 0; k < 26; k++){
            r[k][26] += d[trie[c][k]];
        }
        for(int j : v[i]){
            for(int l = 0; l < 26; l++) ans[j] += r[26][l];
            bool b[26]{0};
            for(int k = 0; k < 26; k++){
                b[p[j][k] - 'a'] = true;
                for(int l = 0; l < 26; l++){
                    if(!b[l]) ans[j] += r[p[j][k] - 'a'][l];
                }
            }
        }
    }
    for(int i = 0; i < q; i++) cout << ans[i] << endl;
}


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

int main(){
  int N,A,x,y,ac=0,ans=0,a=1,c=0;
  cin>>N;
  vector<vector<pair<int,int>>> xy(N+1);
  
  for(int i=1;i<=N;i++){
    cin>>A;
    for(int j=0;j<A;j++){
      cin>>x>>y;
      xy.at(i).push_back(make_pair(x,y));
    }
  }
  
  for(int i=0;i<N;i++)
    a*=2;

  for (int tmp = 0; tmp < (1 << 15); tmp++) {
    bitset<15> s(tmp);
    ac=0;
    if(a==c)
      break;
    // (ビット列sに対する処理)
    for(int i=0;i<N;i++){
      if(s.test(i)==1){
        for(int j=0;j<xy.at(i+1).size();j++){
          if(xy.at(i+1).at(j).second==1){
            if(s.test(xy.at(i+1).at(j).first-1)==0)
              ac=1;
          }
          else{
            if(s.test(xy.at(i+1).at(j).first-1)==1)
              ac=1;
          }
        } 
      }
    }
    if(ac==0)
        if(ans<s.count())
          ans=s.count();
    c++;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool flag = true;
  long long out=1e+18,ans=1,A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
    for(int i = 0; i < N; i++){
      if(out/ans < A[i]){
        cout << -1 << endl;
        return 0;
      }
      ans *= A[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){cout<<endl;}template<class H,class...T>void put(string d,H&&h,T&&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

template<class T>string bitstr(T x){return typeid(T)==typeid(int)?bitset<32>(x).to_string('_','#'):bitset<64>(x).to_string();}
template<class T>int bitcnt(T x){return typeid(T)==typeid(int)?__builtin_popcount(x):__builtin_popcountll(x);}
template<class T>int bitdig(T x){return x?typeid(T)==typeid(int)?32-__builtin_clz(x):64-__builtin_clzll(x):0;}
template<class T>int bitpow(T x){return x?typeid(T)==typeid(int)?__builtin_ctz(x):__builtin_ctzll(x):0;}


int main(){
    vvi c(3,vi(3));
    getii(c);
    rep(i,3){
        int mn=*min_element(all(c[i]));
        rep(j,3){
            c[i][j]-=mn;
        }
    }
    if(c[0]==c[1] && c[1]==c[2]) cout<<"Yes"<<endl; else cout<<"No"<<endl;
}



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

int main()
{ 
   string s;
   cin >> s;
   int n = s.size();
   dp[0][0][0][0][0][0] = 1;
   rep(i,n)rep(j,2)rep(k,2)rep(l,2)rep(m,2)rep(f,2){
       int x = s[i] - '0';
       rep(d,10){
           int ni = i+1,nj = j,nk = k,nl = l,nm = m,nf = f;
           if(!j && d > x)continue;
           if(d < x) nj = 1;
           
           if(d == 3)nk = 1,nf = 1;
           else if(d == 5)nl = 1,nf = 1;
           else if(d == 7)nm = 1,nf = 1;
           else if(d == 0){
               if (f)continue;

           }
           else continue;
           dp[ni][nj][nk][nl][nm][nf] +=dp[i][j][k][l][m][f];
       }
       
   }
   int ans = dp[n][0][1][1][1][1]+dp[n][1][1][1][1][1];
   cout << ans << endl;

   

    return 0;
}   

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;


int main()
{
    ll n,k,q;
    cin >> n >> k >> q;
    vector<ll> s(n);
    rep(i,q){
        ll a;
        cin >> a;
        a--;
        s[a]++;
    }
    rep(i,n){
        if(k-q+s[i]>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
} 

Measured memory_bytes: 1408
// ref: https://par.hateblo.jp/entry/2018/06/24/213218
// ref: https://hackmd.io/@Mister/Bk8xU7lzQ?type=view
// ref: https://drken1215.hatenablog.com/entry/2018/06/24/010600
// ref: https://img.atcoder.jp/arc099/editorial.pdf

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int64 fn_S(const int64 rhs){
    int64 sum=0ll;
    string s=to_string(rhs);
    for(uint i=0; i<s.size(); ++i){ sum+=s[i]-'0'; }
    return sum;
}

void solver(int64 K){
    int64 sn = 0;
    int64 add = 1;
    for(int64 k=0; k<K; ++k){
        int64 i = sn + add;
        int64 n = sn + add*10;
        if((i * fn_S(n))<(n * fn_S(i))){
            sn = i;
        }else{
            sn = n;
            add *= 10;
        }
        cout << sn << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int64 K; cin >> K;
    solver(K);
    
    /*
    vector<int64> vSN;
    
    cout << "print sunuke numbers" << endl;
    for(int64 n=1; n<K; ++n){
        bool exist=false;
        int64 sx_n = fn_S(n);
        
        for(int64 i=n+1; i<100000; ++i){
            int64 sx_i = fn_S(i);
//            if(((double)i/(double)sx_i)<((double)n/(double)sx_n)){ exist=true; break; }
            if((i * sx_n)<(n * sx_i)){ exist=true; break; }
        }
        
        if(!exist){
            cout << n << endl;
            vSN.push_back(n);
        }
    }
    cout << endl;
    
    cout << "print diff of sunuke numbers" << endl;
    for(uint i=1; i<vSN.size(); ++i){
        cout << vSN[i]-vSN[i-1] << endl;
    }
    //*/
    return 0;
}

/*
100000
print sunuke numbers
1
2
3
4
5
6
7
8
9
19
29
39
49
59
69
79
89
99
199
299
399
499
599
699
799
899
999
1099
1199
1299
1399
1499
1599
1699
1799
1899
1999
2999
3999
4999
5999
6999
7999
8999
9999
10999
11999
12999
13999
14999
15999
16999
17999
18999
19999
20999
21999
22999
23999
24999
25999
26999
27999
28999
29999
39999
49999
59999
69999
79999
89999
99999

print diff of sunuke numbers
1
1
1
1
1
1
1
1     8
10
10
10
10
10
10
10
10
10    9
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100   19
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000  28
10000
10000
10000
10000
10000
10000
10000
*/


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int m,f,r,a;
char class;

while(1){
scanf("%d %d %d",&m,&f,&r);
if(m==-1&&f==-1&&r==-1)break;
if(m==-1||f==-1)class='F';
else if(m+f>=80)class='A';
else if(m+f>=65)class='B';
else if(m+f>=50)class='C';
else if(m+f>=30){
class='D';
if(r>=50)class='C';
}
else if(m+f<30)class='F';


printf("%c\n",class);
}
return 0;
}


Measured memory_bytes: 1952
#include<iostream>


int main() {
	char c[3][3];
	for (int i = 0;i < 3;i++) {
		for (int n = 0;n < 3;n++) {
			std::cin >> c[i][n];
		}
	}
	std::cout << c[0][0] << c[1][1] << c[2][2];
}

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

int main (void){
  int a[] = {0, 0, 0};
  int p;
  cin >> p;
  for(int j=0;j<p;j++){
    for(int i=0;i<3;i++) cin >> a[i];
    sort(a,a+3);
    if(pow(a[2],2) == (pow(a[1],2) + pow(a[0],2))){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

using namespace std;

int a[110][110];
int vis[110];
int n, x, y, z;
int main()
{
    while(1)
    {
        scanf("%d", &n);
        if (n == 0) break;
        memset(a, 0, sizeof(a));
        for(int i=0; i<=9; i++)
            for(int j=0; j<=9; j++)
                a[i][j] = 100000;

        for(int i=0; i<=9; i++)
            a[i][i] = 0;
        memset(vis, 0, sizeof(vis));
        for(int i=1; i<=n; i++)
        {
            scanf("%d%d%d", &x, &y, &z);
            a[x][y] = min(a[x][y], z);
            a[y][x] = min(a[y][x], z);
            vis[x] = 1; vis[y] = 1;
        }

        for(int i=0; i<=9; i++)
            for(int j=0; j<=9; j++)
                for(int k=0; k<=9; k++)
        {
            if (a[j][i] + a[i][k] < a[j][k])
                a[j][k] = a[j][i] + a[i][k];
        }


        int ans1 = -1;
        int ans2 = 0;
        for(int i=0; i<=9; i++)
        {
            if (vis[i] == 0) continue;
            int sum = 0;
            for(int j=0; j<=9; j++)
                sum += a[i][j] * vis[j];
            if (sum < ans2 || ans1 == -1) {ans1 = i; ans2 = sum;}
        }
        cout<<ans1<<' '<<ans2<<endl;
    }
}



Measured memory_bytes: 3192
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
using namespace std;

int main(){
    set<string> st;
    int n;
    cin >>n;
    for(int i=0;i<n;i++){
        string s,w;
        cin >>s>>w;
        if(s=="insert"){
            st.insert(w);
        }
        if(s=="find"){
            set<string>::iterator itr=st.find(w);
            if(itr==st.end())cout<<"no";
            else cout<<"yes";
            cout<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 32132
///*/////////////////////////////*///
/// IN THE NAME OF ALMIGHTY ALLAH ///
///*/////////////////////////////*///

///*////////////////////*///
/// Author : SAIFULLAH29 ///
///*////////////////////*///

///*//////////////////////////////////////////*///
/// "When you want something, all the universe ///
///  conspires in helping you to achieve it."  ///
///              - Paulo Coelho, The Alchemist ///
///*//////////////////////////////////////////*///

#include <bits/stdc++.h>

#define SS           " "
#define endl         "\n"
#define EPS          1e-9
#define gcd          __gcd
#define pb           push_back
#define pi           acos(-1.0)
#define Ars          greater<int>()
#define vi           vector<int>
#define vvi          vector<vector<int> >
#define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define wow          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long              ll;
typedef double                 dbl;
typedef unsigned long long     ull;

ll lcm(ll a, ll b)
{
    return (a/gcd(a, b))*b;
}

void solve()
{
    int n;
    string s;
    cin>>n>>s;

    if(n&1)
        cout<<"No"<<endl;
    else
    {
        bool flg=1;

        for(int i=0, j=n/2; i<n/2; i++, j++)
        {
            if(s[i] != s[j])
            {
                flg = 0;
                break;
            }
        }

        if(flg)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

int main()
{
    wow

    int t=1;
    //cin>>t;

    while(t--)
        solve();

    return 0;
}

///*////////////////////////////////////////////*///
/// "There is only one thing that makes a dream  ///
/// impossible to achieve: the fear of failure." ///
///                - Paulo Coelho, The Alchemist ///
///*////////////////////////////////////////////*///


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>

int Hash[300000000];
char s[13];  
 
int getChar(char ch){
	if(ch=='A') return 1;
	else if(ch=='C') return 2;
	else if(ch=='G') return 3;
	else return 4;
}
 
int getKey(){
	int sum=0,p=1;
	
	for(int i=0;i<strlen(s);i++){
		sum+=p*(getChar(s[i]));
		p*=5;
	}
	return sum;
}
 
int main(){
	int n;
	char com[7];
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %s",com,s);
		if(com[0]=='i'){
			Hash[getKey()]=1;
		}
		else{
			if(Hash[getKey()]==1)
			printf("yes\n");
			else
			printf("no\n");
		}
	}
}

Measured memory_bytes: 20072
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
A = list(map(int,input().split()))

s = sum(A[:k])
t = 0
for i in range(k):
    t += max(A[i], 0)
a = min(t-s, t)
ai = 0
b = 1 if t > t-s else 0
# print(a)
for i in range(1, n-k+1):
    s -= A[i-1]
    s += A[i+k-1]
    t -= max(A[i-1], 0)
    t += max(A[i+k-1], 0)
    if a > t:
        a = t
        ai = i
        b = 0
    if a > t-s:
        a = t-s
        ai = i
        b = 1

ans = 0
# print(a,ai,b)

for i in range(0, ai):
    ans += max(0, A[i])
for i in range(ai+k, n):
    ans += max(0, A[i])

if b > 0:
    ans += sum(A[ai:ai+k])

print(ans)

Measured memory_bytes: 62188
#include <iostream>
    #include <bits/stdc++.h>
    #include <map>


    using namespace std;


    int main()
    {
      int n,k;
      cin>>n>>k;
      int arr[n];
      map<int,int> mp;
      for(int i=0;i<n;i++)
      {
          cin>>arr[i];
          mp[arr[i]]++;

      }
     // cout<<mp.size()<<endl;
      int fr[mp.size()];
      int c=0;
      map<int,int> ::iterator it= mp.begin();
      while(it!=mp.end())
      {
       //   cout<<it->second<<"   ";
          fr[c]= it->second ;
          it++;
          c++;
      }
     sort(fr,fr+mp.size());
      int sum=0;
     for(int i=0;i<(int)mp.size()-k;i++)
        sum+=fr[i];

     cout<<sum;








        return 0;
    }


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

int x[999999],y,n,q,r;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>y;
		for(int j=0;j<n;j++){
			if(y==x[j]){
				r++;
				break;
			}
		}
	}
	cout<<r<<endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int ans = 1000;
  for (int i=0; i<S.size()-2; i++){
    ans = min(ans, abs(753-stoi(S.substr(i,3))));
  }
  cout << ans << endl;
}


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

long long int d[114514][13] = {};
long long int mod = 1000000007;

int main() {

    string s;
    cin >> s;
    long long int n = s.size();

    d[0][0] = 1;
    for ( long long int i = 0; i < n; i++ ) {
        for ( long long int j = 0; j < 13; j++ ) {
            if ( s[i] == '?' ) {
                for ( long long int k = 0; k <= 9; k++ ) {
                    d[i+1][(j*10+k)%13] += d[i][j];
                    d[i+1][(j*10+k)%13] %= mod;
                }
            } else {
                long long int k = s[i] - '0';
                d[i+1][(j*10+k)%13] += d[i][j];
                d[i+1][(j*10+k)%13] %= mod;
            }
        }
    }

    cout << d[n][5] << endl;

    return 0;

}


Measured memory_bytes: 10752
import math
from functools import reduce
import itertools

k = int(input())
total = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)


for i in range(1,k+1,1):
    for j in range(i,k+1,1):
        for l in range(j,k+1,1):
            GCD = gcd(i, j, l)
            l = [i,j,l]
            cnt = 0
            for num in l:
                cnt = max(cnt, l.count(num))
            if cnt == 1:
                sum = 6
            elif cnt == 2:
                sum = 3
            elif cnt == 3:
                sum = 1

            total += GCD*sum

print(total)


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,d[100000]; cin>>n;
	rep(i,n) cin>>d[i];

	sort(d,d+n);

	cout<<d[n/2]-d[n/2-1]<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>

int main()
{
	int N, A, B;
	std::cin >> N >> A >> B;

	int train = N * A;
	int taxi = B;

	if (train > taxi) {
		std::cout << taxi;
	}
	else if(taxi >= train) {
		std::cout << train;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	int n; cin >> n;
	rep(i, 50000)
	{
		int x = (double)i * 1.08;
		if (x == n)
		{
			co(i);
			return 0;
		}
	}
	co(":(");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	long long h, count = 0;
	scanf("%lld", &h);
	while (h != 0) {
		h /= 2;
		count++;
	}
	long long binary = 1, sum = 0;
	for (int i = 0; i < count; i++) {
		sum += binary;
		binary *= 2;
	}
	printf("%lld\n", binary - 1);
	return 0;
}

Measured memory_bytes: 128