akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    double a = nextDouble();
    double b = nextDouble();

    int[] okA = new int[100];
    int[] okB = new int[100];

    int cntA = 0;
    int cntB = 0;

    boolean ok = false;

    for(int i=1;i<5000;i++){

      //A
      ok = (a<=(8*i/100) && (8*i/100)<(a+1));
      if(ok){
        okA[cntA] = i;
        cntA++;
      }

      //B
      ok = (b<=(10*i/100) && (10*i/100)<(b+1));
      if(ok){
        okB[cntB] = i;
        cntB++;
      }

    }

    int ans = 0;

    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
        if(okA[i]==okB[j]){
          ans = okA[i];
        }
      }
      if(ans!=0){
        break;
      }
    }

    if(ans==0){
      ans = -1;
    }

    System.out.println(ans);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23636
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t a, b, c;
    cin >> a >> b >> c;

    // sqrt(a) + sqrt(b) < sqrt(c)
    // a + b + 2 * sqrt(ab) < c
    // 2 * sqrt(ab) < c - a - b
    // 4 * ab < (c - a - b) ^2

    if (c < a + b)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << (4ll * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << endl;
    }
}


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

double PI = 3.141592653589793;

int64_t mypow(int64_t x, int64_t y, int64_t MOD) //x ^ y
{
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1, MOD) * x % MOD;
    else
    {
        int64_t tmp = mypow(x, y / 2, MOD);
        return tmp * tmp % MOD;
    }
}

int popcount(int64_t N)
{
    int x = 0;
    while (N > 0)
    {
        if (N % 2 == 1)
            x++;
        N /= 2;
    }
    return x;
}

int main()
{
    int N, tmp, one = 0;
    string X;
    cin >> N >> X;

    for (int i = 0; i < N; i++)
        if (X[i] == '1')
            one++;
    int plus = one + 1, minus = one - 1;

    bool x = false;
    if (minus == 0)
        x = true, minus = 1;

    int p = 0, p_kt = 1, m = 0, m_kt = 1; //0→1,1→0
    reverse(X.begin(), X.end());
    for (int i = 0; i < N; i++)
    {
        if (X[i] == '1')
            p += p_kt, m += m_kt;
        p %= plus, m %= minus;
        p_kt = (p_kt * 2) % plus, m_kt = (m_kt * 2) % minus;
    }
    reverse(X.begin(), X.end());

    for (int i = 0; i < N; i++)
    {
        int count = 0;
        if (X[i] == '0')
            tmp = (p + mypow(2, N - 1 - i, plus)) % plus;

        if (X[i] == '1')
        {
            if (x)
            {
                cout << 0 << endl;
                continue;
            }
            else
                tmp = (m - mypow(2, N - 1 - i, minus) + minus) % minus;
        }
        while (tmp != 0)
        {
            tmp %= popcount(tmp);
            count++;
        }
        cout << count + 1 << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  int ret = 0;
  REP(i, n) {
    if(i == a[a[i]-1]-1) ret++;
  }

  cout << ret/2 << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;

  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) ans++;
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, j;
    int m, n;
    scanf("%d %d\n", &n, &m);
    int matrixA[n][m];
    int matrixB[m];
    int matrixR[n];
    for(i = 0; i < n; i++){
        matrixR[i] = 0;
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &matrixA[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d\n", &matrixB[i]);
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
           matrixR[i] += matrixA[i][j]*matrixB[j];
        }
    }
    
    for(i = 0; i < n; i++){
        printf("%d\n", matrixR[i]);
    }
    return 0;
}


Measured memory_bytes: 644
while True:
    n,r = map(int,raw_input().split())
    if(n == 0 and r == 0):
        break
    li = []
    for i in xrange(1,n+1):
        li.append(i)
    for i in xrange(r):
        temp_lis1 = []
        p,c = map(int,raw_input().split())
        if(c == 1):
            temp_lis1.append(li[n-p])
            del(li[n-p])
        else:
            temp_lis1.extend(li[n-p-c+1:n-p+1])
            del(li[n-p-c+1:n-p+1])
        li.extend(temp_lis1)
    print li[n-1]

Measured memory_bytes: 6172
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    
    long long n,k,t;
    cin>>n>>k;

    t=n%k;
    t=min(t,abs(t-k));
    cout<<t;
    
}

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

#define forsn(i, s, n)	for (int i = s; i < n; i++)
#define forn(i, n)		for (int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;

int main() {
	ull n;
	cin >> n;
	ull ans = n*(n+1)/2;
	//cout << ans << '\n';
	ans -= 3 * (n/3)*(n/3+1) / 2;
	//cout << ans << '\n';
	ans -= 5 * (n/5)*(n/5+1) / 2;
	//cout << ans << '\n';
	ans += 15 * (n/15)*(n/15+1) / 2;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long fact[100001];
int main(){
	fact[0]=1;
	for(int i=1;i<=100000;i++)
		fact[i]=fact[i-1]*i%mod;
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>=2)
		cout<<0<<endl;
	else if(n==m)
		cout<<fact[n]*fact[m]*2%mod<<endl;
	else
		cout<<fact[n]*fact[m]%mod<<endl;
}


Measured memory_bytes: 1024
// id: ALDS1_3_B
// CPU: 00:sec  Memory: KB
#include <cstdio>
#include <queue>
#include <string>

using std::queue;
using std::string;

static const int NAME_LEN = 10;

struct Process {
	string pid;
	int rest;

	Process(const string &s, int t): pid(s), rest(t) { }
	Process(const Process &p): pid(p.pid), rest(p.rest) { }
};

int main()
{
	int n, slice;
	int time = 0;
	queue<Process> processes;

	scanf("%d%d", &n, &slice);

	for ( int i = 0; i < n; ++i ) {
		char pid[NAME_LEN + 1];
		int rest;

		scanf("%s%d", pid, &rest);

		processes.push(Process(string(pid), rest));
	}

	while ( !processes.empty() ) {
		Process p(processes.front());
		processes.pop();

		if ( p.rest > slice ) {
			p.rest -= slice;
			time += slice;
			processes.push(p);
		}
		else {
			time += p.rest;
			printf("%s %d\n", p.pid.c_str(), time);
		}
	}

	return 0;
}


Measured memory_bytes: 5880
#include <cstdio>
#include <vector>
int main() {
  int n;
  scanf("%d", &n);
  
  int t[100];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
    sum += t[i];
  }
  int m;
  scanf("%d", &m);
  
  int p[100];
  int x[100];
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
    scanf("%d", &x[i]);
  }
  
  for (int i = 0; i < m; i++) {
    printf("%d\n", sum-t[p[i]-1]+x[i]);
  }
  return 0;
}

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

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

    int x;
    cin >> x;
    if(x == 3 or x == 5 or x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    int mx=0;
    int mx_n=0;
    int co=-1;
    int co_n=-1;
    for(int i=0; i<n; i++){
        mx=max(mx,a[i]);
        if (mx==a[i]) co=i;
    }
    for(int i=0; i<n; i++){
        if (co!=i){
            mx_n=max(mx_n,a[i]);
            if (mx_n==a[i]) co_n=i; 
        }
    }

    for (int i=0; i<n; i++){
        if(co==i){
            cout<<mx_n<<endl;
        }
        else{
            cout<<mx<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
N,K=map(int,input().split())
A=[int(i) for i in range(1,N+1,1)]

for _ in range(K):
    d=int(input())
    A_lis=list(map(int,input().split()))
    
    for i in A_lis:
        if i in A: A.remove(i)
print(len(A))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans = -1;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      int p = a[i] * a[j];
      string s = to_string(p);
      int m = s.size();
      bool ok = true;
      for (int k = 0; k < m - 1; k++){
        if (s[k + 1] != s[k] + 1){
          ok = false;
        }
      }
      if (ok){
        ans = max(ans, p);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3288
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, 0, n) cin >> a[i];
    pll bc[m];
    rep(i, 0, m)
    {
        cin >> bc[i].se >> bc[i].fi;
    }

    sort(a.begin(), a.end());
    //rep(i, 0, n) cout << a[i] << " ";
    //cout << endl;
    sort(bc, bc + m);
    reverse(bc, bc + m);
    //rep(i, 0, m) cout << bc[i].fi << " " << bc[i].se << endl;

    ll sp = 0;
    rep(i, 0, m)
    {
        rep(j, 0, bc[i].second)
        {
            if (bc[i].first <= a[sp])
            {
                ll sum = 0;
                rep(k, 0, n)
                {
                    sum += a[k];
                }
                cout << sum << endl;
                return 0;
            }
            a[sp] = bc[i].first;
            sp++;
        }
    }
    ll sum = 0;
    rep(k, 0, n)
    {
        sum += a[k];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
  int N, ans = 1;

  cin >> N;

  while(ans <= N) ans *= 2;
  ans /= 2;

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n, k;
    scanf("%d %d", &n, &k);
	printf("%d", n-k+1);
	return 0;	
}

Measured memory_bytes: 256
S = input()
N = len(S)
if S[0:7] == 'keyence':
  print('YES')
  exit()
if S[-7:] == 'keyence':
  print('YES')
  exit()
for i in range(6):
  X = S[0:i+1]
  Y = S[-6+i:]
  if X + Y == 'keyence':
    print('YES')
    exit()
print('NO')

Measured memory_bytes: 3064
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
Mod = 1000000007




def main(): #startline--------------------------------------------
    N,M = map(int,input().split())
    AB = [list(map(int,input().split())) for i in range(M)]
    AB.sort(key = lambda x:x[1],reverse = True)
    l = AB[0][0]
    r = AB[0][1]
    ans = 1
    for i in range(1,M):
        if r <= AB[i][0] or l >= AB[i][1]:
            ans += 1
            l = AB[i][0]
            r = AB[i][1]
        else:
            l = max(AB[i][0],l)
            r = AB[i][1]

    print(ans)
if __name__ == "__main__":
    main() #endline===============================================





def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 33200
#include<bits/stdc++.h>
#define INF "{"
using namespace std;
typedef pair<string,int> P;

vector<string> e[41][41];
int n,a,s,g;
string cal(){
  priority_queue<P,vector<P>,greater<P> > q;
  bool used[40][481]={};
  q.push(P("",s));
  while(!q.empty()){
    string sm=q.top().first;
    int p=q.top().second;
    q.pop();
    if(p==g){
      if(sm.size()>240) return "NO";
      return sm;
    }
    if(sm.size()>480||used[p][sm.size()])continue;
    used[p][sm.size()]=1;
    for(int i=0;i<n;i++)
      for(int j=0;j<e[p][i].size();j++)
	q.push(P(sm+e[p][i][j],i));
  }
  return "NO";
}

int main(){
  while(cin>>n>>a>>s>>g,n){
    string st;
    for(int i=0;i<40;i++)
      for(int j=0;j<40;j++)e[i][j].clear();
    for(int i=0,x,y;i<a;i++){
      cin>>x>>y>>st;
      e[x][y].push_back(st);
    }
    cout<<cal()<<endl;
  }
  return 0;
}

Measured memory_bytes: 34152
N = int(raw_input())
ans = 0
for i in range(1, N+1):
    num = 0
    if i%2 != 0:
        for j in range(1, N+1):
            if i%j == 0:
                num = num + 1
#        print i, num                                                                                  
        if num == 8:
            ans = ans + 1

print ans


Measured memory_bytes: 2568
n,k=map(int,input().split())
a=list(map(int,input().split()))
pl=1
visit=[-1]*n
visit[0]=0
loop=0
cnt=0

while 1:
    cnt+=1
    pl=a[pl-1]
    if visit[pl-1]!=-1:
        loop=visit[pl-1]
        break
    visit[pl-1]=cnt
    if cnt==k:
        print(pl)
        exit()

loop_len=cnt-loop
q=True
k=(k-loop)%loop_len+loop
print(visit.index(k)+1)

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

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


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

  int dist0,dist1;
  if(M%2 == 0){
    dist0 = M;
    dist1 = M-1;
  }  else{
    dist0 = M-1;
    dist1 = M;
  }
  bool turn = true;
  int left = 1,right = dist0+2;
  rep(i,M){
  if(turn){
    cout<<right<<' '<< right + dist1<<endl;
    right++;
    dist1 -= 2;
    turn = false;
  }
    else{
      cout<<left<<' '<<left+dist0<<endl;
      left++;
      dist0 -=2;
      turn = true;
    }
  }
}


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
from collections import Counter
from operator import itemgetter

def mpsort(m):
	ary = sorted([[k, v] for (k, v) in m.items()], key=itemgetter(1), reverse=True)
	if len(ary) == 1:
		return ary[0], [0, 0]
	return ary[0], ary[1]

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	gu = [i for i in v[::2]]
	ki = [i for i in v[1::2]]
	gu_map = Counter(gu)
	ki_map = Counter(ki)
	s = n//2
	# print(gu_map)
	gu_f, gu_s = mpsort(gu_map)
	ki_f, ki_s = mpsort(ki_map)

	if gu_f[0] == ki_f[0]:
			print(min(s - gu_s[1] + s - ki_f[1],
					  s - gu_f[1] + s - ki_s[1]))
	else:
		print(s - gu_f[1] + s - ki_f[1])

if __name__ == '__main__':
	main()


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,a[maxn];
vector<int > ans;

int main() {
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int t=1;t<=n;t++) {
        int mx=-1;
        for(int i=1;i<=n;i++) if(a[i]==i) mx=i;
        if(mx==-1) return puts("-1"),0;
        ans.pb(mx);
        for(int i=mx;i<=n;i++) a[i]=a[i+1];
    }
    reverse(ans.begin(),ans.end());
    for(auto v:ans) write(v);
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

if (C>=(A+B)/2):
    price = A*X+B*Y
    print(price)
else:
    if(X>=Y):
        price = C*Y*2+A*(X-Y)
    else:
        price = C*X*2+B*(Y-X)
    print(min(price,C*2*max(X,Y)))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void  main(String args[]){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        sc.close();
        if(S.length() > K){
            String s = S.substring(0,K);
            S = s + "...";
        }
        System.out.println(S);
    }
}


Measured memory_bytes: 38652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	c := make([]string, 3)
	for i := range c {
		c[i] = next()
	}
	fmt.Printf("%c%c%c\n", c[0][0], c[1][1], c[2][2])
}


Measured memory_bytes: 640
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn main() {
    let v:Vec<i128> = procon_read();
    let mut maxv:Vec<i128> = Vec::new();
    maxv.push(v[0]*v[2]);
    maxv.push(v[0]*v[3]);
    maxv.push(v[1]*v[2]);
    maxv.push(v[1]*v[3]);
    maxv.sort();
    println!("{}", maxv[3]);
}

Measured memory_bytes: 2168
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
s = S()
cnt = 0
ans = set()
one_digit_set = set()
two_digit_set = set()
for i in range(n):
    for two_d in two_digit_set:
        ans.add(s[i] + two_d)
    for one_d in one_digit_set:
        two_digit_set.add(s[i] + one_d)
    one_digit_set.add(s[i])


print(len(ans))



Measured memory_bytes: 42476
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+50;
int n,a[maxn];
int main()
{
    memset(a,0,sizeof a);
    cin>>n;
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        if(x==y) a[i]=1;
    }
    int flag=0;
    for(int i=0;i<n-2;++i)
    {
        if(a[i]==1)
        {
            if(a[i+1]==1&&a[i+2]==1)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

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

  int answer = 700;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'o') {
      answer += 100;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
import sys
if __name__ == "__main__":
    N, M, X = list(map(int, (input().split(' '))))
    A = list(map(int, (input().split(' '))))
    cost = [0 for i in range(N+1)]
    ans1 = 0
    ans2 = 0
    for i in range(N+1):
        if i in A:
           cost[i] = 1
    for i in range(X, -1, -1):
        ans1 += cost[i]
    for i in range(X, N+1):
        ans2 += cost[i]
    if ans1 < ans2:
        print(ans1)
    else:
        print(ans2)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef complex<double> cdouble;
typedef vector<complex<double>> vcd;
typedef vector<vector<complex<double>>> vvcd;

/*******************************************************/

int main() {
  int n, m; cin >> n >> m;
  vi a(n); Loop(i, n) cin >> a[i];
  // preparing
  map<int, int> mp;
  Loop(i, n) mp[a[i]]++;
  vi b(n * 2, 0);
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int k = n + itr->first;
    Loop1(i, itr->second) {
      b[k - i]++;
    }
  }
  int cnt = 0;
  Loop(i, n) {
    if (b[n + i] == 0) cnt++;
  }
  // queries
  Loop(nonsense, m) {
    int x, y; cin >> x >> y;
    x--;
    int pre_ax = a[x];
    a[x] = y;

    b[n + pre_ax - mp[pre_ax]]--;
    if (n + pre_ax - mp[pre_ax] >= n && b[n + pre_ax - mp[pre_ax]] == 0) cnt++;
    mp[pre_ax]--;

    mp[y]++;
    if (n + y - mp[y] >= n && b[n + y - mp[y]] == 0) cnt--;
    b[n + y - mp[y]]++;

    cout << cnt << endl;
  }
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for(int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x)                                                              \
    rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
    if(a > b)
        a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
    if(a < b)
        a = b;
}
int N, W;
int w[105];
int v[105];
void input() {
    cin >> N >> W;
    rep(i, 0, N - 1) { cin >> w[i] >> v[i]; }
}

int dp[105][100005] = {0}; // dp[個数][重さ合計] = 価値合計の最大
void solve() {
    rep(i, 0, N - 1) {
        rep(j, 0, W) {
            if(j - w[i] >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }

            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

signed main() {
    input();
    solve();
    return 0;
}

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

using namespace std;

int main(){
	int n, m, tage[100], choice[100][100];
	int score[100];
	fill_n(score, 100, 0);
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> tage[i];
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin >> choice[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(tage[j] == choice[j][i]) score[i]++;
			if(i+1 == tage[j]){
				int hazure = 0;
				for(int k = 0; k < n; k++) if(choice[j][k] != tage[j]) hazure++;
				score[i] += hazure;
			}
		}
	}

	for(int i = 0; i < n; i++) cout << score[i] << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, u, v; cin >> n >> u >> v; u--; v--;

    //ここで木に対する隣接リストを作る。
    Graph g(n);
    rep(i,n-1){
        int f, t; cin >> f >> t; f--; t--;
        g[f].push_back(t);
        g[t].push_back(f);
    }
    //作りました。



    Graph dist(2, (vector<int> (n, 1002003004)));
    vector<int> start(2); start[0] = u, start[1] = v;
    

    rep(i,2){
        vector<int> tmpd(n,1002003004);
        queue<int> q;

        auto push = [&](int v,int d){
            if(tmpd[v] != 1002003004) return;
            tmpd[v] = d;
            q.push(v);
        };

        push(start[i],0);
        while(!q.empty()){
            int p = q.front(); q.pop();
            int d = tmpd[p];

            for(auto nv: g[p]){
                push(nv, d+1);
            }
        }

        rep(j,n) dist[i][j] = tmpd[j];
    }

    int ans = 0;

    rep(i,n){
        if(dist[0][i] < dist[1][i]){
            ans = max(ans,dist[1][i] - 1);
        }
    }

    cout << ans << endl;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = (n+1)*(n-2)/2 + 1;
  cout << ans << endl;  
}


Measured memory_bytes: 3564
#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 ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b;
  cin >> a >>b;
  cout << ceil((a+b)/2) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int gcd(int x,int y){
	return x ? gcd(y%x,x) : y;
}
int main()
{
	int n,a,Max,k;
	int i;
	cin>>n>>a>>k;
	int tmp=k;
	Max=k;
	int ans=0;
	for(i=1;i<n;i++)
	{
		int t;
		cin>>t;
		tmp=gcd(tmp,t);
		Max=max(Max,t);
	}
	//cout<<a<<endl;
	if(n == 1)
	{
		if(a == tmp) 
			ans = 1;
	}
		
	else
	{
		if(a%tmp == 0 && a <= Max) 
		ans = 1;
	}
		
	if(ans == 1) 
		puts("POSSIBLE");
	
	else 
		puts("IMPOSSIBLE");
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   if(!(n&1)){
      cout << n/2-1 << '\n';
   }else{
      cout << n/2 << '\n';
   }
   return 0;
} 

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

typedef pair <int, int> ii;

const int Maxn = 606;

int n;
char S[Maxn][Maxn];
ii my[Maxn];
int mlen;
bool ok[Maxn][Maxn];
int cnt[Maxn][Maxn];

bool Equal(const ii &a, const ii &b)
{
	return S[a.first][a.second] == S[b.first][b.second];
}

void Check(const ii &p)
{
	if (0 <= p.first && p.first < n && 0 <= p.second && p.second < n)
		cnt[p.first][p.second]++;
}

void Update(const ii &p, int len)
{
	Check(ii(p.first - len + 1, p.second));
	if (len != n)
		Check(ii(p.first - n + 1, p.second - n + len));
}

void Solve(int r, int c)
{
	mlen = 0;
	while (r >= 0 && c < 2 * n) {
		my[mlen++] = ii(r, c);
		r--; c++;
	}
	for (int i = 0; i < mlen; i++) {
		ok[i][i] = true; Update(my[i], 1);
	}
	for (int l = 2; l <= n && l <= mlen; l++)
		for (int i = 0; i + l <= mlen; i++) {
			int j = i + l - 1;
			ok[i][j] = Equal(my[i], my[j]) && (i + 1 >= j || ok[i + 1][j - 1]);
			if (ok[i][j]) Update(my[i], l);
		}
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			scanf(" %c", &S[i][j]);
			S[i + n][j] = S[i][j + n] = S[i + n][j + n] = S[i][j];
		}
	for (int i = 0; i < 2 * n; i++)
		Solve(i, 0);
	for (int j = 1; j < 2 * n; j++)
		Solve(2 * n - 1, j);
	int res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			res += cnt[i][j] == 2 * n - 1;
	printf("%d\n", res);
	return 0;
}

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

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n-90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n-9090)
elif n == 100000:
    print(90909)

Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int m[10];
	int a,i,j;
	for(i=0; i<10; i++){
	scanf("%d", &m[i]);
	}
	for(i=0; i<10; ++i){
		for(j=i+1; j<10; ++j){
			if(m[i]<m[j]){
				a=m[i];
				m[i]=m[j];
				m[j]=a;
			}
		}
	}
	for(i=0; i<3; i++){
	printf("%d\n",m[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll p[35];
void solve(){
	ll n,res=0;
	cin>>n;
	multiset<ll> m;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		m.insert(x);
	}
	while(!m.empty()){
		ll val=(*prev(m.end(),1));
		m.erase(prev(m.end(),1));
		if(m.empty())
		break;
		for(ll i=34;i>=0;i--)
		if(p[i]>val){
			auto it=m.find(p[i]-val);
			if(it==m.end())
			continue;
			m.erase(it);
			res++;
			break;
		}
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    p[0]=1;
    for(ll i=1;i<35;i++)
    p[i]=p[i-1]*2;
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 13020
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<list>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>

using namespace std;

#define MAX_N 1000005
const int INF = 0x3f3f3f3f;

int prime[1000000];
int c[MAX_N];

void Prime_creat()
{
    int i,j;
    for(i=2; i<=1000000; i++)
    {
        if(prime[i])
        {
            c[i] = c[i - 1] + 1;
            for(j=i+i; j<=1000000; j+=i)
                prime[j]=0;
        }
        else
        {
            c[i] = c[i - 1];
        }
    }
}

int main()
{
    memset(prime, 1, sizeof(prime));
    Prime_creat();
    int n;

    while(~scanf("%d", &n))
    {
        printf("%d\n", c[n]);
    }

    return 0;
}

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,W;
  cin >> n >> W;
  long long int w[n];
  long long int v[n];
  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
  }
  long long int dp[n+1][W+1];
  for(int i = 0;i <= W;i++){
    dp[0][i] = 0;
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= W;j++){
      if(w[i] <= j){
        dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[n][W] << endl;
}

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

int main(){
  int n;
  cin >> n;
  int p[n];
  for ( int i = 0; i < n; i++) cin >> p[i];
  int cnt=0;
  
  for ( int i = 1; i < n-1; i++){
    if (p[i] > p[i-1] && p[i] < p[i+1]) cnt++;
    else if ( p[i] < p[i-1] && p[i] > p[i+1] ) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 10;
vector<int> pd[N];
bool mark[N];

void sieve(){
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = i; j < N; j += i) {
                if(j != i) mark[j] = 1;
                pd[j].emplace_back(i);
            }
        }
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    sieve();
    vector<int> cnt(N,0);
    int n;
    cin >> n;
    int gcd = 0;
    bool pair_wise = 1;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        gcd = __gcd(gcd,tmp);
        for(auto x : pd[tmp]){
            cnt[x]++;
            if(cnt[x] > 1) pair_wise = 0;
        } 
    }
    if(pair_wise)  cout << "pairwise coprime\n";
    else if(gcd == 1) cout << "setwise coprime\n";
    else cout << "not coprime\n";
    return 0;
}

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


class comb{
	vector<ll> f,fr;
	ll MOD_;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		if(n<0||r<0||n<r)return 0;
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}
};
int main(){

	ll N,P,ans=0,zero=0,one=0,a;
	cin >> N >> P;
	for(int i=0;i<N;i++){
		cin >> a;
		if(a&1){
			one++;
		}else{
			zero++;
		}
	}
	comb co;
	co.init(N+1,1000000007LL);
	for(int i=P;i<=one;i+=2){
		ans += co.nCr(one,i);
	}
	cout << ans*(1LL<<zero) << endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define bitcount __builtin_popcount
#define bitctz __builtin_ctz
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; double p;
	cin>>n>>m>>p; p/=100;
	int a[100], b[100];
	for(int i=0; i<m; i++){
		cin>>a[i]>>b[i]; a[i]--; b[i]--;
	}
	int ct[1<<14]={};
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<m; j++){
			if((i&(1<<a[j])) && (i&(1<<b[j]))) ct[i]++;
		}
	}
	double dp[15][1<<14]={};
	for(int i=0; i<n; i++) dp[1][1<<i]=1;
	for(int i=1; i<(1<<n); i++){
		if(bitcount(i)==1) continue;
		int t=bitctz(i);
		for(int j=i; j>0; j=(j-1)&i){
			if((j&(1<<t))==0) continue;
			if(j==i) continue;
			for(int k=1; k<n; k++){
				dp[k+1][i]+=(dp[k][i-j]*dp[1][j]*pow(p, (double)(ct[i]-ct[j]-ct[i-j])));
			}
		}
		dp[1][i]=1;
		for(int k=2; k<=n; k++){
			dp[1][i]-=dp[k][i];
		}
	}
	printf("%.10lf\n", dp[1][(1<<n)-1]);
	return 0;
}


Measured memory_bytes: 5384
<?php
$n = trim(fgets(STDIN));
$array = explode(" ", trim(fgets(STDIN)));

$bp = 0;
$move = 0;
foreach($array as $p){
    $move+=abs($p-$bp);
    $bp = $p;
}
$move+=abs($bp);
foreach($array as $i => $p){
    $bp = @$array[$i-1];
    $np = @$array[$i+1];
    if(($np - $p) * ($p - $bp) > 0){
        echo $move."\n";
    }else{
        echo ($move-min(abs($np-$p), abs($bp-$p))*2)."\n";
    }
}


Measured memory_bytes: 13940
#include <cstdio>

int a[10];

int main(int argc, const char * argv[]) {
    int T;
    scanf("%d", &T);
    while (T--) {
        bool ans = true;
        for (int i = 0; i < 10; i++) {
            scanf("%d", &a[i]);
        }
        int l, r;
        l = r = 0;
        for (int i = 0; i < 10; i++) {
            if (a[i] > l) {
                l = a[i];
            } else if (a[i] > r) {
                r = a[i];
            } else {
                ans = false;
                break;
            }
        }
        printf("%s\n", ans ? "YES" : "NO");
    }
    return 0;
}


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

int main(){
  int n; int i=0; int sum=0; int sum2=0; int ans; int d1, d2;
  cin >> n;
  vector<int> w(n);
while(i<n){
    cin >> w[i++];
}

for(int j=0; j<n; j++) sum += w[j];

for(int k=0; k<n; k++){
sum2 += w[k];
if(sum2>(sum/2)){
    d1=sum2+sum2-sum;
    d2=sum-(sum2-w[k])*2;
ans = (d1<d2) ? d1 : d2;
break;
}
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define NIL (-1)
#define M 1046527
#define L 14

char H[M][L];
 
int getch(char ch)//将字符串转化为数值 
{  if(ch=='A')  return 1;
   else if(ch=='C')  return 2;
   else if(ch=='G')  return 3;
   else if(ch=='T')  return 4;
   else return 0;
}
long long getkey(char str[])//将字符串转化为数值并生成key 
{  long long sum,p,i;
   sum=0;p=1;
   for(i=0;i<strlen(str);i++)
   {  sum=sum+p*(getch(str[i]));
      p=p*5;
   }
   return sum;
}
int h1(int key)
{  return key%M;
}
int h2(int key)
{  return 1+(key%(M-1));
}
int find(char str[])
{  long long key,i,h;
   key=getkey(str);//将字符串转化为数值 
   for(i=0;;i++)
   {  h=(h1(key)+i*h2(key))%M;
      if(strcmp(H[h],str)==0) return 1;
      else if(strlen(H[h])==0)  return 0;
   }
   return 0;
}
int insert(char str[])
{  long long key,i,h;
   key=getkey(str);//将字符串转化为数值 
   for(i=0;;i++)
   {  h=(h1(key)+i*h2(key))%M;
      if(strcmp(H[h],str)==0)  return 1;
      else if(strlen(H[h])==0)
      {  strcpy(H[h],str);
         return 0;
      }
   }
   return 0;
}
int main()
{  int i,n,h;
   char str[L],com[9];
   for(i=0;i<M;i++)  H[i][0]='\0';
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {  scanf("%s %s",&com,&str);
      if(com[0]=='i')  insert(str);
      else
	  {  if(find(str))  printf("yes\n");
	     else printf("no\n");
	  }   
   }
   return 0;
}


Measured memory_bytes: 16044
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
ll solve(ll n,ll x) {
	ll k = n / x;
	if (n%x == 0)return x * (2 * k - 1);
	return 2 * k*x + solve(x, n%x);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x;
	cin >> n >> x;
	if (x * 2 <= n)cout << solve(n - x, x) + n << endl;
	else cout << solve(x, n - x) + n << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
monster = 0
hero = 0
for i in range(N):
    allhero = B[i] + hero
    if allhero<=A[i]:
        monster += allhero
        hero = 0
    else:
        monster += A[i]
        if hero>A[i]:
            hero = B[i]
        else:
            hero = allhero-A[i]
    #print(monster,allhero,hero)

if hero>0:
    monster += min(hero,A[N])
print(monster)

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

using namespace std;

#define int long long

void solve() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector <pair <int, int> > pr(n);
    if (s[0] == 'o') pr[0] = {1, 0};
    else pr[0] = {0, -1};
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'o') {
            if (pr[i - 1].first == 0 || i - pr[i - 1].second > c) pr[i] = {pr[i - 1].first + 1, i};
            else pr[i] = pr[i - 1];
        }
        else pr[i] = pr[i - 1];
    }
    vector <pair <int, int> > suf(n);
    if (s[n - 1] == 'o') suf[0] = {1, n - 1};
    else suf[0] = {0, n};
    for (int i = 1; i < n; ++i) {
        if (s[n - i - 1] == 'o') {
            if (suf[i - 1].first == 0 || suf[i - 1].second - (n - i - 1) > c) suf[i] = {suf[i - 1].first + 1, (n - i - 1)};
            else suf[i] = suf[i - 1];
        }
        else suf[i] = suf[i - 1];
    }
    //for (int i = 0; i < n; ++i) cout << pr[i].first << ' ' << pr[i].second << '\n';
    //for (int i = 0; i < n; ++i) cout << suf[i].first << ' ' << suf[i].second << '\n';
    //assert(pr[n - 1].first >= k);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'x') continue;
        int val = 0;
        if (i > 0) val += pr[i - 1].first;
        if (i < n - 1) val += suf[n - 2 - i].first;
        if (i > 0 && i < n - 1 && suf[n - 2 - i].second - pr[i - 1].second <= c && suf[n - 2 - i].first && pr[i - 1].first) --val;
        if (val < k) cout << i + 1 << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 8084
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 14:28:43 2020

@author: NEC-PCuser
"""

S = input()
T = input()

start = -1

i = 0
for i in range(0, len(S) - len(T) + 1):
    k = 0
    for b in T:
        if S[i + k] != b and S[i + k] != '?':
            break
        k += 1
    else:
        start = i

if start == -1:
    print("UNRESTORABLE")
else:
    s = list(S)
    s[start:start + len(T)] = T
    S = "".join(s)
    
    print(S.replace('?', 'a'))
    
    

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define MAX 16

using namespace std;
double d[MAX];
double km[MAX],kazu[1<<MAX],num[MAX],kazu2[1<<MAX];
double dp[1<<MAX][MAX];
int n;
vector<int> prev[(1<<MAX)][MAX];  //同じく経路復元用　最短経路の直前の頂点を示す
//vector<int> path[(1<<n)][MAX];  //経路復元用
void solve();

int main(){
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> num[i] >> d[i] >> kazu2[i];
      kazu2[i]*=20;
    }

  for(int i=0;i<(1<<n);i++)
    {
      int sum=0,count=0;
      for(int j=1;j<(1<<n);j=(j<<1),count++){
	if((i&j)!=0){
	  sum += kazu2[count];
	}
      }
      kazu[i]=sum;
    }

  solve();


}

void solve()
{

  rep(i,(1<<n))rep(j,n)dp[i][j]=INF;

  rep(i,n)
    {
    dp[1<<i][i]=0.0;
    prev[1<<i][i].push_back(i);
    }
  double cost;

  for(int S=1;S<(1<<n);S++)
    {
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<n;j++)
	    {
	      if(!(S & (1<<j)))
		{
		  cost = ((70.0+kazu[S])/2000.0)*abs(d[i] - d[j]);
		  //cout << "cost = " << cost << endl;
		  if(dp[S|(1<<j)][j] > dp[S][i] + cost)
		    {
		      dp[S|(1<<j)][j]=dp[S][i]+cost;
		      prev[S|(1<<j)][j]=prev[S][i];
		      prev[S|(1<<j)][j].push_back(j);
		    }
		}
	    }
	}
    }
    
  double mini = INF;
  vector<int> path;

  for(int i=0;i<n;i++){
    if(mini > dp[(1<<n)-1][i]){
      mini = dp[(1<<n)-1][i];
      path = prev[(1<<n)-1][i];
    }
  }

  for(int i=0;i<path.size();i++){
    cout << num[path[i]];
    if(i != path.size()-1)cout << " ";
  }
  cout << endl;



}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import deque
N, M = map(int, input().split())
edge = []
for _ in range(M):
    edge.append(list(map(int, input().split())))
ans = 0 
for i in range(M):
    done = [True for _ in range(N + 1)]
    renketu = [[] for _ in range(N + 1)]
    for j in [k for k in range(M) if k != i]:
        a, b = edge[j][0], edge[j][1]
        renketu[a].append(b)
        renketu[b].append(a)
    q = deque([1])
    while q:
        now = q.pop()
        done[now] = False

        for r in renketu[now]:
            if done[r]:
                q.append(r)
    if sum(done) > 1:
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
double H,M,x,y; 
int main(){
	cin>>x>>y>>H>>M;
	double AR=fabs(H*30.0-(6.0-0.5)*M);
	if(AR>=180.0)AR=360.0-AR;
	printf("%.10lf",sqrt(x*x+y*y-2.0*x*y*cos(AR*3.141592653579693/180.0)));
}

Measured memory_bytes: 4164