akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class UnionFind {
    int[] roots;
	
	public UnionFind(int N) {
		this.roots = new int[N];
		for(int i = 0; i < N; ++i) this.roots[i] = i;
	}
	
	int getRoot(int x) {
		if(this.roots[x] == x) return x;
		else return this.roots[x] = getRoot(this.roots[x]);
	}
	
	boolean isSameSet(int x, int y) {
		return getRoot(x) == getRoot(y);
	}
	
	void unite(int x, int y) {
		if(getRoot(x) != getRoot(y)) roots[x] = y;
	}
}

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main (String[] args) {
        int N = sc.nextInt();
        UnionFind uf = new UnionFind(N);
        int M = sc.nextInt();
        
        int[] p = new int[N];
        for(int i = 0; i < N; ++i) p[i] = sc.nextInt() - 1;
        
        for(int i = 0; i < M; ++i) {
            uf.unite(uf.getRoot(sc.nextInt() - 1), sc.nextInt() - 1);
        }
        
        int ans = 0;
        for(int i = 0; i < N; ++i) {
            if(uf.isSameSet(i, p[i])) ++ans;
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 90340
#include <stdio.h>

typedef long long ll;

ll a[100005];

int main() {

	int n;

	scanf("%d",&n);

	int i;

	for (i = 0; i < n; i++) {
		scanf(" %lld",&a[i]);
	}
	ll sum = 0ll;
	ll ans1 = 0ll;
	for (i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0) {
			if (sum <= 0ll) {
				ans1 += -sum + 1ll;
				sum += -sum + 1ll;
			}
		}
		else {
			if (sum >= 0ll) {
				ans1 += sum + 1ll;
				sum += -sum - 1ll;
			}
		}
	}
	sum = 0ll;
	ll ans2 = 0ll;
	for (i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0) {
			if (sum >= 0ll) {
				ans2 += sum + 1ll;
				sum += -sum - 1ll;
			}
		}
		else {
			if (sum <= 0ll) {
				ans2 += -sum + 1ll;
				sum += -sum + 1ll;
			}
		}
	}
	if (ans1 < ans2) {
		printf("%lld\n",ans1);
	}
	else {
		printf("%lld\n",ans2);
	}

	return 0;
}

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

int main() {
    int  n, cnt=0,x=1000000000;
    long long ans=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        ans+=abs(a[i]);
        x=min(x, abs(a[i]));
        if(a[i]<0) cnt++;
    }
    sort(a.begin(), a.end());
    if(cnt%2!=0) {
        ans-=(2*x);
    }
    cout <<ans;
}

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

const int MOD = 1e9 + 7;
int number(string& s, int & i) {
    int ret = 0;
    while (isdigit(s[i])) {
        ret = ret * 10 + (s[i++] - '0');
    }
    return ret;
}
int exp1(string& s, int & i);
int exp2(string& s, int & i);
int exp1(string& s, int & i) {
    int acc = exp2(s, i);
    while (i < s.size()) {
        if (s[i] == '>' && i + 2 < s.size() && s[i + 1] == '>' && s[i + 2] != '>') {
            i += 2;
            int rhs = exp2(s, i);
            acc = rhs < 32 ? acc / (1LL << rhs) : 0;
        } else break;
    }
    return acc;
}
int exp2(string& s, int & i) {
    if (s[i] == 'S') {
        assert(s[++i] == '<');
        int ret = exp1(s, ++i);
        assert(s[i++] == '>');
        return ret * ret % MOD;
    } else {
        return number(s, i);
    }
}
void solve() {
    string s;
    {
        string t;
        getline(cin, t);
        if (t == "#") exit(0);
        for (char c : t) {
            if (c != ' ') s.push_back(c);
        }
    }
    int i = 0;
    cout << exp1(s, i) << endl;
}

signed main() {
    while (1) solve();
}


Measured memory_bytes: 6220
import copy
import fractions
import sys
n,m=map(int,input().split())
A=list(map(int,input().split()))
a=copy.copy(A[0])
c=0
while a%2==0:
  a=a//2
  c=c+1
d=2**c
for i in range(n):
  if A[i]//d!=float(A[i])/d or A[i]//(2*d)==float(A[i])/(2*d):
    print(0)
    sys.exit()
B=[]
for i in range(n):
  B.append(A[i]//2)
b=1
for i in range(n):
  b=b*B[i]//fractions.gcd(b,B[i])
  if b>m:
    print(0)
    sys.exit()
if b>m:
  print(0)
else:
  print(1+(m-b)//(2*b))

Measured memory_bytes: 89184
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
const LL mod = 1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    LL ans = 1;
    loop(i, 1, n + 1) {
        ans = ans * i % mod;
    }
    loop(i, 1, m + 1) {
        ans = ans * i % mod;
    }
    cout << ans * ((n == m) + 1) % mod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	REP(i, N) scanf("%d", &P[i]);
	
	int ans = 0;
	set<int> ss;
	REP(i, N) {
		auto it = ss.lower_bound(P[i]);
		
		if (it == ss.begin()) ++ans;
		ss.insert(P[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

typedef string::const_iterator State;
class ParseError {};

int number(State &begin){
    int ret = 0;
    while(isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}

int calc(State &begin){
    if(*begin != '['){
        cerr << "error!" << endl;
        return -1;
    }
    if(*(++begin) != '[') return (number(begin)/2 + 1);
    vector<int> a;
    while(*begin == '['){
        a.pb(calc(begin));
        begin++;
    }
    sort(all(a));
    int ans = 0;
    REP(i, a.size()/2+1) ans += a[i];
    return ans;
}

signed main(){
    int n;
    cin >> n;
    REP(i, n){
        string s;
        cin >> s;

        State begin = s.begin();
        int ans = calc(begin);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3276
word = gets.split
seven_count = 0
five_count = 0
word.each do |w|
  seven_count += 1 if w == "7"
  five_count += 1 if w == "5"
end

if seven_count == 1 and five_count == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 14228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

int check(int a,int n){
	int b=0;
	for(int i=0;i<n;i++){
		if(a&(1<<i))b++;
	}
	return b;
}

int s[1<<20];
vector<int> v1,v2;
bool rev[2][8]={{false,false,true,true,true,true,false,false},{false,true,true,false,false,true,true,false}};
bool rev_2[2][8]={{false,false,true,true,true,false,false,true},{false,true,true,false,false,false,true,true}};

int main(){
	int n;
	int a,b,c;
	int i,j,k;
	int p,q,r;
	cin>>n>>a>>b;
	c=check(b,n)-check(a,n)+2*n;
	if(c%2==0){
		cout<<"NO"<<endl;
		return 0;
	}
	for(i=0;i<n;i++){
		if((a^b)&(1<<i))v2.push_back(i);//違う
		else v1.push_back(i);//同じ
	}
	if(n%2!=0){
		p=v2.back(),v2.pop_back();
		for(i=0;i<(1<<(n-1));i++)s[i]=a&(1<<p);
		for(i=(1<<(n-1));i<(1<<n);i++)s[i]=(~a)&(1<<p);
		c=n-1;
	}else{
		p=v1.back(),v1.pop_back();
		q=v2.back(),v2.pop_back();
		for(i=0;i<(1<<n);i++){
			r=i>>(n-2);
			if(rev[0][r])s[i]+=(~a)&(1<<q);
			else s[i]+=a&(1<<q);
			if(rev[1][r])s[i]+=(~a)&(1<<p);
			else s[i]+=a&(1<<p);
		}
		c=n-2;
	}
	while(!v1.empty()){
		p=v1.back(),v1.pop_back();
		q=v1.back(),v1.pop_back();
		c-=2;
		for(i=0;i<(1<<n);i++){
			r=(i>>c)%8;
			if(rev[0][r])s[i]+=(~a)&(1<<q);
			else s[i]+=a&(1<<q);
			if(rev[1][r])s[i]+=(~a)&(1<<p);
			else s[i]+=a&(1<<p);
		}
	}
	while(!v2.empty()){
		p=v2.back(),v2.pop_back();
		q=v2.back(),v2.pop_back();
		c-=2;
		for(i=0;i<(1<<n)-(1<<(c+3));i++){
			r=(i>>c)%8;
			if(rev[0][r])s[i]+=(~a)&(1<<q);
			else s[i]+=a&(1<<q);
			if(rev[1][r])s[i]+=(~a)&(1<<p);
			else s[i]+=a&(1<<p);
		}
		for(i=(1<<n)-(1<<(c+3));i<(1<<n);i++){
			r=(i>>c)%8;
			if(rev_2[0][r])s[i]+=(~a)&(1<<q);
			else s[i]+=a&(1<<q);
			if(rev_2[1][r])s[i]+=(~a)&(1<<p);
			else s[i]+=a&(1<<p);
		}
	}
	cout<<"YES"<<endl;
	array_show(s,(1<<n));
	return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int N;
vector<int> v;
int main(){
    cin >> N;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout << v[N-1] - v[0] << endl;
    return 0;
}

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

namespace ABC
{
    using System.Collections.Generic;
#if USE_STUB
    using static Stub.Console;
#else
    using static System.Console;
#endif
    using static System.Math;
    public class Program
    {
        static void Main(string[] args)
        {
            var DN = ReadLine().Split().Select(int.Parse).ToArray();
            var D = DN[0];
            var N = DN[1];
            var a = Math.Pow(100, D);
            WriteLine(a * (N + N / 100));
        }
    }
}


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

int main() {
  int n = 3;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  cout << arr[0] + arr[1] << endl;
}

Measured memory_bytes: 256
def resolve():
    N, M = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for i in range(N)]
    CD = [list(map(int, input().split())) for i in range(M)]
    for ab in AB:
        dist = float("inf")
        point = None
        for i, cd in enumerate(CD):
            if dist > abs(ab[0]-cd[0])+abs(ab[1]-cd[1]):
                dist = abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
                point = i+1
        print(point)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
char imap[8][9];
static pair<int, int> forms[7][3] = {
    {{0, 1}, {1, 0}, {0, -1}},
    {{1, 0}, {1, 0}, {1, 0}},
    {{0, 1}, {0, 1}, {0, 1}},
    {{1, 0}, {0, -1}, {1, 0}},
    {{0, 1}, {1, 0}, {0, 1}},
    {{1, 0}, {0, 1}, {1, 0}},
    {{0, 1}, {1, -1}, {0, -1}}
};
static char decoder[7] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
int res;

bool search(int x, int y, int t) {
    bool isFound = true;
    for (int i = 0; i < 3; i++) {
        x += forms[t][i].first, y += forms[t][i].second;
        if (x < 0 || x > 7 || y < 0 || y > 7 || imap[x][y] != '1') { isFound = false; break; }
    }
    return isFound;
}

void solve() {
    bool flag = false;
    res = -1;
    for (int i = 0; i < 8; i++) {
        if (res > -1) break;
        for (int j = 0; j < 8; j++) {
            if (imap[i][j] == '0') continue;
            for (int k = 0; k < 7; k++) {
                if (search(i, j, k)) { res = k; break;}
            }
            break;
        }
    }
}



int main(){

    while(scanf("%s", imap[0]) != EOF) {
        for (int i = 1; i < 8; i++) {
            scanf("%s", imap[i]);
        }
        solve();
        printf("%c\n", decoder[res]);
    }
    return 0;
}



Measured memory_bytes: 2624
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = Integer.parseInt(line1[i]);
        int[] dp = new int[n];
        dp[0] = 0;
        if(ary[0] > ary[1]) dp[1] = ary[0] - ary[1];
        else    dp[1] = ary[1] - ary[0];
        for(int i = 2; i < n; i++){
            int a;
            int b;
            if(ary[i] > ary[i - 2]) a = ary[i] - ary[i - 2];
            else    a = ary[i - 2] - ary[i];
            if(ary[i] > ary[i - 1]) b = ary[i] - ary[i - 1];
            else    b = ary[i - 1] - ary[i];
            dp[i] = Math.min(dp[i - 2] + a, dp[i - 1] + b);
        }
        System.out.println(dp[n - 1]);
    }
}

Measured memory_bytes: 38344
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
 
		int[] ans = new int[N];
		
		for(int i=1; i*i<=N; i++) {
			for(int j=1; j*j<=N; j++) {
				for(int k=1; k*k<=N; k++) {
					int n = i*i+j*j+k*k+i*j+j*k+k*i;
					if(n<=N)
						ans[n-1]++;
				}
			}
		}
		for(int i=0; i<N; i++)
			pw.println(ans[i]);
 
		sc.close();
		pw.close();
	}
}

Measured memory_bytes: 29724
N,x = map(int, input().split())
A = [int(i) for i in input().split()]

B = list(A)

ans1 = ans2 = 0
for i in range(N-1):
  if B[i]+B[i+1] > x:
    b = B[i]+B[i+1] - x
    ans1 += b
    B[i+1] -= b
    if B[i+1] < 0: B[i+1] = 0


B = list(A[::-1])
for i in range(N-1):
  if B[i]+B[i+1] > x:
    b = B[i]+B[i+1] - x
    ans2 += b
    B[i+1] -= b
    if B[i+1] < 0: B[i+1] = 0

print( min(ans1, ans2) )



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

using ll = long long;
using ld = long double;

const ll llinf = (ll)1e18;
const int intinf = 1e9;
const int MOD =  (int)(1e9 + 7);
const ld EPS =  1e-7;


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

	map <ll, ll> cnt;
	ll sum = 0;

	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		cnt[x]++;
		sum += x;
	}

	int q;
	cin >> q;
	while (q--) {
		ll b, c;
		cin >> b >> c;

		sum -= cnt[b]*b;
		sum += cnt[b]*c;

		cnt[c] += cnt[b];
		cnt[b] = 0;

		cout << sum << endl;
	}



}

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	// cin >> t;
	while (t--){
		solve();
	}

	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 3000;
int dp[MAXN + 5][MAXN + 5];
int best[MAXN + 5][MAXN + 5];

bool maxx(auto& a, auto b) {
  if (a > b) return false;
  a = b;
  return true;
}

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

  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);

  memset(dp, -1, sizeof(dp));
  rep(i, 0, n + 1)
    dp[i][0] = 0;
  rep(i, 0, m + 1)
    dp[0][i] = 0;
  rep(i, 1, n + 1) {
    rep(j, 1, m + 1) {
      if (maxx(dp[i][j], dp[i - 1][j]))
	best[i][j] = 0; // ignore i-th letter from s
      if (maxx(dp[i][j], dp[i][j - 1]))
	best[i][j] = 1; // ignore j-th letter from t
      if (s[i - 1] == t[j - 1] and maxx(dp[i][j], dp[i - 1][j - 1] + 1))
	best[i][j] = 2; // use i-th and j-th letter from s, t respectively
    }
  }

  string res;
  int ci = n, cj = m;
  while (ci != 0 and cj != 0) {
    if (best[ci][cj] == 2) {
      res += s[ci - 1];
      --ci; --cj;
    } else if (best[ci][cj] == 1) {
      --cj;
    } else {
      assert(best[ci][cj] == 0);
      --ci;
    }
  }
  reverse(all(res));
  cout << res << '\n';
}


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

namespace AtCorder_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var k = int.Parse(Console.ReadLine());

            Console.WriteLine(s.Select(x => x == s[k - 1] ? x : '*').ToArray());
        }
    }
}


Measured memory_bytes: 13268
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
s = ['0']*N
for i in range(N):
  s[i] = str(input())
M = I()
t = ['0']*M
for i in range(M):
  t[i] = str(input())

from collections import Counter
sc = Counter(s)
tc = Counter(t)
ans = 0
for i in range(N):
  tmp = sc[s[i]] - tc[s[i]]
  if tmp > ans:
    ans = tmp
print(ans)

Measured memory_bytes: 38256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        mut x: u64,
    }

    let n500 = x / 500;
    x -= n500 * 500;
    let n5 = x / 5;

    println!("{}", n500 * 1000 + n5 * 5);
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

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

    int a=1,b=1;
    rep(i,N){
        int A,B;
        cin>>A>>B;
        int lb=0,ub=1000000000000000000ll/max(A,B)+10;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            int x=A*mid;
            int y=B*mid;
            if(x<a||y<b)lb=mid;
            else ub=mid;
        }
        a=A*ub;
        b=B*ub;
    }
    cout<<a+b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x/gcd(x,y)*y;
}
int main(){
	ll N,M;
	string S,T;
	scan(N);scan(M);
	scan(S);scan(T);
	ll L=lcm(N,M);
	ll soki=L/M,toki=L/N;
	ll num=L/soki;
	int flag=1;
	vector<char> stest,ttest;
	rep(i,N){
		if(i%soki==0) stest.push_back(S[i]);
	}
	rep(i,M){
		if(i%toki==0) ttest.push_back(T[i]);
	}
	/*rep(i,stest.size()){
		printf("%c",stest[i]);
	}
	kaigyo;
	rep(i,ttest.size()){
		printf("%c",ttest[i]);
	}
	kaigyo;*/
	if(stest==ttest) prin(L);
	else prin(-1);
	return 0;
}


Measured memory_bytes: 512
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


int main()
{
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    
    int a=II(),b=II();
    if(a<=8 && b<=8)
    {
    	cout << "Yay!\n";
    }
    else
    {
    	cout << ":(\n";
    }
	
	return 0;
}



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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] c1 = sc.next().toCharArray();
		char[] c2 = sc.next().toCharArray();
//		int h = 2;
		int w = 3;

		for (int i = 0; i < w; i++) {
			if (c1[i] != c2[w - 1 - i]) {
				pr.println("NO");
				return;
			}
		}

		pr.println("YES");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

ll pos_arr[100002];
ll neg_arr[100002];

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

    int N;
    cin>> N;

    ll num_of_neg = 0;
    ll num_of_zero = 0;
    ll num_of_pos = 0;

    ll temp;
    for(int i = 0; i< N; i++){
        cin >> temp;
        if (temp < 0)
            neg_arr[num_of_neg++] = temp;
        else if (temp == 0)
            num_of_zero++;
        else
            pos_arr[num_of_pos++] = temp;
    }

    ll sum = 0;
    if (num_of_zero != 0){ 
        for(int i = 0; i< num_of_neg;i++)
            sum += -neg_arr[i];
        for (int i = 0; i < num_of_pos; i++)
            sum += pos_arr[i];
    }
    else{
        if ((num_of_neg % 2) == 0){
            for(int i = 0; i< num_of_neg;i++)
                sum += -neg_arr[i];
            for (int i = 0; i < num_of_pos; i++)
                sum += pos_arr[i];
        }
        else{
            ll min_abs = 1000000001;
            for(int i = 0; i < num_of_neg; i++){
                sum += -neg_arr[i];
                min_abs = (min_abs > -neg_arr[i]) ? -neg_arr[i] : min_abs;
            }
            for(int i = 0; i < num_of_pos; i++){
                sum += pos_arr[i];
                min_abs = (min_abs > pos_arr[i]) ? pos_arr[i] : min_abs;
            }

            sum -= min_abs;
            sum -= min_abs;
        }
    }

    cout << sum;

}

Measured memory_bytes: 1024
a,b = map(int,input().split(" "))
ar = [[0 for i in range(b)]for j in range(a)]
c = int(input())
br = list(map(int,input().split(" ")))
s = "p"
count = 0
x = 0
y = 0
t = 1
while count != a * b:
    ar[x][y] += t
    br[0] -= 1
    if br[0] == 0:
        del br[0]
        t += 1
    if s == "p":
        y += 1
        if y == b:
            y -= 1
            x += 1
            s = "m"
    else:
        y -= 1
        if y == -1:
            y = 0
            x += 1
            s = "p"
    count += 1
for d in range(a):
    for e in range(b-1):
        print(ar[d][e],end=" ")
    print(ar[d][b-1])
        

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

using namespace std;

//State
//dp[i] The minimum cost to reach the i-th step from 1st step

//Initialization
//dp[1] = 0, dp[2] = abs(h[1] - h[0])

//Transitions
//dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),	dp[i-2]+abs(h[i]-h[i-2]))

//Order of evaluation
// i = 1...N

//Answer
//return dp[N]

//Time Complexity = O(n)

int dp[100005]; //Max value of N is 10^5
int h[100005]; //Max value of h is 10^5
const int inf = 1e9 + 5;

int main(){
	int N;
	cin >> N;
	for(int i=1; i<=N; i++){
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[1]-h[2]);
	for(int i=3; i<=N; i++){
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[N] << endl;
}

/*
Better way to write transitions
dp[1...N] = inf;
for(int i=3; i<=N; i++){
	for(int j: {i-1, i-2}){
		dp[i] = max(dp[i], dp[j]+abs(h[i]-h[j]));
	}
}
*/

Measured memory_bytes: 4380
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

X = i()
if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 10044
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[111][111],n,L[111],R[111];
int f(int l,int r){
	if(dp[l][r]>-1)return dp[l][r];
	int res=1e9;
	for(int i=l;i<r;i++){
		res=min(res,f(l,i)+f(i+1,r)+L[l]*R[i]*R[r]);
	}
	return dp[l][r]=res;
}
main(){
	memset(dp,-1,sizeof(dp));
	r(i,111)dp[i][i]=0;
	cin>>n;
	r(i,n)cin>>L[i]>>R[i];
	cout<<f(0,n-1)<<endl;
}


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


def comb(n, r):
    numerator = denominator = 1
    for i in range(r):
        numerator = numerator * (n - i)
        denominator = denominator * (i + 1)
    return numerator // denominator


ans = comb(m, 2) + comb(n, 2)
print(ans)


Measured memory_bytes: 2940
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

int play(int n,int m){
    int me[55]={0};
    int cur=0;
    int left = m;
    
    while(1){
        if(cur == n) cur = 0;
        
        if(left == 1 && me[cur] == (m-1)) return cur;
        
        if(left == 0){
            left = me[cur];
            me[cur] = 0;
        }
        else{
            left--;
            me[cur]++;
        }
        
        cur++;
    }
}
main(){
    int n,m;
    
    while(cin >> n >> m){
        if(n == 0) break;
        cout << play(n,m) << endl;
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans=INF;
    for(int i=0;i<=100;i++){
        int t=0;
        rep(j,n){
            t += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans,t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

const int N = 55, INF = 1E9;
int p[N][N], n, a[N], b[N];
int ok[N];

bool optimistic_check(int k) {
    FOR (i, 1, k) ok[i] = 1;
    memset(p, 0, sizeof p);
    FOR (k, 1, N) if (ok[k])
        FOR (i, 1, N) FOR (j, 0, N)
            if (i % k == j) p[i][j] = 1;
    FOR (k, 0, N) FOR (i, 0, N) FOR (j, 0, N)
        p[i][j] |= p[i][k] & p[k][j];
    FOR (i, 1, n + 1) {
        if (a[i] != b[i] && !p[a[i]][b[i]])
            return false;
    }
    return true;
}

bool go(int now) {
    if (now == 0) return true;
    FOR (t, 0, 2) {
        ok[now] = t;
        if (optimistic_check(now)) {
            go(now - 1);
            return true;
        }
    }
    return false;
}

int main() {
    cin >> n;
    FOR (i, 1, n + 1) cin >> a[i];
    FOR (i, 1, n + 1) cin >> b[i];
    if (!go(50)) {
        puts("-1");
        return 0;
    }
    LL ans = 0;
    FOR (i, 1, N) if (ok[i]) ans += 1LL << i;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define rEP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

int a, b, N, C;
int s, t, c;
int imos[35][200010];
int ans[200010];
int main() {
    cin>>N>>C;
    REP(i,0,N){
        cin>>s>>t>>c;
        c--;
        imos[c][2*s-1]=1;
        imos[c][2*t]=-1;
    }
    REP(i,0,C){
        REP(j,1,200005) {
            imos[i][j]=imos[i][j]+imos[i][j-1];
            if(imos[i][j]>1) imos[i][j]=1,imos[i][j+1]=0;
        }
    }
    REP(i,0,C) {
        REP(j, 0, 200005) {
            ans[j] += imos[i][j];
        }
    }
    p(*max_element(ans,ans+200005));
    return 0;
}

Measured memory_bytes: 24832
n = int(input())
L = list(map(int, input().split()))
ans = 0
if n<3:
    print(0)

else:
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                max_L = max(L[i],L[j],L[k])
                min_L = min(L[i],L[j],L[k])
                mid_L = L[i]+L[j]+L[k]-max_L-min_L
                if (((min_L+mid_L)>max_L) & (min_L!=mid_L!=max_L)):
                    ans+=1
    print(ans)

Measured memory_bytes: 69056
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define NMAX int(10e5+3)
#define ll long long
using namespace std;
typedef pair<int, string> pii;

ll n, k, dp[NMAX];

int main() {
    cin >> n >> k;
    for(int i = 1; i < NMAX; i++) dp[i] = LINF;

    for(int i = 1; i <= n; i++) {
        ll v, p;
        cin >> p >> v;
        for(int j = NMAX-1; j >= v; j--)
            if(dp[j-v] != LINF) dp[j] = min(dp[j], dp[j-v]+p);
    }

    ll ans = 0;
    for(int i = 1; i < NMAX; i++)
        if(dp[i] <= k) ans = i;
    cout << ans << endl;

}


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

int X[] = {0, 0, 1, -1};
int Y[] = {1, -1, 0, 0};

bool valido(int i, int j, const vector <vector<char>>& matrix) {
	if(i < 0 || i >= matrix.size() || j < 0 || j >= matrix[0].size()) return false;
	return matrix[i][j] == '.';
}

void bfs(int i, int j, int& resp, vector <vector<char>> matrix) {
	typedef pair <int,int> pii;
	queue <pii> q;
	q.push(pii(i,j));

	vector <vector <int>> dist(matrix.size(), vector<int>(matrix[0].size(), 1000000000));

	dist[i][j] = 0;

	while(!q.empty()) {
		auto u = q.front();
		q.pop();
		i = u.first;
		j = u.second;

		for(int x = 0; x < 4; x++) {
			int ii = i + X[x];
			int jj = j + Y[x];
			if(valido(ii, jj, matrix) and dist[i][j] + 1 < dist[ii][jj]) {
				matrix[ii][jj] = '#';
				dist[ii][jj] = dist[i][j] + 1;
				resp = max(resp, dist[ii][jj]);
				q.push(pii(ii,jj));
			}
		}
	}
}

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

	vector <vector<char>> matrix(n, vector <char>(m));

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			scanf(" %c", &matrix[i][j]);
		}
	}

	int resp = 0;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(matrix[i][j] != '#') bfs(i, j, resp, matrix);
		}
	}

	printf("%d\n",resp );

	return 0;
}

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

int main() {
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int> to(N);
    for(auto &e : to) {
        cin >> e;
        e--;
    }

    vector<int> dist(N, -1);
    int cur = 0;
    dist[cur] = 0;
    while(dist[to[cur]] == -1) {
        dist[to[cur]] = dist[cur] + 1;
        cur = to[cur];
    }

    for(int i = 0; i < N; ++i) {
        if(dist[i] == K) {
            cout << i + 1 << '\n';
            return 0;
        }
    }

    int D = dist[cur] - dist[to[cur]] + 1; // 閉路の頂点数
    cur = to[cur]; // 閉路の始点
    K -= dist[cur];
    K %= D;

    for(int i = 0; i < N; ++i) {
        if(dist[i] - dist[cur] == K) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	ll x,y;
	cin >> x >> y;
	int ans = 0;
	rep(i,1111111111111)
	{
		
		if((x<<i)>y)break;
		ans ++;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N, M, R;
int r[10];
int d[210][210];

signed main() {
    cin >> N >> M >> R;
    rep(i, R) cin >> r[i];
    rep(i, R) r[i]--;
    rep(i, N) rep(j, N) d[i][j] = 1000000000;
    rep(i, N) d[i][i] = 0;
    rep(i, M) {
        int A, B, C; cin >> A >> B >> C;
        d[A-1][B-1] = C;
        d[B-1][A-1] = C;
    }
    
    rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    int ans = 1000000000;
    vector<int> l;
    rep(i, R) l.pb(i);
    
    do {
        int ans_cand = 0;
        rep(i, R-1) {
            int now = r[l[i]], nex = r[l[i+1]];
            ans_cand += d[now][nex];
        }
        ans = min(ans, ans_cand);
    } while (next_permutation(l.begin(), l.end()));
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			double v = scan.nextDouble();
			double t = v / 9.8;
			double y = 4.9 * t * t;
			int N = (int)Math.ceil((4.9 * t * t + 5) / 5);
			System.out.printf("%d\n", N);
		}
	}
}

Measured memory_bytes: 27892
a,q,o,x,b;
main(){
  for(scanf("%d",&q);~scanf("%s",&a);o=o==3?b=x=!printf("%d\n",x):o){
    //printf("%d\n",a%9);
    ///*
    //printf("bef x:%d b:%d o:%d\n",x,b,o);
    if(a%9==7)b=b*2+1,x+=b>>3&1;
    if(a%9==8)o++;
    if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
    //printf("x:%d b:%d o:%d\n",x,b,o);
     //*/
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

long long int N, Y, one = 0, five = 0, ten = 0;
bool dp[2001][20001] = {};

int main() {
	cin >> N >> Y;
	dp[1][1] = true;
	dp[1][5] = true;
	dp[1][10] = true;
	for (int i = 2; i <= N; i++) {
		for (int j = 1; j <= 20000; j++) {
			if (dp[i - 1][j - 1] || dp[i - 1][j - 5] || dp[i - 1][j - 10])dp[i][j] = true;
		}
	}
	Y /= 1000;
	if (dp[N][Y]) {
		for (int i = N; i > 1; i--) {
			if (dp[i - 1][Y - 1]) {
				Y--;
				one++;
			}
			else if (dp[i - 1][Y - 5]) {
				Y -= 5;
				five++;
			}
			else if (dp[i - 1][Y - 10]) {
				Y -= 10;
				ten++;
			}
		}
		if (Y == 1)one++;
		if (Y == 5)five++;
		if (Y == 10)ten++;
		cout << ten << " " << five << " " << one << endl;
	}
	else {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 37760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,a,b,c,d;
    while(~scanf("%d",&n))
    {
        if(n==1)
        {
            printf("Hello World\n");
        }
        else
        {
            scanf("%d%d",&a,&b);
            printf("%d\n",a+b);
        }
    }

  return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

AB = sorted([list(map(int, input().split())) for i in range(N)])
ans = 0
idx = 0
while M:
    
    b = min(M, AB[idx][1])
    ans += AB[idx][0] * b
    M -= b
    idx += 1
    
print(ans)

Measured memory_bytes: 28652
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

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

    void run() {
        String[] arr = new String[3];
        for (int i=0; i<3; i++) arr[i] = sc.next();

        out.print(arr[0].charAt(0));
        out.print(arr[1].charAt(1));
        out.print(arr[2].charAt(2));
        out.flush();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cmath>

//c++は戻り値に配列はだめ
/*
char* solve(){
    int n_10 = pow(10,5);
    int MAX_N = 2*n_10;

    char s[MAX_N+1];
    scanf("%s", s);
    //'D'としないとだめ.
    //前後の関係があるため愚直に数えた方が合理的.

    int res = 0;
    for(int i=0; i < MAX_N; i++){
        if(s[i] == 'P'){
            if(s[i+1] == 'D' || s[i+1] == '?'){
                res += 2;
            }
        }
        if(s[i] == 'D' || s[i] == '?'){
            res += 1;
        }
    }
   for(int i=0; i < MAX_N; i++){
       if(s[i] == '?'){
           s[i] = 'D';
       }
   }
    return s;
}
*/

int main(){
    int n_10 = pow(10,5);
    int MAX_N = 2*n_10;

    char s[MAX_N+1];
    scanf("%s", s);
    //'D'としないとだめ.
    //前後の関係があるため愚直に数えた方が合理的.

    /*
    int res = 0;
    for(int i=0; i < MAX_N; i++){
        if(s[i] == 'P'){
            if(s[i+1] == 'D' || s[i+1] == '?'){
                res += 2;
            }
        }
        if(s[i] == 'D' || s[i] == '?'){
            res += 1;
        }
    }
    */
   for(int i=0; i < MAX_N; i++){
       if(s[i] == '?'){
           s[i] = 'D';
       }
   }
    //return s;
    //char* res = solve();
    printf("%s\n", s);
    return 0;
}


Measured memory_bytes: 3956
N, A, B, C = map(int, input().split())
L = [0]*N
for i in range(N):
  L[i] = int(input())

import itertools
bambuu = [[0,0,0] for _ in range(4**N)]
for i,pro in enumerate(itertools.product(['A','B',"C",'D'], repeat=N)):
    lisA = [L[j] for j in range(N) if pro[j]=='A']
    lisB = [L[j] for j in range(N) if pro[j]=='B']
    lisC = [L[j] for j in range(N) if pro[j]=='C']
    sumA = [sum(lisA),(len(lisA)-1)*10]
    sumB = [sum(lisB),(len(lisB)-1)*10]
    sumC = [sum(lisC),(len(lisC)-1)*10]
    bambuu[i-1] = [sumA,sumB,sumC]

ans = 10000
for sA,sB,sC in bambuu:
    if sA[0]>0 and sB[0]>0 and sC[0]>0:
        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]
        if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record)
print(ans)
#print(*ans, sep='\n')

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

l_list = list()
r_list = list()
for _ in range(m):
  l, r = map(int, input().split())
  l_list.append(l)
  r_list.append(r)
  
ll = max(l_list)
rr = min(r_list)
if (rr-ll+1) <=0:
  print(0)
else:
  print(rr-ll+1)

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


int main(){

  double r,x,y ;

  scanf("%lf",&r) ;
  
  x =(double) r*r*3.141592653589 ;
  y =(double) 2*r*3.141592653589 ;

  printf("%f %f\n",x,y);


  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll la = 1e18;
int main(){
    ll N; cin >> N;
    ll ans = 1;
    bool flag = true;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        if(a==0){
            ans = 0;
            flag = true;
            break;
        }
        if(la/a < ans){
            //cout << a << " " << ans << endl; 
            ans = -1;
            flag = false;
        }
        ans *= a;
    }
    if(flag == true){
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


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

int main()
{
    int N;
    cin >> N;
    int *A = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    double s = 0.0;
    for (int i = 0; i < N; i++) {
        s += (double) 1 / A[i];
    }
    s = 1 / s;
    cout << setprecision(10) <<  s << endl;
}

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

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

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

    double ans = 0,weight = 0.0;
    vector<double> w(n), v(n);
    rep(i,n) cin>>w[i]>>v[i];

    vector<pair<double,int> > pv;
    rep(i,n) {
        if(w[i] >= 0 && v[i] <= 0) continue;
        if(w[i] <= 0 && v[i] >= 0) {
            ans += v[i], weight += w[i];
            continue;
        }

        if(v[i] >= 0) {
            ans += v[i], weight += w[i];
            w[i] *= -1, v[i] *= -1;
        }
        pv.push_back(make_pair(v[i]/w[i],i));
    }

    sort(pv.begin(), pv.end());
    //reverse(pv.begin(), pv.end());

    rep(i,pv.size()) {
        if(weight <= W) break;
        int idx = pv[i].second;

        if(weight+w[idx] >= W) {
            weight += w[idx];
            ans += v[idx];
        }else{
            ans += v[idx]*(W-weight)/w[idx];
            weight = W;
        }
    }

    printf("%.12f\n", ans);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!
 
int main() {
    string s;
    cin >> s;
    int n = s.size(), zero = 0, one = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            if (zero) zero--, ans += 2;
            else one++;
        } else {
            if (one) one--, ans += 2;
            else zero++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

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

    int sum=0;
    for(int i=1; i<=100000; i++){
        if(cnt[i] > 0) cnt[i]--;
        sum += cnt[i];
    }

    if(sum % 2 == 1) sum++;

    cout << n - sum << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define W first
#define L second
#define F 5000
using namespace std;pair<int,int> c[F*20];int n,m,g[F],q[F],l[F],h,t;void B(int x,int len){cout<<x+1<<endl;int le=0,ri=m,ms,me;while(1){if(le>=ri-1)break;ms=(le+ri)/2;if(c[ms].W<x)le=ms;else ri=ms;}le=0,ri=m;while(1){if(le>=ri-1)break;me=(le+ri)/2;if(c[me].W<=x)le=me;else ri=me;}ms-=2,me+=2;for(int i=max(0,ms);i<(m,me);i++){if(c[i].W==x){g[c[i].L]--;if(!g[c[i].L])q[t]=c[i].L,l[t]=len+1,t++;}}}int main(){cin>>n>>m;for(int i=0;i<n;i++)g[i]=0;for(int i=0;i<m;i++){cin>>c[i].W>>c[i].L;c[i].W--,c[i].L--;g[c[i].L]++;}sort(c,c+m);h=0,t=0;int bf=F;bool tw=0;for(int i=0;i<n;i++)if(!g[i])q[t]=i,l[t]=0,t++;while(1){B(q[h],l[h]);if(l[h]==bf)tw=1;bf=l[h],h++;if(h==t)break;}cout<<tw<<endl;return 0;}

Measured memory_bytes: 3932
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

ll D, N, base = 1, ans;

int main() {
	cin >> D >> N;
	repi(i, 0, D) {
		base *= 100;
	}
	if (N == 100) N++;
	ans = base*N;
	wrln(ans);
	return 0;
}


Measured memory_bytes: 256