akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#include <limits.h>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll INF = 100000000;
const ll MOD = 1000000007;

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

    ll x = 1;

    while (b > 0)
    {
        if (b & 1)
        {
            x = (x * a) % mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //問題文中の添え字が0-indexか1-indexか確認!

    ll n, min = INT_MAX, max = -INT_MAX;
    ll maxitr = 0, minitr = 0;
    std::cin >> n;
    std::vector<ll> a(n);

    rep(i, 0, n)
    {
        std::cin >> a[i];
        if (min > a[i])
        {
            min = a[i];
            minitr = i + 1;
        }
        if (max < a[i])
        {
            max = a[i];
            maxitr = i + 1;
        }
    }

    if (min < 0 && max >= 0)
    {
        std::cout << 2 * n - 1 << "\n";
        if (max + min >= 0)
        {
            rep(i,0,n){
                std::cout << maxitr << " " << i + 1 << "\n";
            }
            rep(i,1,n){
                std::cout << i << " " << i + 1 << "\n";
            }
        }
        else
        {
            rep(i, 0, n)
            {
                std::cout << minitr << " " << i + 1 << "\n";
            }
            rep(i, 0, n-1)
            {
                std::cout << n-i << " " << n-1-i << "\n";
            }
        }
        return 0;
    }

    std::cout << n - 1 << "\n";
    if(min>=0){
        rep(i, 1, n)
        {
            std::cout << i << " " << i + 1 << "\n";
        }
    }else{
        rep(i, 0, n - 1)
        {
            std::cout << n - i << " " << n - 1 - i << "\n";
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int H, W;
    while (1) {
        cin>>H>>W;
        if (H==0 && W==0) break;

        rep(i, H) {
            rep(j, W) {
                if (i==0 || i==H-1) cout<<"#";
                else if (j==0 || j==W-1) cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3112
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

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, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    int balance = 0;
    int ans = 0;
    for (auto c : s) {
        if (balance > 0) {
            balance--;
            if (c == 'g') {
                ans++;
            }
        } else {
            balance++;
            if (c == 'p') {
                ans--;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 107
	// https://atcoder.jp/contests/abc107/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] candies = new int[n];
		int res = Integer.MAX_VALUE;
 		for (int i = 0; i < n; i++) {
 			candies[i] = sc.nextInt();
		}
 		
 		for (int i = 0; i < n - k + 1; i++) {
 			int left = Math.abs(candies[i]) + (candies[i + k - 1] - candies[i]);
 			int right = Math.abs(candies[i + k - 1]) + (candies[i + k - 1] - candies[i]);
 			int tmp = Math.min(left, right);
 			res = Math.min(res, tmp);
 		}
 		
		System.out.println(res);
	}
	
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 37548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v));
#define MP make_pair
#define X first
#define Y second

using namespace std;

const double EPS = 1e-8;

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

template<class T> inline T sq(T a){return a*a;}
template<class T> T gcd(T m, T n){return n?gcd(n, m%n):m;}

int dp[101][11];

vector<P> G[101];

struct state{
	int p, c, t;
	state(int p, int c, int t):p(p), c(c), t(t){}
	bool operator<(const state &r) const {
		return c > r.c;
	}
};

int main(){
	int c, n, m, s, d;
	while(cin >> c >> n >> m >> s >> d, c|n|m|s|d){
		rep(i, 101) G[i].clear();
		s--, d--;
		rep(i, m){
			int a, b, f;
			cin >> a >> b >> f;
			a--, b--;
			G[a].push_back(MP(b, f));
			G[b].push_back(MP(a, f));
		}
		rep(i, 101) rep(j, 11) dp[i][j] = 1<<29;

		priority_queue<state> q;
		q.push(state(s, 0, c));
		int ans = -1;
		while(!q.empty()){
			state st = q.top();
			q.pop();

			if(dp[st.p][st.t] < st.c) continue;
			if(st.p == d) break;

			rep(i, G[st.p].size()){
				state next = st;
				next.p = G[st.p][i].first;
				next.c += G[st.p][i].second;
				if(next.c < dp[next.p][next.t]){
					dp[next.p][next.t] = next.c;
					q.push(next);
				}
				if(next.t > 0){
					next.c -= G[st.p][i].second/2;
					next.t--;
					if(next.c < dp[next.p][next.t]){
						dp[next.p][next.t] = next.c;
						q.push(next);
					}
				}
			}
		}

		cout << *min_element(dp[d], dp[d]+11) << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
import java.util.Arrays;
import java.util.Scanner;

//線分交差判定を使用
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Double[] list = Arrays.stream(sc.nextLine().split(",")).map(Double::parseDouble).toArray(Double[]::new);
            System.out.println(intersected(list) ? "YES" : "NO");
        }
    }

    static boolean intersected(Double[] list) {
        double ta = (list[0] - list[2]) * (list[5] - list[1]) + (list[1] - list[3]) * (list[0] - list[4]);
        double tb = (list[0] - list[2]) * (list[7] - list[1]) + (list[1] - list[3]) * (list[0] - list[6]);
        double tc = (list[4] - list[6]) * (list[1] - list[5]) + (list[5] - list[7]) * (list[4] - list[0]);
        double td = (list[4] - list[6]) * (list[3] - list[5]) + (list[5] - list[7]) * (list[4] - list[2]);

        return ta * tb > 0 && tc * td > 0;
    }
}


Measured memory_bytes: 31848
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] hop = new boolean[N];
        boolean[] step = new boolean[N];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 1) {
                hop[b - 1] = true;
            } else if (b == 1) {
                hop[a - 1] = true;
            } else if (a == N) {
                step[b - 1] = true;
            } else if (b == N) {
                step[a - 1] = true;
            }
        }
        for (int i = 0; i < N; i++) {
            if (hop[i] && step[i]) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 93376
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string change(string s,int k) {
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='.' || s[i]==' ') continue;
    s[i]+=k;
    if(s[i]<'a') s[i]+=26;
    if(s[i]>'z') s[i]-=26;
  }
  return s;
}

string a[3]={"the","that","this"};

bool check(string s) {
  for(int i=0; i<3; i++) {
    for(int j=0; j<s.size()-a[i].size(); j++) {
      if(s.substr(j,a[i].size())==a[i]) return true;
    }
  }
  return false;
}

int main() {
  string s;
  while(getline(cin,s)) {
    for(int k=0; k<26; k++) {
      s=change(s,1);
      if(check(s)) {
	pr(s);
	break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1188
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り


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

int n;
long k;
int curr;
int a[200000];
int d[200000][64];

void step() {
  if (k == 0) return;
  --k;
  curr = a[curr];
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  curr = 0;
  for (int i = 0; i < 300000; ++i) step();
  
  for (int i = 0; i < n; ++i) d[i][0] = a[i];
  for (int k = 1; k < 64; ++k) {
    for (int i = 0; i < n; ++i) {
      d[i][k] = d[d[i][k - 1]][k - 1];
    }
  }
  
  for (int p = 0; p < 60; ++p) {
    if (k & (1ll << p)) {
      curr = d[curr][p];
    }
  }
  cout << curr + 1 << endl;
}

Measured memory_bytes: 54312
/**
 *      ABC 58 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:22:36
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c; cin >> a >> b >> c;
    (b - a == c - b) ? cout << "YES" : cout << "NO";

    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll A, B;
    cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 764
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    uf = UnionFind(N+1)
    for a, b in zip(A, B):
        uf.union(a, b)
    fr = [uf.size(i)-1 for i in range(N+1)]
    for a, b in zip(A, B):
        fr[a] -= 1
        fr[b] -= 1
    for c, d in zip(C, D):
        if not uf.same(c, d):
            continue
        fr[c] -= 1
        fr[d] -= 1
    return fr[1:]


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    print(*solve(N, M, K, A, B, C, D), sep=' ')

# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


if __name__ == '__main__':
    main()


Measured memory_bytes: 24516
a,b,c = map(int,input().split())
if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
    exit()
    
if a == b == c:
    print(-1)
    exit()

cnt = 0
while True:
    x = (b+c)//2
    y = (a+c)//2
    z = (a+b)//2
    cnt += 1
    if x % 2 == 1 or y % 2 == 1 or z % 2 == 1:
        break
    a,b,c = x,y,z
print(cnt)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int N, M;

bool is_fitting(
  vector<string> A,
  vector<string> B,
  int x, int y,
  char dir
){
  if(x+M > N || y+M > N){
    return false;
  }
  for(int i=0;i<M;++i){
    for(int j=0;j<M;++j){
      // printf("Are %c and %c same ?\n", A[i+x][j+y], B[i][j]);
      if(A[i+x][j+y] != B[i][j]){
        // printf("pixels are not match... \t");
        // printf("current cursor is (%d, %d)\n",x, y);
        switch (dir){
          case 'd':
            return is_fitting(A, B, x+1, y, 'h') ||
            is_fitting(A, B, x, y+1, 'v') ||
            is_fitting(A, B, x+1, y+1, 'd');
          case 'h':
            return is_fitting(A, B, x+1, y, 'h');
          case 'v':
            return is_fitting(A, B, x+1, y, 'v');
        }
      }
    }
  }
  // printf("current cursor is (%d, %d)\n",x, y);
  return true;
}

int main(void){
  cin >> N >> M;
  int tmp;
  vector<string> A = vector<string>(N);
  vector<string> B = vector<string>(M);

  for(int i=0;i<N;++i){
    cin >> A[i];
  }
  for(int i=0;i<M;++i){
    cin >> B[i];
  }
  if(is_fitting(A, B, 0, 0, 'd')){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int si;
  string s;
  cin>>s;
  si=s.size();
  if(si==2){
    cout<<s[0]<<s[1];
  }
  else{
    cout<<s[2]<<s[1]<<s[0];
  }
  return(0);
}


Measured memory_bytes: 256
import math
N = int(input())

s = ''

if N == 0:
    s = str(0)
while N != 0:
    if N%(-2) == -1:
        s += str(1)
        N //= (-2)
        N += 1
    else:
        s += str(N % (-2))
        N //= (-2)
print(s[::-1])

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

int main(){
    int a,b,c,swap;

    cin >> a >> b >> c;

    if(a > b){
        swap = b;
        b = a;
        a = swap;
    }
    if(b > c){
        swap = c;
        c = b;
        b = swap;
    }
    if(a > b){
        swap = b;
        b = a;
        a = swap;
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
void solve(void)
{
	int n;
	char s[102], *p=s;
	int x=0,max=0;
	scanf("%d %s", &n,s);
	while(n-->0){
		switch(*p++){
			case 'I':
				++x;
				break;
			case 'D':
				--x;
				break;
		}
		if(max < x)
			max = x;
	}
	printf("%d\n", max);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int cot=0;
  if(1<=n && n<=9)cot=n;
  if(10<=n && n<=99)cot=9;
  if(100<=n && n<=999)cot=n-90;
  if(1000<=n && n<=9999)cot=909;
  if(10000<=n && n<=99999)cot=n-9090;
  if(100000==n)cot=90909;
  cout<<cot;
}

Measured memory_bytes: 256
n = int(input())
a_list = []
b_list = []
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list = list(reversed(a_list))
b_list = list(reversed(b_list))
ans = 0
for i in range(n):
    a = a_list[i]
    b = b_list[i]
    a += ans
    if (a % b) != 0:
        ans += b - (a % b)
print(ans)

Measured memory_bytes: 11860
#include <stdio.h>

int main(void){
	int n,x,i,minj,tmp,count;
	count = 0;
	scanf("%d", &n);
	int A[n];
	for(i=0;i<n;i++){
		scanf("%d", &x);
		A[i] = x;
	}
	for(i=0;i<n;i++){
		minj = i;
		for(int j=i;j<n;j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(minj != i){
			tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			count++;
		}
	}
	for(i=0;i<n;i++){
		printf("%d", A[i]);
		if(i!=n-1){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	printf("%d\n",count);
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f = true;
    if (s.size() % 2 == 1) {
        f = false;
    } else {
        string t = "";
        for (int i = 0; i < s.size(); i += 2) {
            t += "hi";
        }
        f = (s == t);
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k;
	bool found = false;
	cin >> n;
	for (i = 0; i <= n/4; i++) {
		if ((n - i * 4) % 7 == 0) found = true;
	}
	if (found) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, a[100][100], b[100], sum;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        sum = 0;
        for(int j=0;j<m;j++){
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func NewScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func NewWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func ScanString(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan string failed")
	}
	return s.Text()
}

// https://atcoder.jp/contests/abc051/tasks/abc051_a
func main() {
	s := NewScanner()
	w := NewWriter()
	defer w.Flush()
	fmt.Fprintln(w, strings.Replace(ScanString(s), ",", " ", -1))
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  ll r = a % b;

  while (r) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

void solve(long long N, long long K, vector<long long> a) {
  a.push_back(a[0]);
  sort(ALL(a));

  ll p = gcd(a[0], a[1]);
  FOR(i, 1, N) { p = gcd(p, a[i]); }

  if (K % p == 0 && a.back() >= K) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long K;
  long long N;
  cin >> N;
  vector<long long> A(N - 1 + 1);
  cin >> K;
  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
  }
  solve(N, K, A);
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
	int n,sj,so;
	sj=0;
	so=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2==0)
		{
			so=so+a[i];
		}
		else
		{
			sj=sj+a[i];
		}
	}
	if(so%2==sj%2)
	{
		printf("%s","YES");
	}
	else
	{
		printf("%s","NO");
	}
}

Measured memory_bytes: 1272
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
 
int main(){
int i,j,a=read(),b=read();
write(max(max(a+b,a-b),a*b));
}

Measured memory_bytes: 256
/*
[abc132] D - Blue and Red Balls
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf operator/(const gf x) const { return *this * x.inv(); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
    gf& operator/=(const gf x) { return *this = (*this / x); }
    gf inv() const { return gf(mod_inv(n, MOD)); }
    gf pow(ll e) const {
        gf a = *this;
        gf x = 1;
        for (; e > 0; e >>= 1) {
            if (e & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

int N, K;
gf fact[MAX_N + 1];

gf c(int n, int k) {
    return (n < 0 || k < 0 || n - k < 0) ? 0
                                         : fact[n] / (fact[k] * fact[n - k]);
}

void solve() {
    if (N == K) {
        cout << 1 << endl;
        for (int i = 2; i <= K; i++) {
            cout << 0 << endl;
        }
        return;
    }

    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
        fact[i] = fact[i - 1] * i;
    }

    for (int i = 1; i <= K; i++) {
        gf b = c(K - 1, i - 1);
        gf r = c(N - K + 1, i);
        cout << (b * r).n << endl;
    }
}

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

    solve();

    return 0;
}


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

int n, m;
int field[90][90];
int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};

bool infield(int x, int y)
{
    return (x >= 0 && x < m && y >= 0 && y < n);
}

int rec(int x, int y, int step)
{
    if(!infield(x, y) || field[y][x] == 0)
        return step;
    
    int ret = 0;
    field[y][x] = 0;
    for(int k = 0; k < 4; k++) {
        int nx, ny;
        nx = x + dx[k]; ny = y + dy[k];
        ret = max(ret, rec(nx, ny, step + 1));
    }
    field[y][x] = 1;
    return ret;
}

int main()
{
    while(cin >> m >> n && m && n) {
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
                cin >> field[i][j];
        
        int ans = 0;
        for(int i = 0; i < n; i++) 
            for(int j = 0; j < m; j++)
                ans = max(ans, rec(j, i, 0));
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const int mod=1000000007;

ll f(ll x,int n){
  ll ans=1;
  rep(i,n){
    ans*=x;
    ans%=mod;
  }
  return ans;
}

int main(){
  int n; cin>>n;
  ll ans=f(10LL,n)+2 *(mod-f(9LL,n))+f(8LL,n);
  ans%=mod;
  cout<<ans<<endl;
}


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

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char buf[20];char *p=buf;if(n<0)pcu('-'),n*=-1;
	if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10; while (p!=buf)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n, k; n = in(), k = in();) {
		vector<bool> c(n + 1);
		while (k--)
			c[in()] = true;
		int m = 0, a = 0, b = 0;
		for (int i = 1; i <= n; i++) {
			if (c[i]) {
				a++, b++;
				m = max(m, a);
			} else {
				a = c[0] ? b + 1 : 0;
				b = 0;
			}
		}
		outl(m);
	}
}


Measured memory_bytes: 2412
let mod = 2019

let S = readLine()!
var place = 1
var remainder = 0
var count = Array(repeating: 0, count: mod)
count[0] = 1
for char in S.reversed() {
    remainder += place * Int(String(char))!
    remainder %= mod
    count[remainder] += 1
    place = place * 10 % mod
}

var ans = 0
count.forEach({m in ans += m * (m - 1) / 2})
print(ans)


Measured memory_bytes: 8100
fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    readLongList().sortedDescending().drop(k).sum().let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 83280
import sys

import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

import heapq

class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class PriorityQueue:

    def __init__(self, x=[], desc=False):
        if desc:
            for i in range(len(x)):
                x[i] = Reverse(x[i])
        self._desc = desc
        self._container = x
        heapq.heapify(self._container)

    @property
    def is_empty(self):
        return not self._container

    def pop(self):
        if self._desc:
            return heapq.heappop(self._container).val
        else:
            return heapq.heappop(self._container)

    def push(self, item):
        if self._desc:
            heapq.heappush(self._container, Reverse(item))
        else:
            heapq.heappush(self._container, item)

    def top(self):
        if self._desc:
            return self._container[0].val
        else:
            return self._container[0]

    def sum(self):
        return sum(self._container)

    def __len__(self):
        return len(self._container)


def main():
    n, m = list(map(int, readline().split()))

    ab = [list(map(int, readline().split())) for _ in range(n)]

    ab.sort(key=itemgetter(0))
    a = [ab[i][0] for i in range(n)]
    b = [ab[i][1] for i in range(n)]
    pq = PriorityQueue(desc=True)
    ans = 0

    idxprev = 0

    for day in range(1, m + 1):
        idxcur = bisect.bisect_right(a, day)
        if idxcur > idxprev:
            for i in range(idxprev, idxcur):
                pq.push(b[i])
                idxprev = idxcur
        if pq:
            ans += pq.pop()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84188
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    auto b = aryread();
    // writeln(a);
    // writeln(b);
    long cnt;
    long tmp;
    long tmptmp;
    foreach (i; 0 .. n)
    {
        tmp = min(a[i], b[i]);
        cnt += tmp;
        a[i] -= tmp;
        b[i] -= tmp;
        // writeln("a:", a);
        // writeln("b:", b);
        // writeln(cnt);

        tmptmp = min(a[i + 1], b[i]);
        cnt += tmptmp;
        a[i + 1] -= tmptmp;
        b[i] -= tmptmp;
        // writeln("a:", a);
        // writeln("b:", b);

    }
    writeln(cnt);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 11408
using System;
using System.Linq;

namespace ABC133E
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NAB = CIN.LongArray();
            Console.WriteLine(Math.Min(NAB[0] * NAB[1], NAB[2]));
    }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

int sum(int n){
    int sum = 0;
    while( n > 0 ){
        sum += n%10;
        n /= 10;
    }
  	return sum;
}

int main(){
    int n;
    cin >> n;
  
    string ans;
    if ( n % sum(n) == 0 ) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  if((s.size()-2)%2){
    if(s[0]==s[s.size()-1])cout<<"Second"<<endl;
    else cout<<"First"<<endl;
  }
  else{
    if(s[0]==s[s.size()-1])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 200010
#define MAX_N N
#define rank adofijadsfsad
using namespace std;
typedef pair<int,int> P;
vector<int> GK[N],GL[N];
using namespace std;

class UF{
public:
  vector<int> par,rank,cnt;
  vector<vector<int>  > U; 
  UF(){};
  UF(int n){
    rank.resize(N,0);
    cnt.resize(N,1);
    par.resize(N);
    U.resize(N);
    for(int i=0;i<N;i++)par[i]=i;
  }
  
  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y,cnt[y]+=cnt[x];
    else{
      par[y]=x;
      cnt[x]+=cnt[y];
      if(rank[x]==rank[y])rank[x]++;
    }
  }

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

};

UF K,L;
void dfsK(int pos){
  for(int i=0;i<GK[pos].size();i++){
    int nx=GK[pos][i];
    if(K.same(pos,nx))continue;
    K.unite(pos,nx);
    dfsK(nx);
  }
}


void dfsL(int pos){
  for(int i=0;i<GL[pos].size();i++){
    int nx=GL[pos][i];
    if(L.same(pos,nx))continue;
    L.unite(pos,nx);
    dfsL(nx);
  }
}

/*
UF U;
void And(int pos){
  if(U.find(pos)!=pos) return;
  int par=K.find(pos);
  set<int>::iterator it = K.U[par].begin();

  while(it!=K.U[par].end()){
    int nx=*it;
    if(!L.same(pos,nx))break;
    U.unite(pos,nx);
    //K.U[par].erase(it++);
    it++;
  }
  
}
*/

int main(){
  int n,k,l;
  cin>>n>>k>>l;

  for(int i=0,a,b;i<k;i++){
    cin>>a>>b;
    a--,b--;
    GK[a].push_back(b);
    GK[b].push_back(a);
  }
  
  for(int i=0,a,b;i<l;i++){
    cin>>a>>b;
    a--,b--;
    GL[a].push_back(b);
    GL[b].push_back(a);
  }
  

  K=UF(n),L=UF(n);
  for(int i=0;i<n;i++)if(K.find(i)==i)dfsK(i);
  for(int i=0;i<n;i++)if(L.find(i)==i)dfsL(i);

  
  //  for(int i=0;i<n;i++)K.U[K.find(i)].insert(i);
  //for(int i=0;i<n;i++)L.U[L.find(i)].insert(i);
  for(int i=0;i<n;i++)K.U[K.find(i)].push_back(i);
  for(int i=0;i<n;i++)L.U[L.find(i)].push_back(i);


  map<P,int> ans;
  for(int i=0;i<n;i++){
    vector<int> U;
    if(i)cout<<" ";
    int parK=K.find(i);
    int parL=L.find(i);
    ans[P(parK,parL)]++;
  }  

  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    int parK=K.find(i);
    int parL=L.find(i);
    cout<<ans[P(parK,parL)];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 50304
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = prev_lcm * (t // tmp)
        prev_lcm = lcm
    print(lcm)


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

using namespace std;

int a,b;
int ans[4001];
int main()
{
	int n;
	cin >> a >> b;
	n = a + b;
	if (a <= b) cout << "Impossible";
	else
	{
		stack<int> tmp;
		tmp.push(0);
		for (int i=1;i<=n-1;i++)
		{
			if (tmp.empty())
				tmp.push(i);
			else	
			{
				cout << '?' << ' ' << tmp.top() << ' ' << i << endl;
				char r; cin >> r;
				if (r == 'N') tmp.pop();
				else tmp.push(i);
			}	
		}
		int id = tmp.top();
		ans[id] = 1;
		for (int i=0;i<=n-1;i++)
		{
			if (i == id) continue;
			cout << '?' << ' ' << id << ' ' << i << endl;
			char r; cin >> r;
			if (r == 'N') ans[i] = 0;
			else ans[i] = 1;
		}
		cout << '!' << ' ';
		for (int i=0;i<=n-1;i++)	
			cout << ans[i];
	}	
	return 0;
}

Measured memory_bytes: 724
#include <stdio.h>

int main() {
    long int K, A, B, num = 1;
    if (scanf("%ld %ld %ld", &K, &A, &B) == -1) return -1;
    if (B - A <= 1) num += K;
    else {
        num += A - 1;
        for (int i = 0; i < (K - A + 1) / 2; i++) {
            num += B - A;
        }
        if ((K - A + 1) % 2 == 1) num++;
    }
    printf("%ld\n", num);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=100000+100;
int n,ans;
int a[maxn];

inline void file() {
	freopen("AGC002E.in","r",stdin);
	freopen("AGC002E.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

bool cmp(int x,int y) { return x>y; }

int main() {
//	file();
	n=read();
	For (i,1,n) a[i]=read();
	sort(a+1,a+n+1,cmp);
	For (i,1,n)
		if (i+1>a[i+1]) {
			int j=i+1;
			while (j<=n && a[j]==i) ++j,ans^=1;
			ans|=(a[i]-i)&1;
			break;
		}
	if (ans) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main(void) {
  char n;
  cin >> n;
  if (n == 'A') {
    cout << 'T' << endl;
  }
  if (n == 'T') {
    cout << 'A' << endl;
  }
  if (n == 'C') {
    cout << 'G' << endl;
  }
  if (n == 'G') {
    cout << 'C' << endl;
  }
  
 
  return 0;
}


Measured memory_bytes: 760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int h, w, ans = 0;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10));
	for(int i = 0; i <= 9; i++){
		for(int j = 0; j <= 9; j++){
			cin >> c[i][j];
		}
	}
	for(int k = 0; k <= 9; k++){
		for(int i = 0; i <= 9; i++){
			for(int j = 0; j <= 9; j++){
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	for(int i = 0; i < h * w; i++){
		int x;
		cin >> x;
		if(x == -1) continue;
		ans += c[x][1];
	}
	cout << ans << endl;
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	ll k;
	cin >> k;
	ll m = 7 % k;
	if (m == 0) {
		cout << 1 << endl;
		return 0;
	}
	ll v = 7;
	for (int i = 2; i <= k+1; i++) {
		v *= 10;
		v += 7;
		v %= k;
		if (v == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3632
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print(s[:3])
    return




s = RS()
solve()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

int h, w;
vector<string> fi;

long long numb = 0, numw = 0;
bool seen[MAX][MAX];
void dfs(int x, int y) {
  seen[x][y] = true;
  if (fi[x][y] == '#')
    ++numb;
  else
    ++numw;

  rep(dir, 4) {
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if (nx < 0 || nx >= h || ny < 0 || ny >= w || fi[x][y] == fi[nx][ny] ||
        seen[nx][ny])
      continue;
    dfs(nx, ny);
  }
}

int main() {
  cin >> h >> w;
  fi.resize(h);
  rep(i, h) cin >> fi[i];

  long long res = 0;
  rep(x, h) {
    rep(y, w) {
      if (fi[x][y] == '.' || seen[x][y]) continue;
      numb = numw = 0;
      dfs(x, y);
      res += numb * numw;
    }
  }
  cout << res << endl;
}


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

int main() {
    int s; cin >> s;
    set<int> used;

    int ans = 1, cur = s;
    while(used.count(cur) == 0) {
        ans += 1;
        used.insert(cur);
        cur = (cur & 1 ? 3 * cur + 1 : cur / 2);
    }

    cout << ans << endl;
}


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

int main(){
  string s;
  cin >> s;
  int ret = 0;
  int cur = 0;

  for(int i = 0;i < s.length();i++){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
      cur++;
    }else{
      ret = max(cur,ret);
      cur = 0;
    }
  }

  ret = max(cur,ret);
    
  cout << ret << endl;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  
  ll N,K;
  cin >> N >> K;
  ll A[N];
  rep(i,N) cin >> A[i];
  
  for(ll i=K; i<N; i++){
    if(A[i]>A[i-K]){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }

  return 0;
}

Measured memory_bytes: 5192
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<pair<int,int>> LR(Q);
    for(int i = 0; i < Q; i++) cin >> LR[i].fi >> LR[i].se;
    vector<int> A(N);
    for(int i = 1; i < N; i++){
        if(S[i - 1] == 'A' and S[i] == 'C') A[i] = A[i - 1]+1;
        else A[i] = A[i - 1];
    }
    // for(int a : A)cout << a << ' ';
    for(auto p : LR) cout << A[p.se - 1] - A[p.fi - 1] << endl;
}

Measured memory_bytes: 4508
#include<iostream>
using namespace std;
int main(){
int x;
cin>>x;
int a[x];
for(int i=0;i<x;i++){
  cin>>a[i];
} 
int min=a[0];
int max=a[0];
long int sum=a[0];
for(int i=1;i<x;i++){
  sum+=a[i];
  if(min>a[i]){
    min=a[i];
  }
  if(max<a[i]){
    max=a[i];
  }
}
cout <<min<<" "<<max<<" "<<sum<<endl;
return 0;
}

Measured memory_bytes: 3132