akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int n;
  cin>>n;
  VI v(n+1,0);
  for(i=0;i<n-1;i++){
    int x;
    cin>>x;
    v[x-1]++;
  }
  for(i=0;i<n;i++) cout<<v[i]<<endl;

}

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>

using namespace std;

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

vector<int> g[1010];
int n, m;
 
//vector<bool> visited, matched;
//vector<int> levels, matching;
bool visited[1010],matched[1010];
int levels[1010], matching[1010];
 
bool augment(int left) {
  if(left == n) return true;
  if(visited[left]) return false;
  visited[left] = true;
  rep(i, g[left].size()) {
    int right = g[left][i];
    int next = matching[right];
    if (levels[next] > levels[left] && augment(next)) {
      matching[right] = left;
      return true;
    }
  }
  return false;
}
 
int bimatch() {
  //matching.assign(m, n);
  //matched.assign(n, false);
  fill(matching, matching+m, n);
  fill(matched, matched+n, false);
  int ret = 0;
  bool cont;
  do {
    //levels.assign(n+1, -1);
    //memset(levels,-1,sizeof(levels));
    fill(levels, levels+n+1, -1);
    levels[n] = n;
    queue<int> q;
    rep(left, n) if (!matched[left]) {
      q.push(left);
      levels[left] = 0;
    }
    while(!q.empty()) {
      int left = q.front();
      q.pop();
      rep(i, g[left].size()) {
        int right = g[left][i];
        int next = matching[right];
        if (levels[next] < 0) {
          levels[next] = levels[left] + 1;
          q.push(next);
        }
      }
    }
    //visited.assign(n, false);
    //memset(visit,false,sizeof(visit));
    fill(visited, visited+n, false);
    cont = false;
    /*
    rep(i,n){
      cout << "match:" << i << " : " << matched[i] << endl;
    }
    rep(i,n){
      cout << "levels:" << i << " : " << levels[i] << endl;
    }
      */
    rep(left, n) if(!matched[left] && augment(left)){
      matched[left] = cont = true;
      ret++;
    }
  } while(cont);
  //printf("ret:%d\n",ret);
  //return count(matched.begin(), matched.end(), true);
  return ret;
}

int blue[510],red[510];

int main(){
  while(scanf("%d%d",&n,&m),n|m){
    //init
    rep(i,n+m)g[i].clear();
    //visited.clear();
    //matched.clear();
    //levels.clear();
    //matching.clear();
    
    
    
    rep(i,n)scanf("%d",blue+i);
    rep(i,m)scanf("%d",red+i);

    rep(i,n){
      rep(j,m)if( __gcd(blue[i],red[j])!=1 ){
        g[i].push_back(n+j);
        g[n+j].push_back(i);
      }
    }
    //
    /*
    rep(i,n+m){
      printf("%d: ",i);
      rep(j,g[i].size())printf("%d ",g[i][j]);
      puts("");
    }
      */
    m += n;
    printf("%d\n",bimatch());
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int h, w;
   cin >> h >> w;
   vector<vector<char>> s(h, vector<char>(w)), t(h, vector<char>(w, '.'));
   rep(i, 0, h) rep(j, 0, w) cin >> s[i][j];
   int dx[] = {-1, 1};
   int dy[] = {-1, 1};
   rep(i, 0, h) rep(j, 0, w) {
      rep(k, 0, 2) {
         int x, y;
         x = dx[k] + j, y = i;
         if (x < 0 || x >= w || y < 0 || y >= h) continue;
         if (s[i][j] == '#' && s[y][x] == '#') {
            t[i][j] = t[y][x] = '#';
         }
      }
      rep(k, 0, 2) {
         int x, y;
         x = j, y = dy[k] + i;
         if (x < 0 || x >= w || y < 0 || y >= h) continue;
         if (s[i][j] == '#' && s[y][x] == '#') {
            t[i][j] = t[y][x] = '#';
         }
      }
   }
   rep(i, 0, h) rep(j, 0, w) {
      if (s[i][j] != t[i][j]) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int ans=0;
    cin>>n;
    int v[50],c[50];
    int plus[50];
    for(int i=0;i<n;i++){
    	cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
		plus[i]=v[i]-c[i];
	}
	for(int i=0;i<n;i++){
		if(plus[i]>0){
			ans+=plus[i];
		}
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
from itertools import product
n, m = map(int, input().split())
switches = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    switches.append(s)
p = list(map(int, input().split()))

ans = 0
for subset in product((0, 1), repeat=n):
    for j in range(m):
        on_cnt = sum(subset[s] for s in switches[j])
        if on_cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 9108
#include <iostream>

using namespace std;

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

  for (int i = 0; i <= 50000; ++i) {
    if (int(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<cassert>

int solve(std::vector<int> &dp, int n){
    if(n == 0) return 0;
    if(dp[n] >= 0) return dp[n];

    // 1, 6, 6^2,...
    int res = n;
    for(int k = 1; k <= n; k *= 6){
        res = std::min(res, solve(dp, n - k) + 1);
    }
    // 1, 9, 9^2,...
    for(int k = 1; k <= n; k *= 9){
        res = std::min(res, solve(dp, n - k) + 1);
    }

    dp[n] = res; // メモ
    return res;
}

int main(){
    int n;
    std::cin >> n;
    std::vector<int> dp(n + 1, -1);
    std::cout << solve(dp, n) << std::endl;
    return 0;
}


Measured memory_bytes: 5376
#include<cstdio>

using namespace std;

bool prime[500000];

void check(){
	for(int i = 3; i < 400000; i+=2){
		if(prime[i]){
			for(int j = i*2; j< 400000; j+=i){
				prime[j] = false;
			}
		}
	}
}

int main(void){
	int n;
	
	for(int i = 3; i < 400000; i+=2){
		prime[i] = true;
	}
	prime[2] = true;
	
	check();
	
	while(scanf("%d", &n)  && n != 0 ){
		int c = 0;
		int ans = 0;
		for(int i = 0; c < n; i++){
			if(prime[i]){
				ans += i;
				c++;
			}
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<string> res(n, "-");
    for (int i = 0, ia = a, ib = b, ic = c; i < n; i++) {
        if (s[i] == "AB") {
            if (ia == 0 && ib == 0) {
                res[0] = "x";
                break;
            } else if (ia == 0) {
                res[i] = "A";
                ia++;
                ib--;
            } else if (ib == 0) {
                res[i] = "B";
                ia--;
                ib++;
            } else if (i < n - 1 && (s[i + 1] == "AB" || s[i + 1] == "AC")) {
                res[i] = "A";
                ia++;
                ib--;
            } else {
                res[i] = "B";
                ia--;
                ib++;
            }
        } else if (s[i] == "AC") {
            if (ia == 0 && ic == 0) {
                res[0] = "x";
                break;
            } else if (ia == 0) {
                res[i] = "A";
                ia++;
                ic--;
            } else if (ic == 0) {
                res[i] = "C";
                ia--;
                ic++;
            } else if (i < n - 1 && (s[i + 1] == "AB" || s[i + 1] == "AC")) {
                res[i] = "A";
                ia++;
                ic--;
            } else {
                res[i] = "C";
                ia--;
                ic++;
            }
        } else {
            if (ib == 0 && ic == 0) {
                res[0] = "x";
                break;
            } else if (ib == 0) {
                res[i] = "B";
                ib++;
                ic--;
            } else if (ic == 0) {
                res[i] = "C";
                ib--;
                ic++;
            } else if (i < n - 1 && (s[i + 1] == "AB" || s[i + 1] == "BC")) {
                res[i] = "B";
                ib++;
                ic--;
            } else {
                res[i] = "C";
                ib--;
                ic++;
            }
        }
    }

    if (res[0] == "x") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 0; i < n; i++) {
            cout << res[i] << endl;
        }
    }
}


Measured memory_bytes: 9612
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int mx = 1;
  for(int i = 0; (long long)i * i <= N; i++) {
    long long a = (long long)i * i;
    if (a <= N && mx < a) mx = a;
  }

  cout << mx << endl;

  return 0;
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
vector<ll> b(n);
rep(i, n){
  a[i]+=i*n;
  b[i]+=(n-i-1)*n;
  ll r;
  cin >> r;
  b[r-1]+=i;
}
for(auto an:a)cout << an+1 << " ";
cout << endl;
for(auto an:b)cout << an+1 << " ";
cout << endl;
return 0;
}

Measured memory_bytes: 896
import collections
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    def find(self, x):
        deque = collections.deque()
        t = x
        while t != self.parent[t]:
            deque.append(t)
            t = self.parent[t]
        while deque:
            tmp = deque.pop()
            self.parent[tmp] = t
        return t
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.depth[x] < self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x] += self.cnt[y]
            if self.depth[x] == self.depth[y]:
                self.depth[x] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return self.cnt[self.find(x)]
n, m = map(int, input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x, y, z = map(int, input().split())
    utree.unite(x, y)
s = {utree.find(i) for i in range(1, n+1)}
print(len(s))

Measured memory_bytes: 17908
X, N = map(int, input().split())
p = [int(i) for i in input().split()]

if X in p:
    for i in range(1,1000):
        if not (X-i) in p:
            ans = (X-i)
            break
        if not (X+i) in p:
            ans = (X+i)
            break
else:
    ans = X
    
        
print(ans)

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

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

#define MP make_pair
 
int main() {
  
  int N, L;
  while(cin >> N >> L && (N|L)) {
    vector<pair<int, int> > v;
    rep(i, N) {
      char d; int p; cin >> d >> p;
      v.push_back(MP(d == 'R' ? +1 : -1, p));
    }
    
    int time = 0;
    int ans = -1;
    int remain = N;
    while(remain > 0) {
      int ch[2200] = {};
      int *check = ch+1100;
      rep(i, N) {
        v[i].second += v[i].first;
        check[v[i].second] ++; 
      }
      
      rep(i, N) {
        if(check[v[i].second] == 2) {
          v[i].first *= -1;
        }
      }

      bool f = 0;
      rep(i, N) {
        if(v[i].second == 0) {
          remain --;
          f = 1;
          ans = i+1;
        }
        if(v[i].second == L) {
          remain --;
          if(!f) { ans = i+1; }
        }
      }
      time ++;
    }
    cout << time << " " << ans << endl;
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
string s,t;
int main(){
  cin >> s >> t;
  if(s.size() < t.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  bool set;
  for(int i=s.size()-t.size();i>=0;i--){
    set = true;
    for(int j=0;j<t.size();j++){
      if(s[i+j] != '?' && s[i+j] != t[j]){
        set = false;
        break;
      }
    }
    if(set){
      for(int j=0;j<t.size();j++) s[i+j] = t[j];
      for(int j=0;j<s.size();j++) if(s[j] == '?') s[j] = 'a';
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int h,w,a[501][501],c=0;
    string s[250000];
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        if(i%2==1){
            for(int j=1;j<=w;j++){
                if(a[i][j]%2==1){
                    if(j==w&&i!=h){
                        a[i+1][j]++;
                        s[c]=to_string(i)+" "+to_string(j)+" "+to_string(i+1)+" "+to_string(j);
                        c++;
                    }else if(j!=w){
                        a[i][j+1]++;
                        s[c]=to_string(i)+" "+to_string(j)+" "+to_string(i)+" "+to_string(j+1);
                        c++;
                    }
                }
            }
        }else{
            for(int j=w;j>=1;j--){
                if(a[i][j]%2==1){
                    if(j==1&&i!=h){
                        a[i+1][j]++;
                        s[c]=to_string(i)+" "+to_string(j)+" "+to_string(i+1)+" "+to_string(j);
                        c++;
                    }else if(j!=1){
                        a[i][j-1]++;
                        s[c]=to_string(i)+" "+to_string(j)+" "+to_string(i)+" "+to_string(j-1);
                        c++;
                    }
                }
            }
        }
    }
    cout<<c<<endl;
    for(int i=0;i<c;i++){
        cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 12800
def main():
    mod=998244353
    a,b,c,d=map(int,input().split())
    dx,dy=c-a,d-b
    if dx==0:
        return pow(a,dy,mod)
    if dy==0:
        return pow(b,dx,mod)
    DP=[[0]*(d+1) for _ in range(c+1)]
    DP[a][b]=1
    for x in range(a+1,c+1):
        DP[x][b]=pow(b,x-a,mod)
    for y in range(b+1,d+1):
        DP[a][y]=pow(a,y-b,mod)
    #print(DP)
    for x in range(a+1,c+1):
        for y in range(b+1,d+1):
            DP[x][y]=DP[x-1][y]*y+DP[x][y-1]*x
            DP[x][y]-=DP[x-1][y-1]*(x-1)*(y-1)
            DP[x][y]%=mod
    #print(DP)
    return DP[-1][-1]

if __name__=='__main__':
    print(main())

Measured memory_bytes: 133668
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

int main(void) {
  int a, b;
  char c[50];
  int i;
  scanf("%d %d", &a, &b);
  scanf("%s", c);
  c[b-1] = tolower(c[b-1]);
  printf("%s\n", c);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
#define MAX 200005
const int M=1e9+7;
const ll INF = 1LL << 60;
typedef pair<int,int> pii;
typedef double ld;
bool visited[MAX];
vector<int>adj[MAX];
ll n;
ll dp[MAX],last[MAX];
vector<int>vec;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	vec.pb(0);
	for(int i=1;i<=n;i++)
	{
		int a;cin>>a;
		if(vec.empty() || vec.back()!=a) vec.pb(a);
	}
	dp[0]=1;
	for(int i=1;i<vec.size();i++)
	{
		dp[i]=dp[i-1];
		if(last[vec[i]]>0)
		{
			int s=dp[last[vec[i]]];
			dp[i]=(dp[i-1]+s)%M;
		}
		last[vec[i]]=i;
	}
	cout<<dp[vec.size()-1]<<endl;
	return 0;	
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n, k;
    cin >> n >> k;

    long ans = 0;
    for(long b = k + 1; b <= n; b++)
    {
        ans += (n / b) * (b - k);
        int x = n % b;
        if (x >= k && k > 0)
        {
            ans += x - (k - 1);
        }
        else if (k == 0)
        {
            ans += x;
        }
    }
    cout << ans << endl;
}



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

long long n, k, r, s, p;
char str[100005];
long long used[100005];
long long ans;

int main() {
	scanf("%lld %lld %lld %lld %lld", &n, &k, &r, &s, &p);
	scanf("%s", str + 1);
	for (int i = 1; i <= n; i++) {
		if (str[i] == 'r') {
			if (i <= k || used[i-k] != 1) {
				ans += p; used[i] = 1;
			}
		} else if (str[i] == 's') {
			if (i <= k || used[i-k] != 2) {
				ans += r; used[i] = 2;
			}
		} else {
			if (i <= k || used[i-k] != 3) {
				ans += s; used[i] = 3;
			}
		}
	}
	printf("%lld", ans);
	return 0;
}

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    flag = True

    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                flag=True
            else:
                flag=False
                break

    if flag == True:
        print('APPROVED')
    else:
        print('DENIED')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	if(a > b){
	    for(int i=0;i<a;i++) System.out.print(b);
	}else{
	    for(int i=0;i<b;i++) System.out.print(a);
	}
    }
}


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

int main() {
  string S;
  string T;
  int count = 0;
  cin >> S >> T;
  for(int i=0;i<S.size();i++){
    if(S[i]==T[i]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
t = []
for i in s:
    if i in t:
        print('no')
        break
    else:
        t.append(i)
else:
    print('yes')

Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>
int main(){
    int kaisu;
    int i,j,k;
    char muki[10];
    int daisu[6]; //上下北東南西
    int tmp;
    int ans;

    while(1) {
       scanf("%d", &kaisu);

        if(kaisu == 0) {
            break;
        }
	
	ans = 0;
	daisu[0] = 1;
	daisu[1] = 6;
	daisu[2] = 5;
	daisu[3] = 3;
	daisu[4] = 2;
	daisu[5] = 4;
	
        for(i = 0; i < kaisu; i++){
	  scanf("%s", muki);

	  if(strcmp(muki,"North") == 0){
	    tmp = daisu[0];
	    daisu[0]=daisu[4];
	    daisu[4]=daisu[1];
	    daisu[1]=daisu[2];
	    daisu[2]=tmp;
	  }
	  
	  if(strcmp(muki,"East" ) == 0){
	    tmp = daisu[0];
	    daisu[0]=daisu[5];
	    daisu[5]=daisu[1];
	    daisu[1]=daisu[3];
	    daisu[3]=tmp;
	  }
	  
	  if(strcmp(muki,"South") == 0){
	    tmp = daisu[0];
	    daisu[0]=daisu[2];
	    daisu[2]=daisu[1];
	    daisu[1]=daisu[4];
	    daisu[4]=tmp;
	  }
	  
	  if(strcmp(muki,"West") == 0){
	    tmp = daisu[0];
	    daisu[0]=daisu[3];
	    daisu[3]=daisu[1];
	    daisu[1]=daisu[5];
	    daisu[5]=tmp;
	  }
	  
	  if(strcmp(muki,"Left") == 0){
	    tmp = daisu[2];
	    daisu[2]=daisu[3];
	    daisu[3]=daisu[4];
	    daisu[4]=daisu[5];
	    daisu[5]=tmp;
	  }
	  
	  if(strcmp(muki,"Right") == 0){
	    tmp = daisu[2];
	    daisu[2]=daisu[5];
	    daisu[5]=daisu[4];
	    daisu[4]=daisu[3];
	    daisu[3]=tmp;
	  }
	  
	  /* printf("%d ",daisu[0]); */
	  ans+=daisu[0];
	  /* printf("daisu ="); */
	  /* for(k = 0; k < 6; k++) { */
	  /*   printf("%d ", daisu[k]); */
	  /* } */
	  /* printf("\n"); */
	}
	/* printf("\n"); */
	
	

	printf("%d\n", ans+1);
    }

    return 0;
}

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

using namespace std;

int main()
{
  int N, K, T, U, V, L;
  cin >> N >> K >> T >> U >> V >> L;
  vector<bool> carrot(L+1, false);  
  while(N--) {
    int D; cin >> D;
    carrot[D] = true;
  }
  double ans = 0.0;
  int hold = 0, fast = 0;
  for(int i = 1; i <= L; i++) {
    if(fast) fast--, ans += 1.0 / V;
    else ans += 1.0 / U;    
    if(carrot[i]) hold++;
    if(hold > K) hold = K, fast = T*V;
    else if(!fast && hold > 0) hold--, fast = T*V;
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3212
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i=0; i<n; i++) {
    cin >> v[i];
  }

  vector<int> dp(n);
  dp[0] = 0;
  for (int i=1; i<n; i++) {
    int min_a = INT_MAX;
    for (int j=i-1; j>=i-k && j>=0; j--) {
      min_a = min(min_a, dp[j] + abs(v[j] - v[i]));
    }
    dp[i] = min_a;
  }
  cout << dp[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define ll long long
using namespace std;
ll a,b,c;
ll divide(ll a,ll b,ll c)
{
        if(a%2==0) return 0;
		return b*c;	  
}
int main()
{
	cin>>a>>b>>c;
	cout<<min(min( divide(a,b,c), divide(b,a,c) ),divide(c,a,b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
    int a,b,m=1e9+7,x;cin>>a>>b;
    vector<int> dp(a+1);
    dp[0]=1;dp[1]=1;
    for(int i=0;i<b;i++){
        cin>>x;dp[x]=-1;
    }
    for(int i=2;i<=a;i++){
        if(dp[i]==-1) continue;
        int t=0;
        if(dp[i-1]!=-1) t+=dp[i-1];
        if(dp[i-2]!=-1) t+=dp[i-2];
        t%=m;
        dp[i]=t;
    }
    cout<<dp[a];
}

Measured memory_bytes: 640
n, m = map(int, input().split())
a = [-1]+[int(input()) for _ in range(m)]+[n+1]
b = []
ans, mod = 1, 10**9+7
for i in range(m+1):
    b.append(a[i+1]-a[i]-1)

for i in range(m+1):
    diff = b[i]
    dp = [1, 1]
    if i != 0 and diff == 0:
        print(0)
        exit()
    for j in range(diff-2):
        dp.append(dp[j]+dp[j+1])
    ans *= dp[-1]
    ans %= mod
print(ans)

Measured memory_bytes: 460020
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(A*B);
		

	}

}


Measured memory_bytes: 35788
//can not solve problem with negative edges
//worst O(V^2)
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 0x7fffffff;
const int MAXV=100+5;

int cost[MAXV][MAXV];
int d[MAXV];
bool used[MAXV];
int prev_vertex[MAXV]; //for path restore
int V;

void dijkstra(int s)
{
    fill(d, d+V, INF);
    fill(used, used+V, false);
    fill(prev_vertex, prev_vertex+V, -1);
    d[s]=0;

    while(true)
    {
        int v=-1;
        for(int u=0;u<V;++u)
            if(!used[u] && (v==-1||d[u]<d[v])) v=u;

        if(v==-1) break;

        used[v] = true;
        for(int u=0;u<V;++u)
        {
            if(cost[v][u]!=INF&&cost[v][u]!=-1&&d[u]>d[v]+cost[v][u])
            {
                d[u] = d[v]+cost[v][u];
                prev_vertex[u] = v;
            }
        }
    }
}

//get min path to t
vector<int> get_path(int t)
{
    vector<int> path;
    for(; t!=-1; t=prev_vertex[t]) path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}

int main()
{
    int n, a, b, w;
    while(scanf("%d", &n)!=EOF){
        if(n==0) break;
        memset(cost, -1, sizeof(cost));
        int minv=100,maxv=0;
        for(int i=0;i<n;++i){
            scanf("%d%d%d", &a, &b, &w);
            cost[a][b] = cost[b][a] = w;
            if(a<minv) minv = a;
            if(b<minv) minv = b;
            if(a>maxv) maxv = a;
            if(b>maxv) maxv = b;
        }
        V = maxv + 1;
        for(int i=0;i<V;++i) cost[i][i] = 0;
        int ansi = 0;
        int ansd = INF;
        for(int i=0;i<V;++i){
            dijkstra(i);
            int tmp = 0;
            for(int i=0;i<V;++i){
                tmp += d[i];
            }
            if(tmp < ansd){
                ansi = i;
                ansd = tmp;
            }
        }
        printf("%d %d\n", ansi, ansd);
    }
    return 0;
}


Measured memory_bytes: 3248
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    a1 = p[i-1]
    a2 = p[i]
    a3 = p[i+1]
    if (a1<=a2)and(a2<=a3):
        count += 1
    elif (a3<=a2)and(a2<=a1):
        count += 1
print(count)

Measured memory_bytes: 3060
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    c_arr = []
    for i in range(3):
        _ = list(map(int,_in[i].split(' ')))
        c_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    sum_c_arr = sum([sum(c) for c in c_arr])
    if (c_arr[0][0]+c_arr[1][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[2][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[0][1]+c_arr[1][2]+c_arr[2][0]) == sum_c_arr/3:
        TF = 'Yes'
    else:
        TF = 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38384
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            k = a[i][j]
            if {x[j], x[-j-1]} != {y[k], y[-k-1]}:
                break
            if x[j] == y[k]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
    return False

a = [[0, 1, 2], [2, 0, 1], [1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]
n = int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

Measured memory_bytes: 7808
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	set<int> s;
	rep(i,3){
		int a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
const int N=1000+7;
int n,size[N],w[N];
int lst[N],nxt[N],to[N],tot;
void add(int x,int y){
    nxt[++tot]=lst[x];
    to[tot]=y;
    lst[x]=tot;
}
void init(){
    cin>>n;
    int fa;
    for(int i=2;i<=n;i++){
        scanf("%d",&fa);
        add(fa,i);
    }
    for(int i=1;i<=n;i++) scanf("%d",&w[i]);
}
bool run(int u){
    int sum=0,cnt=0,box[N];
    for(int i=lst[u];i;i=nxt[i]){
        int v=to[i];
        if(!run(v)) return 0;
        size[u]+=size[v];
        int les=min(w[v],size[v]-w[v]);
        int lar=max(w[v],size[v]-w[v]);
        sum+=les;
        box[++cnt]=lar-les;
    }
    if(sum>w[u]){ return 0; }
    sum=w[u]-sum; int maxn=0;
    sort(box+1,box+1+cnt);
    priority_queue<int> h[cnt+7];
    for(int i=1;i<=cnt;i++){
        if(box[i]>sum) break;
        for(int j=i;j>=1;j--){
            int tmp=0;
            if(!h[j-1].empty()) tmp=h[j-1].top();
            while(!h[j-1].empty()&&tmp+box[i]>sum){ h[j-1].pop();tmp=h[j-1].top(); }
            if(tmp+box[i]>sum) continue;
            h[j].push(tmp+box[i]);
            maxn=max(maxn,tmp+box[i]);
            }
    }
    //printf("\n");
    size[u]+=sum-maxn;
    //printf("%d: %d %d\n\n",u,w[u],size[u]);
    return 1;
}
int main(){
    //freopen("tree.in","r",stdin);
    init();
    if(run(1)) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 2048
/**
 * @Author:      G_bg
 * @DateTime:    2019-08-04 20:10:57
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int a[maxn];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
    }
    a[0]--;
    for(int i = 1;i < n;i++){
        if(a[i] > a[i-1]) a[i]--;
    }
    bool flag = true;
    for(int i = 1;i < n;i++){
        if(a[i] < a[i-1]) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    //system("pause");
    return 0;
}

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

const int N = 2 * 1000 * 100 + 100;
int p[N], n, Min[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	Min[1] = p[1];
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		if (Min[i - 1] >= p[i])
			ans++;
		Min[i] = min(Min[i - 1], p[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string str;
    string rep;
    string code;
    string f;
    int a=0;
    int b=0;
    int b_2=0;
    int m=0;
    int now=0;
    cin >> str;
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> code >> a >> b ;
        b_2 =b;
        if(code[2] == 'p') {
            cin >> rep;
            for(int j=a;j<=b;j++){
                str[j] = rep[now];
                now++;
            }
            now = 0;
        }else if(code[0] == 'p'){
            for(int j=a;j<=b;j++){
                cout << str[j];
            }
            putchar('\n');
        }else{
            string s3=str.substr(a,b-a+1);
            reverse(s3.begin(),s3.end());
            str=str.substr(0,a)+s3+str.substr(b+1,str.size()-b-1);
            }
    }
    
    return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int i=0;
        int count=0;
        while(i<n){
            count++;
            i+=count;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

const int MAXN = 212345;

int n, m, k;
int s[MAXN];

ll p(ll x){
	return x*x;
}
int main (){
	scanf("%d", &n);
	for(int a=0;a<n;a++){
		scanf("%d", s+a);
	}
	ll res = LLONG_MAX;
	ll ans = 0;
	for(ll v = -100;v<=100;v++){
		ans = 0;
		for(int a=0;a<n;a++){
			ans+= p(s[a] -v); 

		}
		if(res > ans) res = ans;
	}
	printf("%lld\n", res);
}


Measured memory_bytes: 256
s = int(input())
List = [s]
n = s
a = 0
while a==0 :
    if n%2==0:
        n = n//2
    else:
        n = 3*n+1
    if n in List:
        print(len(List)+1)
        a += 1
    else:
        List.append(n)

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


int main() {
    string N, M;
    cin >> N >> M;
    int n = N.size();
    int m = M.size();
    if (n + 1 != m) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        char sn = N[i];
        char sm = M[i];
        if (sn != sm){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

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

void roll(int Dice[], char c)
{
    int t;
    if (c == 'E')
    {
        t = Dice[2];
        Dice[2] = Dice[0];
        Dice[0] = Dice[3];
        Dice[3] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'W')
    {
        t = Dice[3];
        Dice[3] = Dice[0];
        Dice[0] = Dice[2];
        Dice[2] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'N')
    {
        t = Dice[4];
        Dice[4] = Dice[0];
        Dice[0] = Dice[1];
        Dice[1] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'S')
    {
        t = Dice[1];
        Dice[1] = Dice[0];
        Dice[0] = Dice[4];
        Dice[4] = Dice[5];
        Dice[5] = t;
    }
    else if (c == 'R')
    {
        t = Dice[2];
        Dice[2] = Dice[1];
        Dice[1] = Dice[3];
        Dice[3] = Dice[4];
        Dice[4] = t;
    }
}

int top(int Dice[])
{
    return Dice[0];
}

int front(int Dice[])
{
    return Dice[1];
}

int left(int Dice[])
{
    return Dice[3];
}

int right(int Dice[])
{
    return Dice[2];
}

int main()
{
    int D1[6], D2[6];
    bool flat;
    for (int i = 0; i != 6; ++i)
    {
        cin >> D1[i];
    }
    for (int i = 0; i != 6; ++i)
    {
        cin >> D2[i];
    }
    for (int i = 0; i != 6; ++i)
    {
        for (int j = 0; j != 4; ++j)
        {
            flat = true;
            for (int k = 0; k != 6; ++k)
            {
                if (D1[k] != D2[k])
                {
                    flat = false;
                    break;
                }
            }
            if (flat)
            {
                cout << "Yes" << endl;
                return 0;
            }
            roll(D2, 'R');
        }
        if (i % 2 == 0)
        {
            roll(D2, 'N');
        }
        else
        {
            roll(D2, 'E');
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

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

char choice(char x) {
  if (x == 'r') return 'p';
  if (x == 's') return 'r';
  if (x == 'p') return 's';
}

void solve() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  vector<int> cr(N, 0), cs(N, 0), cp(N, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (T[i] == 'r') {
      if (i < K || cp[i - K] == 0) {
        ans += P;
        cp[i] = 1;
      }
    } else if (T[i] == 's') {
      if (i < K || cr[i - K] == 0) {
        ans += R;
        cr[i] = 1;
      }
    } else if (T[i] == 'p') {
      if (i < K || cs[i - K] == 0) {
        ans += S;
        cs[i] = 1;
      }
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

bool isLeapYear( int n ) {
	if( n % 400 == 0 ) return true;
	if( n % 100 == 0 ) return false;
	if( n % 4 == 0 ) return true;
	return false;
}

int main(void){

	int cnt = 0;
	while( true ) {
		
		int a, b;
		bool flg = false;
		cin >> a >> b;
		if( !( a|b ) ) break;
		if( cnt > 0 ) cout << endl;
		for( int i = a; i <= b; i++ ) {
			bool b = isLeapYear( i );
			flg |= b;
			if( b ) cout << i << endl;
		}
		if( !flg ) cout << "NA" << endl;
		cnt ++;
	}

    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  int ans = -1;
  for(int i = 1;i*i<=n;i++)
    ans = max(ans,i*i);

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


Measured memory_bytes: 3600
loop {
    n, m = gets.split.map &:to_i
    break if n == 0
    regexp = {}
    n.times {
        s, k = gets.split
        s =~ /(\d+)$/
        regexp[/#{$1}$/] = k.to_i
    }   
    sum = 0
    m.times {
        s = gets.chomp
        regexp.each{|r, k|
            sum += k if s =~ r
        }   
    }   
    p sum
}

Measured memory_bytes: 6264
def main():
  import sys
  input = sys.stdin.readline
  n,w=map(int,input().split())
  wv=[tuple(map(int,input().split())) for _ in range(n)]
  dp=[[0]*(w+1) for _ in range(n+1)]
  for i in range(n):
    for j in range(w+1):
      dp[i+1][j]=max(dp[i][j-wv[i][0]]+wv[i][1],dp[i][j]) if j-wv[i][0]>=0 else dp[i][j]
  print(dp[n][w])
if __name__=='__main__':
  main()

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

void solve()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    int n = s.size();
    bool ok = true;
    rep(i, n)
    {
        if (i == a)
        {
            if (s[i] != '-')
                ok = false;
        }
        else
        {
            if (s[i] == '-')
                ok = false;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    solve();
    return 0;
}

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

int main() {
    int h,w;
    cin >> h >> w;
    string board[50];
    
    for(int i=0;i<h;i++) cin>>board[i];
    
    const int dx[8] = {1,0,-1,0,1,-1,-1,1};
    const int dy[8] = {0,1,0,-1,1,1,-1,-1};
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(board[i][j]=='#') continue;
            
            int num=0;
            for(int d=0;d<8;d++){
                const int ni =i+dy[d];
                const int nj =j+dx[d];
                
                if(ni<0 or h<=ni) continue;
                if(nj<0 or w<=nj) continue;
                if(board[ni][nj]=='#') num++;
            }
            board[i][j]=char(num+'0');
        }
    }
    for(int i=0;i<h;i++) cout<<board[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)

const int MAXN = 1e5;
int N;
int A[MAXN]={};
int PAIR[MAXN]={};

int main() {
  cin >> N;
  int p=0,m=0;
  REP(i,N) {
    cin >> A[i];
    if (A[i]>=0) p+=1;
    else m+=1;
  }
  sort(A, A+N);

  int mmax = 0;
  if (p==N) { // all plus
    mmax = -A[0];
    RREP(i,1,N) mmax += A[i];
    m+=1; p-=1;
  } else if (m==N) { // all minus
    mmax = A[N-1];
    RREP(i,0,N-1) mmax -= A[i];
    m-=1; p+=1;
  } else {
    REP(i,m) mmax -= A[i];
    RREP(i,m,N) mmax += A[i];
  }
  printf("%d\n", mmax); // MAX


  int midx=0,pidx=m;
  while ((pidx-midx) != (N-pidx)) {
    int x = A[midx], y = A[pidx];
    // printf("p=%d m=%d\n", pidx, midx);
    if ((pidx-midx) > (N-pidx)) {
      A[pidx] = y - x; // P - M -> P
      printf("%d %d\n", y, x);
      midx+=1;
    } else {
      A[pidx] = x - y; // M - P -> M
      printf("%d %d\n", x, y);
      pidx+=1; midx+=1;
    }
  }
  // RREP(i,midx,N) {printf("%d ", A[i]);} printf("\n");
  int idx = 0;
  printf("%d %d\n", A[pidx], A[midx]); // P - M
  PAIR[idx] = A[pidx] - A[midx];
  pidx++; midx++; idx++;

  RREP(i,1,pidx-midx) {
    printf("%d %d\n", A[midx],A[pidx]);
    PAIR[idx] = A[midx] - A[pidx];
    pidx++; midx++; idx++;
  }
  RREP(i,1,idx) {
    printf("%d %d\n", PAIR[0], PAIR[i]);
    PAIR[0] -= PAIR[i];
  }
  return 0;
}

/*
5
1 -1 2 2 2
5
-1 -1 2 2 2
 */


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

public class Main {
  private static boolean solve(char[] ss) {
    Arrays.sort(ss);
    for (int i = 1; i < ss.length; i++) {
      if (ss[i] == ss[i - 1]) {
        return false;
      }
    }
    return true;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] ss = reader.nextCharArray();
    out.println(solve(ss) ? "yes" : "no");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23120
#include<iostream>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;

int m,n,sum=0;
int u[110][110]={0};
int p[110][110]={0};
string s;

int main(){
    scanf("%d%d",&m,&n);
    for(int i=0;i<=m;i++){
        getline(cin,s);
        for(int j=0;j<s.length();j++){
            if(s[j]=='#'){
                p[i][j+1]=1;
            }
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(p[i][j]==0){
                for(int k=i-1;k<=i+1;k++){
                    for(int l=j-1;l<=j+1;l++){
                        if(p[k][l]==1){
                            sum++;
                        }
                    }
                }
                u[i][j]=sum;
                sum=0;
            }
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(p[i][j]==1){
                printf("#");
            }
            if(p[i][j]==0){
                printf("%d",u[i][j]);
            }
        }
        cout<<endl;
    }
    return 0;
}

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

typedef long long ll;

int main(){
    int n;
    string s,t,ans="";
    cin>>n>>s>>t;
    int cnt=1;
    for(int i=0;i<n;i++){
        /* if(cnt&1) ans+=s[i];
        else ans+=t[i]; */
        //cnt++;
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}

int main(){
ll N;
cin>>N;
int sum=0,X=N;
if(N==10||N==100||N==1000||N==10000||N==100000)
sum+=10;
else if(N!=10&&N!=100&&N!=1000&&N!=10000&&N!=100000)
while(X!=0){
  sum+=X%10;
  X/=10;
    }
  cout<<sum<<endl;

}




Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int c[3][3];
  int sum = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++) {
      scanf("%d", &c[i][j]);
      sum += c[i][j];
    }
  }
  int a[3], b[3];
  a[0] = 1;
  for(int i = 0; i < 3; i++){
    b[i] = c[0][i] - a[0];
    a[1] = c[1][i] - b[i];
    a[2] = c[2][i] - b[i];
  }
  int flag = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(a[i] + b[j] != c[i][j]) flag = 1;
    }
  }
  if(flag) printf("No\n");
  else printf("Yes\n");
}

Measured memory_bytes: 128
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>

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

//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
	long long X, K, D;
	std::cin >> X >> K >> D;
	X = std::abs( X );	// absするので符号は関係ない わかりやすいので+から引き算する 

	// Y = D * K <-> K = Y / D 
	long long by_0_cnt = std::min( K, X / D );	// K回動くか、X / D(0にたどりつくまでの回数)を得る
	K -= by_0_cnt;
	X -= by_0_cnt * D;

	long long ans = 0;
	if( K % 2 == 0 )
	{
		ans = X;
	}
	else
	{
		ans = D - X;	// 最小まで言っているのでDのほうがXより大きいj
						// 最小まで行ってない場合はK == 0になる 
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 3620
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)

for i in range(N):
  L[i+1] = gcd(L[i], A[i])
  
for i in range(N,0,-1):
  R[i-1] = gcd(R[i], A[i-1])
  
ans = 1
for i in range(N):
  ans = max(ans, gcd(L[i], R[i+1]))

print(ans)

Measured memory_bytes: 16148
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    long d = K / 50;
    long r = K % 50;

    vector<long> v;
    for (long i = 0; i < r; ++i)
        v.push_back(d + 51 - r);
    for (long i = 0; i < 50 - r; ++i)
        v.push_back(d - r);

    for (long& x : v)
        x += 49;

    cout << "50\n";
    for (int i = 0; i < 50; ++i) {
        if (i > 0)
            cout << ' ';
        cout << v[i];
    }
    cout << '\n';

    return 0;
}


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

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

Measured memory_bytes: 3916
def conbi(n):
  count  = 1
  for i in range(1,n+1):
    count *= i
  return count
N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
  x[i],y[i] = map(int,input().split())
X = conbi(N)
leng = 0
for i in range(N):
  for j in range(N):
    if i != j:
      leng += (((x[i]-x[j])**2 + (y[i]-y[j])**2))**0.5
print(leng/N)

Measured memory_bytes: 3064