akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int MOD = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    string s;
    cin >> s;

    int len = s.size();
    ll ans = 0;
    vi v(len+1);
    rep(i, len){
        if(s.at(i) == '<'){
            v.at(i+1) = max(v.at(i+1), v.at(i) + 1);
        }
    }

    for(int i = len - 1; i >= 0; i--){
        if(s.at(i) == '>'){
            v.at(i) = max(v.at(i), v.at(i+1) + 1);
        }
    }

    rep(i, len+1){
        ans += v.at(i);
    }

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



Measured memory_bytes: 2844
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,102)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])

Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#define F first
#define S second
using namespace std;

int main(){

  int n;
  typedef pair <double , int> P;
  P d[10];
  P p[100];

  for(int i=0;i<3;i++){
    for(int j=0;j<8;j++) cin >> d[j].S >> d[j].F;
    sort(d,d+8);

    printf("%d %.2lf\n",d[0].S,d[0].F);
    printf("%d %.2lf\n",d[1].S,d[1].F);

    d[0].F = d[1].F = 1 << 28;

    int l = 0;
    for(int j=i*8;j<i*8+8;j++){
      p[j].F = d[l].F;
      p[j].S = d[l].S;
      l++;
    }

  
  }

  sort(p,p+24);

  printf("%d %.2lf\n",p[0].S,p[0].F);
  printf("%d %.2lf\n",p[1].S,p[1].F);

}

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

int main() {
    int A;      //電源タップについている差込口の数
    int B;      //必要な差込口の数
    int num = 0, i = 0;

    cin >> A >> B;

    if(B != 1){ 
        do{
            if(i == 0) num += A;
            else num += A - 1;
            i++;
        }while(num < B); 
    }   

    cout << i << endl;
}


Measured memory_bytes: 256
import sys
#n,k=map(int, input().split())
#a=list(map(int, input().split()))
N=str(input())
a=list(N)

#for i in range(len(a)):
    #a.append(-int(a[i]))
for i in range(2**4):
    Sum=0
    tmp=''
    for j in range(4):
        if (i>>j) & 1:
            Sum+=int(a[j])
            tmp+='+'+str(a[j])
        else:
            Sum-=int(a[j])
            tmp+='-'+str(a[j])
    if Sum==7:
        #print('Yes')
        tmp=tmp[1:]
        print(tmp+'=7')
        sys.exit()
print('No')


Measured memory_bytes: 3060
import itertools
import math
n=int(input())
xys=[list(map(int,input().split())) for _ in [0]*n]
rs=0
l=lambda xy1,xy2:math.sqrt((xy1[0]-xy2[0])**2+(xy1[1]-xy2[1])**2)
f=0
for p in itertools.permutations(range(n), n):
  f+=1
  r=0
  for i in range(n-1):
    r+=l(xys[p[i+1]], xys[p[i]])
  rs+=r
print(rs/f)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, M, ans = 0;
    cin >> N >> M;

    rep(i, 0, N) ans += i;
    rep(i, 0, M) ans += i;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	String s=sc.next();
	String ans="";
	for(int i=0;i<s.length();i++) {
		ans=ans+"x";
	}
	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	//ArrayList<String> cc = new ArrayList<>(n);
	
	System.out.print(ans);

	
	
	
	
 }
}

Measured memory_bytes: 22740
#include<iostream>
#define SIZE 200000
using namespace std;
 
struct Queue{
  int table[SIZE];
  int tail,head;
 
  void init(){
    head=tail=0;
  }
 
  bool empty(){
    return head==tail;
  }
   
  void inqueue(int x){
    table[tail]=x;
    tail++;
    tail%=SIZE;
  }
 
  int dequeue(){
    if(empty())return 0;
    int res=table[head];
    head++;
    head%=SIZE;
    return res;
  }
};
 
int main(){
  Queue queue,queue2;
  int n,q,num;
  string table[SIZE];
  cin>>n>>q;
  queue.init();
  queue2.init();
  for(int i=0;i<n;i++){
    cin>>table[i]>>num;
    queue.inqueue(num);
    queue2.inqueue(i);
  }
   
  int now=0,A,B;
  while(!queue.empty()){
    A=queue.dequeue();
    B=queue2.dequeue();
    if(A<=q){
      now+=A;
      cout<<table[B]<<' '<<now<<endl;
    }else{
      now+=q;
      A-=q;
      queue.inqueue(A);
      queue2.inqueue(B);
    }
  }
   
  return 0;
}

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

int main(){
	int n,q;
	char **name;
	int *time;
	int count=0,now=0,point=0;
	
	scanf("%d %d",&n,&q);

	name=(char**)malloc(sizeof(char*)*n);
	time=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;i++){
		name[i]=(char*)malloc(sizeof(char)*11);
		scanf("%s %d",name[i],&time[i]);
	}

	while(count!=n){
		if(time[point]<=q){
			now+=time[point];
			printf("%s %d\n",name[point],now);
			count++;
			time[point]=0;
		}else{
			time[point]-=q;
			now+=q;
		}
		if(count<n){
			while(1){
				if((point+1)==n){
					point=0;
				}else{
					point++;
				}
				if(time[point]!=0){
					break;
				}
			}
		}
	}


   return 0;
}


Measured memory_bytes: 3916
n = int(input())
xi = list(map(int, input().split()))
yi = list(map(int, input().split()))
for i in [1,2,3,0]:
	dd = 0
	for j in range(0,n):
		if i == 0 :
			if dd <= abs(yi[j]-xi[j]):
				dd = abs(yi[j]-xi[j])
		else:
			dd = dd + abs(yi[j]-xi[j])**i
	if i == 0:
		print(dd)
	else:
		print(dd**(1/i))


Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

ll *seen;
ll *a;

ll dfs(ll s) {
    ll u = a[s];
    if (seen[u] != -1) {
        return u;
    }

    seen[u] = seen[s]+1;
    return dfs(u);
}

int main() {
    ll k;
    ll n;  cin >> n >> k;
    a = new ll[n];
    seen = new ll[n];
    seen[0] = 0;
    for (int i = 1; i < n; i++)
        seen[i] = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }

    ll r = dfs(0);
    
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        if (seen[i] == -1)
            cnt++;
    }

    if (k <= seen[r]) {
        ll ans = 0;
        for (ll i = 0; i < k; i++)
            ans = a[ans];
        cout << ans+1 << endl;
        return 0;
    }
    
    k -= seen[r];
    ll l = n-(seen[r]+cnt);
    
    ll y = k%l;
    ll ans = r;
    for (ll i = 0; i < y; i++) {
        ans = a[ans];
    }

    cout << ans+1 << endl;

    return 0;
}

Measured memory_bytes: 6664
unittest
{
	assert( [ "A" ].parse.expand.solve == "T" );
	assert( [ "G" ].parse.expand.solve == "C" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto b = input.front;
	return tuple( b );
}

auto solve( string b )
{
	switch( b )
	{
		case "A": return "T";
		case "C": return "G";
		case "G": return "C";
		case "T": return "A";
		default : assert( false );
	}
}


Measured memory_bytes: 256
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,q=0,x,y=100000000000,m;
     cin>>n;
    if(n%1000==0)
    cout<<0<<endl;
    else
    cout<<1000-n%1000;
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

int main() {
    int N;
    cin >> N;
    int ac(0), wa(0), tle(0), re(0);
    string S;
    while (N--) {
        cin >> S;
        if (S == "AC")
            ++ac;
        else if (S == "TLE")
            ++tle;
        else if (S == "WA")
            ++wa;
        else if (S == "RE")
            ++re;
        else
            ;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3624
def gcd(a, b):
    r = a % b
    return b if r == 0 else gcd(b, r)

def divisors(n):
    DIVISORS = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            DIVISORS.append(i)
            if i != n**0.5:
                DIVISORS.append(n // i)
    DIVISORS.sort()
    return DIVISORS


a, b, k = map(int, input().split())

print(divisors(gcd(a, b))[-k])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int ywq,wsw;
int main() {
	cin>>ywq>>wsw;
	if(ywq%(2*wsw+1)) cout<<ywq/(2*wsw+1)+1;
	else cout<<ywq/(2*wsw+1);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,t,n,k,ct=0,r;
    string s;
    vector<ll>v;
    set<ll>st;
    map<ll,ll>mp;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++)
    {
        if(i%k==0){ct=1; break;}
    }
    if(ct==1) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  bool can = false;
  if (abs(a-c)<=d) can = true;
  else if (abs(a-b)<=d && abs(b-c)<=d) can = true;
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node ");
    printf("%d",i);
    printf(": key = ");
    printf("%d, ",A[i]);
    if(parent(i)>=1){
      printf("parent key = ");
      printf("%d, ",A[parent(i)]);
    }
    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    string s1;
    string s2;
    string s3;
    string tmp1;
    string tmp2;
    string tmp3;
    string ans;

    cin >> s1 >> s2 >> s3;

    tmp1=s1[0];
    tmp2=s2[0];
    tmp3=s3[0];

    ans=tmp1+tmp2+tmp3;

    transform(ans.cbegin(),ans.cend(),ans.begin(),::toupper);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2056
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

cs = [0] * (n+1)
for i in range(n):
    cs[i+1] = cs[i] + a[i]

mc = Counter(cs).most_common()
ans = 0

for _, v in mc:
    if v < 2: break
    ans += v * (v-1) // 2

print(ans)


Measured memory_bytes: 48708
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A = cin.getIntArray(N);
    let B = A.map((v, i) => v - i - 1);
    B.sort((a,b) => a- b);

   let c = Math.floor(N / 2);
    let b = B[c];
    let ans = A.reduce((ac, v, i) => ac + Math.abs(v - (b + i + 1)),  0);
console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0;this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');if(t<1)throw new Error('引数は1以上であること！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36624
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int64_t N, A, B;  
  cin >> N >> A >> B;
  
  int64_t repA = N / (A + B);
  int64_t restA = N % (A + B);
  
  int64_t plusA = min(A, restA);
  
  int64_t num = A * repA + plusA;
  
  cout << num << endl;

}



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

int main()
{
    ll a,b;
    cin>>a>>b;
    //cout<<(b-a)/2<<endl;

    if(a%2==0&&b%2==0)
    {
        if(((b-a)/2+2)%2==0)
            cout<<b<<endl;
        else cout<<(b^1)<<endl;
    }
    else if(a%2==0&&b%2!=0)
    {
        if(((b-a+1)/2+2)%2==0)
            cout<<0<<endl;
        else cout<<1<<endl;
    }
    else if(a%2!=0&&b%2==0)
    {
        if(((b-a)/2+2)%2==0)
            cout<<(a^b)<<endl;
        else cout<<(a^b^1)<<endl;
    }
    else if(a%2!=0&&b%2!=0)
    {
        if(((b-a)/2+2)%2==0)
            cout<<a<<endl;
        else cout<<(a^1)<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	L := make([]int, M)
	R := make([]int, M)
	D := make([]int, M)
	for i := range L {
		L[i] = readInt() - 1
		R[i] = readInt() - 1
		D[i] = readInt()
	}

	if solve(N, M, L, R, D) {
		println("Yes")
	} else {
		println("No")
	}
}

type Edge struct {
	to, dist int
}

func solve(N, M int, L, R, D []int) bool {
	G := make([][]Edge, N)
	for i := 0; i < M; i++ {
		v := L[i]
		u := R[i]
		d := D[i]
		G[v] = append(G[v], Edge{u, d})
		G[u] = append(G[u], Edge{v, -d})
	}

	dist := make([]int, N)
	for i := range dist {
		dist[i] = math.MinInt32
	}
	for i := 0; i < N; i++ {
		if dist[i] == math.MinInt32 {
			dist[i] = 0
			if !dfs(dist, G, i) {
				return false
			}
		}
	}
	return true
}

func dfs(dist []int, G [][]Edge, i int) bool {
	for _, e := range G[i] {
		v := e.to
		d := e.dist
		if dist[v] == math.MinInt32 {
			dist[v] = dist[i] + d
			if !dfs(dist, G, v) {
				return false
			}
		} else if dist[v] != dist[i]+d {
			return false
		}
	}
	return true
}


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

using namespace std;

int n, m, dp[100005], pter, temp;
string s;
vector <int> v;

int main() {
	cin >> n >> m >> s;
	dp[0] = 0;
	for (int i=1; i<=n; i++) {
		if(s[i] == '1') dp[i] = -1;
		pter = max(0, i - m);
		while (dp[i] == 0) {
//			cout << "Filling node: " << i << ", pointer position: " << pter;
			if (dp[pter] != -1) dp[i] = dp[pter] + 1;
//			cout << ", dp value: " << dp[i] << endl;
			pter++;
			if (pter > i) {
				cout << -1 << endl;
				exit(0);
			}
		}
	}
	pter = n;
	while(pter > 0) {
		temp = min(m, pter);
		while (temp) {
			if (s[pter - temp] != '1') {
				v.push_back(temp);
				pter -= temp;
				temp = 0;
			}
			else temp--;
		}
	}
	cout << v[v.size() - 1];
	for (int i=1; i<v.size(); i++) cout << " " << v[v.size() - 1 - i];
	cout << endl;
}

Measured memory_bytes: 1528
import math

S = input("")
S_list = list(S)
N = len(S_list)
N = int(N)
k_0 = 0
k_1 = 0
k_2 = 0
a = math.floor((N-1)/2)
b = math.floor((N-3)/4)
c = math.floor((N+1)/2)

for i in range(a):
    if S_list[i] != S_list[N-i-1]:
        k_0 += 1


if N>5:
    for i in range(b):
        if S_list[i] != S_list[a-i-1]:
            k_1 += 1
elif N == 5:
    if S_list[0] != S_list[1]:
            k_1 += 1


if N>5:
    for i in range(b):
        if S_list[c+i] != S_list[N-i-1]:
            k_2 += 1
elif N == 5:
    if S_list[0] != S_list[1]:
            k_2 += 1

#print(k_0, k_1, k_2)
if k_0==0 and k_1==0 and k_2==0:
    print("Yes")
else:
    print ("No")

Measured memory_bytes: 38384
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
	#ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      }
	
int main()
{   
  // sublime();
	  ll n,i;
	   string s,t;
	   cin>>s;
	   cin>>t;
	   ll j;
	   
	   ll val=s.length()-t.length();
	   ll ans=t.length();

	   for(i=0; i<=val; i++)
	   {
	   	 ll cnt=0;
	   	 ll p=i;
	   	 for(j=0; j<t.length(); j++)
	   	 {
            if(s[p++]!=t[j])
            	cnt++;
	   	 }
	   	 ans=min(ans,cnt);
	   }
	   cout<<ans;
	   
	return 0;
}

Measured memory_bytes: 3592
from sys import stdin
import sys

N = int(input())
A = list(map(int, input().split()))
B = {}
C = {}
# B1=[]
# C1=[]
for i in range(len(A)):
    B[i+1-A[i]] = B.get(i+1-A[i], 0)+1
    C[i+1+A[i]] = C.get(i+1+A[i], 0)+1
    # B1.append(i+1-A[i])
    # C1.append(i+1+A[i])
# print(B)
# print(C)
# print(B1)
# print(C1)
cnt1 = 0
for i, v in enumerate(B):
    # print(i, v)
    if v in C.keys():
        # print(v)
        cnt1 += B.get(v)*C.get(v)

# cnt = 0
# for i in range(1, N+1):
#     for k in range(i+1, N+1):
#         if i != k and A[i-1] < N and A[k-1] < N:
#             if abs(i-k) == A[i-1]+A[k-1]:
#                 cnt += 1
print(cnt1)


Measured memory_bytes: 150676
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 21;
const int M = 1e9+7;
int dp[N][1<<N];
bool g[N][N];
int n;

inline int lg2(const int &x) { return 31-__builtin_clz(x); }

int f(int id, int mask) {
    if (id == n) return 1;
    int &r = dp[id][mask];
    if (r != -1) return r;
    
    r = 0;
    for (int aux = mask; aux; aux &= aux-1) {
        int j = lg2(aux & -aux);
        if (g[id][j]) {
            int next = mask^(1<<j);
            r = (r + f(id+1, next)) % M;
        }
    }
    return r;
    
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    forn(i, 0, n) {
        forn(j, 0, n) {
            cin >> g[i][j];
        }
    }
    
    memset(dp, -1, sizeof dp);
    cout << f(0, (1<<n)-1) << endl;
}


Measured memory_bytes: 175696
def resolve():
    def dic_prime_fact(n):
        dic = {}
        i = 2
        while i*i <= n:
            while n%i == 0:
                n //= i
                if i in dic:
                    dic[i] += 1
                else:
                    dic[i] = 1
            i += 1
        if n != 1:
            dic[n] = 1
        return dic

    N, P = map(int, input().split())
    dic_prime = dic_prime_fact(P)

    ans = 1
    for k, v in dic_prime.items():
        for i in range(0, v//N):
            ans *= k
    print(ans)
    
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n=s.length();
		int ans = n;
		for(int i=0; i<n-1; i++) {
			if(s.charAt(i) != s.charAt(i+1)) {
				ans = Math.min(ans, Math.max(i+1, n-i-1));
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 24512
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 3e5 + 5;

int n,m,s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m>>s;
    vector<int> r(n+1),c(m+1);
    vector<pii> V;
    for(int i=1;i<=s;i++){
    	int x,y;
    	cin>>x>>y;
    	r[x]++,c[y]++;
    	V.emplace_back(x,y);
    }
    vector<int> R,C;
    int maR=*max_element(r.begin(),r.end());
    int maC=*max_element(c.begin(),c.end());
    int cnt=0;
    for(auto [x,y]:V) if(r[x]==maR and c[y]==maC) cnt++;
    int ans=maR+maC;
	int tot=count(r.begin(),r.end(),maR)*count(c.begin(),c.end(),maC);
	cout<<ans-(cnt==tot);
    return 0;
}

Measured memory_bytes: 9752
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
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;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

ll gcd(ll x,ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll cc,dc,mc,g;
	cc=b/c-(a-1)/c;
	dc=b/d-(a-1)/d;
	g=lcm(c,d);
	mc=b/g-(a-1)/g;
	cout<<b-a+1-(cc+dc-mc)<<endl;
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;

    string s;

    map<string,ll> mp;
    for(int i=0;i<n;i++)
    {
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#define ll long long int
using namespace std ;

const int maxn = 1e5+10;

int n ;

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


int max(int a, int b)
{
    if( a > b) return a;
    return b;
}


int abs(int x)
{
    if(x<0)
        return (-1*x);
    return x;
}


struct data
{
    int a ;
    int b;
    int c ;
};

data arr[maxn];

int dp[maxn][5];



int cal (int pos, int prev)
{
    if( pos > n ) return 0 ;

    if( dp[pos][prev] != -1 )return dp[pos][prev];


    int ans = -1 ;



    if( prev != 1 )
    {
        ans = max(  ans, cal( pos + 1, 1  ) + arr[pos].a );
    }
    if( prev != 2 )
    {
        ans = max(  ans, cal( pos + 1, 2  ) + arr[pos].b );
    }
    if( prev != 3 )
    {
        ans = max(  ans, cal( pos + 1, 3  ) + arr[pos].c ) ;
    }
    return dp[pos][prev] =  ans ;


}


int main()
{

    cin >> n ;


    for(int i =1 ; i<=n ; i++)
    {
        int x, y, z ;

        cin >> x >> y >> z ;

        arr[i].a = x ;
        arr[i].b = y ;
        arr[i].c = z ;
    }

    for(int i=0 ; i<=n; i++)
    {
        for(int j=0 ; j<=4; j++)
        {
            dp[i][j] = -1;
        }
    }

    cout << cal(1,0)<<endl;


    return 0 ;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
int N;
cin>>N;
for(int i=0;i<N;i++){
    cin>>a[i];
}
int s=0;
for(int i=0;i<N;i++){
    s+=a[i];
}
int ans=s-N;
cout<<ans<<endl;
   return 0;

}



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

typedef long long       ll;
typedef vector<int>     vi;
typedef pair<int,int>   pi;
typedef map<int,int>    mi;

#define F               first
#define S               second
#define pb              push_back
#define mp              make_pair
#define M               1000000007
#define SQ(a)           (a)*(a)
#define rep(i,a,b)      for(int i=a; i<b; i++)

void solve(){
   int n;
   cin >> n;
   int d, dd,cnt=0;
   bool f = false;

   for (int i=0;i<n;i++){
        cin >> d >>dd;

        if(d==dd){
            cnt++;
            if(cnt>2){
                f = true;
            }
        }
        else{
            cnt = 0;
            cnt = 0;
        }
   }
   if(f)
   cout << "Yes" << endl;
   else
   cout << "No" << endl;
}
int main(){
    //int t; cin >> t; while(t--)
    solve();

    return 0;
}





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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  // VECINT AS(N);
  // REP(i,N) cin>>AS[i];
  map<int,int> mp;
  REP(i,N) {
    int a;cin>>a;
    mp[a]++;
  }

  // まずmapで数をカウントしていく
  // その上で、順番に見ていって、その数字がその数字よりも個数が多ければその個数になるように、
  // 小さければ0になるまで消す
  int ans = 0;
  for (auto m:mp) {
    if (m.second >= m.first) {
      ans += m.second-m.first;
    } else {
      ans += m.second;
    }
  }
  OUT(ans);

  return 0;
}

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

int n;
int x, y, t, dif;

struct Plan{
    int t;
    int x;
    int y;
};

int main(){
    cin >> n;
    vector<Plan> p;
    for(int i = 0; i < n; i++){
        cin >> t >> x >> y;
        Plan buf = {t, x, y};
        p.push_back(buf);
    }
    x = 0, y = 0, t = 0;
    for(Plan pp: p){
        dif = abs(x - pp.x) + abs(y - pp.y);
        if (pp.t - t >= dif && dif % 2 == (pp.t - t) % 2)
        {
            t = pp.t;
            x = pp.x;
            y = pp.y;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[10010],b[10010];
	scanf("%s%s",&a,&b);
	int x=strlen(a);
	int y=strlen(b);
	int n;
	if(x>y) n=y;
	else n=x;
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<b[i];
	}
	if(x>y) cout<<a[x-1];
	if(y>x) cout<<b[y-1];
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string inStringS = Console.ReadLine();
        inStringS += inStringS;

        if (inStringS.Contains(Console.ReadLine()))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}



Measured memory_bytes: 17860
#include <iostream>
#include <vector>
using namespace std;
vector< pair<int,int> > ans;
int n,i,j;
int main()
{
    cin>>n;
    if((n&1))
    {
        for(i=1; i<=n-1; i++)
            for(j=i+1; j<=n-1; j++)
                if(i+j!=n)
                    ans.push_back({i,j});
        for(i=1;i<n;i++)
        ans.push_back({n,i});
    }
    else
    {
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++)
              if(i+j!=n+1)
        ans.push_back({i,j});
    }
    cout<<ans.size()<<'\n';
    for(i=0;i<ans.size();i++)
        cout<<ans[i].first<<' '<<ans[i].second<<'\n';
    return 0;
}


Measured memory_bytes: 384
import numpy as np
n, a, b = map(int, raw_input().split())
h = []
for i in xrange(n):
    h.append(int(raw_input()))
h = np.array(h)
count = 0
adiff = float(a - b)
top = max(h) / b + 1
bottom = 0
mid = top / 2
while(1):
    if top - bottom < 2:
        break
    hmem = h - b * mid
    if np.sum(np.ceil(hmem[hmem > 0] / adiff)) <= mid:
        top = mid
    else:
        bottom = mid
    mid = (top + bottom) / 2
print top


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    string s, t;
    cin >> s >> t;
    if(s == t.substr(0, s.size())) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 3576
"use strict";
const Main = (input) => {
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    let A = xs[1] - xs[0];
    let B = xs[2] - xs[1];
	//console.log(A,B);
    if(A == B){
    	console.log('YES');
    }else{
    	console.log('NO')
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

bool yymm(string s){
  string y = s.substr(0,2), m = s.substr(2,2);
  int yy = stoi(y), mm = stoi(m);
  return 0<=yy && yy<=99 && 1<=mm && mm<=12;
}

bool mmyy(string s){
  string m = s.substr(0,2), y = s.substr(2,2);
  int yy = stoi(y), mm = stoi(m);
  return 0<=yy && yy<=99 && 1<=mm && mm<=12;
}
signed main(){
  string s;cin>>s;
  if(yymm(s) && mmyy(s))cout << "AMBIGUOUS";
  else if(yymm(s))cout << "YYMM" << endl;
  else if(mmyy(s))cout << "MMYY" << endl;
  else cout << "NA" << endl;
}


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

import itertools, sys

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

s, = read_line(str)

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for p in itertools.product((1, -1), (1, -1), (1, -1)):
    n = a + p[0] * b + p[1] * c + p[2] * d
    if n == 7:
        print('%d%+d%+d%+d=7' % (a, p[0] * b, p[1] * c, p[2] * d))
        sys.exit(0)


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

int x, y;
bool ans=0;

int main(){
	cin >> x >> y;
	for (int a=0;a<=100;a++){
		for (int b=0;b<=100;b++){
			if (a+b==x && 2*a+4*b==y) ans=1;
		}
	}
	cout << (ans ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, col[100003] = {}, t;
    string s;

    cin >> s;

    n = s.size();
    t = 0;
    i = 0;
    while (i < n)
    {
        if (t > 0 && col[t - 1] != s[i] - '0')
            t--;
        else
            col[t++] = s[i] - '0';
        i++;
    }

    printf("%d\n", n - t);

    return 0;
}

Measured memory_bytes: 4240
#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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

int main (){
	string s;
	cin >> s;
	int cn=0,cw=0,cs=0,ce=0;
	rep (i,s.size()){
		if (s[i]=='N') cn++;
		if (s[i]=='W') cw++;
		if (s[i]=='S') cs++;
		if (s[i]=='E') ce++;
	}
	//cout << cn << " " << cs  << endl; 
	bool flag = true;
	
		if ((cn!=0&&cs==0)||(cn==0&&cs!=0)||(ce!=0&&cw==0)||(ce==0&&cw!=0)){
			flag = false;
		
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}




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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long long mod = 1000000007;

int main() {
    long long int a, b, x;
    cin >> a >> b >> x;
    long long int sa = b - a;
    long long int amari1 = (x - a % x) % x;
    long long int amari2 = b % x;
    long long int amari = amari1 + amari2;
    sa -= amari;
    cout << sa / x + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    string w;
    cin >> w;
    if(w.size()>n){
        rep(i,n){
            cout << w[i];
        }
        cout << "...";
    } else {
        cout << w;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <complex>
using namespace std;


int main(void){
	int a, b;
	string s1, s2;
	cin >> s1 >> s2;
	string s3 = s1 + s2;
	int n = atoi(s3.c_str());
	if((int)sqrt(n) * (int)sqrt(n) == n){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int min_cost=100000000;
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      int B=A.at(j)-i;
      cost+=pow(B,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
} 

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

/**
 * Created by fcdkbear on 15.10.16.
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int k = in.nextInt();
        int res = k;
        for (int i = 1; i < n; ++i) {
            res *= (k - 1);
        }
        out.println(res);
        out.close();
    }

    static class Pair {
        private long first;
        private int second;

        public Pair(long first, int second) {
            this.first = first;
            this.second = second;
        }

        public long getFirst() {
            return first;
        }

        public void setFirst(long first) {
            this.first = first;
        }

        public int getSecond() {
            return second;
        }

        public void setSecond(int second) {
            this.second = second;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }

}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, h, w, cnt = 0; cin >> n >> h >> w;
    rep(i, n){
        ll a, b; cin >> a >> b;
        if(a >= h && b >= w) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3656
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

/**
 * @brief ラムダ式の再帰
 * @author えびちゃん
 */

#ifndef H_make_fix_point
#define H_make_fix_point

#include <utility>

template <typename Fn>
class fix_point: Fn {
public:
  explicit constexpr fix_point(Fn&& f) noexcept: Fn(std::forward<Fn>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return Fn::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <typename Fn>
static inline constexpr decltype(auto) make_fix_point(Fn&& f) noexcept {
  return fix_point<Fn>{std::forward<Fn>(f)};
}

#endif  /* !defined(H_make_fix_point) */

#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>

int main() {
  size_t n;
  scanf("%zu", &n);

  char buf[524288];
  scanf("%s", buf);
  std::string s = buf;

  std::vector<int> p(1_zu << n);
  for (auto& pi: p) scanf("%d", &pi), --pi;

  std::vector<int> res(1_zu << n);
  make_fix_point([&](auto& dfs, std::vector<int> const& cur, size_t dep, size_t k) -> void {
      if (cur.size() == 1) {
        res[k] = cur[0];
        return;
      }
      // for (size_t i = 0; i < cur.size(); ++i)
      //   fprintf(stderr, "%d%c", cur[i], i+1<cur.size()? ' ': '\n');
      {
        std::vector<int> next;
        next.reserve(cur.size()/2);
        for (size_t i = 0; i < cur.size(); i += 2) {
          int x, y;
          std::tie(x, y) = std::minmax(cur[i], cur[i+1]);
          next.push_back((s[y-x-1] == '1')? y: x);
        }
        dfs(next, dep + 1, k);
      }
      {
        std::vector<int> next;
        next.reserve(cur.size()/2);
        for (size_t i = 1; i < cur.size(); i += 2) {
          int x, y;
          std::tie(x, y) = std::minmax(cur[i], cur[(i+1)%cur.size()]);
          next.push_back((s[y-x-1] == '1')? y: x);
        }
        dfs(next, dep + 1, 1_zu << dep | k);
      }
  })(p, 0, 0);

  for (auto ri: res) printf("%d\n", ri+1);
}



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

/*int main()
{
    string s;
    cin >> s;

    int x = s.size() - 2;

    cout << s[0] << x << s[x + 1] << endl;

}*/

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    cout << s[0] << N - 2 << s[N-1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, x;
    char op;
    char arr[20];
    
    while (1) {
        fgets(arr, 20, stdin);
        sscanf(arr, "%d %c %d", &a, &op, &b);
        if (op == '+') x = a + b;
        else if (op == '-') x = a - b;
        else if (op == '*') x = a * b;
        else if (op == '/') x = a / b;
        else  break;
        printf("%d\n", x);
    }
}



Measured memory_bytes: 2088
import java.util.*;

public class Main{
    public static void main(String[] args){

        int score_A = 1;
        int score_B = 0;
        int score_C = -1;
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();

        int score=0;
        for(int loop=0; loop<K; loop++){
            if(A>0){
                score += score_A;
                A--;

            }else if(B>0){
                score += score_B;
                B--;

            }else{
                score += score_C;
                C--;
            }
        }
        System.out.println( score );
    }
}

Measured memory_bytes: 36224
ls = map(int, input().split())
a, b, c = sorted(ls)
count = 0

while max(a, b, c) - min(a, b, c) >= 2:
    count += 1
    min_num = min(a, b, c)
    if a == min_num:
        a += 2
    else:
        b += 2

if (a == b) & (b == c):
    print(count)
elif a == b:
    print(count + 1)
else:
    print(count + 2)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;    
int a[100005];
int main()
{
   int n,ans=0;
   int x;
   cin >> n;
   for (int i=1;i<=n;i++){
   	cin >> x;
   	if (x>n) ans++;
   	else a[x]++;
}
    for (int i=1;i<=100005;i++){
    	if (a[i]==0) continue;
    	if (a[i]<i) ans+=a[i];
    	if (a[i]>i) ans+=a[i]-i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main(){
	var s string
	ans := 700
	fmt.Scan(&s)
	count := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'o' {
			count = count + 100
		}
	}
	fmt.Println(ans + count)
}

Measured memory_bytes: 512
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
ddd = input().split()
for i in range(n, 100000):
    flag = True
    for c in str(i):
        if c in ddd:
            flag = False
            break
    if flag:
        ans = i
        break
print(ans)


Measured memory_bytes: 3060
#include <iostream>
int main(void)
{
  while (1) {
    int a, b, r;
    char op;
    std::cin >> a >> op >> b;
    switch (op) {
    case '+':
      r = a + b;
      break;
    case '-':
      r = a - b;
      break;
    case '*':
      r = a * b;
      break;
    case '/':
      r = a / b;
      break;
    case '?':
      return 0;
    }
    std::cout << r << std::endl;
  }
}

Measured memory_bytes: 1160