akhauriyash/Code-Regression huggingface dataset:
N,A,B,C=map(int,input().split())
mod=10**9+7

#factorial,facotiralの逆数を事前計算.
#N=10**5あたりまで有効

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV=FACT_INV[::-1]
    
 
def Combi(N,K):
    return FACT[N]*FACT_INV[N-K]*FACT_INV[K]%mod


ANS=0
SUM=A+B
A_n=pow(A,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
B_n=pow(B,N,mod)*pow(pow(SUM,mod-2,mod),N,mod)%mod
SUMINV=pow(SUM,mod-2,mod)

for i in range(N):
    ANS=(ANS+(A_n*pow(B,i,mod)+B_n*pow(A,i,mod))*Combi(N-1+i,i)*pow(SUMINV,i,mod)*(N+i))%mod

print(ANS*100*pow(100-C,mod-2,mod)%mod)


Measured memory_bytes: 20528
#include<stdio.h>
#include<string.h>
int main(){
	char s[100];
	scanf("%s",&s);
	int count=0;
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='1')
			count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(int argc, const char * argv[]) {
    
    const int MAX_WORKS_COUNT = 100000+1;
    //方針
    //0〜M-1日間で考える（M日目は報酬を受け取ることはできるが、仕事をしても翌日以降がないため意味がない）
    //M-1日目から初めて、残り日数のうちに報酬がもらえる仕事のうち、報酬が最大の仕事を順番にこなしていく
    
    //インプットの処理
    
    //n：仕事の数
    //m：日数
    int n, m;
    cin >> n >> m;
    
    //報酬受け取り期間と報酬の２次元配列を作る。
    //vectorの配列とする。
    
    typedef vector<int> values;
    values works[MAX_WORKS_COUNT];
    
    for(int i=0;i<n;i++)
    {
        int a, b;
        cin >> a >> b;
        works[a].push_back(b);
    }
    
    //報酬受け取り期間の昇順にソート
    for(int i=0;i<MAX_WORKS_COUNT;i++)
    {
        sort(works[i].begin(), works[i].end());
    }
    
    
    //合計報酬の最大値を計算
    //一度行った仕事は除外するため、priority_queueで管理
    long value = 0;
    priority_queue< int> pq;
   
    //日付をM日目からループ
    for(int i = m;i >= 0;i--)
    {
        //最終日からi日目に報酬受け取り期間iの仕事ができるようになる。
        int daysLeft = m - i;
        for(int value : works[daysLeft])
        {
            pq.push(value);
        }
        
        if(pq.empty()) continue;
        
        //仕事の取り出し
        value += pq.top();
        pq.pop();
    }
    
    
    cout << value;
    
    return 0;
}


Measured memory_bytes: 5632
S = input()

if S[-1] == "1" or S[0] == "0":
    print("-1")
    exit()

for i in range(len(S)//2):
    if S[i] != S[-2-i]:
        print("-1")
        exit()

print("1 2")
current_root = 1
for i in range(1, len(S)-1):
    print("{:d} {:d}".format(i+2, current_root+1))
    if i << len(S)//2 and S[i] == "1":
        current_root = i+1



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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int m = min(a, b);
  int s = a + b;
  cout << m << ' ';;
  if (s > n) {
    cout << s - n <<endl;
  }
  else {
    cout << 0 <<endl;
  }
} 



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

long long cnt=0;
void insertionSort(int a[],int n,int g){
	for(int i=g;i<n;i++){
		int v=a[i], j=i-g;
		while(j>=0 && a[j]>v){
			a[j+g]=a[j];
			j-=g;
			cnt++;
		}
		a[j+g]=v;
	}
}

int genG(int g[],int maxv,int GM){
	g[0]=1;
	int i=1;
	while(true){
		if(g[i-1]>maxv || !(i<GM)){
			return i-1;
		}
		g[i]=g[i-1]*3+1;
		i++;
	}
}

void shellSort(int a[],int n){
	cnt=0;
	const int GM=100;
	int g[GM];
	const int m=genG(g,n,GM);
	
	cout<<m<<endl;
	for(int i=m-1;i>=0;i--){
		cout<<g[i]<<' '<<flush;
		insertionSort(a,n,g[i]);
	}
	cout<<endl;
}

int main(){
	int n;
	cin>>n;
	int *a=new int[n];
	if(a==NULL)return 1;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	shellSort(a,n);
	cout<<cnt<<endl;
	for(int i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 7028
#include <iostream>

long long cnt = 0;

class Shell{
public:
	void insertion_sort(int *A, int N, int g){
		for(int i = g; i < N; ++i){
			int v = A[i];
			int j = i - g;
			while(A[j] > v && j >= 0){
				A[j+g] = A[j];
				j -= g;
				++cnt;
			}
			A[j+g] = v;
		}
	}
	void shell_sort(int *A, int N){
		int G[1000000];
		int i = 0;
		for(int h = 1; ; ){
			if(h > N) break;
			G[i] = h;
			h = 2 * h + 1;
			++i;
		}
		std::cout << i << std::endl;
		for(int j = i - 1; j >= 0; --j){
			std::cout << G[j];
			if(j) std::cout << " ";
			insertion_sort(A, N, G[j]);
		}
		std::cout << std::endl;
	}
};

int main(){
	int N;
	int A[1000000];
	std::cin >> N;
	for(int i = 0; i < N; ++i){
		std::cin >> A[i];
	}
	Shell s;
	s.shell_sort(A, N);

	std::cout << cnt << std::endl;
	for(int i = 0; i < N; ++i){
		std::cout << A[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 6964
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

int dh[4] = {-1, 0, 1, 0};
int dw[4] = {0, 1, 0, -1};

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<char>> s =
      vector<vector<char>>(H + 2, vector<char>(W + 2, '_'));
  ll black = 0;
  REP(i, H)
  REP(j, W) {
    cin >> s[i + 1][j + 1];
    black += (s[i + 1][j + 1] == '#' ? 1 : 0);
  }

  queue<pair<int, int>> q;
  q.push(make_pair(1, 1));
  int cnt, h, w;
  for (cnt = 0; q.size(); cnt++) {
    queue<pair<int, int>> tmp_q;
    while (q.size()) {
      h = q.front().first;
      w = q.front().second;
      for (int i = 0; i < 4; i++) {
        if (s[h + dh[i]][w + dw[i]] == '.') {
          s[h + dh[i]][w + dw[i]] = '#';
          tmp_q.push(make_pair(h + dh[i], w + dw[i]));
        }
        if (h + dh[i] == H && w + dw[i] == W) {
          cout << H * W - black - cnt - 2 << endl;
          exit(EXIT_SUCCESS);
        }
      }
      q.pop();
    }
    q = tmp_q;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
def t(l_2d):
  return [list(i) for i in zip(*l_2d)]

def clean(a):
  a_white = ["."]*len(a[0])
  #print(a_white)
  a_ret=[]
  for ai in a:
    if ai!=a_white:
      a_ret.append(ai)
  return a_ret


h,w = map(int, input().split())
a = [list(input()) for i in range(h)]

a = clean(a)
#print(t(a))
a = t(clean(t(a)))

for ai in a:
  for aii in ai:
    print(aii, end="")
  print("")

Measured memory_bytes: 4724
#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 ll = long long;
using namespace std;
int main(){
  ll p[3],ii;
  ll max = -1;
  ll sum = 0;
  for(ii=0;ii<3;ii++){
    cin >> p[ii];
    if(p[ii] > max){
      max = p[ii];
    }
    sum += p[ii];
  }

  cout << (sum - max)  << endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           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++)
// mp::cpp_int


int solve( ){
 
int n;
cin>>n;
vi a(n);
rep(i,0,n)cin>>a[i];
sort(all(a));
int sum=0;
rep(i,0,n)sum+=a[i];
cout<<sum-a[n-1]+a[n-1]/2;



return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
using System;
namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');

            int a = Convert.ToInt32(inputs[0], 10);
            int b = Convert.ToInt32(inputs[1], 10);

            Console.WriteLine( a * b + " " + (2*a + 2*b));
        }
    }
}

Measured memory_bytes: 5652
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    road = []

    for m in range(M):
        road.append(list(map(int, input().split())))
    
    ans = [True]*N

    for r in road:
        if H[r[0]-1] > H[r[1]-1]:
            ans[r[1]-1] = False
        elif H[r[0]-1] < H[r[1]-1]:
            ans[r[0]-1] = False
        else:
            ans[r[0]-1] = False
            ans[r[1]-1] = False
    
    print(sum(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 93400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

int a[2001];
int main(){
    int n,k,q;
    cin>>n>>k>>q;
    rep(i,n) cin>>a[i];
    int ans=1000100010;
    rep(i,n){
        int x=a[i];
        vector<int>v,vv;
        rep(j,n){
            if(a[j]>=x) v.pb(a[j]);
            else{
                sort(v.begin(),v.end());
                if(v.size()>=k){
                    rep(p,(int)v.size()-k+1){
                        vv.pb(v[p]);
                    }
                }
                v.clear();
            }
        }
        sort(v.begin(),v.end());
        if(v.size()>=k){
            rep(p,(int)v.size()-k+1){
                vv.pb(v[p]);
            }
        }
        sort(vv.begin(),vv.end());
        if(vv.size()>=q)ans=min(ans,vv[q-1]-x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b,c, = map(int,input().split())
bb = [int(input()) for i in range(n)]
res = []
for j in range (4**n-1) :
  t = str(bin(j))
  tt = t[2:]
  ttt = "0" * (2*n-len(tt)) + tt
  tttt = tuple(ttt)
  ttttt = tuple(map (int,tttt))
  mp = 0
  lg = [0,0,0,0]
  for take in range(n) :
      use = ttttt[take*2]*2 + ttttt[take*2+1]
      mp += 10
      if lg[use] == 0:
          mp -= 10
      lg[use] += bb[take]
      lg[3] = 0 
  if lg[0]*lg[1]*lg[2] == 0 :
      mp=10000000
  mp += abs(a-lg[0])
  mp += abs(b-lg[1])
  mp += abs(c-lg[2])
  res.append(mp)
print (min(res))

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 190;
int n, m;
char s[N][N];
int f[2][N][N][N];
int main() {
#ifdef fwat
	freopen("data.in", "r", stdin);
#endif
	n = gi(), m = gi();
	rep(i, 1, n) scanf("%s", s[i] + 1);
	for(int i = n; i; --i)
	for(int j = i; j <= n; ++j)
	for(int k = m; k; --k)
	if(i == j) {
		if(k == m) f[0][i][j][k] = m + 1;
		else f[0][i][j][k] = s[i][k] == s[i][k + 1] ? f[0][i][j][k + 1] : k + 1;
	}else f[0][i][j][k] = s[i][k] == s[i + 1][k] ? min(f[0][i][i][k], f[0][i + 1][j][k]) : k;
	
	for(int ans = 0; ; ++ans) {
//		#define A ans & 1
//		#define B (ans + 1) & 1
		int A = ans & 1;
		int B = ans + 1 & 1;
		if(f[A][1][n][1] == m + 1) return printf("%d\n", ans), 0;
		for(int i = n; i; --i)
		for(int j = i; j <= n; ++j)
		for(int k = m; k; --k) {
			f[B][i][j][k] = f[A][i][j][k] == m + 1 ? m + 1 : f[A][i][j][f[A][i][j][k]];
			if(i < j) {
				int l = i, r = j - 1, ret = l;
				while(l <= r) {
					int mid = l + r >> 1;
					if(f[A][i][mid][k] <= f[A][mid + 1][j][k]) {
//						Max(f[B][i][j][k], f[A][i][mid][k]);
						ret = mid;
						r = mid - 1;
					}
					else {
//						Max(f[B][i][j][k], f[A][mid + 1][j][k]);
						l = mid + 1;
					}
				}
				Max(f[B][i][j][k], min(f[A][i][ret][k], f[A][ret + 1][j][k]));
				if(ret != i)
				Max(f[B][i][j][k], min(f[A][i][ret - 1][k], f[A][ret][j][k]));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 53376
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
	char a1,a2,a3,a4,a5,a6;
	scanf("%c%c%c\n",&a1,&a2,&a3);
	scanf("%c%c%c",&a4,&a5,&a6);
	if(a1==a6 and a2==a5 and a3==a4) printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    map<int,int>mp;
    int n,x;
    cin>>x>>n;
    while(n--){
        int a;
        cin>>a;
        mp[a]=1;
    }
    int ans=INT_MAX,p;
    for(int i=-200;i<=200;i++){
        if(mp[i])
            continue;
        else
        {
            int dif=abs(x-i);
            if(dif<ans)
                ans=dif,p=i;
            else if(dif==ans)
                p=min(p,i);
        }
    }
    cout<<p<<endl;
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,k,ans=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(ans>=k){
      ans+=k;
    }else{
      ans*=2;
    }
  }
  cout<<ans<<endl;
}
///////////////////////////



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <typeinfo>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>

const int INF = 100000001;

string a;

int main(){
    cin >> a;
    REP(i, a.size()){
        if(i%2 == 0) cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 512
function main(input){
  input = input.split('\n');
  const N = Number(input[0]);
  const S = input.slice(1, N+1);
  const result = {
    AC: 0,
    WA: 0,
    TLE: 0,
    RE: 0,
  };

  S.forEach(s =>{
    result[s]++;
  });

  console.log(`AC x ${result.AC}`);
  console.log(`WA x ${result.WA}`);
  console.log(`TLE x ${result.TLE}`);
  console.log(`RE x ${result.RE}`);

}


main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 37192
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        int vessel1 = a - b;
        int vessel2 = c - vessel1;
        System.out.println(Math.max(vessel2,0));
    }
}

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

int n;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n == 0) return 0;
		vector<int> a;
		readVector(n, a);
		sort(a.begin(), a.end());
		int ans = 1e9+7;
		for(int i=1; i<n; ++i)
			ans = min(ans, a[i] - a[i-1]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a(3);
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    SORT(a);
    cout<<a[0] + a[1]<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

c=[[0]*10 for i in range(10)]
for k in range(1,n+1):
  k=str(k)
  i=int(k[0])
  j=int(k[-1])
  c[i][j]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<bool> latte(n, true);
	for(int i = 0; i < m; i++) {
		int a; scanf("%d", &a);
		
		latte[a - 1] = false;
	}
	
	const int MOD = 1e9 + 7;
	std::vector<int> dp(n + 1, 0); dp[0] = 1;
	for(int i = 0; i < n; i++) {
		if(latte[i]) (dp[i + 1] += dp[i]) %= MOD;
		if(i + 1 < n and latte[i + 1]) (dp[i + 2] += dp[i]) %= MOD;
	}
	
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  sort(rall(arr));

  bool possible = false;
  ll a = 0, b = 0;

  rep(i,n-1) {
    if (arr[i] == arr[i+1]) {
      if (possible) {
        b = arr[i];
        break;
      } else {
        a = arr[i];
        possible = true;
        ++i;
      }
    }
  }

  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
// bs(string &s){int c; s = "";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
// vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

struct point {int x, y;};

int main() {
	for (int n; (n = in());) {
		point ps = {0, 0}, pe = ps;
		vector<point> tiles = {ps};
		for (int i = 1; i < n; i++) {
			int n = in(), d = in();
			point p = tiles[n];
			switch (d) {
			case 0: p.x--; ps.x = min(ps.x, p.x); break;
			case 1: p.y++; pe.y = max(pe.y, p.y); break;
			case 2: p.x++; pe.x = max(pe.x, p.x); break;
			case 3: p.y--; ps.y = min(ps.y, p.y); break;
			}
			tiles.push_back(p);
		}
		out(pe.x - ps.x + 1, " ", pe.y - ps.y + 1, '\n');
	}
}


Measured memory_bytes: 2516
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	hs := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&hs[i])
	}

	costs := make([]int, N)
	costs[0] = 0
	costs[1] = abs(hs[1] - hs[0])

	for i := 2; i < N; i++ {
		c1 := costs[i-1] + abs(hs[i]-hs[i-1])
		c2 := costs[i-2] + abs(hs[i]-hs[i-2])
		costs[i] = min(c1, c2)
	}

	fmt.Println(costs[N-1])
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int ans = 0;
int n;
int l,r;

int main(){
	cin >> n;
	for( int i = 1 ; i <= n ; i++ ){
		cin >> l >> r;
		ans += r-l+1;
	}
	cout << ans << endl;
	return 0;
}


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

vector<vector<int>> g;
vector<int> d;

int main()
{
	int n;
	cin >> n;
	g = vector<vector<int>>( n );
	d = vector<int>( n );
	for( int i = 0; i < n; i++ ) {
		int u, k;
		cin >> u >> k;
		u--;
		for( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			v--;
			g[u].push_back( v );
		}
	}

	queue<pair<int, int>> que;
	que.push( make_pair( 0, 1 ) );
	while( !que.empty() ) {
		int v, l;
		tie( v, l ) = que.front();
		que.pop();
		if( d[v] == 0 ) d[v] = l;
		for( int u : g[v] ) {
			if( d[u] ) continue;
			que.push( make_pair( u,  l + 1 ) );
		}
	}

	for( int i = 0; i < n; i++ ) {
		cout << i + 1 << " " << d[i] - 1 <<  endl;
	}
}



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

int n;
long long a[100004], ans[100004];

int main() {
	cin>>n;
	long long x = 0;
	bool plus = true;
	for(int i = 0;i<n;i++){
		cin>>a[i];
		if(plus)
			x += a[i];
		else
			x -= a[i];
		plus ^= 1;
	}
	x /= 2;
	ans[0] = x;
	for(int i = n-1; i; i--){
		ans[i] = a[i] - x;
		x = a[i] - x;
	}
	for(int i = 0;i<n;i++)	cout<<2*ans[i]<<' ';	
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 120000;
int gcd(int a, int b){return !b?a:gcd(b,a%b);}
int n,a[N];
void print(int x){
	printf("%s",x==1?"First":"Second");exit(0);
}
int main() {
	read(n);rep(i,1,n)read(a[i]);
	int now=1;
	while(1){
		int cnt=0,flag=1;
		rep(i,1,n)cnt+=!(a[i]&1),flag&=a[i]==1;
		if(flag)print(3-now);
		if(cnt&1)print(now);
		if(n-cnt!=1)print(3-now);
		rep(i,1,n)if(a[i]&1){if(a[i]==1)print(3-now);a[i]--;}
		int g=0;rep(i,1,n)g=gcd(g,a[i]);
		rep(i,1,n)a[i]/=g;now=3-now;
	}
	return 0;
}


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

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

    vector<tuple<string, int, int>> a;

    for(int i = 1; i <= N; i++) {
        string s;
        int p;

        cin >> s >> p;
        a.push_back(make_tuple(s, -p, i));
    }

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

    for(tuple<string, int, int> t : a) {
        string s;
        int p;
        int i;
        tie(s, p, i) = t;

        cout << i << endl;
        
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int a[n];
    int sum = 0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        sum += a[i];
    }

    int avg_ceil = int(round((double)sum / n));
    //cout<<avg_ceil<<endl;
    int cost=0;
    for(int i=0;i<n;i++)    cost += ((a[i]-avg_ceil)*(a[i]-avg_ceil));

    cout<<cost<<endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define tin cin>>t;while(t--)
#define pii pair<int,int>
#define endl '\n'
#define MIN 1000000000
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

int dp[100001][3]={-1};
int func(int n,int k,vector<int> v[])
{
	//cout<<n<<" "<<dp[n]<<endl;
	if(n==0&&k==0)
		return max(v[0][1],v[0][2]);
	if(n==0&&k==1)
		return max(v[0][0],v[0][2]);
	if(n==0&&k==2)
		return max(v[0][0],v[0][1]);

	if(dp[n][k]!=-1)
		return dp[n][k];
	if(k==0)
		dp[n][k]=v[n][k]+max(func(n-1,1,v),func(n-1,2,v));
	if(k==1)
		dp[n][k]=v[n][k]+max(func(n-1,0,v),func(n-1,2,v));
	if(k==2)
		dp[n][k]=v[n][k]+max(func(n-1,1,v),func(n-1,0,v));
	return dp[n][k];



	
}


int main()
{
	int n,a,b,c;
	cin>>n;
	vector<int> v[n];
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		v[i].pb(a);
		v[i].pb(b);
		v[i].pb(c);
	}
	memset(dp,-1,sizeof(dp));
	cout<<max(max(func(n-1,0,v),func(n-1,1,v)),func(n-1,2,v));
}

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

using namespace std;

typedef struct node
{
    int key;
    struct node *next;
}Node;

Node *creeazaNod(int k)
{
    Node* p=(Node*)malloc(sizeof(Node));
    p->key=k;
    p->next=NULL;
    return p;
}

void insert_last(Node** first,Node** last,int givenKey)
{
    Node *p=creeazaNod(givenKey);
    if (*first==NULL)
        *first=*last=p;
    else
    {
        p->next=NULL;
        (*last)->next=p;
        *last=p;
    }
}

int main()
{
    int n,m,nrg=0;
    cin>>n>>m;
    vector<Node*>fst(n+1);
    vector<Node*>lst(n+1);
    for (;m;--m)
    {
        int a,b;
        cin>>a>>b;
        insert_last(&fst[a],&lst[a],b);
        insert_last(&fst[b],&lst[b],a);
    }
    vector<int>c(n+1),viz(n+1);
    for (int i=1; i<=n;++i)
        if (viz[i]==0)
        {
            ++nrg;
            int st=0,dr=0;
            c[st]=i;
            viz[i]=1;
            while (st<=dr)
            {
                int prim=c[st];
                for (Node* p=fst[prim];p!=NULL;p=p->next)
                {
                    int nod=p->key;
                    if (viz[nod]==0)
                    {
                        viz[nod]=1;
                        ++dr;
                        c[dr]=nod;
                    }
                }
                ++st;
            }
        }
    cout<<nrg-1;
}


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

 int main() {
     int n, y;;
     int i,j,k;
     
     scanf("%d%d", &n, &y);
     for(i = 0; i <= n; i++){
         for(j = 0; j <= (n-i); j++){
             for(k = 0; k <= (n-i-j); k++){
                 if(10000*i+5000*j+1000*k == y && i+j+k == n){
                     printf("%d %d %d\n", i, j, k);
                     return 0;
                 }
             }
         }
     }
     printf("-1 -1 -1\n");
 }


Measured memory_bytes: 128
N, Y = map(int, input().split())

ans = [-1, -1, -1]

for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        total = i * 10000 + j * 5000 + k * 1000
        if total == Y:
            ans = [i, j, k]
            break
    else:
        continue
    break

print(" ".join(map(str, ans)))


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  load(v, n);

  int before, count = 1, sum = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      before = v[i];
    } else {
      if (before == v[i]) {
        count++;
      } else {
        sum += floor(count / 2.0);
        count = 1;
      }
      before = v[i];
    }
  }
  sum += floor(count / 2.0);
  p(sum);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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


    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if(a %2 == 0){
            if(a %3 != 0 && a%5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll

int main() {
  deque<ll> a;
  vector<string> s(300);
  loop(i,300){
    cin>>s[i];
  }
  loop(i,300){
   if(s[i]=="+"){
     ll x,y;
     x=a.back();
     a.pop_back();
     y=a.back();
     a.pop_back();
     a.push_back(x+y);
     continue;
   }
   if(s[i]=="-"){
     ll x,y;
     x=a.back();
     a.pop_back();
     y=a.back();
     a.pop_back();
     a.push_back(y-x);
     continue;
   }
   if(s[i]=="*"){
     ll x,y;
     x=a.back();
     a.pop_back();
     y=a.back();
     a.pop_back();
     a.push_back(x*y);
     continue;
   }
    if(s[i]==""){
      continue;
    }
    a.push_back(stoll(s[i]));
  }
  cout<<a.front()<<endl;
  
  
  
  

}


Measured memory_bytes: 3196
#include <stdio.h>

int cmp_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(void) {
    int c[5];
    int cmb[5], m, incr, i;
    char *hand;

    while (scanf("%d", &c[0]) == 1) {
        for (i = 1; i < 5; i++) {
            scanf(",%d", &c[i]);
            cmb[i] = 0;
        }
        qsort(c, 5, sizeof(int), cmp_int);
        
        for (i = 1, m = 1, incr = 0; i < 5; i++) {
            m = c[i-1] == c[i]? m + 1: 1;
            cmb[m]++;
            incr += (c[i] - c[i-1]) == 1;
        }
        if (incr == 4 || (c[0] == 1 && c[1] == 10 && incr == 3)) {
            hand = "straight";
        }
        else if (cmb[4]) {
            hand = "four card";
        }
        else if (cmb[3] && cmb[2] == 2) {
            hand = "full house";
        }
        else if (cmb[3]) {
            hand = "three card";
        }
        else if (cmb[2] == 2) {
            hand = "two pair";
        }
        else if (cmb[2]) {
            hand = "one pair";
        }
        else {
            hand = "null";
        }
        puts(hand);
    }

    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int N, K;
    cin >> N >> K;
    vec<int> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());
    ll ans = 0;
    for (int i=N-1; i>=0; i--){
        if (K>0) K--;
        else ans += H[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  if(a.size()>b.size()){
    cout << "GREATER" << "\n";
    return 0;
  }
  else if(a.size()<b.size()){
    cout << "LESS" << "\n";
    return 0;
  }
  else{
    int i;
    for(i=0;i<a.size();i++){
      if(a[i]>b[i]){
        cout << "GREATER" << "\n";
        return 0;
      }
      else if(a[i]<b[i]){
        cout << "LESS" << "\n";
        return 0;
      }
      else continue;
    }
  }
  cout << "EQUAL" << "\n";
  return 0;
}


Measured memory_bytes: 256
# 2019/08/07

from bisect import bisect_left,bisect_right

n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0

for i in range(n):
    bc=n-bisect_right(c,b[i])
    ba=bisect_left(a,b[i])
    ans+=bc*ba    

print(ans)


Measured memory_bytes: 23232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <stack>


int main (void){

	int h, w;

	std::cin >> h >> w;

	std::vector<std::string> v(h);

	for (size_t i = 0; i < h; i++)
	{
		std::cin >> v[i];
	}

	std::priority_queue<std::pair<std::pair<int, int>, int> > pq;
	std::vector<std::vector<bool> > visited(h, std::vector<bool>(w, 0));
	std::vector<std::vector<int> > dist(h, std::vector<int>(w, 100000000));

	pq.push({ { 0, 0 }, 0 });

	while (!pq.empty()) {
		int x = pq.top().first.first;
		int y = pq.top().first.second;
		int d = pq.top().second;

		pq.pop();

		if (x < 0 || y < 0 || x >= h || y >= w ||  dist[x][y] <= d || v[x][y] == '#') {
			continue;
		}

		dist[x][y] = d;
		visited[x][y] = true;
		pq.push({ {x + 1, y}, d + 1 });
		pq.push({ { x - 1, y }, d + 1 });
		pq.push({ { x, y + 1}, d + 1 });
		pq.push({ { x, y - 1}, d + 1 });
	}

	int count_white = 0;

	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (v[i][j] == '.') {
				count_white++;
			}
		}
	}

	if (dist[h - 1][w - 1] == 100000000) {
		std::cout << -1 << std::endl;
		return 0;
	}

	count_white -= 2; // スタート地点とゴール地点を引く

	std::cout << (count_white - dist[h - 1][w - 1] + 1) << std::endl;

	return 0;
}

Measured memory_bytes: 384
s = list(input())
n = len(s)

flg = 1
for i in range(n):
  if s[i] != s[n-i-1]:
    flg = 0

for i in range((n-1)//2):
  if s[i] != s[(n-1)//2-i-1]:
    flg = 0
  if s[(n+3)//2+i-1] != s[n-i-1]:
    flg = 0

print("Yes" if flg else "No")

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

const double PI=3.14159265358979323846;

int main(){
    double a, b, x,d;
    cin >> a >> b >> x;
    if(a*a*b/2 <= x){
        d = atan(2 * b / a - 2 * x / pow(a,3));
    }else{
        d = PI / 2 - atan(2 * x / a / b / b);
    }
    cout <<  fixed << setprecision(10) <<  d * 180.0 / PI;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(s) printf("%c",s)
int main(void){
  int n;
  scanf("%d",&n);
  int a,max = 0,min=10000;
  FOR(n){
    scanf("%d",&a);
    if(max < a){
      max = a;
    }
    if(min > a){
      min = a;
    }
  }
  PRN(max-min);
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

Measured memory_bytes: 256
#include<iostream>
typedef long long ll;

int main() {
    ll A, B, result;
    std::cin >> A >> B;
    for(ll i=1;i <= B;i++){
        if((A*i) % B == 0){
            result = A*i;
            break;
        }
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    string s;
    cin >> s;
    bool a = false, b = false;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A')
            a = true;
        else
            b = true;
    }
    if(a && b)
        cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int ans, A, B, C;
int main() {
	scanf("%d%d%d", &A, &B, &C);
	
	if(A == B && B == C && !(A & 1))
		return puts("-1"), 0;
	
	while(!(A & 1) && !(B & 1) && !(C & 1)) {
		int new_A = (A + B) / 2;
		int new_B = (A + C) / 2;
		int new_C = (B + C) / 2;
		++ans; A = new_A; B = new_B; C = new_C;
	}
	
	printf("%d\n", ans);
	return 0;
}

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

const int N = 500000 + 5; 
string str;
int d[N], len, ans[N];
vector <int> g[N]; 

void toposort() {
    queue <int> q;
    for (int i = 1; i <= len; i++) if(!d[i]) q.push(i), ans[i] = 0; 
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = 0; i < g[u].size(); i++) {
            int v = g[u][i];
            if (d[v]) ans[v] = max(ans[v], ans[u] + 1);
            d[v]--; 
            if (d[v] == 0) q.push(v); 
        }
    }
}
int main() {
    cin >> str;
    len = str.length() + 1;
    for (int i = 1; i < len; i++) {
        if (str[i - 1] == '<') g[i].push_back(i + 1), ++d[i + 1];
        else g[i + 1].push_back(i), ++d[i];
    }

    toposort(); 

    cout << accumulate(ans + 1, ans + len + 1, 0LL) << endl; 
    return 0; 
}

Measured memory_bytes: 32004
N, Q = map(int, input().split())
S = input()
L = len(S)
ACnum = [0] * L
for i in range(1, L):
    ACnum[i] += ACnum[i - 1]
    if S[i - 1] == "A" and S[i] == "C":
        ACnum[i] += 1

lr = [None] * Q
for _ in range(Q):
    lr[_] = list(map(int, input().split()))

for i in range(Q):
    ans = ACnum[lr[i][1] - 1] - ACnum[lr[i][0] - 1]
    print(ans)


Measured memory_bytes: 32292
from bisect import bisect_left
N, K = map(int, input().split())
As = list(map(int, input().split()))

if K >= 40:
    print(' '.join(map(str, [N]*N)))
    exit()

for _ in range(K):
    events = [[] for _ in range(N*2+2)]
    for i, a in enumerate(As):
        l = 2*(i-a)-1
        r = 2*(i+a)+1
        events[-1 if l < -1 else l].append(i)
        events[N*2 if r > N*2 else r].append(i)
    active = [0] * N
    L = 0
    nextAs = [0] * N
    for i in range(N):
        for k in events[2*i-1]:
            if active[k]:
                active[k] = 0
                L -= 1
            else:
                active[k] = 1
                L += 1
        nextAs[i] = L
    As = nextAs

print(' '.join(map(str, As)))


Measured memory_bytes: 316304
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
if s1 > 12 or s1 == 0:
    if s2 > 12 or s2 == 0:
        print("NA")
    else:
        print("YYMM")
elif s2 > 12 or s2 == 0:
    print("MMYY")
else:
    print("AMBIGUOUS")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    string s; 
    int q; 
    cin >> s >> q; 
    string f = "", l = "";
    int z = 0; // zero means f is first and l is last 
               // while one means the opposite 
    deque<char>dq;
    for(int i = 0; i<s.size(); ++i)dq.push_back(s[i]);
    while(q--){
       int tp;
       scanf("%d", &tp);
       if(tp == 1){
          z ^= 1; 
       }
       else {
         int x; 
         char c;
         cin >> x >> c;
         if(z){
           if(x == 1)l += c, dq.push_back(c);
           else f += c, dq.push_front(c);
         }
         else {
           if(x == 1)f += c, dq.push_front(c);
           else l += c, dq.push_back(c);
         }
       }
    }
    string an = "";
    while(!dq.empty())an += dq.front(), dq.pop_front();
    if(z)reverse(all(an));
    printf("%s\n", an.c_str());
} 


Measured memory_bytes: 1696
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
int n, m;
const int ma = 1e6 + 10;
ll a[ma]; /* 
P p[ma]; */
map<int, int> mp;
signed main()
{
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%lld", a + i);
    /*     rep(i, m) scanf("%lld%lld",&p[i].first,&p[i].second); */
    /* sort(p, p + m, [&](P a, P b) {
        return a.second > b.second;
    }); */
    rep(i, m)
    {
        int b, c;
        scanf("%d%d", &b, &c);
        mp[c] += b;
    }
    sort(a, a + n);

    ll ans = 0;
    rep(i, n)
    {
        if (mp.size() && mp.rbegin()->first > a[i])
        {
            a[i] = mp.rbegin()->first;
            mp.rbegin()->second--;
            if (mp.rbegin()->second == 0)
                mp.erase(mp.rbegin()->first);
        }
        ans += a[i];
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, p_1, p_2;
  cin >> N >> A >> B;
  p_1 = N*A;
  p_2 = B;
  if (p_1 < p_2) cout << p_1 << endl;
  else cout << p_2 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def is_unique(seq):
    return len(seq) == len(set(seq))
N = int(input())
a = []
for i in range(N):
    a.append(input())
#print a # [a1, a2, a3, ..., aN]
flag = True

if is_unique(a) == False:
  flag = False
  
for i in range(1,N):
    s1 = a[i-1]
    s2 = a[i]
    s3 = s1[len(s1)-1]
    s4 = s2[0]
    if s3 != s4:
      flag = False
      
if flag == False:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define inf 9223372036854775807;
#define pb push_back;
#define umap unordered_map;
#define uset unordered_set;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    ll x;
    cin>>x;
    ll ans = 0;
    ll n = 100;
    while(n<x){
        n +=n/100;
        ans++;
    }
    cout<<ans;
}
int main(){
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
}   

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pas=0;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	d=sqrt(b);
	for(c=1; c<=d; c++){
		if(b%c==0){
			e=c;
			if(e*a<=b&&pas<e) pas=e;
			e=b/c;
			if(e*a<=b&&pas<e) pas=e;
		}
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC148A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());

            switch (A + B)
            {
                case 3:
                    System.Console.WriteLine("3");
                    break;
                case 4:
                    System.Console.WriteLine("2");
                    break;
                case 5:
                    System.Console.WriteLine("1");
                    break;
            }

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
  long long ans{}, a{};
  string S;
  cin >> S;
  for (int i = 0, n = 1 << (S.size() - 1); i != n; ++i) {
    a = 0;
    for (int j = 0; j != (int)S.size(); ++j) {
      a = 10 * a + (S[j] - '0');
      if (i & (1<<j)) {
        ans += a;
        a = 0;
      }
    }
    ans += a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define INT long long
#define MOD 1000000007
using namespace std;
INT n, k, ans, dp[100010];
vector<INT> G[100010];
void dfs(int x, int y, int d)
{
    int p = (d>1?1:0);
    for(int i = 0, j = 0 ; i < G[x].size() ; i++ )
    {
        int w = G[x][i];
        INT z = (d == 0 ? k-1:k-2);
        if( w == y ) continue;
        ans *= (z-j);
        ans %= MOD;
        dfs(w, x, d+1);
        j++;
    }
    return;
}
int main(void)
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i = 0 ; i < n-1 ; i++ )
    {
        int a, b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans = k;
    dfs(1, 1, 0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11648
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

l = int(input())
print(s[l-1])


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1&&b==2) printf("3");
	if(a==2&&b==1) printf("3");
	if(a==1&&b==3) printf("2");
	if(a==3&&b==1) printf("2");
	if(a==2&&b==3) printf("1");
	if(a==3&&b==2) printf("1");
 } 

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int work()
{
  ll x , k , d ;
  cin >> x >> k >> d ;
  ll res = abs(x / d) ;
  if(res >= k) {
    if(x > 0) cout << x - k * d << endl ;
    else cout << abs(x + k * d) << endl ;
  }
  else {
    ll l , r ;
    if(x > 0) r = x - res * d , l = r - d ;
    else l = x + res * d , r = l + d ;
    if((k - res) % 2){
      if(x > 0)
       cout << abs(l) << endl ;
      else cout << abs(r) << endl ;
    }
    else {
      if(x > 0) cout << abs(r) << endl ;
      else cout << abs(l) << endl ;
    }
  }
  return 0 ;
}
int main()
{
  //   freopen("C:UsersspnooyseedDesktopin.txt" , "r" , stdin) ;
  //   freopen("C:UsersspnooyseedDesktopout.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3192