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

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

  if (S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy" ) {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
  
}

Measured memory_bytes: 256
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>

using namespace std;

int main()
{
    string s;

    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length() / 2; i++) {
        if (s[i] != s[s.length() - i - 1])ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int a,b;
    cin>>a>>b;
    int ans = 0;
    while(a*ans-(ans-1)<b) {
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3636
N = int(input())
L = list(map(int, input().split()))

ans = "APPROVED"
for i in range(N):
  if L[i]%2 == 0:
    if L[i]%3 == 0 or L[i]%5 == 0:
      pass
    else:
      ans = "DENIED"
      break
      
print(ans)
      


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	String a = sc.next();
    	String b = sc.next();
    	
    	String ab = a+b;
    	int n = Integer.valueOf(ab);
    	int r = (int) (Math.sqrt(n));
    	
    	if(r*r == n){
    		System.out.println("Yes");
    	}
    	else{
    		System.out.println("No");
    	}

    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
n = int(input())
A = list(map(int,input().split()))

S={}
for i in range(n):
    a = A[i]
    if a in S :
        S[a]+=1
    else:
        S[a]=1

V=list(S.values())
c = sum([v*(v-1)//2 for v in V])

cdiff=0
K=[]
for i in range(n):
    cdiff=0
    a = A[i]
    s=S[a]
    if s>=2 :
        cdiff=(s*(s-1)-(s-1)*(s-2))//2
    print(c-cdiff)





Measured memory_bytes: 32364
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, S: str):
    ret = 0
    cnt = 1
    tmp = 0
    for i in range(N - 1):
        if S[i] == S[i + 1]:
            cnt += 1
        else:
            if cnt > 1:
                ret += cnt - 1
            cnt = 1
            tmp += 1
    ret += cnt - 1
    ret += min(K, tmp // 2) * 2
    if K > tmp // 2:
        ret += tmp % 2
    ret = min(ret, N - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
ll ans=0;
ll val=1;
while(val<=n)
{
    val=val*k;
    ans++;
}
cout<<ans<<endl;

return 0;
}


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

using namespace std;

int main()
{
    int L, M, N;
    while (cin >> L, L) {
        int sum = 0, j = -1;
        for (int i = 0; i < 12; i++) {
            cin >> M >> N;
            sum += (M - N);
            if (j == -1 && sum >= L) {
                j = i;
            }           
        }
        if (j >= 0) {
            cout << j+1 << endl; 
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3096
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double ans = 0;
            double temp = 0;
            for (int i = 0; i < N; i++)
            {
                string[] S = Console.ReadLine().Split(' ');
                if(S[1] == "BTC")
                {
                    temp = double.Parse(S[0]) * 380000.0;
                }
                else
                {
                    temp = double.Parse(S[0]);
                }
                ans += temp;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#pragma region header
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif
#pragma endregion

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vi32> g(n);
  vi32 deg(n);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    deg[v] += 1;
  }
  vi32 x;
  rep(i, n) if (deg[i] == 0) {
    x.push_back(i);
  }
  for (int i = 0; i < sz(x); i++) {
    int u = x[i];
    for (int v : g[u]) {
      deg[v] -= 1;
      if (deg[v] == 0) {
        x.push_back(v);
      }
    }
  }
  vi32 dp(n);
  rep(i, n) {
    int u = x[i];
    for (int v : g[u]) {
      amax(dp[v], dp[u] + 1);
    }
  }
  int ans = 0;
  rep(i, n) amax(ans, dp[i]);
  cout << ans << endl;
}

#pragma region footer
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}
#pragma endregion

Measured memory_bytes: 10112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int main() {
	int n, y;
	cin >> n >> y;
	int sum = 0;
	REP(i, n+1) {
		REP(j, n + 1 - i) {
			sum = 10000 * i + 5000 * j + 1000 * (n - i - j);
			if (sum == y) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int A[N], kotae[N];
    for (int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        kotae[A[i] - 1] = i + 1;
    }
    for (int i = 0; i < N; i++){
        printf("%d ", kotae[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1536
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, ans, a[N], x, y;
vector <int> v;

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

      for(int i = 1; i <= n; i ++){
            scanf("%d", &a[i]);
            v.pb(a[i]);
      }

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

      for(int i = 1; i <= n; i ++){
            a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
            if(i % 2){
                  if(a[i] % 2 == 0) x ++;
            } else {
                  if(a[i] % 2) y ++;
            }
      }

      cout << max(x, y) << endl;
}


Measured memory_bytes: 1148
#include <stdio.h>

int main(void) {
	int W, H;
	char c[4];
	int i, j;
	if (scanf("%d%d%1s", &W, &H, c) != 3) return 1;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			int pc = ' ';
			if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) pc = '+';
			else if (i == 0 || i == H - 1) pc = '-';
			else if (j == 0 || j == W - 1) pc = '|';
			else if (i == H / 2 && j == W / 2) pc = c[0];
			else pc = '.';
			putchar(pc);
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2060
def test():
    r = int(input())
    rank = {1199:"ABC",2799:"ARC",4200:"AGC"}

    if r < 1200:
        print(rank[1199])
    elif r >= 1200 and r < 2800:
        print(rank[2799])
    else:
        print(rank[4200]) 


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);i++)
#define PI 3.1415926535897932384626433832795028841971693993
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    ll n;
    cin>>n;
    vector<ll> dat(1e7);
    dat[1]=7%n;
    for(int i=2;i<=n;i++){
        dat[i]=(dat[i-1]*10+7)%n;
    }
    rep(i,n){
        if(dat[i]==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 81400
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,t;
    cin>>a>>b>>t;
    
    int ans = b*(t/a);
    cout<<ans<<endl;;
}

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

int main() {
  int n, m, i, j, ans = 0, score;
  string w;
  vector<string> s, t;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> w;
    s.push_back(w);
  }

  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> w;
    t.push_back(w);
  }

  for (i = 0; i < n; i++) {
    score = 0;

    for (j = 0; j < n; j++) {
      if (s.at(j) == s.at(i)) {
        score++;
      }
    }

    for (j = 0; j < m; j++) {
      if (t.at(j) == s.at(i)) {
        score--;
      }
    }

    ans = max(ans, score);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

string s,t;cin >> s >> t;

ll cnt = 0;
int slen = s.size();
unordered_map<char, set<int>> m; // 文字の出現位置
rep(i, 0, slen) m[s[i]].insert(i+1);

int prev = 0; // 前の文字の出現位置
rep(i, 0, t.size()){
    if (m[t[i]].empty()) {
        cout << -1 << "\n";
        return 0;
    }
    if (m[t[i]].upper_bound(prev) == m[t[i]].end()){
        cnt += slen - prev;
        prev = 0;
    }
    cnt += *m[t[i]].upper_bound(prev) - prev;
    prev = *m[t[i]].upper_bound(prev);
}

cout << cnt << "\n";

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
struct node{
  int d;
  int station;
  int route;
};
bool operator< (const node &l, const node &r){
  return l.d > r.d;
};
int main(){
  int n, m;
  cin >> n >> m;
  vector<unordered_map<int, int>> cost(n, {{0, 1e9}});
  vector<unordered_map<int, vector<int>>> train(n);
  for(int i=0; i<m; i++){
    int p, q, c;
    cin >> p >> q >> c;
    train[--p][c].push_back(--q);
    train[q][c].push_back(p);
  }
  cost[0][0] = 0;
  priority_queue<node> pq;
  node init, next;
  init.d = 0;
  init.station = 0;
  init.route = 0;
  pq.push(init);
  while(!pq.empty()){
    auto now = pq.top();
    pq.pop();
    if(now.route != 0){
      if(cost[now.station][0] > now.d){
        cost[now.station][0] = now.d;
        next = now;
        next.route = 0;
        pq.push(next);
      }
      if(train[now.station].count(now.route) != 0){
         for(auto t: train[now.station][now.route]){
          if(cost[t].count(now.route) == 0 || cost[t][now.route] > now.d){
            cost[t][now.route] = now.d;
            next = now;
            next.station = t;
            pq.push(next);
          }
        }
      }
    }
    else{
      for(auto to:train[now.station]){
        for(auto t:to.second){
          if(cost[t].count(to.first) == 0 || cost[t][to.first] > now.d + 1){
            cost[t][to.first] = now.d + 1;
            next.d = now.d + 1;
            next.station = t;
            next.route = to.first;
            pq.push(next);
          }
        }        
      }
    }
  }
  cout << (cost[n-1][0] < 1e9 ? cost[n-1][0] : -1) << endl;
}

Measured memory_bytes: 74216
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;

string s;
int N;
ll m, a, r, c, h;
ll D[5];

int P[10] = {0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
int Q[10] = {1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
int R[10] = {2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};

int main (){

    scanf ("%d", &N);
    for(int i = 0; i < N ;i++){
        cin >> s;
        if( s[0]== 'M') m++;
        if( s[0]== 'A') a++;
        if( s[0]== 'R') r++;
        if( s[0]== 'C') c++;
        if( s[0]== 'H') h++;
    }

    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    ll res = 0;
    for (int d = 0; d < 10; d++) res += D[ P[d] ] * D[ Q[d] ] * D[ R[d] ];

    printf ("%lld \n", res);

    return 0;
}

Measured memory_bytes: 384
def calculate(w,h,x,y):

    b = 0
    if (x - w/2 == 0) and (y - h/2 == 0):
        b = 1


    arr = [w*h/2,b]
    print(" ".join([str(item) for item in arr]))


arr = input().split(" ")
W = int(arr[0])
H = int(arr[1])
x = int(arr[2])
y = int(arr[3])

calculate(W,H,x,y)

Measured memory_bytes: 3064
from itertools import accumulate
N, C = map(int, input().split())
TimeTable = [[0] * (10 ** 5 + 2) for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    TimeTable[c][s] += 1
    TimeTable[c][t + 1] -= 1

for c in range(C + 1):
    TimeTable[c] = list(accumulate(TimeTable[c]))


ans = 0
for i in range(10 ** 5 + 2):
    cnt = 0
    for c in range(C + 1):
        cnt += min(TimeTable[c][i], 1)
    ans = max(ans, cnt)

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<int> pos(n, -1), rev(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(pos[a] != -1){
            cout << -1 << endl;
            return 0;
        }
        pos[a] = b;
        rev[b] = a;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(pos[i] == i) continue;
        ans++;
        int j = rev[i];
        swap(pos[i], pos[j]);
        rev[pos[j]] = j;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
n, m = map(int, input().split())

fib = [0]*(n + 1)
fib[0] = 1
fib[1] = 1
for x in range(2, n+1):
    fib[x] = fib[x-1] + fib[x-2]

mod = 10**9+7
ans = 1
prev_a = -1
a = 0
for i in range(m):
    a = int(input())
    if a - 1 == prev_a:
        ans = 0
        break
    else:
        ans = (ans * fib[a - prev_a - 2]) % mod
    prev_a = a

if m == 0:
    ans = fib[n] % mod
else:
    ans = (ans * fib[n - a - 1]) % mod
print(ans)

Measured memory_bytes: 476408
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>

using namespace std;

#define n 4
#define n2 16
#define LIM 100

static const int dx[4]={0, -1, 0, 1};
static const int dy[4]={1, 0, -1, 0};
static const char dir[4]={'r', 'u', 'l', 'd'};
int MDT[n2][n2];

struct puz {int f[n2], space, MD; };

puz state;
int limit;
int path[LIM];

int getAllMD(puz pz){
  int cnt=0;
  for(int i=0 ; i<n2 ; i++){
    if(pz.f[i]==n2)continue;
    cnt+=MDT[i][pz.f[i]-1];
  }
  return cnt;
}

bool isSolved(){
  for(int i ; i<n2 ; i++)if(state.f[i]!=i+1)return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD==0)return true;
  if(depth+state.MD>limit)return false;
  int sx=state.space/n;
  int sy=state.space%n;
  puz tmp;
  for(int r=0 ; r<4 ; r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0 || ty<0 || tx>=n || ty>=n)continue;
    if(max(prev, r)-min(prev, r)==2)continue;
    tmp=state;
    state.MD-=MDT[tx*n+ty][state.f[tx*n+ty]-1];
    state.MD+=MDT[sx*n+sy][state.f[tx*n+ty]-1];
    swap(state.f[tx*n+ty], state.f[sx*n+sy]);
    state.space=tx*n+ty;
    if(dfs(depth+1,r)){path[depth]=r; return true; }
    state=tmp;
  }
  return false;
}

string indep(puz in){
  in.MD=getAllMD(in);
  for(limit=in.MD ; limit<=LIM ; limit++){
    state=in;
    if(dfs(0, -100)){
      string ans="";
      for(int i=0 ; i<limit ; i++)ans+=dir[path[i]];
      return ans;
    }
  }
 return "unsolvabe";
}

int main(){
 for(int i=0 ; i<n2 ; i++)
   for(int j=0 ; j<n2 ; j++)
     MDT[i][j]=abs(i/n-j/n)+abs(i%n-j%n);
 puz in;
 for(int i=0 ; i<n2 ; i++){
   cin>>in.f[i];
   if(in.f[i]==0){
     in.f[i]=n2;
     in.space=i;
   }
 }
 string ans=indep(in);
 cout<<ans.size()<<endl;
 return 0;
}
  



Measured memory_bytes: 3228
n = int(input())
l = [int(input()) for i in range(5)]

index = 0
v = l[0]
for i in range(len(l)):
    if l[i] < v:
        index = i
        v = l[i]

result = index + n // v + len(l) - index
if (n % v == 0):
    result -=1
print(result)


Measured memory_bytes: 3060
/**
*	created: 11.09.2020 17:51:38
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T &b) {if (b < a) {a = b; return 1;} return 0;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

struct edge {int to, cost;};

struct graph {
    int n;
    vector<vector<edge>> G;
    vector<int> d, pre;
    graph(int i) : n(i), G(n), pre(n), d(n,INF) {}
    void add_edge(int s, int t, int cost) {
        edge e; e.to = t; e.cost = cost;
        G[s].push_back(e);
    }
    void dijkstra(int s) {
        rep(i,n) {d[i] = INF; pre[i] = 0;}
        d[s] = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(P(0,s));
        while(!que.empty()){
            P p = que.top(); que.pop(); int v = p.second;
            if(d[v] < p.first) continue;
            for(auto e : G[v]) if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost; pre[e.to] = v;
                que.push(P(d[e.to],e.to));
            }
        }
    }
};

signed main() {
    int n, m; cin >> n >> m;
    map<P,int> edge_list;
    graph g(n);
    rep(i,m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        edge_list[P(min(a,b),max(a,b))]++;
        g.add_edge(a,b,c);
        g.add_edge(b,a,c);
    }
    rep(i,n) {
        g.dijkstra(i);
        rep(f,n) {
            if (f == i) continue;
            int t = g.pre[f];
            edge_list[P(min(f,t),max(f,t))]++;
        }
    }
    int ans = 0;
    for (auto p : edge_list) if (p.second == 1) ans++;
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B,C;
    cin>>A>>B>>C;
    if (A<=C && B>=C) {
        cout<<"Yes"<<endl;
    }
    else if (A>=C && B<=C) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = sorted([int(x) for x in input().split()])

color_min = 0
creature_size = A[0]

for i in range(1, N):
    if 2 * creature_size >= A[i]:
        creature_size += A[i]
    else:
        color_min = i
        creature_size += A[i]

ans = N - color_min

print(ans)

Measured memory_bytes: 20348
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(); cout.tie();
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i++){
        int inp;
        cin >> inp;
        mp[inp] = i;
    }
    for (auto i : mp)
        cout << i.second << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 5504
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    match = [0,2,5,5,4,5,6,3,7,6]
    dp = [-1] * (N + 10)
    dp[0] = 0
    for i in range(N):
        if dp[i] != -1:
            for a in A:
                dp[i+match[a]] = max(dp[i+match[a]], dp[i] * 10 + a)
        
    print(dp[N])


if __name__ == "__main__":
    main()

Measured memory_bytes: 50908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine()); //標準入力

            Console.WriteLine(a%2 + a/2);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    //cout.precision(10);
    ll N,w;
    cin>>N;
    for(ll h=3500;h>0;h--){
        for(ll n=3500;n>0;n--){
            if(!((N*h*n)%(4*h*n-N*(n+h)))){
                w=(N*h*n)/(4*h*n-N*(n+h));
                if(w>0){
                    cout<<h<<" "<<n<<" "<<w<<endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
<?php
        for($loop_cnt = 0; $loop_cnt < 5; $loop_cnt++)
        {
                $data_set = array();
                $data = array();

                // 変換表数設定
                $input_n = trim(fgets(STDIN));
                if( 0 == $input_n)
                {
                        break;
                }

                // 変換表設定
                for($loop_n = 0; $loop_n < $input_n; $loop_n++)
                {
                        $input_conv = explode( " " , trim(fgets(STDIN)) );

                        $data_set[$input_conv[0]] = $input_conv[1] ;
                }

                // データ数設定
                $input_m = trim(fgets(STDIN));

                // データ設定
                for($loop_m = 0; $loop_m < $input_m; $loop_m++)
                {
                        $input_data =trim(fgets(STDIN));
                        $data[$loop_m] = $input_data;
                }

                // 変換後出力
                $work = [];
                for($loop_m = 0; $loop_m < $input_m; $loop_m++)
                {
                        if( isset( $data_set[$data[$loop_m]] ) )

                        {
                                $work[] = $data_set[ $data[$loop_m] ];
                        }
                        else
                        {
                                $work[] = $data[$loop_m];
                        }
                }
                echo implode('',$work);
                echo "\n";
        };


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

Measured memory_bytes: 128
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int k;
  int a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll cnt[100010];
int main()
{
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a] += b;
	}
	int ans = 0;
	while (K > 0) {
		K -= cnt[ans++];
	}
	cout << ans - 1 << endl;
}

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

string a[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
string s;

string solve(){
  string t = "";

  int key=0, cnt=0;
  for(int i=0; i<(int)s.size(); i++){
    int S = s[i] - '0';
    if(S==0){
      if(key!=0){
        cnt--;
        int len=a[key].size();
        t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    } else if(key==S){
      cnt++;
    } else {
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 3052
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long
#define ull unsigned long long
#define debug(x) cerr<<#x<<"="<<x<<'\n'
//#define DEBUG

const int MOD=1e9+7;

int n;
string s;
int E[300100],W[300100];

int main()
{
	#ifdef DEBUG
	clock_t tStart = clock();
	#endif
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='E') E[i]++;
		if(i) E[i]+=E[i-1];	
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='W') W[i]++;
		if(i!=n-1) W[i]+=W[i+1];
	}
	int res=0;
	for(int i=0;i<n;i++)
	{
		int k=0;
		if(i!=0) k+=E[i-1];
		if(i!=n-1) k+=W[i+1];
		res=max(res,k+1);
	}
	printf("%d\n",n-res);
	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
	return 0;
}



Measured memory_bytes: 2948
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
vector<ll> v;
int main()
{
    fastio();
    ll x;
    cin>>x;
    rep(i,0,4000){
        ll tmp = pow(i,5);
        v.pb(tmp);
    }
    rep(i,0,4000){
        rep(j,0,4000){
            ll a = pow(i,5),b = pow(j,5);
            if(a-b==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
            if(a+b==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4312
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long min = 1;
		long max = A;
		for(var i=0;i<B;i++){
			string[] str2 = Console.ReadLine().Split();
			long C1 = long.Parse(str2[0]);
			long C2 = long.Parse(str2[1]);
			min = Math.Max(min,C1);
			max = Math.Min(max,C2);
		}
		long ans = Math.Max(0,max-min+1);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 15296
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

using namespace std;

struct Node {
    int to;
    ll length;
    Node(){}
    Node(ll to, ll length) : to(to), length(length){};
};

bool operator>(const Node& ls, const Node& rs) {
    return ls.length > rs.length;
}
bool operator<(const Node& ls, const Node& rs) {
    return ls.length < rs.length;
}

int main(){
    int v,e,r; cin >> v >> e >> r;
    vector<vector<pair<int,int>>> edges(v, vector<pair<int,int>>(0));
    rep(i, e) {
        ll s,t,d; cin >> s >> t >> d;
        edges[s].push_back(make_pair(t,d));
    }
    vector<ll> ans(v, INF);
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push(Node(r,0));
    while(!pq.empty()) {
        Node top = pq.top();
        pq.pop();
        if(top.length >= ans[top.to])
            continue;
        ans[top.to] = top.length;
        for(auto it = edges[top.to].begin(); it != edges[top.to].end(); it++) {
            pq.push(Node(it->first, top.length + it->second));
        }
    }
    for(ll i = 0; i < v; i++) {
        if(ans[i] != INF) {
            cout << ans[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}




Measured memory_bytes: 16468
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, K, a[200010];

template <typename T>
struct BIT{
private:
    vector<T> array;
    int n;

public:
    // 初期化 (適当)
    BIT() : array(11, 0), n(10) {}
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 他のクラスで BIT を呼び出すときに便利なので作った
    void resize(int _n) {
        array.resize(_n + 1);
        n = _n;
    }

    // 1番目から i番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;      // LSB 減算
        }
        return s;
    }

    // [i, j] の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i 番目に 要素 x を追加
    void add(int i, T x) {
        while(i <= n) {
            array[i] += x;
            i += i & -i;      // LSB 加算
        }
    }
};

signed main() {
    cin >> N >> K;
    map<int, int> m;
    repq(i,1,N) {
        cin >> a[i];
        a[i] = a[i] + a[i-1];
    }

    repq(i,0,N) {
        a[i] -= K * (i+1);
        // printf("debug: a[%lld] = %lld\n", i, a[i]);
        m[ a[i] ];
    }

    int num = 1;
    for(auto &x : m) x.second = num++;
    repq(i,0,N) a[i] = m[ a[i] ];

    int ans = 0;
    BIT<int> bit(N+1);
    repq(i,0,N) {
        // printf("debug: a[%lld] = %lld\n", i, a[i]);
        ans += bit.sum(a[i]);
        bit.add(a[i], 1);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b;
cin>>a>>b;
if (a>b)
{
    cout<<"safe"<<endl;
}
else
{
    cout<<"unsafe"<<endl;
}

    return 0;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e2 + 10;
int Chk[999], N;
char S[MAX_N];
char Nr[2][MAX_N];
int main() {
	scanf("%s", S); N = strlen(S);
	for(int i=0; i<N; i++) Chk[S[i]] = 1;

	int ans = INF;
	for(char c='a'; c<='z'; c++) {
		if(Chk[c] == 0) continue;
		for(int i=0; i<N; i++) Nr[0][i] = S[i];
		int now = 0;
		for(int it=0; ; it++) {
			bool isSame = true;
			int n = it%2, o = 1-n;
			for(int i=0; i<N-it; i++) if(Nr[n][i] != Nr[n][0]) isSame = false;
			if(isSame) {
				now = it;
				break;
			}
			for(int i=0; i<N-it-1; i++) {
				if(Nr[n][i] == c || Nr[n][i+1] == c) Nr[o][i] = c;
				else Nr[o][i] = Nr[n][i];
			}
		}
		ans = min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i%2 ==0:
                if j%2 ==0:
                    print('#', end="")
                else:
                    print('.', end="")
            else:
                if j%2 ==0:
                    print('.', end="")
                else:
                    print('#', end="")
        print('')
    print('')



Measured memory_bytes: 7012
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

#define MAX_N 110000

using namespace std;

class UnionFind {
  public :
    void init(int n) {
      par.resize(n + 1);
      rnk.resize(n + 1);
      _size.resize(n + 1);
      for (int i = 0; i <= n; i++) {
        par[i] = i;
        rnk[i] = 0;
        _size[i] = 1;
      }
    }
    
    int find(int x) {
      if (par[x] == x) return x;
      else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
      x = find(x); y = find(y);
      if (x == y) return;
      
      if(rnk[x] < rnk[y]) {
        par[x] = y;
        _size[y] += _size[x];
      } else {
        par[y] = x;
        _size[x] += _size[y];
        if (rnk[x] == rnk[y]) rnk[x]++;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }

    int size(int x) {
      return _size[find(x)];
    }

  private:
    vector<int> par;
    vector<int> rnk;
    vector<int> _size;
};

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pair<int, int>> edge;
  REP(i, M) {
    int A, B; cin >> A >> B;
    edge.PB(MP(A, B));
  }

  vector<ll> v(M);
  UnionFind uf;
  uf.init(N);
  v[M - 1] = N * (N - 1) / 2;
  for (int i = M - 1; i > 0; i--) {
    int A = edge[i].FI, B = edge[i].SE;
    ll X, Y;
    if (!uf.same(A, B)) {
      X = uf.size(A);
      Y = uf.size(B);
    } else {
      X = 0;
      Y = 0;
    }
    v[i - 1] = v[i] - X*Y;
    uf.unite(A, B);
  }
  REP(i, M) cout << v[i] << endl;
  return 0;
}

Measured memory_bytes: 4084
def check(x, A, B):
    if int(x * 0.08) == A and int(x * 0.1) == B:
        return True
    else:
        return False

def solve(A, B):
    left = 0
    right = 1250
    ans = []
    for i in range(0, 1251):
        if check(i, A, B):
            print(i)
            exit()
    print(-1)

def main():
    A, B = map(int, input().split())

    solve(A, B)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  int g = gcd<int>(a, b);

  printf("%lld\n", (ll)a * b / g);
  return 0;
}


Measured memory_bytes: 256
#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;
}


signed main(){
  int n;cin>>n;
  int a[100000];rep(i,n)cin>>a[i];
  int aa = 0;
  rep(i,n){
    if(i%2 == 0){
      aa += a[i];
    }else{
      aa -= a[i];
    }
  }
  vector<int> ans;ans.push_back(aa);
  repd(i,1,n){
    ans.push_back(a[i-1] * 2 - ans[i-1]);
  }
  rep(i,n){
    cout << ans[i] << (i == n-1 ? "\n" : " ");
  }
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

int a[100000], b[100000];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d%d", a + i, b + i);
	ll an = 0;
	for (int i = n - 1; i >= 0; --i){
		ll z = an + a[i];
		ll w = (z + b[i] - 1) / b[i] * b[i];
		an += w - z;
	}
	printf("%lld\n", an);
}


Measured memory_bytes: 1024
# 単純に真ん中でよくない？ -> ダメです 愚直にやりましょう
n = int(input())
s = input()

tmp = 0
for i in range(n):
    x, y = list(s[:i]), list(s[i:])
    tmp = max(tmp, len(set(x) & set(y)))
print(tmp)


Measured memory_bytes: 2940
public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();
    char[] s = ns();
    
    s[k - 1] = (char)(s[k - 1] - 'A' + 'a');
    System.out.println(s);
        
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static 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();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    vector<in> a(n);
        rep(i,n) cin>>a.at(i);
    in tot=0ll;
    rep(i,n) tot = (tot^a[i]);
    rep(i,n){
        in ans= (tot^a[i]);
        cout<<ans;
        if(i<n-1) cout<<" ";
        else cout<<endl;
    }
}/*
./problem.exe
*/

Measured memory_bytes: 4724