akhauriyash/Code-Regression huggingface dataset:
import java.util.*; 
import java.io.*; 
public class Main{
	public static void main(String ...strings ) {
		Scanner sc = new Scanner(System.in);
		int arr[][] = new int[3][3]; 
		
		for(int i = 0; i<3; i++) 
			for(int j = 0; j<3; j++) 
				arr[i][j] = sc.nextInt(); 
			
		HashMap<Integer,Integer> map = new HashMap<>(); 
		int n = sc.nextInt(); 
		
		for(int i = 0; i<n; i++) {
			int x = sc.nextInt(); 
			map.put(x, x); 
		}
		
		if(map.containsKey(arr[0][0]) && map.containsKey(arr[1][0]) && map.containsKey(arr[2][0]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[0][1]) && map.containsKey(arr[1][1]) && map.containsKey(arr[2][1]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[0][2]) && map.containsKey(arr[1][2]) && map.containsKey(arr[2][2]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[0][0]) && map.containsKey(arr[0][1]) && map.containsKey(arr[0][2]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[1][0]) && map.containsKey(arr[1][1]) && map.containsKey(arr[1][2]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[2][0]) && map.containsKey(arr[2][1]) && map.containsKey(arr[2][2]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[0][0]) && map.containsKey(arr[1][1]) && map.containsKey(arr[2][2]))
			System.out.println("Yes"); 
		else if(map.containsKey(arr[0][2]) && map.containsKey(arr[1][1]) && map.containsKey(arr[2][0]))
			System.out.println("Yes"); 
		else System.out.println("No"); 
	}
}

Measured memory_bytes: 23636
def together(N: int, A: list)->int:
    d = {}
    for a in A:
        d.setdefault(a, 0)
        d[a] += 1

        d.setdefault(a+1, 0)
        d[a+1] += 1

        d.setdefault(a-1, 0)
        d[a-1] += 1

    return max(d.values())


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = together(N, A)
    print(ans)


Measured memory_bytes: 19756
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      
      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int totalPrice = 0;
      int maxPrice = 0;
      
      for(int i = 0 ; i < n ; i++){
      	int value = sc.nextInt();
        totalPrice += value;
        maxPrice = Math.max(maxPrice,value);
      }
      
      totalPrice -= maxPrice/2;
      
      System.out.print(totalPrice);
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


input = sys.stdin.readline


def main():
    n = int(input())
    for i in range(1, 10):
        if n % i == 0:
            if n//i < 10:
                print("Yes")
                exit(0)
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    a[x - 1].append(y - 1)
    a[y - 1].append(x - 1)
c = [0] * n
que = deque([])
que.append(0)
while len(que) > 0:
    e = que.popleft()
    for i in a[e]:
        if c[i] > 0:
            continue
        c[i] = e + 1
        que.append(i)
print("Yes")
for i in range(1, n):
    print(c[i])

Measured memory_bytes: 36892
D,G=map(int,raw_input().split())

A=[map(int,raw_input().split()) for i in range(D)]

N=1000
dp=[ [ float("-inf") for i in range(N+100)]  for j in range(D) ] 

p=A[0][0]
c=A[0][1]


for i in range(1,p+1):
	if i==p: dp[0][i]=i*100+c
	else: dp[0][i]=i*100

for i in range(D):
	dp[i][0]=0



for k in range(1,D):
	p=A[k][0]    # number of problems per line
	c=A[k][1]    # bonus

	for i in range(N):		         #dp[k][i]
		for j in range(1,p+1):    #number of problems per line
			dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100, dp[k-1][i+j] )
		dp[k][i+j]=max( dp[k][i+j], dp[k-1][i]+j*(k+1)*100+c,dp[k-1][i+j] )



for idx,i in enumerate(dp[D-1]):
	if i>=G:
		print idx
		quit()
		


Measured memory_bytes: 33516
import sys
c=[]
l=[list(map(int,t.split(","))) for t in sys.stdin]
for i in l:
    if i[0]**2+i[1]**2==i[2]**2:
        c.extend([1])
    elif i[0]==i[1]:
        c.extend([2])
print("{}\n{}".format(
    len([i for i in c if i==1]),
    len([i for i in c if i==2])
    ))
    



Measured memory_bytes: 5612
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	A := nextInt64()
	B := nextInt64()
	N := nextInt64()

	var x int64
	if B > N {
		// Rが最大になるのは x == Nのとき
		x = N
	} else {
		// Rは全ての値を取ることができる。最大になるのは B-1のとき
		x = B - 1
	}
	fmt.Println(divfloor(A*x, B) - A*divfloor(x, B))
}

func divfloor(a, b int64) int64 {
	return int64(math.Floor(float64(a) / float64(b)))
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 201

#define ll long long
#define ld long double
#define vi vector<string>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cerr << i << " ";

int main() {
    fast
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll count=0;
    if(k<=a)cout<<k<<endl;
    else if(k<=a+b)cout<<a<<endl;
    else if(k<a+b+c)cout<<a-(k-a-b)<<endl;
    else cout<<a-c<<endl;
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else cout << 1 << endl;
    

}

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

int main() {
	int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
	cin>>x>>y;
	if(a[x]==a[y]){cout<<"Yes"<<endl;}else cout<<"No"<<endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

#define N_LIM 8
bool edge[N_LIM][N_LIM];
bool visited[N_LIM];
int ans = 0;

int n;

bool visit_check(){
  REP(i, n){
    if(visited[i] == false)
      return false;
  }
  return true;

}

void dfs(ll cur){
  if(visited[cur])
    return;

  visited[cur] = true;
  if(visit_check()){
    ans++;
    return;
  }
  REP(i, n){
    if(edge[cur][i] && !visited[i]){
      dfs(i);
      visited[i] = false;
    }
  }
}

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

  int m;
  cin >> n >> m;

  REP(i, n){
    REP(j, n)
      edge[i][j] = edge[j][i] = false;
    visited[i] = false;
  }

  int a, b;
  REP(i, m){
    cin >> a >> b;
    a--;
    b--;
    edge[a][b] = edge[b][a] = true;
  }

  dfs(0);
      
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/

void solve()
{
    ll n,m;
    cin>>n>>m;
    ll arr[m],s=0;
    for(ll i=0;i<m;i++)
        {
            cin>>arr[i];
            s+=arr[i];
        }
    if(s>n)
        cout<<-1<<endl;
    else
        cout<<n-s<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

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

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  REP(i, 1000){
    int digits[3] = {i/100, (i%100)/10, i%10};
    int chk = 0;
    for(int j=0; j<s.length(); j++){
      if(digits[chk]==s[j]-'0') chk++;
      if(chk==3) { res++; break; }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n,K;
int main(){
    cin>>n>>K;
    int t = n / K;
    LL ans = 1LL * t * t * t;
    if (K % 2 == 0){
        if (n % K >= K / 2) t++;
        ans += 1LL * t * t * t;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int h,n,a,s;
int main(){
	cin>>h>>n;
	for(int i=1;i<=n;i++)cin>>a,s+=a;
	if(s>=h)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,M,u,v,D,c,d[10010];
struct E{
	int to,dist,cost;
	E(int a,int b,int c):to(a),dist(b),cost(c){}
};
vc<E> e[10010];

void f(int s){
	fill(d,d+N,INF);
	multimap<int,int> Q;
	d[s]=0;
	Q.insert(pi(0,s));
	while(Q.sz){
		pi p=*(Q.begin());
		Q.erase(Q.begin());
		int v=p.sec;
		if(d[v]<p.fir)continue;
		rep(i,e[v].sz){
			E f=e[v][i];
			if(d[f.to]>d[v]+f.dist){
				d[f.to]=d[v]+f.dist;
				Q.insert(pi(d[f.to],f.to));
			}
		}
	}
}

int main(){
	while(cin>>N>>M&&N){
		rep(i,N)e[i].clear();
		rep(i,M)cin>>u>>v>>D>>c,u--,v--,e[u].pb(E(v,D,c)),e[v].pb(E(u,D,c));
		f(0);
		int a=0;
		rep2(i,1,N){
			int m=INF;
			rep(j,e[i].sz){
				E f=e[i][j];
				if(d[i]==d[f.to]+f.dist&&f.cost<m)m=f.cost;
			}
			a+=m;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  vector<int> y(n);
  y = x;
  sort(all(y));
  int ml, mr;
  ml = y[n/2-1];
  mr = y[n/2];
  
  rep(i, n){
    if(x[i] <= ml) cout << mr << endl;
    else cout << ml << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdint>

typedef int64_t lint;
#define LINT_MAX (INT64_MAX / 2)
#define LINT_MIN (INT64_MIN / 2)

using namespace std;

lint max(lint a,lint b) {
    if(a > b)
        return a;
    return b;
}

int main(void) {
    lint n,m;
    cin >> n >> m;
    lint p[1001][3];
    for(lint i = 1;i <= n;i++) {
        cin >> p[i][0] >> p[i][1] >> p[i][2];
    }
    lint retval = LINT_MIN;
    for(lint f = 0;f < 8;f++) {
        lint dp[1001][1001] = {};
        for(lint i = 0;i < 1001;i++) {
            for(lint ii = 1;ii < 1001;ii++) {
                dp[i][ii] = LINT_MIN;
            }
        }
        lint ff[3] = {1,1,1};
        if(f % 2 == 1)
            ff[0] = -1;
        if((f / 2) % 2 == 1)
            ff[1] = -1;
        if((f / 4) % 2 == 1)
            ff[2] = -1;
        
        for(int i = 1;i <= n;i++) {
            for(int ii = 1;ii <= m && ii <= i;ii++) {
                dp[i][ii] = max(dp[i-1][ii],dp[i-1][ii-1] + (p[i][0] * ff[0]) + (p[i][1] * ff[1]) + (p[i][2] * ff[2]));
            }
        }
        
        retval = max(retval,dp[n][m]);
    }
    cout << retval;
    return 0;
}


Measured memory_bytes: 8696
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

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

	int ans = 1e9;
	for (int i = 0; i < n-k+1; ++i) {
		int l = a[i];
		int r = a[i + k-1];
		ans = min(ans, abs(l) + abs(r - l));
		ans = min(ans, abs(r) + abs(r - l));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int k;
    cin >> k;

    Int na = 7;
    Int ans = 1;

    if (k & 1) {
        for (; ans < 100000000; ans++) {
            if (na % k == 0) {
                break;
            } else {
                na %= k;
                na = na * 10 + 7;
            }
        }

        if (ans == 100000000) {
            ans = -1;
        }

    } else {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	def num2alp = "abcdefghijklmnopqrstuvwxyz"(_)

	@scala.annotation.tailrec
	def posnot26(n: Long, now: Seq[Char] = Seq.empty): Seq[Char] =
		if (n <= 0) now
		else posnot26((n-1) / 26L, num2alp(((n-1) % 26L).toInt) +: now)

	pw.println(posnot26(Scanner.nextLong).mkString)

	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
// ll knapsack1(int n, int W){
    
//     ll mat[n][2] = {};
//     for(int i = 0; i < n; i++){
//         cin >> mat[i][0] >> mat[i][1];
//     }
    
    
//     // ll** dp = new ll*[n+1];
//     // for(int i = 0; i < n+1; ++i)
//     //     dp[i] = new ll[W+1];
    
//     ll dp[n+1][W+1] = {};
//     for(int i = 1; i < n+1; i++){
//         int w = mat[i-1][0];
//         ll value = mat[i-1][1];
//         for(int j = 1; j < W+1; j++){
            
//             if(j < w) dp[i][j] = dp[i-1][j];
//             else{
//                 dp[i][j] = max(dp[i-1][j], value + dp[i-1][j-w]);
//             }
//         }
//     }
//     return dp[n][W];
// }
 
 
const ll INF = 1e18L + 5; 
 
int main(){
    int n,W ; cin >> n >> W;
    vector<int> value(n), weight(n);
    
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i] ;
    int val_sum = 0;
    for(int x : value) val_sum += x;
    
    vector<ll> dp(val_sum+1,INF);
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = val_sum; j >= value[i]; j--){
            dp[j] = min( dp[j], (dp[j-value[i]]+weight[i]) );
            // if(i==0) cout << j<< "-" << dp[j] << " ";
        }
    }
    
    ll ans = 0;
    for(int i = 0; i <= val_sum; i++){
        if(dp[i] <=W) ans = max(ans,(ll)i);
    }
    
    cout << ans ;
    return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

long long a[100010];

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

    for (int i = 0; i < (int) S.size();) {
        int l = i;
        while (S[i] == 'R') i++;
        int m = i;
        while (i < (int) S.size() && S[i] == 'L') i++;
        int r = i;
        a[m - 1] = (m - l + 1) / 2 + (r - m) / 2;
        a[m] = (m - l) / 2 + (r - m + 1) / 2;
    }
    for (int i = 0; i < (int) S.size(); ++i) {
        printf("%lld ", a[i]);
    }
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
using namespace std;

int main(){
  char a[1000], b[1000], c[1000];
  int an, bn, cn;
  //int ac[3] = {0}, bc[3] = {0}, cc[3] = {0};
  char temp[10];
  int i = 1, j = 0, k = 0;
  scanf("%s", a);
  an = strlen(a); 
  scanf("%s", b);
  bn = strlen(b);
  scanf("%s", c);
  cn = strlen(c);
  
  temp[0] = a[0];
  while(an >= i && bn >= j && cn >= k){
    if(temp[0] == 'a'){
      temp[0] = a[i++];
      if(i > an){
	printf("A\n");
	break;
      }
    }else if(temp[0] == 'b'){
      temp[0] = b[j++];
      if(j > bn){
	printf("B\n");
	break;
      }
    }else{
      temp[0] = c[k++];
      if(k > cn){
	printf("C\n");
	break;
      }
    }
    //printf("%d, %d, %d\n", i, j, k);
  }
  //printf("%d, %d, %d\n", ac[0], ac[1], ac[2]);
  //printf("%c\n", temp[0]);
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def solve():
    N = int(raw_input())
    a = map(int, raw_input().split())
    if N == 2 and a == [1, 1]:
        return True

    cnt = [0]*(N + 1)
    for ai in a:
        cnt[ai] += 1

    mx = max(a)
    l, r = 0, mx
    for i in xrange(1, mx):
        l += 1
        r -= 1
        cnt[max(l, r)] -= 1

    if cnt[mx] < 2: return False
    for i in xrange(1, (mx + 1)/2 + 1):
        if cnt[i] > 0:
            return False
    for i in xrange(1, N):
        if cnt[i] < 0:
            return False
    return True

print "Possible" if solve() else "Impossible"


Measured memory_bytes: 4648
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int n;
cin >> n;
if(n%2==1){
   cout <<n/2+1<<endl;
}
else {
   cout << n/2<<endl;
}
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

ll calc(ll b,ll n) {
  ll ret = 0;
  while( n ) {
    ret += ( n % b );
    n /= b;
  }
  return ret;
}

void compute(ll n,ll s) {
  if( n == s ){
    cout << n + 1LL << endl;
    return;
  }
  if( s > (ll)((n+n-1)/2LL) ) {
    puts("-1");
    return;
  }
  for(ll b=2;b<=sqrt(n)+1;++b) {
    if( calc(b,n) == s ) {
      cout << b << endl;
      return;
    }
  }
  ll mini = LLONG_MAX;
  for(ll p=1;p<=sqrt(n)+1;++p) {
    ll q = s - p;
    if( 0 > q ) continue;
    if( ( n - q ) % p ) continue;
    ll b = ( n - q ) / p;
    if( calc(b,n) == s ) {
      mini = min(mini,b);
    }
  }
  if( mini == LLONG_MAX ) puts("-1");
  else cout << mini << endl;
}

int main() {
  ll n,s;
  cin >> n >> s;
  compute(n,s);
  return 0;
}


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

using namespace std;

#define N 100000

struct Queue {
	string name;
	int t;
};

Queue queue[N];
int head, tail;

void enqueue(Queue q, int n)
{
	queue[tail] = q;
	if (tail == n) tail = 0;
	else tail++;
}

Queue dequeue(int n)
{
	Queue x = queue[head];
	if (head == n) head = 0;
	else head++;

	return x;
}

int isEnpty(void)
{
	if (head == tail) return 1;
	else return -1;
}

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

	for (int i = 0; i < n; i++) {
		cin >> queue[i].name >> queue[i].t;
	}

	head = 0;
	tail = n;
	int ptime = 0;
	int i = 0;
	Queue Answer[N];
	while (isEnpty() != 1) {
		if (queue[head].t - q <= 0) {
			Queue a = dequeue(n);
			ptime += a.t;
			Answer[i].name = a.name;
			Answer[i].t = ptime;
			i++;
		}
		else {
			ptime += q;
			queue[head].t -= q;
			enqueue(dequeue(n), n);
		}
	}

	for (int i = 0; i < n; i++) {
		cout << Answer[i].name << " " << Answer[i].t << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

// 11:42:95

#define inside(y,x) (0<=(y)&&(y)<8&&0<=(x)&&(x)<8)

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

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi C(8,-1);
    rep(i,N){
        int r,c; cin>>r>>c;
        C[r] = c;
    }
    vi p(8);
    rep(i,8) p[i]=i;
    do{
        bool ng=false;
        rep(i,8)if(p[i]!=C[i] && C[i]!=-1) ng=true;
        rep(y,8){
            int x = p[y];
            rep(j,8){
                int mv=1;
                while(true){
                    int ty = y+dy[j]*mv;
                    int tx = x+dx[j]*mv;
                    if (!inside(ty,tx)) break;
                    if (p[ty]==tx){
                        ng=true;
                        break;
                    }
                    mv++;
                }
                if (ng) break;
            }
        }
        if (!ng) break;
    }while(next_permutation(all(p)));
    rep(y,8){
        rep(x,8){
            cout<<((p[y]==x)?'Q':'.');
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <sysexits.h>

using namespace std;

int N;
string answer;
vector<int> b, ans;

int main()
{
    cin >> N;
    string b;
    for (int i = 0; i < N;i++)
    {
        int bi;
        cin >> bi;
        bi--;
        b.push_back(bi);
    }
    bool f;
    for (int i = 0; i < N; i++)
    {
        f = false;
        for (int j = N - 1 - i; 0 <= j; j--)
        {
            if(b[j] == j)
            {
                ans.push_back(j);
                b.erase(b.begin() + j);
                f = true;
                break;
            }
        }
        if(f == false)
        {
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    if (f == true)
    {
        for (int i : ans)
        {
            cout << i + 1 << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll ans=0,cnt=0;
    REP(i,n){
        ans+=max(0LL,cnt-a[i]);
        chmax(cnt,a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4788
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    K = ii()
    ans = 1
    for i in range(N):
        ans = min(ans+K, 2*ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61292
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	for b := 0; b < 60; b++ {
		a := make([]int, N)
		for i := 0; i < N; i++ {
			a[i] = (A[i] >> uint(b)) & 1
		}

		bs := make([]int, N)
		bs[N-1] = a[N-1]
		for i := N - 2; i > -1; i-- {
			bs[i] = bs[i+1] + a[i]
		}

		t := 0
		for i := 0; i < N-1; i++ {
			if a[i] == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
			t %= 1000000007
		}
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 20224
local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local sum = 0
for i = 1, k do
  sum = sum + t[i]
end
local ret = sum
for i = k + 1, n do
  sum = sum + t[i] - t[i - k]
  ret = math.max(ret, sum)
end
print((ret + k) / 2)


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

ll kyori(ll x,ll y,ll nx,ll ny){
  ll a=0;
  a+=max(x-nx,nx-x);
  a+=max(y-ny,ny-y);
  return(a);
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> s(n);
  for(int i=0;i<n;i++) cin >> s.at(i).first >> s.at(i).second;
  vector<pair<ll,ll>> p(m);
  for(int i=0;i<m;i++) cin >> p.at(i).first >> p.at(i).second;
  
  for(int i=0;i<n;i++){
    ll ans=1;
    ll k=kyori(s.at(i).first,s.at(i).second,p.at(0).first,p.at(0).second);
    for(int j=1;j<m;j++){
      if(kyori(s.at(i).first,s.at(i).second,p.at(j).first,p.at(j).second)<k){
        ans=j+1;
        k=kyori(s.at(i).first,s.at(i).second,p.at(j).first,p.at(j).second);
      }
    }
    cout << ans << endl;
  }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;


int main(){
  ll n;
  cin >> n;
  st str;
  cin >> str;
  vll countE(n);
  countE.at(0) = (str.at(0) == 'E' ? 1 : 0);
  rep(i, 1, n){
    countE.at(i) = countE.at(i - 1) + (str.at(i) == 'E' ? 1 : 0);
  }
  ll ans = countE.at(n - 1) - (str.at(0) == 'E' ? 1 : 0);
  rep(i, 1, n){
    ll sw = i - countE.at(i - 1) + countE.at(n - 1) - countE.at(i);
    if(ans > sw) ans = sw;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cstdio>

using namespace std;

const int INF = 100000;

int N;
int D;
int C;

array<int, INF> S;
array<int, INF> I;
array<int, INF> Dp;

struct L
{
    int v;
    int n;
};

array<L, INF> E;

void Link(int u, int v)
{
    E[++D] = { v, S[u] };
    S[u] = D;
}

// descending
bool Cmp(int a, int b)
{
    return  Dp[a] > Dp[b];
}

void DFS(int u)
{
    for (int i = S[u]; i; i = E[i].n)
    {
        DFS(E[i].v);
    }

    int a = 0;
    for (int i = S[u]; i; i = E[i].n)
    {
        I[++a] = E[i].v;
    }

    sort(&I[0] + 1, &I[0] + a + 1, Cmp);

    for (int i = 1; i <= a; i++)
    {
        Dp[u] = max(Dp[u], Dp[I[i]] + i);
    }
}

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    gc(N);

    int x;
    for (int i = 2; i <= N; i++)
    {
        gc(x);
        Link(x, i);
    }

    DFS(1);
    printf("%d\n", Dp[1]);

    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    int ans = 7;
     if (s =="MON") ans = 6;
    else if (s == "TUE") ans = 5;
    else if (s == "WED") ans = 4;
    else if (s == "THU") ans = 3;
    else if (s == "FRI") ans = 2;
    else if (s == "SAT") ans = 1;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
lst1 = [a,b,c]
lst2 = sorted(lst1)
if lst2[0] == lst2[1] == lst2[2]:
    print("1")
elif lst2[0] == lst2[1] or lst2[1] == lst2[2] or lst2[2] == lst2[0]:
    print("2")
else:
    print("3")


Measured memory_bytes: 3060
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;

int main()
{
    string s,t;
    cin>>s>>t;
    int ma=INT_MAX;
    for(int i=0;i<s.size()-t.size()+1;i++)
    {
        int c=0;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]!=t[j])
            c++;
        }
        ma=min(c,ma);
    }
    cout<<ma;
    

    return 0;
}


Measured memory_bytes: 3604
function Main(input) {

  var tmp = input.trim().split("\n");
  var array = tmp.slice(0,tmp.length-1);
  var max = parseInt(tmp[tmp.length-1],10);
  array = array.map(val=>parseInt(val,10));
  var success = true;
  
  for(var i=0;i<array.length;i++){
    
    for(var j=0;j<array.length;j++){
      if(i>=j) continue;
      var dist = array[j]-array[i];

      if(max<dist) {
        success=false;    
        break;
      }
    }
  }
  console.log(success?"Yay!":":(")
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
a;main(b){
	scanf("%d%d",&a,&b);
	puts("99 99");
	for(int i=0;i<99;i++)
	{
		for(int j=0;j<99;j++)
		{
			putchar((i%2|j%2||(i<49?b--:a--)<2)^i>48?'.':'#');
		}
		puts("");
	}
}

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

int main() {
  int x, A, B;
  
  cin >> x >> A >> B;
  
  int da, db;
  
  if(A>x) da = A-x;
  else da = x-A;
  
  if(B>x) db = B-x;
  else db = x-B;
  
  if(da > db) cout << "B" << endl;
  else cout << "A" << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, v=0;
  cin >> n;
  vecll a(3 * n);
  forll(i, 0, 3 * n)
	cin >> a[i];
  sort(a.begin(), a.end());
  for (int i=n; i<3*n; i+=2)
	v += a[i];
  cout << v << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define sz(arr) (ll) arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

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

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int main() {
  Cin(ll, a, b);

  cout << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int temp;
        if(c<b) {
            temp = c;
            c = b;
            b = temp;
        }

        if(b<a) {
            temp = a;
            a = b;
            b = temp;
        }

        if(c<b){
            temp = c;
            c = b;
            b = temp;
        }

        System.out.println(a + " " + b + " " + c);
    }
}



Measured memory_bytes: 26172
//36
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  while (cin >> a >> b) {
    int c = a, d = b;
    int e;
    while ((e = c % d) > 0) {
      c = d;
      d = e;
    }
    cout << d << " " << a / d * b << endl;
  }
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////

/*
 * (0,0) ~~~~~ (0,w-1)
 *   |            |
 * (0,h) ~~~~~ (0,h-1)
 */

int mp[501][501] = {0};//map[w][h];
ll h,w;
void write(int x,int y,int num){//(x,y)にnumを移す
    if(x>=0 && x<w && y>=0 && y<h){
        mp[x][y]+=num;
    }else{
        // no action
    }
}

vi y10,x1,y2,x2;

int main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>mp[j][i];
        }
    }
    for(int i = h-1;i>=0;i--){
        rep(j,w-1){
            if(mp[j][i]%2!=0) {
                write(j + 1, i, 1);
                mp[j][i] -= 1;
                y10.pb(i);
                x1.pb(j);
                y2.pb(i);
                x2.pb(j + 1);
            }
        }
        if(mp[w-1][i]%2==1 && i!=0){
            write(w-1,i-1,1);
            mp[w][i]-=1;
            y10.pb(i);
            x1.pb(w-1);
            y2.pb(i-1);
            x2.pb(w-1);
        }
    }
    cout<<y10.size()<<endl;
    rep(i,y10.size()){
        cout<<y10[i]+1<<" "<<x1[i]+1<<" "<<y2[i]+1<<" "<<x2[i]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 5220
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
x = [0]*m
for i in range(n):
    for j in range(1, a[i][0] + 1):
        for k in range(1, 31):
            if a[i][j] == k:
                x[k-1] += 1
ans = 0
for l in x:
    if l == n:
        ans += 1
print(ans)

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

B = list(map(int, input().split()))

ans = 0
for _ in range(N):
    A = list(map(int, input().split()))

    wa = 0
    for i in range(M):
        wa += A[i] * B[i]

    if wa + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		a: [usize; n],
	}

	let mut i = 0;
	let mut count = 0;
	loop {
		count += 1;
		if count > n {
			println!("-1");
			return;
		}
		if a[i] == 2 {
			println!("{}", count);
			return;
		}
		i = a[i] - 1;
	}
}



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

using namespace std;

int n,niz[100005];
long long rj[100005];

int abs(int x, int y){
	return max(x,y)-min(x,y);
}

int main () {
	
	int k;
	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>niz[i];
		rj[i]=10000000000005;
	}
	rj[0]=0;
	rj[1]=abs(niz[1],niz[0]);
	for(int i=2; i<n; i++){
		for(int j=max(0,i-k); j<i; j++){
			rj[i]=min(rj[i],rj[j]+abs(niz[i],niz[j]));
		}
	}
	cout<<rj[n-1];
	
	return 0;
}

Measured memory_bytes: 1408
def count(N):
    pn = 2**(N+1)-1 #パテ
    bn = 2**(N+1)-2 #バン
    rn = pn + bn    #バーガー枚数(右端)
    return pn, bn, rn
    
if __name__ == "__main__":
    N, X = map(int, input().split())
    pn,bn,rn = count(N)
    mid = (1+rn)//2
    cnt = 0
    # Xの位置関係で場合分け
    while N > 0:
        # print(X,"l m r",1,mid,rn)
        # print("cnt",N,cnt)
        pn_prev, bn_prev, rn_prev = count(N-1)

        if X == 1:
            break
        elif X == mid:
            cnt +=  pn_prev + 1
            break
        elif rn == X:
            cnt += 2*pn_prev + 1
            break
        elif 1 < X < mid:
            X -= 1
        elif mid < X < rn:
            cnt += pn_prev + 1
            X -= mid

        pn, bn, rn = pn_prev,bn_prev,rn_prev
        mid = (1+rn)//2
        N -= 1
        if N == 0:
            cnt += 1
    print(cnt) #0段目のパテ

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
char field[1010][1010];
int score[1010][1010][4] = {0};//0 j 1 o 2 i
int main()
{
    char E[2][2];
    int x,y,cou = 0,ans = 0,mx,my;
    int dx[] = {0,1,0,1},dy[] = {0,0,1,1};
    scanf("%d%d",&y,&x);
    for(int i = 0; i < y; i++)
    {
        scanf(" %c",&field[0][i]);
        for(int j = 1; j < x; j++)
                scanf("%c",&field[j][i]);
    }
    for(int i = 0; i < 2; i++)
    {
        scanf(" %c",&E[0][i]);
        for(int j = 1; j < 2; j++)
                scanf("%c",&E[j][i]);
    }
    for(int i = 0; i < y ; i++)
        for(int j = 0; j < x ; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                if(field[j + dx[k]][i + dy[k]] == E[dx[k]][dy[k]])
                        cou++;
                else
                {
                    mx = j + dx[k];
                    my = i + dy[k];
                }
            }
            if(cou == 3)
            {
                if(E[mx - j][my - i] == 'J')score[mx][my][0]++;
                else if(E[mx - j][my - i] == 'O')score[mx][my][1]++;
                else score[mx][my][2]++;
            }
            else if(cou == 4)
            {
                ans++;
            for(int k = 0; k < 4; k++)
                score[j + dx[k]][i + dy[k]][3]--;
            }
            cou = 0;
        }
    for(int l = 0; l < 3; l++)
        for(int i = 0; i < y; i++)
            for(int j = 0; j < x; j++)
            {
                cou = max(cou,score[j][i][l] + score[j][i][3]);
            }
    printf("%d\n",ans + cou);
    return 0;
}

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

using namespace std;

#define li long long int
#define ld long double

const int N 	= 3e2 + 3;
const int mod 	= 1e9 + 7;

int n;
int cnt[4];
ld dp[N][N][N];

ld go(int x, int y, int z) {
	if (x == 0 and y == 0 and z == 0) return 0.0;
	if (dp[x][y][z] >= 0.0) return dp[x][y][z];
	ld sum = x + y + z;
	ld ans = n * 1.0 / sum;
	if (x) ans += go(x - 1, y + 1, z) * x * 1.0 / sum;
	if (y) ans += go(x, y - 1, z + 1) * y * 1.0 / sum;
	if (z) ans += go(x, y, z - 1) * z * 1.0 / sum;
	return dp[x][y][z] = ans;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				dp[i][j][k] = -1.0;
			}
		}
	}
	ld ans = go(cnt[3], cnt[2], cnt[1]);
	cout << fixed << setprecision(15);
	cout << ans;
}

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

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

int main() {
  string O,E;
  cin >> O >> E;
  for (int i=0; i<O.size()+E.size(); i++) {
      if (i%2==0) cout << O.at(i/2);
      else cout << E.at(i/2);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  long long int h, w; cin >> h >> w;
  long long int ans = 10000000000;
  for(int i = 1; i < w; i++){
    vector<long long int> a(3);
    a[0] = h * i;
    if((w - i) % 2 != 0 && h % 2 != 0){
      if((w - i) < h){
        a[1] = (h / 2 + 1) * (w - i);
        a[2] = (h / 2) * (w - i);
      }
      else{
        a[1] = ((w - i) / 2 + 1) * h;
        a[2] = (w - i) / 2 * h;
      }
    }
    else{
      a[1] = a[2] = (w - i) * h / 2;
    }
    long long int maxa = max(a[0], a[1]), mina = min(a[0], a[2]);
    ans = min(maxa - mina, ans);
  }
  for(int i = 1; i < h; i++){
    vector<long long int> a(3);
    a[0] = w * i;
    if((h - i) % 2 != 0 && w % 2 != 0){
      if((h - i) < w){
        a[1] = (w / 2 + 1) * (h - i);
        a[2] = (w / 2) * (h - i);
      }
      else{
        a[1] = ((h - i) / 2 + 1) * w;
        a[2] = (h - i) / 2 * w;
      }
    }
    else{
      a[1] = a[2] = (h - i) * w / 2;
    }
    long long int maxa = max(a[0], a[1]), mina = min(a[0], a[2]);
    ans = min(maxa - mina, ans);
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256