akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int num1 = int.Parse(input[0]);
            int num2 = int.Parse(input[1]);
            int gcd = 0;

            if (num1 <= num2)
            { 
                gcd = calcu_gcd(num2, num1);
            }
            else
            {
                gcd = calcu_gcd(num1, num2);
            }

            Console.WriteLine(gcd);
        }

        static int calcu_gcd(int x, int y)
        {
            int tmp_x = x;
            int tmp_y = y;
            int div = 0;
            int check = 0;
            bool div_flg = false;

            while (div_flg == false)
            {
                div = tmp_x % tmp_y;
                if (div == 0)
                {
                    div = tmp_x;
                    break;
                }

                check = tmp_y % div;
                
                if (check == 0)
                {
                    div_flg = true;
                }
                else
                {
                    tmp_x = tmp_y;
                    tmp_y = div;
                }
            }

            return div;
        }
    }
}

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

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

 cin>>a>>b>>c;

 if(a<c&&c<b){
     cout<<"Yes";
 }
 else if(a>c&&c>b){
     cout<<"Yes";
 }
 else{
     cout<<"No";
 }
}



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

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r = m % n;
        while(r != 0){
            m = n;
            n = r;
            
            r = m % n;
        }
        return n;
    }

}

Measured memory_bytes: 9396
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll H, W;

ll two(ll h, ll w, int c) {
  if (c == 0) return h/2 * w;
  return w/2 * h;
}

ll solve() {
  ll ans = H * W;
  for (auto i = 1; i < H; ++i) {
    for (auto c = 0; c < 2; ++c) {
      ll X[3];
      X[0] = i * W;
      X[1] = two(H-i, W, c);
      X[2] = (H-i) * W - X[1];
      sort(X, X+3);
      // cerr << X[0] << " " << X[1] << " " << X[2] << endl;
      ans = min(ans, X[2]-X[0]);      
    }
  }
  return ans;
}

int main () {
  cin >> H >> W;
  if (H%3 == 0 || W%3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = min(H, W);
  ans = min(ans, solve());
  swap(H, W);
  ans = min(ans, solve());
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
string s;
int main()
{
    int n0=0,n1=0;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
        if(s[i]=='0')n0++;
    else n1++;
    printf("%d\n",min(n0,n1)*2);
    return 0;
}


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

const long mod = 1000000007;
long n, k;
long f[100001];

long powmod(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return b * powmod(b, e - 1) % mod;
  long t = powmod(b, e / 2);
  return t * t % mod;
}

long inv(long n) {
  return powmod(n, mod - 2);
}

long comb(long n, long r) {
  if (n < 0 || r < 0 || n - r < 0) return 0;
  return f[n] * inv(f[r]) % mod * inv(f[n - r]) % mod;
}

long sub(vector<long> a) {
  sort(a.rbegin(), a.rend());
  for (long& i : a) {
    i = (i + mod * mod) % mod;
    cerr << i << endl;
  }
  
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum = (sum + a[i] * comb(n - 1 - i, k - 1)) % mod;
  }
  return sum;
}

int main() {
  cin >> n >> k;
  
  vector<long> v;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  
  f[0] = 1;
  for (int i = 0; i < n; ++i) {
    f[i + 1] = f[i] * (i + 1) % mod;
  }
  
  long p = sub(v);
  for (long& i : v) i = -i;
  long q = sub(v);
  cout << (p + q) % mod << endl;
}

Measured memory_bytes: 2676
#include <iostream>
#define MAX 500001
#define SENTINEL 1000000001
using namespace std;

int cnt;
int n;

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1];
    int R[n2 + 1];
    for (int i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    scanf("%d", &n);
    int A[MAX];
    cnt = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }
    mergeSort(A, 0, n);
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 7056
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

string data[55];
int memo[55][55];

int solve(int y, int x){

  if(!y && !x) return memo[y][x] = 0;
  if(y < 0 || x < 0) return 1<<28;
  if(~memo[y][x]) return memo[y][x];
  return memo[y][x] = min(solve(y-1, x), solve(y, x-1))+data[y][x]-'0';

}

int main(){

  int h, w;

  cin >> h >> w;
  for(int i=0;i<h;i++) cin >> data[i];

  memset(memo, -1, sizeof(memo));
  cout << solve(h-1, w-1) << endl;

}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<P, P>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int H, W;
int a[550][550];

int main() {
  // 入力
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }

  int cnt = 0;
  vector<PP> ans;
  for (int i = 0; i < H - 1; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] % 2 == 1) {
        cnt++;
        ans.push_back(PP(P(i + 1, j + 1), P(i + 2, j + 1)));
        a[i+1][j]++;
      }
    }
  }

  for (int j = 0; j < W - 1; j++) {
    if (a[H-1][j] % 2 == 1) {
      cnt++;
      ans.push_back(PP(P(H, j + 1), P(H, j + 2)));
      a[H-1][j+1]++;
    }
  }

  // 解答
  cout << cnt << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
  }
  return 0;
}


Measured memory_bytes: 5232
S = input()
N = len(S)
mod = 998244353

blue = [0] * N
red = [0] * N
for i in range(N):
    blue[i] = blue[i-1] + int(S[i])
    red[i] = red[i-1] + 2 - int(S[i])

dp = [[0 for _ in range(blue[-1] + 1)] for _ in range(2*N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(blue[-1]+1):
        if j + 1 <= blue[i]:
            dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod
        if i+1-j <= red[i]:
            dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod
for i in range(N, 2*N):
    for j in range(blue[-1]+1):
        if j+1 <= blue[-1]:
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod

print(dp[-1][-1])


Measured memory_bytes: 168200
# from pprint import pprint
import math
from numba import jit, njit

# import numpy as np
# import collections

n = int(input())
# n = 10000000
# n = 100


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

def g(x):
    y = n // x
    return y * (y + 1) * x // 2


ans = 0
for i in range(1, n + 1):
    ans += g(i)

print(ans)

Measured memory_bytes: 91688
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, p=0;
	cin >> x;
	for (size_t i = 1; i < 10; i++)
	{
		if (x / i <= 9 && x % i == 0)
		{
			p = 1;
			break;
		}
	}
	if (p)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	void solve(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
			c[i] = scan.nextInt();
		}
		int[][] dp = new int[n][3];
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];
		for(int i = 1; i < n; i++) {
			dp[i][0] = Math.max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
			dp[i][1] = Math.max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
			dp[i][2] = Math.max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
		}
		System.out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
		scan.close();
	}

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

Measured memory_bytes: 61048
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

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

bool b[9] = {};
ll N;
ll m[9][9] = {};
bool check() {
	bool v = true;
	repe(i, 1, N) {
		v &= b[i];
	}
	return v;
}
ll cnt = 0;
void dfs(int n)
{
	if (check()) {
		cnt++;
		return;
	}

	repe(i, 1, N) {
		if (n != i) {
			if (m[n][i] == 1 && !b[i]) {
				b[i] = true;
				dfs(i);
				b[i] = false;
			}
		}
	}
}
int main() {
	ll  M; cin >> N >> M;
	rep(i, 0, M) {
		ll a, b;
		cin >> a >> b;
		m[a][b] = 1;
		m[b][a] = 1;
	}

	b[1] = true;
	dfs(1);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
x = a[0]
ans = 0
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
for j in a:
    ans += (x - 1) % j
print(ans)

Measured memory_bytes: 5344
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
using namespace std;
int n,k,c;
string s;
int pre[200100],suf[200100];
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c>>k>>s;
	s="?"+s;
	bool ok=false;
	memset(pre,0,sizeof(pre));
	memset(suf,0,sizeof(suf));
	for(int i=1;i<=min(k+1,n);i++){
		if(s[i]=='o')
			ok=1;
		pre[i]=ok;
	}
	for(int i=k+2;i<=n;i++){
		if(s[i]=='o')
			pre[i]=max(pre[i],pre[i-k-1]+1);
		pre[i]=max(pre[i],pre[i-1]);
	}
	ok=false;
	for(int i=n;i>=max(n-k-1,0);i--){
		if(s[i]=='o')
			ok=true;
		suf[i]=ok;
	}
	for(int i=n-k;i>=1;i--){
		if(s[i]=='o')
			suf[i]=max(suf[i],suf[i+k+1]+1);
		suf[i]=max(suf[i],suf[i+1]);
	}
	for(int i=1;i<=n;i++){
		if(s[i]=='x')
			continue;
		if(pre[i-1]+suf[i+1]<c){
			cout<<i<<endl;
		}
	}
	return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int n,k; cin >> n >> k;
  vector<lint> p(n); for(int i=0;i<n;i++) { cin >> p[i]; }
  
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<k;i++) { sum += p[i]; }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int s = 0;
  for (int i = 0; i < N; i++){
    int l_i, r_i;
    cin >> l_i >> r_i;
    s += r_i - l_i +1;
  }
  cout << s << endl;
}


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

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

int main(){

	string s, t1, t2;
	cin >> s;
	
	rep(i, s.size()) t1+= to_string((i%2) ? 1 : 0 );
	rep(i, s.size()) t2+= to_string(((i+1)%2) ? 1 : 0 );
	
	int cont1 = 0, cont2 = 0;
	rep(i, s.size()) if (s[i] ^ t1[i]) cont1++;
	rep(i, s.size()) if (s[i] ^ t2[i]) cont2++;
	
	printf("%d\n", (cont1 < cont2) ? cont1 : cont2);
	return 0;
}


Measured memory_bytes: 3976
n, m = map(int, input().split())
graph = {}
for i in range(m):
    am, bm = map(int, input().split())
    if am not in graph:
        graph[am] = [bm]
    else:
        graph[am].append(bm)
    if bm not in graph:
        graph[bm] = [am]
    else:
        graph[bm].append(am)
guide = {1: 0}
visited = [1]
i = 0
while True:
    for j in graph[visited[i]]:
        if j not in guide.keys():
            guide[j] = visited[i]
            visited.append(j)
    i += 1
    if i == len(visited):
        break

if len(visited) == n:
    print("Yes")
    for x in range(2, n+1):
        print(guide[x])
else:
    print("No")


Measured memory_bytes: 49144
import sys

input = sys.stdin.readline

N, Y = map(int, input().split())

result = "-1 -1 -1"
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if (0 <= z <= 2000) and (10000*x + 5000*y + 1000*z == Y):
            result = "{} {} {}".format(x, y, z)
            print(result)
            exit()

print(result)

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

list = list(map(int, input().split()))
rlist=[]
i=0
r="APPROVED"

while(i<n):
  if(list[i]%2 == 0):
    rlist.append(list[i])
  i+=1

l=len(rlist)
j=0

while(j<l):
  if(rlist[j]%3 != 0):
    if(rlist[j]%5 !=0):
      r="DENIED"
  j+=1

print(r)

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  string N;
  cin >> N;
  int ans = 0;
  
  rep(i,N.size()){
    int n = N[i] - '0';
    ans += n;
  }
  
  if(stoi(N)%ans==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int arr[n];
for(int i = 0;i<n;i++)
{
    cin >> arr[i];
}
sort(arr,arr+n);
int ans = arr[n/2]-arr[n/2-1];
cout << ans << endl;
}


Measured memory_bytes: 3996
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  (ls,rs) <- fmap U.unzip $ U.replicateM m $ do
    [l,r] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (l,r)
  let maxL = U.maximum ls
      minR = U.minimum rs
  print $ max 0 (minR - maxL + 1)


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

void solve() {

}

int main() {
  int n,k;
  cin >> n >>k;
  set<int> S;
  rep(i,k) {
    int d;
    cin >> d;
    rep(i,d) {
      int a;
      cin >> a;
      S.insert(a);
    }
  }
  cout << n - (int)S.size() << endl;

  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);
    vector<int> sol;

    for(int i = 0; i < n; i += 1) {
        cin >> v[i];
        v[i] -= 1;
    }

    for(int it = 0; it < n; it += 1) {
        int chosen = -1;
        for(int i = int(v.size()) - 1; i >= 0; i -= 1) {
            if(v[i] == i) {
                chosen = i;
                break;
            }
        }
        
        sol.push_back(chosen + 1);
        if(chosen == -1) {
            cout << "-1\n";
            return 0;
        }

        v.erase(v.begin() + chosen);
    }

    reverse(sol.begin(), sol.end());
    for(auto val : sol)
        cout << val << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v;

    int num_dig(int n)
    {
        int ans=0;
        v.clear();
        if(n==0)
        {
            v.pb(0);
            return 1;
        }
        while(n>0)
        {
            ++ans;
            v.pb(n%10);
            n=n/10;
        }
        reverse(v.begin(),v.end());
        return ans;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,m;
            cin>>n>>m;
            pii ar[m+1];
            for(i=1;i<=m;++i)
                cin>>ar[i].f>>ar[i].s;
            int flag=0;
            for(i=0;i<=10000;++i)
            {
                if(num_dig(i)!=n)
                    continue;
                for(j=1;j<=m;++j)
                {
                    if(ar[j].f>n)
                        continue;
                    if(v[ar[j].f-1]!=ar[j].s)
                        break;
                }
                if(j==m+1)
                {
                    cout<<i<<endl;
                    return 0;
                }
            }
            cout<<-1<<endl;
        }
        return 0;
    }


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

int main(){
	int a[9];
	bool flag = false;
	for(int i=0;i<9;i++){
		cin >> a[i];
	}
	int c1[3],c2[3],c3[3];
	for(int i=0;i<3;i++){
		c1[i] = a[i] - a[0];
		c2[i] = a[i+3] - a[3];
		c3[i] = a[i+6] - a[6];
	}
	for(int i=0;i<3;i++){
		if(c1[i] != c2[i] || c2[i] != c3[i]) flag = true;
	}

	for(int i=0;i<3;i++){
		c1[i] = a[3*i] - a[0];
		c2[i] = a[3*i+1] - a[1];
		c3[i] = a[3*i+2] - a[2];
	}
	for(int i=0;i<3;i++){
		if(c1[i] != c2[i] || c2[i] != c3[i]) flag = true;
	}
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  string b = "0";
  string w = "1";
  for(int i = 0; i < s.size()-1; i++){
    if(b[i] == '0') b.push_back('1');
    else b.push_back('0');
    if(w[i] == '0') w.push_back('1');
    else w.push_back('0');
  }
  int x = 0;
  int y = 0;
  for(int i = 0; i < s.size(); i++){
    if(b[i] != s[i]) x++;
    if(w[i] != s[i]) y++;
  }
  cout << min(x,y) << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdio>
#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
#define INF INT_MAX
#define debug(a) cout<<a
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);
int main()
{
	int a;
	cin >> a;
	VEC b(a);
	VEC c(a);
	int d = -1;
	int e = -1;
	loop(i, a)
	{
		cin >> b[i] >> c[i];
		if (b[i] > e)d = i, e = b[i];
	}
	cout << b[d] + c[d] << endl;
	return 0;
}

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

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

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int maxA = 0;
  int minA = 1 << 30;
  rep(i, n) {
    int a;
    cin >> a;
    maxA = max(a, maxA);
    minA = min(a, minA);
  }

  cout << abs(maxA - minA) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

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

cnt = [0] * 1000005
for x in a:
    if cnt[x] != 0: 
        cnt[x] = 2
    else: 
        for i in range(x,1000005,x):
            cnt[i] += 1

ans = 0
for x in a:
    if cnt[x] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 117812
import java.util.Scanner; 

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

                Scanner sc = new Scanner(System.in); 
                String line1 = sc.nextLine(); 
                int N = Integer.parseInt(line1); 

                String[] inputData = new String[N]; 
                for (int i = 0; i < N; i++) { 
                        String line2 = sc.nextLine(); 
                        inputData[i] = line2; 
                } 

                boolean[] cards = new boolean[52]; 
                for (int i = 0; i < cards.length; i++) { 
                        cards[i] = false; 
                } 

                int x = 0; 
                for (int i = 0; i < inputData.length; i++) { 
                        String str = inputData[i].substring(0, 1); 
                        if (str.equals("S")) { 
                                x = 0; 

                        } else if (str.equals("H")) { 
                                x = 13; 

                        } else if (str.equals("C")) { 
                                x = 13 * 2; 

                        } else if (str.equals("D")) { 
                                x = 13 * 3; 

                        } 
                        x += Integer.parseInt(inputData[i].substring(2)) - 1; 
                        cards[x] = true; 
                } 
                for (int i = 0; i < cards.length; i++) { 
                        if (cards[i] == false) { 
                                if (i / 13 == 0) { 
                                        System.out.print("S "); 

                                } else if (i / 13 == 1) { 
                                        System.out.print("H "); 
                                } else if (i / 13 == 2) { 
                                        System.out.print("C "); 
                                } else if (i / 13 == 3) { 
                                        System.out.print("D "); 
                                } 
                                System.out.println(String.valueOf(i % 13 + 1)); 
                        } 
                } 
        } 
} 

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

int main() {
  int n, k, r, s, p, o = 0;
  string t;
  cin >> n >> k >> r >> s >> p;
  cin >> t;
  vector<string> st(k);
  for(int i = 0; i < n; i++)
    st.at(i % k).push_back(t.at(i));
  int lo = 0;
  for(int i = 0; i < k; i++) {
    char prev = '\0';
    for(int j = 0; j < st.at(i).length(); j++) {
      if(st.at(i).at(j) != prev || !lo) {
        switch(st.at(i).at(j)) {
        case 'r':
          o += p;
          break;
        case 's':
          o += r;
          break;
        case 'p':
          o += s;
          break;
        }
        lo = 1;
      } else
        lo = 0;
      prev = st.at(i).at(j);
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>h(N+1);
  for(int i=1;i<=N;i++)cin>>h[i];
  vector<int>dp(N+3,INT_MAX);
  dp[1]=0;
  for(int i=1;i<=N;i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M, K;
    scan(N, M, K);
    UnionFind uf = UnionFind(N);
    auto friends = new long[](N);
    auto blocked = new long[](N);
    foreach (_; 0 .. M)
    {
        long A, B;
        scan(A, B);
        A--, B--;
        uf.unite(A, B);
        friends[A]++;
        friends[B]++;
    }
    foreach (_; 0 .. K)
    {
        long C, D;
        scan(C, D);
        C--, D--;
        if (uf.find(C) == uf.find(D))
        {
            blocked[C]++;
            blocked[D]++;
        }
    }
    auto ans = new long[](N);
    foreach (i; 0 .. N)
    {
        ans[i] = uf.size(i) - friends[i] - blocked[i] - 1;
    }
    ans.map!text().join(' ').writeln();
}

alias UnionFind = UnionFindImpl!long;
struct UnionFindImpl(T)
{
    T[] _rank, _data, _size;
    this(long n)
    {
        _rank = new long[](n);
        _size = new long[](n);
        _size[] = 1;
        _data = iota!T(n).array();
    }

    T find(T x)
    {
        if (_data[x] == x)
            return x;
        T r = _data[x] = this.find(_data[x]);
        return r;
    }

    void unite(T x, T y)
    {
        T rx = this.find(x), ry = this.find(y);
        if (rx == ry)
            return;
        _size[rx] = _size[ry] = (_size[rx] + _size[ry]);
        if (_rank[rx] == _rank[ry])
        {
            _data[rx] = ry;
            _rank[ry]++;
        }
        else if (_rank[rx] < _rank[ry])
            _data[rx] = ry;
        else
            _data[ry] = rx;
    }

    T size(T x)
    {
        return _size[this.find(x)];
    }
}


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

int main() {
  string s;
  ll k;
  cin >> s >> k;
  for (int i = 0;; i++)
    if (s[i] > '1' || i + 1 == k) return cout << s[i] << endl, 0;
}


Measured memory_bytes: 256
def gcd(x, y):
	if y == 0L:
		return x
	elif x < y:
		return gcd(y, x)
	else:
		ny = x % y
		return gcd(y, ny)

while True:
	try:
		inpt = map(long, raw_input().split())
		g = gcd(inpt[0], inpt[1])
		h = inpt[0] * inpt[1] / g
		print str(g) + ' ' + str(h)

	except:
		break

Measured memory_bytes: 6608
#include <stdio.h>
int h, w;
char maze[51][51];
int dist[50][50];
int qx[100000], qy[100000], head, tail;
void bfs(int stx, int sty) {
	int vx[4] = {0, 1, 0, -1};
	int vy[4] = {1, 0, -1, 0};
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = -1;
		}
	}
	dist[sty][stx] = 0;
	head = tail = 0;
	qx[tail] = stx;
	qy[tail] = sty;
	tail++;
	while (head != tail) {
		for (int i = 0; i < 4; i++) {
			int nx = qx[head] + vx[i];
			int ny = qy[head] + vy[i];
			if (0 <= nx && nx < w && 0 <= ny && ny <= h && dist[ny][nx] == -1 &&
				maze[ny][nx] == '.') {
				dist[ny][nx] = dist[qy[head]][qx[head]] + 1;
				qx[tail] = nx;
				qy[tail] = ny;
				tail++;
			}
		}
		head++;
	}
}
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", maze[i]);
	}
	int ans = h * w;
	bfs(0, 0);
	if (dist[h - 1][w - 1] == -1) {
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (maze[i][j] == '#') {
				ans--;
			}
		}
	}
	ans -= dist[h - 1][w - 1];
	ans--;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
bool isSqrt(int n)
{
	for(int i=1;n>0;i+=2) n-=i;
    return 0 == n;
}
int main()
{
	int a,b,c,d=1;
	cin>>a>>b;
	while(1)
	{
		if(b/d<10) break;
	    else d*=10;
	}
	c=a*d*10+b;
	if(isSqrt(c)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

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

const int mod = 1e9 + 7;

int pw(int a, int b) {
	int res = 1;
	while(b) {
		if(b % 2)
			res = (res * a) % mod;
		b /= 2;
		a = (a * a) % mod;
	}
	return res;
}

int cnt = 0, ans = 0;

int32_t main() {
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		if(s[i] == '0')
			continue;
		int A = pw(2, cnt);
		int B = pw(3, n - i - 1);
//		cout << i << " -> " << A << " : " << B;
		cnt++;
		int res = (A * B) % mod;
		ans= (ans + res) % mod;
//		cout << " = " << ans << endl;
	}
	ans = (ans + pw(2, cnt)) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(void){
  int n,m,h[201],r[201];

  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> h[i] >> r[i];
    cin >>m;
    for(int i=n;i<n+m;i++)cin >> h[i] >> r[i];

      for(int i=0;i<n+m;i++){
	  for(int j=i;j<n+m;j++){
	    int t;
	      if(h[i]>h[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}
	      if(h[i]==h[j] && r[i]>r[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}
	    }
	}

    int dp[201]={0};
    dp[0]=1;
    for(int i=0;i<n+m;i++){
      for(int j=i+1;j<n+m;j++){
	if(h[i]<h[j] && r[i]<r[j] && dp[i]>=dp[j])dp[j]=dp[i]+1;
      }
    }
    int res=0;
    for(int i=0;i<n+m;i++)res=max(res,dp[i]);
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000LL
#define M 1000000007
typedef long long ll;
using namespace std;
const int N = 105001;

int n , k , a , ans;

signed main(){
    cin >> n >> k ;
    while(n--){
        cin >> a;
        ans+=a>=k;
    }
    cout << ans << endl;


    return 0;
}


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

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

    vector<ll> a(n);

    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    bool posi = false;

    ll balance = 1000, stock = 0;

    if (a.at(0) < a.at(1)) {
        stock = balance/a.at(0);
        balance -= a.at(0) * stock;
        posi = true;
    }

    for (int i=1; i<n-1; i++) {
        if (posi) {
            if (a.at(i) > a.at(i+1)) {
                balance += stock * a.at(i);
                stock = 0;
                posi = false;
            }
        } else {
            if (a.at(i) < a.at(i+1)) {
                stock = balance/a.at(i);
                balance -= a.at(i) * stock;
                posi = true;
            }
        }
    }

    if (posi) {
        balance += stock * a.at(n-1);
    }

    cout << balance << endl;
}   

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

ll fastPowMod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    map<int, int> m;
    for (int i = 0; i < n; ++i) {
        m[a[i]]++;
    }
    bool ok = true;
    bool odd = n % 2 == 1;
    if (odd) {
        if (m[0] != 1)
            ok = false;
        for (int i = 2; i <= n - 1; i += 2) {
            if (m[i] != 2)
                ok = false;
        }
    } else {
        for (int i = 1; i <= n - 1; i += 2) {
            if (m[i] != 2)
                ok = false;
        }
    }

    if (ok) {
        cout << fastPowMod(2, n / 2) << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(void) {
  int n, m;
  cin >> n >> m;
  int food[m];
  rep(i,m){
    food[i]=0;
  }

  rep(i,n){
    int k;
    cin >> k;

    rep(j,k){
      int a;
      cin >> a;
      a--;

      food[a]++;
    }
  }

  int ans=0;
  rep(i,m){
    if(food[i]==n){
      ans++;
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

a = (60 * H + M) / 2
b = 6 * M
r = min(abs(a-b), 360-abs(a-b))

c = math.sqrt(A**2+B**2 - 2*A*B*math.cos(math.radians(r)))

print(c)

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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1));
  for(int r=1; r<=n; r++){
    for(int l=r-1; l>=0; l--){
      if(r-l == 1) dp[l][r] = a[l];
      else dp[l][r] = max(a[l] - dp[l+1][r], a[r-1] - dp[l][r-1]);
    }
  }
  cout << dp[0][n] << endl;
}


Measured memory_bytes: 73692
#include <iostream>
#include <string>

using namespace std;

int main() {
    int i,j,ok=0,nagasa=0;
    // float n;
    string s;
    cin >> s;
    for(char c:s){
        nagasa++;
      if(c=='o'){
          ok++;
      }
    }
    if(15-nagasa+ok>=8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split())) #食べた料理（n種類）
b = list(map(int, input().split())) #料理ごとの満足度
c = list(map(int, input().split())) #満足度ボーナス
total = 0
tmp = -10

for i in a:
    total += b[i-1]
    if tmp == i-1:
        total += c[tmp-1]
    tmp = i

print(total)

Measured memory_bytes: 3064
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp*/
#include<iostream>

using namespace std;

void println(int *a,int n){
    for(int i=0;i<n;i++){
        cout<<a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout<<endl;
}

int main()
{
    int n;
    int j=0;
    int a[100];
    int count=0;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(bool flag= true;flag == true;j++){
        flag = false;
        for(int i=n-1;j<i;i--){
            if(a[i]<a[i-1]){
                int tmp=a[i];
                a[i]=a[i-1];
                a[i-1]=tmp;
                flag=true;
                count++;
            }
        }
    }
    println(a,n);
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int n, a[100001];

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    multiset<int, greater<int>> m;
    for (int i = 0; i < n; ++i)
    {
        if (m.lower_bound(a[i] - 1) == m.end())
            m.insert(a[i]);
        else
            m.erase(m.lower_bound(a[i] - 1)), m.insert(a[i]);
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,n) for(int i;i <(int)(n);i++)
using namespace std;
int main(){
  int n,c=0;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    if((i+1)%2==1 && a%2==1) c++;
  }
    cout << c << endl;
  }
  

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int x[n]={};
    int s[m],c[m];
    for(int i=0;i<m;i++){
        cin>>s[i]>>c[i];
        if(x[s[i]-1]==0)
            x[s[i]-1]=c[i];
        if(x[s[i]-1]!=c[i]){
            cout<<"-1"<<endl;
            return 0;
        }
        else if(n>1 && s[i]==1 && c[i]==0){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    if(n>1 && x[0]==0)x[0]=1;
    int a=1,b=0;
    for(int i=n-1;i>=0;i--){
        b+=a*x[i];
        a*=10;
    }
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			String result = "NO";
			for(int i =  1; i < b; i++){
				if((i * a) % b == c){
					result = "YES";
				}
			}
			System.out.println(result);
		}catch(Exception e){
			e.getMessage();
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    vector<int> ismsp(300005, 0);
    for (int i = 6; i < 300005; ++i) {
        if (i % 7 == 1 || i % 7 == 6) {
            ismsp[i] = 1;
        }
    }
    for (int i = 1; i < 300005; ++i) {
        if (ismsp[i]) {
            for (int j = i * 2; j < 300005; j += i) {
                ismsp[j] = 0;
            }
        }
    }
    vector<int> msp;
    for (int i = 1; i < 300005; ++i) {
        if (ismsp[i])
            msp.push_back(i);
    }
    while (1) {
        int n;
        cin >> n;
        if (n == 1) return 0;
        cout << n << ":";
        for (int i : msp) {
            if (i > n) break;
            if (n % i == 0)
                cout << " " << i;
        }
        cout << "\n";
    }
}

Measured memory_bytes: 4248
# cook your dish here
s=list(input())
a = s.count('N')
b = s.count('W')
c = s.count('S')
d = s.count('E')
ass = 0
if a ==0:
    if c == 0:
        ass += 1
else:
    if c > 0:
        ass += 1
if b == 0:
    if d == 0:
        ass += 1
else:
    if d > 0:
        ass += 1

if ass == 2:
    print('Yes')
else:
    print('No')

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));

  ll diff = INF64;
  ll r = 0;
  rep(i, n) if(chmin(diff, abs(a[i] - (a[n-1]-a[i])))) r = a[i];

  cout << a[n-1] << " " << r << endl;
}


Measured memory_bytes: 3984
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<max({a,b,c})-min({a,b,c})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define SQ(x) ((x) * (x))

typedef struct{
	double x;
	double y;
} POINT;


double intersept(POINT p1, POINT p2, POINT p3, POINT p4){
	return(((p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x)) * ((p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x)));
}

int main(void)
{
	POINT A, B, C, D, G;
	
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &D.x, &D.y) != EOF){
		
		G.x = (A.x + B.x + C.x) / 3;
		G.y = (A.y + B.y + C.y) / 3;
		
		if (intersept(A, C, G, D) > 0){
			printf("NO\n");
			continue;
		}
		
		G.x = (B.x + C.x + D.x) / 3;
		G.y = (B.y + C.y + D.y) / 3;
		
		if (intersept(B, D, G, A) > 0){
			printf("NO\n");
			continue;
		}
		
		G.x = (A.x + C.x + D.x) / 3;
		G.y = (A.y + C.y + D.y) / 3;
		
		if (intersept(A, C, G, B) > 0){
			printf("NO\n");
			continue;
		}
		
		G.x = (D.x + A.x + B.x) / 3;
		G.y = (D.y + A.y + B.y) / 3;
		
		if (intersept(B, D, G, C) > 0){
			printf("NO\n");
			continue;
		}
		else {
			printf("YES\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long A, B, C, D;
long long X, Y;

long gcd(long a,long b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}

int main(){
	cin >> A >> B >> C >> D;
	X = abs(A - C);
	Y = abs(B - D);
	if(X == Y){
		cout << X << endl;
		return 0;
	}
	long long ans;
	long long num = gcd(X, Y);
	X/=num;
	Y/=num;

	ans = 0;
	
	ans = X + Y - 1;
	cout << ans * num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using f32 = float;
using f64 = double;
using LL = long long;
using ULL = unsigned long long;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
int main()
{ 
 LL n,a;
  cin >> n>>a;
  string b=(n==a)?"Yes":"No";
  cout << b;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef pair<int, int> P;
#define INF (1 << 30)
int nowmax = INF, x, y;
char c;
int come[10][10];
int xs[] = {1, 0, -1, 0}, ys[] = {0, 1, 0, -1};
int dfs(int color[][10], int count = 0){
    int res = nowmax;
    if(count >= res)return INF;
    for(int i = 0;i < 3;i++){
	if(i == color[0][0])continue;
	int tmp[10][10];
	int done = 1;
	for(int j = 0;j < y;j++)
	    for(int k = 0;k < x;k++){
		tmp[j][k] = color[j][k];
		if(tmp[j][k] != color[0][0])done = 0;
		come[j][k] = 0;
	    }
	if(done){
	    nowmax = min(nowmax, count);
	    return count;
	}
	queue<P> q;
	q.push(P(0, 0));
	int ok = 0;
	while(!q.empty()){
	    for(int j = q.size();j > 0;j--){
		P t = q.front();q.pop();
		int a = t.first, b = t.second;
		if(come[a][b])continue;come[a][b] = 1;
		if(tmp[a][b] == i)ok = 1;
		if(tmp[a][b] != color[0][0])continue;
		tmp[a][b] = i;
		for(int k = 0;k < 4;k++){
		    int tx = b + xs[k], ty = a + ys[k];
		    if(tx < 0 || tx >= x || ty < 0 || ty >= y)continue;
		    q.push(P(ty, tx));
		}
	    }
	}
	if(ok){
	    res = min(res, dfs(tmp, count + 1));
	    nowmax = min(res, nowmax);
	}
    }
    return res;
}

int main(){
    int color[10][10];
    while(cin >> x >> y, x|y){
	for(int i = 0;i < y;i++)
	    for(int j = 0;j < x;j++){
		cin >> c;
		if(c == 'R')color[i][j] = 0;
		if(c == 'G')color[i][j] = 1;
		if(c == 'B')color[i][j] = 2;
						
	    }
	nowmax = INF;
	cout << dfs(color) << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int e[1000010];

int main(void){

	int n,a,b;
	for(;;){
	cin >> n >> a >> b;
	if(n==0 && a==0 && b==0) break;

	if(a>b) swap(a,b);
	e[0]=1;
	for(int i=0;i+a<=n;i++){
	if(e[i]==1) e[i+a]=1;
	}
	for(int i=0;i+b<=n;i++){
	if(e[i]==1) e[i+b]=1;
	}

	int c=0;
	for(int i=1;i<=n;i++)
	if(e[i]==0) c++;

	cout << c << endl;

	for(int i=1;i<=n;i++) e[i]=0;

	}

	return 0;
}

Measured memory_bytes: 5064
dat = "0"
s = []
while dat != "=":
    dat = input()
    s.append(dat)
ans = int(s[0])
for i in range(1,len(s)-2):
    if s[i] == "+":
        ans += int(s[i+1])
    elif s[i] == "-":
        ans -= int(s[i+1])
    elif s[i] == "*":
        ans *= int(s[i+1])
    elif s[i] == "/":
        ans //= int(s[i+1])
print(ans)


Measured memory_bytes: 5600