akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#define ll long long 
using namespace std;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
string str;
ll a[5000];
ll b[5000];
ll c[5000];
int main(){
	int n;
	ll ans=0;
	cin>>n;
	cin>>str;
	str="Z"+str;
	for(int i=1;i<str.length();i++)
	{
		if(str[i]=='R')
		{
			a[i]+=1;
		}
		if(str[i]=='G')
		{
			b[i]+=1;
		}
		if(str[i]=='B')
		{
			c[i]+=1;
		}
		a[i]+=a[i-1];
		b[i]+=b[i-1];
		c[i]+=c[i-1];
	}
	
	ll RR=0;
	for(int i=2;i<str.length();i++)
	{
		    if(str[i]=='R')
		    {
		    	 ll Q,s,H;
		    	 Q=b[i-1];
		    	 s=0;
		    	 H=c[str.length()-1]-c[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='G'&&2*i-j<str.length()&&str[2*i-j]=='B')
		    		{
		    			s++;
					}
				}
				RR+=(Q*H-s);
				ans+=(Q*H-s);
			   }
				
				 Q=c[i-1];
		    	 s=0;
		    	 H=b[str.length()-1]-b[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='B'&&2*i-j<str.length()&&str[2*i-j]=='G')
		    		{
		    			s++;
					}
				}
				RR+=(Q*H-s);
				ans+=(Q*H-s);
			   }
			}
			
			if(str[i]=='G')
		    {
		    	ll Q,s,H;
		    	 Q=a[i-1];
		    	 s=0;
		    	 H=c[str.length()-1]-c[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='R'&&2*i-j<str.length()&&str[2*i-j]=='B')
		    		{
		    			s++;
					}
				}
				ans+=(Q*H-s);
			   }
				
				 Q=c[i-1];
		    	 s=0;
		    	 H=a[str.length()-1]-a[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='B'&&2*i-j<str.length()&&str[2*i-j]=='R')
		    		{
		    			s++;
					}
				}
				ans+=(Q*H-s);
			   }
			}
			
			if(str[i]=='B')
		    {
		    	ll Q,s,H;
		    	 Q=a[i-1];
		    	 s=0;
		    	 H=b[str.length()-1]-b[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='R'&&2*i-j<str.length()&&str[2*i-j]=='G')
		    		{
		    			s++;
					}
				}
				ans+=(Q*H-s);
			   }
				
				 Q=b[i-1];
		    	 s=0;
		    	 H=a[str.length()-1]-a[i];
		    	if(Q!=0&&H!=0){
				for(int j=1;j<=i-1;j++)
		    	{
		    		if(str[j]=='G'&&2*i-j<str.length()&&str[2*i-j]=='R')
		    		{
		    			s++;
					}
				}
				ans+=(Q*H-s);
			   }
			}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll lcm(ll a, ll b){
  ll x = __gcd(a, b);
  return a / x * b;
}

int main(){
  ll N;
  cin >> N;
  vll T(N);
  ll x;
  for(int i = 0; i < N; i++){
    cin >> T.at(i);
    if(i == 0) x = T.at(i);
    x = lcm(x, T.at(i));
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
v = list(map(int, input().split()))

if k <= n:
    ans = - 10 ** 9
    for i in range(k + 1):
        for j in range(i + 1):
            tmp = v[:j]
            if i != j:
                tmp += v[-(i - j):]
            tmp.sort()
            ans = max(ans, sum(tmp[k - i:]))
            if k != i:
                ans = max(ans, sum(tmp[k - i - 1:]))

elif k >= 2 * n:
    v.sort(reverse = True)
    ans = 0
    for num in v:
        if num <= 0:
            break
        ans += num

else:
    ans = - 10 ** 9
    for i in range(n + 1):
        for j in range(i + 1):
            tmp = v[:j]
            if i != j:
                tmp += v[-(i - j):]
            tmp.sort(reverse = True)
            ans_tmp = 0
            for l, num in enumerate(tmp):
                if l >= 2 * i - k and num <= 0:
                    break
                ans_tmp += num
            ans = max(ans, ans_tmp)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int board[3][3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> board[i][j];
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				if (board[i][j] == a) board[i][j] = 0;
	}
	
	bool yes = 0;
	for (int i = 0; i < 3; i++) {
		bool flag = 1;
		for (int j = 0; j < 3; j++) if (board[i][j] != 0) flag = 0;
		yes |= flag;

		flag = 1;
		for (int j = 0; j < 3; j++) if (board[j][i] != 0) flag = 0;
		yes |= flag;
	}

	if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] == 0) yes = 1;
	if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[0][2] == 0) yes = 1;

	if (yes) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P =pair<int,int>;

ll gcd(ll a,ll b){
    ll c,d,e;
    c=max(a,b);
    d=min(a,b);
    while(1){
        c=c%d;
        if(c==0){
            break;
        }
        e=d;
        d=c;
        c=e;
    }
    return d;
}


int main(){
    ll n;
    ll zg;
    cin >> n;
    vector <ll> a(n);
    vector <int> hyo(1000001,0);
    rep(i,n){
        cin >> a[i];
        ++hyo[a[i]];
        if(i==0){
            zg=a[0];
        }
        else{
            zg=gcd(zg,a[i]);
        }
    }

    int ans1=0;
    int ans2=0;
    int ans3=0;

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

    ll k=0;

    if(zg!=1){
        cout << "not coprime" << endl;
    }
    else{
/*rep(i,n){
        k=2;
        if(i!=0){
            if(a[i]==a[i-1] and a[i]!=1){
                ans1=-1;
            }
        }
        while(k*a[i]>1000001){
            if(hyo[k*a[i]]!=0){
                ans1=-1;
            }
        }
    }
    }*/
    ll ko;

    rep(i,1000001){
        if(i>=2){
            k=1;
            ko=0;
            while(i*k<1000001){
                if(hyo[i*k]!=0){
                    ko+=hyo[i*k];
                }
                ++k;
            }
            if(ko>=2){
                ans1=-1;
            }

        }
    }

    if(ans1==0){
        cout << "pairwise coprime" << endl;
    }
    else{
        cout << "setwise coprime" << endl;
    }
    }
    

    return 0;
}

Measured memory_bytes: 14784
#include<stdio.h>
#include<math.h>
int main()
{
    long long int H;
    scanf("%llu",&H);
    long long int sum=1,i=1;
    while(H>1)
    {
        H=H/2;
        sum+=pow(2,i);
        i++;
    }
    printf("%llu",sum);
}


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

int main(){
    int a, b;

    cin >> a >> b;

    if (a > b) {
        cout << "a > b\n";
    } else if (a < b) {
        cout << "a < b\n";
    } else {
        cout << "a == b\n";
    }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    ll count=0;
    
    for(ll i=0;i<1000;++i){
        bool end=false;
        rep(j,N-2){
            if(S.at(j)-'0'==i/100){
                for(ll k=j+1;k<N-1;++k){
                    if(S.at(k)-'0'==(i-i/100*100)/10){
                        for(ll l=k+1;l<N;++l){
                            if(S.at(l)-'0'==i-i/10*10){
                                count++;
                                end=true;
                                break;
                            }
                        }
                        break;
                    }
                }
                break;
            }
        }
    }
    cout<<count<<endl;
    }


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

int main() {
  int a, b;
  string relation;

  scanf("%d %d", &a, &b);

  if (a < b) {
    relation = "<";
  } else if (a > b) {
    relation = ">";
  } else {
    relation = "==";
  }

  printf("a %s b\n", relation.c_str());
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<pair<int, int>> ab(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end());
  priority_queue<int> q;
  int k = 0;
  ll ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    while (k < n && i + ab[k].first <= m) {
      q.push(ab[k].second);
      k++;
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1660
def draw(i):
    global p,q,hd,wd
    B[p][q] = i
    if (q < W-1 and hd != -1):
        hd = 1
        wd = 0
    elif (hd == 1 and q == W-1) or (hd == -1 and q == 0):
        hd = 0
        wd = 1
    elif (q > 0 and hd != 1):
        hd = -1
        wd = 0
    p += wd
    q += hd

if __name__ == '__main__':
    p = 0
    q = 0
    hd = 1
    wd = 0
    H, W = list(map(int, input().split()))
    N = int(input())
    As = list(map(int, input().split()))
    B = [[0 for i in range(W)] for j in range(H)]

    for i in range(N):
        for j in range(As[i]):
            draw(i+1)

    for i in range(H):
        s = list(map(str, B[i]))
        print(' '.join(s))




Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

    for(int i = 1; i < 4; i++){
        if(S[i-1] == S[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let v1 = read_t_in_line::<i32>();
    let v2 = read_t_in_line::<i32>();
    let (hl, wl) = (v1[0], v1[1]);
    let (h, w) = (v2[0], v2[1]);
    println!("{}", hl * wl - h * wl - hl * w + h * w);

}


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

typedef long long ll;
typedef vector<int> vi;

#define pb push_back

void slove()
{
	set<string> gacha;
	int n;
	string x;
	cin >> n;
	while(n--) {
		cin >> x;
		gacha.insert(x);
	}
	cout << gacha.size() << endl;
}

int main() 
{
	int t;
	t = 1;
	while(t--) {
		slove();
	}
	return 0;
}


Measured memory_bytes: 19124
#include <bits/stdc++.h>
#define maxN 1<<20
#define BIG 1<<30
#define INF 1<<60
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define desLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
using namespace std;

typedef struct{int x,y;}point;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r)
{
    if(l>=r)return;
    int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);
	if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);
}

ll min4(ll a,ll b,ll c,ll d){return min(min(a,b),min(c,d));}
ll max4(ll a,ll b,ll c,ll d){return max(max(a,b),max(c,d));}



int main()
{
	int n, h, w;
	while ( cin >> n >> h >> w )
	{
		printf("%d\n", (n-h+1)*(n-w+1));
	}
	return 0;
}











Measured memory_bytes: 256
/*
看你入眠的侧脸，有多美，和你丢下的一切，好匹配，
我还以为我能，多狼狈，我自以为
——《暧昧》薛之谦
*/
#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
// #define MPS
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int n, Ans;
map<ll,int> Cnt;

int main()
{
	#ifdef MPS
		fp("agc03d.in","r",stdin);
		fp("agc03d.out","w",stdout);
	#endif
	sf("%d",&n);
	fo(i,1,n)
	{
		ll x; sf("%lld",&x);
		for(int j = 2; 1ll * j * j * j <= x; ++ j)
			while(x % (1ll * j * j * j) == 0)
				x /= (1ll * j * j * j);
		Cnt[x] ++;
	}
	if(Cnt[1]) Ans = 1, Cnt.erase(1);
	for(auto p: Cnt)
	{
		ll x = p.fi, z, fix = 1;
		int y = p.se;
		for(int j = 2; 1ll * j * j * j <= x; ++ j)
			if(x % j == 0)
			{
				if(x % (1ll * j * j) == 0)
					x /= (1ll * j * j), fix *= j;
				else
					x /= j, fix *= (1ll * j * j);
			}
		z = sqrt(x);
		if(z * z == x) fix *= z; else fix *= x * x;
		if(Cnt.count(fix) == 0) //there is no such j can satisify i*j = cubic
			Ans += y;
		else
		{
			Ans += max(Cnt[fix], y);
			Cnt.erase(fix);
		}
	} 
	pf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x < 1200){
			System.out.print("ABC");
		}else{
			System.out.print("ARC");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll a, b, c, d, x, y, z, h, w, n, e;

void input()
{
    cin >> n >> a >> b >> c >> d >> e;
}

void solve()
{
    ll sum = 0;
    ll m = min({a, b, c, d, e});
    sum += n % m == 0 ? n / m : n / m + 1;
    sum += 4;

    cout << sum << endl;
}
int main()
{
    input();
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b,m;
  cin >> a>>b>>m;
  int a_arr[a];
  int b_arr[b];
  int m_arr[m][3];
  int mina=INT_MAX;
  int minb=INT_MAX;
  rep(i,a){
    cin >> a_arr[i];
    if(a_arr[i]<mina){
      mina=a_arr[i];
    }
  }
  rep(i,b){
    cin >> b_arr[i];
    if(b_arr[i]<minb){
      minb=b_arr[i];
    }
  }
  int ans = mina+minb;
  rep(i,m){
    rep(j,3){
      cin >> m_arr[i][j];
    }
    int discount_ans = a_arr[m_arr[i][0]-1]+b_arr[m_arr[i][1]-1]-m_arr[i][2];
    if(discount_ans<ans){
      ans=discount_ans;
    }
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	char s[105];

	while(scanf("%s",s)!=EOF){
		int len,n[105]={},ans=0;
		len=strlen(s);
		rep(i,0,len){
			if(s[i]=='I') n[i]=1;
			else if(s[i]=='V') n[i]=5;
			else if(s[i]=='X') n[i]=10;
			else if(s[i]=='L') n[i]=50;
			else if(s[i]=='C') n[i]=100;
			else if(s[i]=='D') n[i]=500;
			else if(s[i]=='M') n[i]=1000;
		}
		rep(i,0,len-1){
			if(n[i]<n[i+1]) ans-=n[i];
			else ans+=n[i];
		}
		ans+=n[len-1];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  bool ex=true;
  if(s[0]!='A')
    ex=false;
  int n=s.size();
  int cnt=0,c=0;
  for(int i=2;i<n-1;i++){
    if(s[i]=='C')
      c++;
  }
  if(c!=1) ex=false;
  rep(i,n){
    if(isupper(s[i]))
       cnt++;
  }
  if(cnt!=2) ex=false;
  if(ex) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}

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

int64_t lcm(int64_t x, int64_t y)
{
  return (x * y) / __gcd(x, y);
}

int main()
{
  int N;
  cin >> N;
  int64_t a, prev = 1;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    prev = lcm(a, prev);
  }
  cout << prev << endl;
}


Measured memory_bytes: 3104
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b = map(int,input().split())
    if a==1 and b!=1:
        print("Alice")
    elif a!=1 and b==1:
        print("Bob")
    elif a==b:
        print("Draw")
    elif a>b:
        print("Alice")
    else:
        print("Bob")
    return

if __name__=='__main__':
    main()


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

using namespace std;

typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    
    ll res = 0;
    
    if(K % 2 != 0){
        ll cnt = 0;
        for(int i = 1; i <= N; i++){
            if(i % K == 0){
                cnt++;
            }
        }
        res = cnt * cnt * cnt;
    }
    else{
        ll cnt = 0;
        for(int i = 1; i <= N; i++){
            if(i % K == 0){
                cnt++;
            }
        }
        res = cnt * cnt * cnt;
        
        cnt = 0;
        for(int i = 1; i <= N; i++){
            if((i - K / 2) % K == 0){
                cnt++;
            }
        }
        res = res + cnt * cnt * cnt;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
label = {
    1: 0,
    3: 0,
    5: 0,
    7: 0,
    8: 0,
    10: 0,
    12: 0,
    4: 1,
    6: 1,
    9: 1,
    11: 1,
    2: 2
}
x, y = map(int, raw_input().split())
print "Yes" if (label[x] == label[y]) else "No"

Measured memory_bytes: 2568
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
const int p=1000000007;
int n,f[100100],g[100100];
LL a[100100],x,y;

LL getLL()
{
    char ch;
    while (!isdigit(ch=getchar()));
    LL x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%lld%lld",&n,&x,&y);
    repu(i,1,n)
        a[i]=getLL();
    f[0]=g[0]=1,f[1]=g[1]=p-1,a[0]=-1LL<<61,a[n+1]=1LL<<61;
    for (int i=0,l1=1,r1=1,l2=1,r2=1; i<n; ++i)
    {
        for (l1=max(l1,i+1); a[l1+1]-a[i]<x; ++l1);
        for (r1=max(r1,i+1); r1<n && a[r1+1]-a[r1]>=y; ++r1);
        for (l2=max(l2,i+1); a[l2+1]-a[i]<y; ++l2);
        for (r2=max(r2,i+1); r2<n && a[r2+1]-a[r2]>=x; ++r2);
        if (l1<=r1)
            (g[l1]+=f[i])%=p,(g[r1+1]+=p-f[i])%=p;
        if (l2<=r2)
            (f[l2]+=g[i])%=p,(f[r2+1]+=p-g[i])%=p;
        (f[i+1]+=f[i])%=p,(g[i+1]+=g[i])%=p;
    }
    printf("%d\n",(f[n]+g[n])%p);
    return 0;
}

Measured memory_bytes: 1664
while True:
    (n, x) = map(int, input().split())
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n - 1):
        xi = x - i
        for j in range(i+1,n):
            if xi - j - j <= 0:
                break
            if xi - j <= n:
                c += 1
    print(c)

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
const int maxn=200000+10;
int n,m;
int a[maxn],f[maxn],INF,du[maxn],ans;
bool v[maxn];
char s[maxn];
int main(){
	cin>>n>>m;
	scanf("%s",s+1);
	int l=2,r=n;
	while(l<=n){
		if(s[l]==s[l-1]){
			l++; continue;
		}
		else{
			l++;
			int tmp1=l-1;
			while(s[l]==s[l-1]) l++;
			for(int i=tmp1; i<l; i++){
				if(s[i]=='L') s[i]='R';
				else s[i]='L';
			}
			l++;
			m--;
			if(m==0) break;
		}
	}
	for(int i=1; i<=n; i++){
		if(s[i]==s[i-1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3844
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAX = 1e3+10;
const int MAXX = 1e5;
const ll MOD = 1e9+7;

ll dp[MAX][MAX];
int N, A, B, C, D;

ll fac[MAXX];  /// fac[n] = n!
ll finv[MAXX]; /// (fac[n] * finv[n]) % MOD = 1
ll inv[MAXX];  /// (n * inv[n]) % MOD = 1

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAXX; i++) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}

ll nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll pow(ll x, int n) {
  ll ret = 1;
  while (n) {
    if (n&1) (ret *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return ret;
}

int main() {

  init();
  cin >> N >> A >> B >> C >> D;

  dp[A][0] = 1;
  for (int i = A*C; i <= min(N, A*D); i += A) dp[A][i] = nCk(N, i) * fac[i] % MOD * pow(finv[A], i/A) % MOD * finv[i/A] % MOD;
  
  for (int i = A+1; i <= B; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i][j] = dp[i-1][j]; // i人のグループを使わない時
      for (int k = C; k <= D; k++) {
        if (j-k*i < 0) break;
        (dp[i][j] += dp[i-1][j-k*i] 
            * nCk(N-(j-k*i), k*i) % MOD // 残りのN-(j-k*i)人のうちk*i人を選出する。
            * fac[k*i] % MOD // そのk*i人を順番に並べる
            * pow(finv[i], k) % MOD // i人ずつ、k人のグループごとにする。
            * finv[k]) %= MOD; // グループの順番は関係ない
      }
    }
  }

  cout << dp[B][N] << endl;
}

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

#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 all(a) (a).begin(),(a).end()

int main() {
	vector<int> A(3);
	cin>>A[0]>>A[1]>>A[2];
	sort(all(A));
	int ans=A[2]-A[0];
	cout<<ans<<endl;
}

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

int main() {
 int N,count;
 count = 0;
 cin >> N;
 for(int i = 0;i < N; i++){
     int l,r;
     cin >> l >> r;
     count += r-l+1;
 }
 cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2LL << endl;
  } else {
    if (a - 1LL < n - b) {
      cout << (a - 1LL) + 1LL + (b - a - 1LL) / 2 << endl;
    } else {
      cout << (n - b) + 1LL + (b - a - 1LL) / 2 << endl;
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var M = consoleReader.Int;
            return (N - 1) * (M - 1);
        }


        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


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

const int MAX_N = 2e5+10;
ll N,K;
ll A[MAX_N],F[MAX_N];

bool ok(ll T)
{
	ll sum = 0;
	for(int i=0;i<N;++i){
		if(A[i]*F[i]>T){
			sum += A[i]-T/F[i];
		}
	}
	return sum <= K;
}

void solve()
{
	sort(A,A+N,greater<ll>());
	sort(F,F+N);
	ll lo=-1, hi=1e18+10;
	while(lo+1<hi){
		ll mid = (lo+hi)/2;
		if(ok(mid)) hi=mid;
		else lo=mid;
	}
	cout << hi << "\n";
}

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

Measured memory_bytes: 3328
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] num = ReadLine().Split(' ');
        int n = int.Parse(num[0]);
        int k = int.Parse(num[1]);
        int m = int.Parse(num[2]);
        int d = n+m+k;
        int a = (n+k+m)/2;
        if((a == n || a == m||a==k )&& d%2==0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14

char H[M][L]; 

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key %(M - 1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
  

  if(strcmp(H[h],str) == 0)return 1;
  else if(strlen(H[h]) == 0)return 0;
}
  return 0;


}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16060
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n  = BigInt(sc.nextLine())
    val (a,b)=(n/11,n%11)

    val c = if (b>6)2 else if (b==0) 0 else 1

    println(a*2+c)
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	ll N = S.size();

	ll res = 0;
	REP(i, N) res += (S[i] - '0');
	REP(i, N){
		if(S[i]==0) continue;
		ll tmp = 0;
		REP(j, N) if(j<i) tmp += (S[j] - '0');
		REP(j, N) if(i<j) tmp += 9;
		tmp += ((S[i] - '0') - 1);
		res = max(res, tmp);
		//dump(i)
		//dump(tmp)
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
L = [str(input()) for _ in range(H)]
ans = [[0] * W for _ in range(H)]
dh = [1, 1, 1, 0, 0, -1, -1, -1]
dw = [-1, 0, 1, -1, 1, -1, 0, 1]
for h in range(H):
    for w in range(W):
        if L[h][w] == '#':
            ans[h][w] = '#'
        else:
            for i in range(8):
                nh = h + dh[i]
                nw = w + dw[i]
                if 0 <= nh < H and 0 <= nw < W and L[nh][nw] == '#':
                    ans[h][w] += 1
for row in ans:
    print(*row, sep='')



Measured memory_bytes: 3444
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        var r = input[i]
        var m = Math.floor(r * r * Math.PI * Math.pow(10, 6)) / Math.pow(10, 6)
        var e = Math.floor(2 * r * Math.PI * Math.pow(10, 6)) / Math.pow(10, 6)
        console.log(m, e)
    }
}

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


Measured memory_bytes: 15424
using System;

namespace ABC051
{
    class Program
    {
        static void Main(string[] args)
        {
            const int MAX_V = 110;
            const int MAX_E = 1100;
            // Warshall–Floyd Initialize

            int[,] dist = new int[MAX_V, MAX_E];
            for (int i = 0; i < MAX_V; i++)
            {
                for (int j = 0; j < MAX_V; j++)
                {
                    dist[i, j] = 1000000;
                    //Console.WriteLine(dist[i, j]);
                }
                dist[i, i] = 0;
            }

            string[] input;
            input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int[] a = new int[M];
            int[] b = new int[M];
            int[] c = new int[M];
            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ');
                a[i] = int.Parse(input[0]) - 1;
                b[i] = int.Parse(input[1]) - 1;
                c[i] = int.Parse(input[2]);

                dist[a[i], b[i]] = c[i];
                dist[b[i], a[i]] = c[i];
            }

            // Warshall–Floyd
            for (int k = 0; k < N; k++)
            {
                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);

                    }
                }
            }

            int result = 0;
            for (int i = 0; i < M; i++)
            {
                if (c[i] > dist[a[i], b[i]]) result++;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13168
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char str[1001];
    while(1){
        scanf("%s",str);
        if(str[0] == '0') break;
        int sum = 0;
        for(int i=0;i<strlen(str);i++){
            sum += (str[i] - '0');
        }printf("%d\n",sum);
        
    }
}


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

int main() {
  char c[2][3];
  rep(i,2) rep(j,3) cin >> c[i][j];
  if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string x;
    cin>>x;
    if(x==s)
        cout<<--a<<" "<<b;
    else
        cout<<a<<" "<<--b;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N=sc.nextInt();
        int M=sc.nextInt();

        if (M==N)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N+2);
  for(int i=1; i<N+1; i++){
    cin >> vec.at(i);
  }
  
  vector<int> dis(N+1);
  for(int j=0; j<N+1; j++){
    dis.at(j) = abs(vec.at(j) - vec.at(j+1));
  }
  int64_t all = 0;
  for(int i=0; i<N+1; i++){
    all += dis.at(i);
  }
  int64_t ans_all = all;
  for(int i=0; i<N; i++){
    all = all - dis.at(i) - dis.at(i+1);
    all += abs(vec.at(i) - vec.at(i+2));
    cout << all << endl;
    all = ans_all;
  }
}

Measured memory_bytes: 2048
#include <cstdio>
#include <map>

int A[1000000];

int main(){
  
  std::map<int,int> A;
  int n,m,ans=0;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    A[a%1000000]=1;
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);
    ans+=A[a%1000000];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 5100
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<cmath>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  double a,b,h,m;
  double x,y;
  cin >> a >> b >> h >> m;
  m = 60*h+m;
  x = 6*m;
  y = 0.5*m;
  double d = abs(x-y);
  while(d>=360) d-=360;
  double ans = a*a+b*b - 2*a*b*cos((d*M_PI)/180.0);
  cout << sqrt(ans) << endl;
}


Measured memory_bytes: 4244
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
    string s;
    cin >> n >> s;
    if (n & 1) cout << "No\n";
    else{
        n >>= 1;
        bool flag = true;
        for (int i = 0; i < n; i++){
            if (s[i] != s[n+i]){
                flag = false;
                break;
            }
        }
        if (flag) cout << "Yes\n";
        else cout << "No\n";
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(final String[] args) {
		final Scanner sc = new Scanner(System.in);
		// 入力
		final int N = sc.nextInt();
		int ans = 0;
		int tmp = 0;
		final int[] H = new int[N];
		Arrays.setAll(H, i -> sc.nextInt());
		sc.close();

		for (int i = 0; i < N - 1; i++) {
			if (H[i] >= H[i + 1]) { // 判定
				tmp++;
				// 毎回ansに入れる
				ans = Math.max(ans, tmp);
			} else {
				tmp = 0;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49512
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f

int map[15][15];
void floyd(int n)
{
	for(int k=0;k<=n;k++)
	{
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				map[i][j]=min(map[i][j],map[i][k]+map[k][j]);
			}
		}
	}
}
int main()
{
	int n,i,j,a,b,t;
	while(scanf("%d",&n),n)
	{
		int m=0;		
//		for(i=1;i<=n;i++)
//		{
//			for(j=1;j<=n;j++)
//			{
//				if(i==j) map[i][j]=0;
//				else	map[i][j]=INF;
//			}
//		}
		memset(map,INF,sizeof(map));
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d",&a,&b,&t);
			map[a][b]=map[b][a]=min(map[a][b],t);
			if(a>m) m=a;
			if(b>m) m=b;
		}
		floyd(m);
		int tmp=0,ans=INF,k;
		for(i=0;i<=m;i++)
		{
			for(j=0;j<=m;j++)
			{
				if(i==j)
					continue;
				tmp+=map[i][j];
			}
			if(tmp<ans)	
			{
				ans=tmp;
				k=i;
			}
			tmp=0;
		}
		printf("%d %d\n",k,ans);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d>=k)cout<<x-k*d;
    else {
      k-=x/d;
      if(k%2)cout<<d-x%d;
      else cout<<x%d;
    }
  return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        boolean ans = false;
        for (int i = 0; i < s.length() * 2; i++) {
            if (s.equals(t))
                ans = true;
            s = s.substring(s.length() - 1) + s.substring(0, s.length() - 1);
        }
        System.out.println(ans ? "Yes" : "No");
    }

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,t,a[3000],b[3000];
    cin>>n>>t;
    vector<P> A;
    rep(i,n) cin>>a[i]>>b[i],A.push_back(P(a[i],b[i]));
    sort(A.begin(),A.end());
    rep(i,n) a[i]=A[i].first,b[i]=A[i].second;
    int dp[3001][6001]={0};
    rep(i,n)rep(j,t+3001){
        if(0<=j-a[i]&&j-a[i]<t) dp[i+1][j]=max(dp[i][j],dp[i][j-a[i]]+b[i]);
        else if(0<=j-a[i]) dp[i+1][j]=max(dp[i+1][j-1],dp[i][j]);
        else dp[i+1][j]=dp[i][j];
    }
    cout<<dp[n][t+3000];
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	string S;
	cin >> N >> S;
	int R = 0;
	int L = 0;
	rep(i, N){
		if(S[i] == '(')R++;
		else{
			if(R == 0)L++;
			else R--;
		}
	}
	rep(i, L)cout << '(';
	cout << S;
	rep(i, R)cout << ')';
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()



int main(){
    int n,m;
    cin >> n >> m;
    vector<pii> data(m);
    rep(i,m){
        cin >> data.at(i).first >> data.at(i).second;
    }
    rep(i,1000){
        bool flag = true;
        string s = to_string(i);
        if(s.size() != n) continue;
        rep(j,m){
            char comp =  '0' + data.at(j).second;
            if(s.at(data.at(j).first-1) != comp){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << s << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

/*
int main(){
    int n,m;
    cin >> n >> m;
    vector<pii> data(m);
    rep(i,m) cin >> data.at(i).first >> data.at(i).second;
    sort(all(data));
    vector<char> ans(n,'@');
    rep(i,m){
        int s = data.at(i).first - 1;
        int c = data.at(i).second;
        if(ans.at(s) != '@' && ans.at(s) != ('0' + c)){
            cout << -1 << endl;
            return 0;
        }
        ans.at(s) = '0' + c;
    }
    rep(i,n){
        if(ans.at(i) == '@') ans.at(i) = '0';
    }
    if(n > 1){
        if(ans.at(0) == '0'){
            cout << -1 << endl;
            return 0;
        }
        
    }
    rep(i,n) cout << ans.at(i);
    cout << endl;
}*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007
using namespace std;
int32_t main(){
    int h,w,i,j;
    cin>>h>>w;
    char a[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    int dp[h][w];
    mem(dp,0);
    dp[0][0]=1;
    for(i=1;i<w;i++){
        if(a[0][i]=='#'){
            break;
        }
        else{
            dp[0][i]=1;
        }
    }
    for(i=1;i<h;i++){
        if(a[i][0]=='#'){
            break;
        }
        else{
            dp[i][0]=1;
        }
    }
    for(i=1;i<h;i++){
        for(j=1;j<w;j++){
            if(a[i][j]=='#' || (a[i-1][j]=='#' && a[i][j-1]=='#')){
                continue;
            }
            else if(a[i-1][j]=='#'){
                dp[i][j]=(dp[i][j]+dp[i][j-1]+MOD)%MOD;
            }
            else if(a[i][j-1]=='#'){
                dp[i][j]=(dp[i][j]+dp[i-1][j]+MOD)%MOD;
            }
            else{
                dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1]+MOD)%MOD;
            }
        }
    }
    cout<<dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int a[100001],b[100001];
int main(int argc, const char * argv[])
{
    int n,x,y,x1=0,x2=0,y1=0,y2=0,a1=0,b1=0;
    cin>>n;
    for(int i=0;i<n/2;i++)
    {
        cin>>x>>y;
        a[x]++;
        if(x1<a[x])
        {
            x1=a[x];
            a1=x;
        }
        else if(x2<a[x])
            x2=a[x];
        b[y]++;
        if(y1<b[y])
        {
            y1=b[y];
            b1=y;
        }
        else if(y2<b[y])
            y2=b[y];
    }
    if(a1!=b1)
        cout<<n-x1-y1<<endl;
    else
        cout<<n-max(x1+y2,x2+y1)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N, K; cin >> N >> K;
    map<long long, long long> vals;
    for (int i = 0; i < N; i++) {
        long long a, b; cin >> a >> b;
        vals[a] += b;
    }
    long long counter = 0;
    for (auto& val : vals) {
        counter += val.second;
        if (K <= counter) {
            cout << val.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
var R = mutableListOf<String>()
fun main(args: Array<String>) {
    val N = nextInt()
    val P = listOfInt().joinToString(separator = "")
    val Q = listOfInt().joinToString(separator = "")
    val A = Array<Int>(N) { it + 1 }
    permutation(A.toIntArray())
    var p = 0
    var q = 0
    for (a in R) {
        if (a == P) break;
        p += 1
    }
    for (a in R) {
        if (a == Q) break;
        q += 1
    }
    println(Math.abs(p - q))
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun permutation(seed: IntArray) {
    val perm = IntArray(seed.size)
    val used = BooleanArray(seed.size)
    buildPerm(seed, perm, used, 0)
}
fun buildPerm(seed: IntArray, perm: IntArray, used: BooleanArray, index: Int) {
    if (index == seed.size) {
        procPerm(perm)
        return
    }
    for (i in seed.indices) {
        if (used[i]) continue
        perm[index] = seed[i]
        used[i] = true
        buildPerm(seed, perm, used, index + 1)
        used[i] = false
    }
}
fun procPerm(perm: IntArray) {
    R.add(perm.joinToString(separator = ""))
}


Measured memory_bytes: 43444
n=int(input())
dlist = list(map(int, input().split()))
answer=0

dlist=sorted(dlist)
#print(dlist)

manaka=int(n/2)

sho=dlist[manaka-1]
dai=dlist[manaka]

#print(sho, dai)
if sho==dai:
    print(0)
else:
    print(dai-sho)

Measured memory_bytes: 13992