akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, K; cin >> N >> K;
  vector <ll> A(N);
  vector <ll> Minus, Zero, Plus;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    if (A[i] < 0) Minus.push_back(-1 * A[i]);
    else if (A[i] > 0) Plus.push_back(A[i]);
    else Zero.push_back(0);
  }
  
  sort(Minus.begin(), Minus.end());
  sort(Plus.begin(), Plus.end());
  ll M = Minus.size(), P = Plus.size(), Z = Zero.size();

  if (K <= M * P){
    K--;
    ll ansL = 0, ansR = 1e18 + 1;

    while (ansR - ansL > 1){
      ll now = (ansL + ansR) / 2;
      ll cnt = 0;
      for (int i = 0; i < Minus.size(); i++){
        if (Minus[i] * Plus[0] >= now){
          cnt += Plus.size();
          continue;
        }
        if (Minus[i] * Plus[P - 1] < now){
          continue;
        }

        int P_L = 0, P_R = P;
        while (P_R - P_L > 1){
          int num = (P_L + P_R) / 2;
          if (Minus[i] * Plus[num] < now) P_L = num;
          else P_R = num;
        }
        cnt += P - P_R;
      }
      
      if (K >= cnt) ansR = now;
      else ansL = now;
    }

    cout << -1 * ansL << endl;
    return 0;
  }

  if (K <= M * P + (M + P) * Z + Z * (Z - 1) / 2){
    cout << 0 << endl;
    return 0;
  }

  K -= M * P + (M + P) * Z + Z * (Z - 1) / 2;
  ll ansL = 0, ansR = 1e18 + 1;
  while (ansR - ansL > 1){
    ll now = (ansL + ansR) / 2, cnt = 0;

    for (int i = 1; i < Minus.size(); i++){
      if (Minus[i] * Minus[0] > now) continue;
      if (Minus[i] * Minus[i - 1] <= now){
        cnt += i; continue;
      }

      int M_Left = 0, M_Right = i - 1;
      while (M_Right - M_Left > 1){
        int num = (M_Left + M_Right) / 2;

        if (Minus[i] * Minus[num] <= now) M_Left = num;
        else M_Right = num;
      }
      cnt += M_Right;
    }
    
    for (int i = 1; i < Plus.size(); i++){
      if (Plus[i] * Plus[0] > now) continue;
      if (Plus[i] * Plus[i - 1] <= now){
        cnt += i; continue;
      }

      int P_Left = 0, P_Right = i - 1;
      while (P_Right - P_Left > 1){
        int num = (P_Left + P_Right) / 2;

        if (Plus[i] * Plus[num] <= now) P_Left = num;
        else P_Right = num;
      }
      cnt += P_Right;
    }
    
    if (K <= cnt) ansR = now;
    else ansL = now; 
  }
  cout << ansR << endl;
  
  return 0;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll ans[101][1000001];
int main()
{
  ll n,w;
  cin>>n>>w;
  ll ans[2][100001],flag=0;
  memset(ans,0,sizeof(ans));
  for(ll i=0;i<n;i++)
  {
     ll val,ww;
      cin>>ww>>val;
      for(ll j=0;j<val;j++)
        ans[flag][j] = ans[flag^1][j];

      if(ans[flag^1][val] == 0) ans[flag][val] = ww;
      else ans[flag][val] = min(ans[flag^1][val],ww);

      for(ll j=1;j+val <100001;j++)
      {

         if(ans[flag^1][j]) 
          {
            if(ans[flag^1][j+val])
              ans[flag][j+val] = min(ans[flag^1][j+val],ans[flag^1][j] + ww);
            else 
              ans[flag][j+val] = ans[flag^1][j] +ww;
          }
          else
          {
            ans[flag][j+val] = ans[flag^1][j+val];
          }
      }

     /*for(int j=0;j<=20;j++)
        cout<<j<<" "<<ans[flag][j]<<endl;
      cout<<endl;*/
      flag^=1;
  }

  ll sum =0;

  for(ll i=0;i<=100000;i++)
  {
    if(ans[flag^1][i] && ans[flag^1][i] <=w)
      sum = i;
  }
  cout<<sum<<endl;
}
              

Measured memory_bytes: 1792
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  assert(p > n)
  # p は素数である必要がある。典型的には 10**9 + 7 とか

  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0

  fac = [1, 1]
  inv = [1, 1]
  finv = [1, 1]
  for i in range(2, n+k+1):
    fac.append(fac[i-1] * i % p)
    inv.append(p - inv[p%i] * (p//i) % p)
    finv.append(finv[i-1] * inv[i] % p)

  return fac[n] * (finv[k] * finv[n-k] % p) % p



x, y = [int(c) for c in input().split()]

if (x + y) % 3 != 0:
  print(0)
  exit(0)

i = (2*x - y) // 3
j = (-x + 2*y) // 3

rem = 10**9 + 7
ans = comb(i + j, i, rem)

print(ans)


Measured memory_bytes: 122000
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
X=0
for i in range(N):
  A=list(map(int,input().split()))
  Y=0
  for i in range(M):
    Y+=A[i]*B[i]
  Y=Y+C
  if Y>0:
    X+=1
  else:
    pass
print(X)

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val W = sc.nextInt()
    val H = sc.nextInt()
    val N = sc.nextInt()
    var LX = 0
    var LY = 0
    var HX = W
    var HY = H
    repeat(N) {
        val x = sc.nextInt()
        val y = sc.nextInt()
        val a = sc.nextInt()
        when (a) {
            1 -> LX = Math.max(LX, x)
            2 -> HX = Math.min(HX, x)
            3 -> LY = Math.max(LY, y)
            4 -> HY = Math.min(HY, y)
        }
    }
    println(Math.max(0, HX - LX) * Math.max(0, HY - LY))
}

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

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S.at(i) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(S.at(i) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int N;

int chain(int i,vector<vector<int>>&stone){
	REP(l,5){
		RFOR(r,l+2,5){
			int t = -INF;
			FOR(j,l,r+1){
				if(stone[i][j]==-1)break;
				if(t == -INF)t = stone[i][j];
				else{
					if(t != stone[i][j])break;
				}
				if(j == r){
					FOR(k,l,r+1)stone[i][k] = -1;
					return t * (r+1-l);
				}
			}
		}
	}
	return 0;
}

int solve(){
	vector<vector<int>>stone(N,vector<int>(5));
	REP(i,N)REP(j,5)cin>>stone[i][j];
	int score = -1,ret = 0;
	int loop = 0;
	while(score){
		score = 0;
		REP(i,N)score += chain(i,stone);
		int flg;
		do{
			flg = 0;
			REP(i,N-1)REP(j,5)if(stone[i+1][j] == -1 && stone[i][j] != -1){
				swap(stone[i+1][j],stone[i][j]);
				flg = 1;
			}
		}while(flg);
		ret += score;
		loop++;
	}
	return ret;
}

signed main(){
	vector<int>ans;
	while(cin>>N,N)ans.push_back(solve());
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int fn(0);
if(a==b&&c!=a&&c!=b)
fn=1;
if(a==c&&b!=a&&b!=c)
fn=1;
if(b==c&&a!=b&&a!=c)
fn=1;
if(fn)
cout<<"Yes";
else
cout<<"No";
}


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

int main(){
  int N;
  cin >> N;
  ll count = 0;                                   //最悪値は10^5 * (10^5-1) / 2  -> 64bit
  map<string, int> anagram;

  for(int i = 0; i < N; i++){
    string s;  cin >> s;
    sort(s.begin(), s.end());
    if(!anagram.count(s))
      anagram[s] = 0;                      //存在を記憶
    else{
      count += anagram[s] + 1;  //アナグラム関係の語句n個 -> n*(n-1)/2が値となる ((n-1)+...+1)
      anagram[s] += 1;                    //当該関係の単語数が1増加
    }
  }

  cout << count << endl;
  

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int w,h,x,y;
    cin>>w>>h>>x>>y;

    int l = 2*x - w;
    int r = 2*y - h;
    cout<<fixed<<setprecision(20)<<double(h)*double(w)/(float)2<<" "<<((l==0&&r==0)?'1':'0')<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string.h>
#include <algorithm>
//#include <bits/stdc++.h>
#include    <vector>
#define INF 999999999
# include <cstdio>
# include <cstdlib>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int n ,k ,num=0, fa =0;
struct shi{
    int x ;
    int y ;
    int next;
}S[200010];
int head[200010];
int dfs(int yy,  int a){
    if(yy==n&&a==2)
    {
        return 1;
    }
    for(int i = head[yy];i!=-1;i=S[i].next)
    {
        int k = S[i].y;
        if(dfs(k,a+1))
            return 1;
    }
    return 0;
}
int main(){
   cin >>n>>k;memset(head,-1,sizeof(head));
   for(int i=1;i<=k;i++)
   {

       int t , l;
       cin>>t >>l;
       S[num].x = t , S[num].y = l;
       S[num].next = head[t];
       head[t] = num++;
   }
   if(dfs(1 , 0 ))
    cout<<"POSSIBLE"<<endl;
   else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 3456
n,k = map(int,input().split())
a = list(map(int,input().split()))
sun = sum(a)
cd = []
rcd = []
for i in range(1,int(sun**0.5)+1):
  if sun % i == 0:
    cd.append(i)
    rcd.append(sun//i)
rcd.reverse()
if cd[-1] == rcd[0]:
  del cd[-1]
gcd = cd + rcd
gcd.reverse()
#print(gcd)
count = -1
while True:
  count += 1
  g = gcd[count]
  b = list(map(lambda x: x % g,a))
  moon = sum(b)
  luna = moon // g
  b.sort()
  score = sum(b[:n-luna])
  if score <= k:
    print(g)
    break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};




int main()
{

    int N,M,K;
    cin >> N >> M >> K;
    ll ans = 0;
    ll n = (ll)N; ll m = (ll)M; ll k = (ll)K;
    
    combination C(n*m);
    ll A = C.com(n*m-2,k-2);
    ll b = 0;
    rep(i,M){
        ans += (ll)i*n*n*A*(ll)(M-i)%mod;
        ans %= mod;
    }
    rep(i,N){
        ans += (ll)i*m*m*A*(ll)(N-i)%mod;
        ans %= mod;
    }
    
    out(ans%mod);


    return 0;
}


Measured memory_bytes: 3328
baisuu = gets.to_i
kazu = gets

ijyou = kazu.split(" ")[0].to_i
ika = kazu.split(" ")[1].to_i
for num in ijyou..ika do
    if num % baisuu == 0
        puts "OK"
        @ppap = "AA"
        return 
    end
end
if @ppap == nil
    puts "NG"
end

Measured memory_bytes: 14372
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans
for i in range(N):
    ans.push_back(graph[i].size())

print(*ans, sep='\n')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Array.Sort(A);
        Array.Reverse(A);

        var bob = 0;
        var alice = 0;
        for (var i = 0; i < N; i++)
        {
            if (i % 2 == 0)
            {
                alice += A[i];
            } else
            {
                bob += A[i];
            }
        }
        
        Console.WriteLine(alice - bob);
    }
}


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

void printArray(int A[], int N){
    for(int i = 0; i < N; i++){
        if(i == 0){
            cout << A[i];
        }else{
            cout << " " << A[i];
        }
    }
    
    cout << endl;
}
void bubbleSort(int A[], int N){
    bool flag = true;
    int inversion = 0; //反転数
    
    
    while(flag){
        flag = false;
        for(int j = N-1; j >= 1; j--){
            if(A[j] < A[j-1]){
                inversion++;
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = true;
            }
        }
    }
    
    printArray(A,N);
    cout << inversion << endl;
    
}

int main(void){
    int N;
    cin >> N;
    
    int A[N];
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    bubbleSort(A, N);
    
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define EPS 1e-9

typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat& A,const vec& b){
	int n=A.size();
	mat B(n,vec(n+1));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			B[i][j]=A[i][j];
		}
		B[i][n]=b[i];
	}

	for(int i=0;i<n;i++){
		int piv=0;
		for(int j=i;j<n;j++){
			if(abs(B[j][i])>abs(B[piv][i]))piv=j;
		}
		swap(B[i],B[piv]);
		if(abs(B[i][i])<EPS)return vec();
		for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
			}
		}
	}
	vec x(n);
	for(int i=0;i<n;i++)x[i]=B[i][n];
	return x;
}

int n;
double x[11],y[11],l[11];

bool judge(double xx,double yy,double zz){
	bool ok=true;
	rep(i,n){
		if(pow(xx-x[i],2)+pow(yy-y[i],2)+pow(zz,2)-pow(l[i],2)>EPS)ok=false;
	}
	return ok;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n)cin>>x[i]>>y[i]>>l[i];
		double res=0;
		{ /// 1
			rep(i,n){
				if(judge(x[i],y[i],l[i])){
					maxch(res,l[i]);
				}
			}
		}
		//dbg(res);
		{ /// 2
			rep(i,n)rep(j,i){
				if(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)-pow(l[i]+l[j],2)>EPS)continue;
				//dbg(i);dbg(j);
				double d=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
				//dbg(d);
				double xx=(l[i]*l[i]-l[j]*l[j]+d*d)/(2*d);
				//dbg(xx);
				double vx=(xx/d)*x[j]+((d-xx)/d)*x[i];
				double vy=(xx/d)*y[j]+((d-xx)/d)*y[i];
				double vz=sqrt(l[i]*l[i]-xx*xx);
				if(judge(vx,vy,vz)){
					maxch(res,vz);
				}
			}
		}
		//dbg(res);
		{ /// 3
			rep(i,n)rep(j,i)rep(k,j){
				mat A(2,vec(2));
				vec b(2);
				A[0][0]=2*(x[j]-x[i]); A[0][1]=2*(y[j]-y[i]);
				A[1][0]=2*(x[k]-x[i]); A[1][1]=2*(y[k]-y[i]);
				b[0]=l[i]*l[i]-l[j]*l[j]-(x[i]+x[j])*(x[i]-x[j])-(y[i]+y[j])*(y[i]-y[j]);
				b[1]=l[i]*l[i]-l[k]*l[k]-(x[i]+x[k])*(x[i]-x[k])-(y[i]+y[k])*(y[i]-y[k]);
				vec X=gauss_jordan(A,b);
				//dbg(X.size());
				if(X.size()!=2)continue;
				else{
					double vx=X[0], vy=X[1];
					double vz=sqrt(l[i]*l[i]-pow(vx-x[i],2)-pow(vy-y[i],2));
					//dbg(vz);
					if(judge(vx,vy,vz)){
						maxch(res,vz);
					}
				}
			}
		}
		printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

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

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main() {
    // vector<vector<int>> bingo(3, vector<int>(3, 1));
    // vector<vector<int>> appear(3, vector<int>(3, 1));
    int bingo[3][3];
    bool appear[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> bingo[i][j];
        }
    }
    int n; 
    cin >> n;

    if (n < 3)
    {
        /* code */
        cout << "No" << endl;
        return 0;
    }
    

    int b[10];
    rep(i, n) {
        cin >> b[i];
    }

    rep(j, n) {
        rep(k, n) {
            appear[j][k] = false;
            rep(l, n) {
                if (b[l] == bingo[j][k])
                {
                    /* code */
                    appear[j][k] = true;
                }
            }
        }
    }
    string ans = "No";
    rep(i, 3) {
            if (appear[i][0] and appear[i][1] and appear[i][2])
            {
                ans = "Yes";
                cout << ans << endl;
                return 0;
            }
    }
    rep(j, 3) {
            if (appear[0][j] and appear[1][j] and appear[2][j])
            {
                ans = "Yes";
                cout << ans << endl;
                return 0;
            }
    }
    if (appear[0][0] and appear[1][1] and appear[2][2]) { 
        ans = "Yes";
        cout << ans << endl;
        return 0;
    }
    if (appear[2][0] and appear[1][1] and appear[0][2]) {
        ans = "Yes";
        cout << ans << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
  int width,number;
  cin >> width >> number;
  int change[number][2];
  string str;
  for(int i=0; i<number; i++){
    scanf("%d,%d",&change[i][0],&change[i][1]);
  }
  int bou[width+1];
  for(int i=0; i<width+1; i++){
    bou[i] = i;
  }
  int temp;
  for(int i=0; i<number; i++){
    temp = bou[change[i][0]];
    bou[change[i][0]] = bou[change[i][1]];
    bou[change[i][1]] = temp;
  }

  for(int i=1; i<width+1; i++){
    cout << bou[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <stdlib.h>

long stack[100];
int stack_p = 0;

void push(long value)
{
    stack[stack_p++] = value;
}

long pop()
{
    int value = 0;
    if (stack_p > 0) {
        value = stack[stack_p - 1];
        stack_p--;
    }
    return value;
}

int main(int argc, char *argv[])
{
    char str[7] = {'\0'};
    long result = 0;

    while (scanf("%s", str) != EOF) {
        if (str[0] == '+') {
            long b = pop();
            long a = pop();
            push(a + b);
        }
        else if (str[0] == '-') {
            long b = pop();
            long a = pop();
            push(a - b);
        }
        else if (str[0] == '*') {
            long b = pop();
            long a = pop();
            push(a * b);
        }
        else if (str[0] == 'Z') {
            break;
        }

        else {
            push(atoi(str));
        }
    }
    printf ("%ld\n", pop());
    return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int a = 0;
  int b = 0;
  int c = 0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) == 'a'){
      a++;
    }
    if(S.at(i) == 'b'){
      b++;
    }
    if(S.at(i) == 'c'){
      c++;
    }
  }
  
  int max_abc = max(a,b);
  max_abc = max(max_abc,c);
  int min_abc = min(a,b);
  min_abc = min(min_abc,c);
  
  bool exist = true;
  if(max_abc >= min_abc+2){
      exist = false;
  }
  if(exist){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <stdio.h>

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

	scanf("%d%d%d", &a, &b, &c);
	if (a == b && b == c)
		cnt = 1;
	else if (a == b || b == c || a == c)
		cnt = 2;
	else
		cnt = 3;
	printf("%d\n", cnt);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "Yes" << endl;
    return 0;
  }
  if (s[1] == s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

#define fr first
#define sc second
#define pii pair < int, int >

const int N = 1e5;
int dp[N + 1], h[N + 1];

#define name "lifeguards"

main()
{
	//freopen(name".in", "r", stdin);
	//freopen(name".out", "w", stdout);
	int n, k; cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	
	
	for(int i = 2; i <= n; i++)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for(int j = 1; j <= k && i > j; j++)
		{
			dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
		}
	}
	
	cout << dp[n] << endl;
}
/***
***/


Measured memory_bytes: 1024
N = int(input())
h = list(map(int, input().split()))
maxh = max(h)

count = 0
for i in range(maxh):
    flag = False
    for j in range(N):
        if h[j] > 0:
            flag = True
        if h[j] == 0 and flag:
            count += 1
            flag = False
        elif j == N-1 and flag:
            count += 1
    h = [x-1 if x >= 1 else 0 for x in h]
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());

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

	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(i % 2 == 0) cout << s[i];
	}
	cout << endl;
}


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

int main () {
    string S, T;
    cin >> S >> T;  
    int times =0;
    for (int i =0; i < S.length(); i++){
        if (S[i] == T[i]){
            times += 1;
        }
    }

    cout << times;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000001;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int x; cin>>x;

  int i=0;
  int z=0;
  while(1){
    z+=i;
    if(z>=x){
      cout<<i<<endl;
      return 0;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#define ll long long
#define PI 3.1415926
using namespace std;
const int maxn=4e4+10;
int main() {
	int n;
	cin>>n;
	printf("%.3f\n",n*2*PI);
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N < 105 ) {
    cout << 0 << endl;
  }
  else if(N < 135){
    cout << 1 << endl;
  }
  else if(N < 165 ) {
    cout << 2 << endl;
  }
    else if(N < 189){
      cout << 3 << endl;
    }
  else if(N < 195) {
    cout << 4 << endl;
  }
  else {
    cout << 5 << endl;
  }
}

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

using namespace std;

int main() {
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  int l[100001];
  int r[100001];
  for (int i = 0; i < Q; ++i) cin >> l[i] >> r[i];

  int table[100001];

  int now = 0;
  table[0] = 0;
  for (int i = 0; i < N-1; ++i) {
    if (S[i] == 'A' && S[i+1] == 'C') {
      ++now;
    }
    table[i+1] = now;
  }

  for (int i = 0; i < Q; ++i) {
    cout << table[r[i]-1] - table[l[i]-1]  << endl;
  }


  return 0;
}

Measured memory_bytes: 2176
from collections import deque

N, M, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)

shortest = N + 1
ans = []
for s in range(1, N + 1):
    D = [-1] * (N + 1)
    P = [-1] * (N + 1)

    D[s] = 0
    Q = deque([s])
    while Q:
        p = Q.popleft()
        for c in E[p]:
            if D[c] < 0:
                D[c] = D[p] + 1
                P[c] = p
                Q.append(c)

    for t in range(1, N + 1):
        if t == s or D[t] < 0:
            continue

        for v in E[t]:
            if v != s:
                continue

            T = [s]
            cur = t
            while cur != s:
                T.append(cur)
                cur = P[cur]

            if shortest > len(T):
                shortest = len(T)
                ans = T

if shortest == N + 1:
    print(-1)
else:
    print(len(ans))
    print("\n".join(map(str, ans)))

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

// #include "../../template-proj/myMente.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int r,d,x;
	cin>>r>>d>>x;
	ll xi = x;
	up(i,1,10+1,1){
		xi = xi*r-d;
		ote(xi);
	}
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> lis(n+1);
    REP(i, 1, n+1){
        for(ll l = i; l < n+1; l+=i){
            lis[l]++;   
        }
    }
    REP(i, 1, n+1){
        ans += lis[i] * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81336
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = 'a' -  'A' + s[k-1];
    cout << s << endl;
    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc126.contest.atcoder.jp/tasks/abc126_a


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法


int main(void) {
	std::ios_base::sync_with_stdio(false);

	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'o') count++;
	}
	int need = 8 - count;
	int rest = 15 - S.size();
	if (need > rest) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())

x_z = max(x) + 1  #以上 最低ライン
y_z = min(y)  #以下 最高ライン

if x_z <= y_z:
  if X < x_z <= Y:
    ans = "No War"
  else:
    for i in range(abs(y_z - x_z)):
      if X < x_z <= Y:
       ans = "No War"
       break
      else:
        x_z += 1
  if not X < x_z <= Y:
    ans = "War"
else:
  ans = "War"

print(ans)

Measured memory_bytes: 3064
numList = input().split()
r = int(numList[0])
c = int(numList[1])
a = [[0 for i in range(c + 1)] for j in range(r + 1)]

for i in range(r):
        sum = 0
        list = input().split()
        for j in range(c):
                a[i][j] = int(list[j])
                sum += a[i][j]
        a[i][c] = sum

for j in range(c + 1):
        sum = 0
        for i in range(r):
                sum += a[i][j]
        a[r][j] = sum

for i in range(r + 1):
        for j in range(c + 1):
                if j < c:
                        print(a[i][j], "", end = "")
                else:
                        print(a[i][j], end = "")
        print()


Measured memory_bytes: 6748
#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        int A,B;
          scanf("%d",&A);
          scanf("%d",&B);
          if (A%2==1&&B%2==1) {
            printf("Yes\n" );
          }else{
            printf("No\n" );
          }
        return 0;

}


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

int main() {
  int n;
  cin >> n;
  n = n % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon" << endl;
  }
  else if (n == 3) {
    cout << "bon" << endl;
  }
  else {
    cout << "pon" << endl;
  }
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 r, c; _i64 sum = 0; vector<vector<_i64>> sheet; vector<_i64> vertical;
        cin >> r >> c; sheet.resize(r, vector<_i64>(c)); vertical.resize(c, 0);
        _rep(i, r) { _rep(j, c) { cin >> sheet[i][j]; } }
        _rep(i, r) {
            _rep(j, c) {
                cout << sheet[i][j] << " ";
                vertical[j] += sheet[i][j];
                sum += sheet[i][j];
            }
            cout << accumulate(_all(sheet[i]), 0) << endl;
        }
        _foreach(e, vertical) { cout << e << " "; }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }   
    vector<int> dp(N,INF);
    dp[0] = 0;
    REP(i, N-1){
        Rep(j, 1, K+1){
            if(i+j < N){
                chmin(dp[i+j], dp[i]+abs(H[i+j] - H[i]));
            }   
        }
    }

    pr(dp[N-1]);
}

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

#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)

int main() {
    ll n,m;
    cin >> n >> m;
    if(n>=1&&n<=9&&m>=1&&m<=9) cout << n*m << endl;
    else cout << -1 << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	double ans=0.0;
	for(int m=1; m<=n; m++){
		int p=1;
		while(p*m<k) p*=2;
		ans+=1.0/p;
	}
	ans/=n;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if (!n) {printf("0");return 0;}
    string ans="";
    while (n!=0)
    {
        int t=n%(-2);
        n/=(-2);
        if (t==-1) {t=1;n++;}
        if (t==1) ans='1'+ans; else ans='0'+ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int, input().split(" "))
#count=0
arr=[]
for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
        #count+=1
        arr.append(i)
        #print(i)
#print(arr)

print(arr[-c])

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int, input().split()))
dp = [sys.maxsize]*N
dp[0] = 0

for i in range(1, N):
  dp[i] = min(dp[i], dp[i-1] + abs(H[i]-H[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(H[i]-H[i-2]))
print(dp[-1])    

Measured memory_bytes: 14016
from functools import reduce

N = int(input())
v = input()
v = map(lambda vi: int(vi), v.split())
v = list(v)

add = lambda a, b: a + b
sum = lambda list: reduce(add, list, 0)

v.sort()

v0 = v[0] / 2 ** (len(v) - 1)
v.pop(0)

total = v0 + sum([vi / 2 ** (len(v) - i) for i, vi in enumerate(v)])

print(total)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B,M;cin>>A>>B>>M;
    vector<ll> a(A),b(B),x(M),y(M),c(M);
    ll amin=INF,bmin=INF;
    
    for(int i=0;i<A;i++){
        cin>>a[i];
        amin=min(amin,a[i]);
    }
    for(int i=0;i<B;i++){
        cin>>b[i];
        bmin=min(bmin,b[i]);
    }
    
    for(int i=0;i<M;i++){
        cin>>x[i]>>y[i]>>c[i];
        x[i]--;
        y[i]--;
    }
    
    ll ans=amin+bmin;
    
    for(int i=0;i<M;i++){
        ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
    }
    
    cout<<ans<<endl;
}



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

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

  int t[100100], x[100100], y[100100];
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool ans = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int M = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < M) {
      ans = false;
      break;
    } else if (dt % 2 != M % 2) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
require 'scanf'
require 'matrix'

n = STDIN.gets.to_i
for i in 0..n-1 do
    str = STDIN.gets
    xa,ya,ra,xb,yb,rb=\
        str.scanf("%f %f %f %f %f %f\n") 
    ab=Vector[xa-xb,ya-yb].norm
    #b in a
    if rb+ab < ra then
        print "2\n"
    #a in b
    elsif ra+ab < rb then
        print "-2\n"
    #crossed
    elsif ab <= ra+rb then
        print "1\n"
    else
        print "0\n"
    end
end

Measured memory_bytes: 7052
object Main extends App {
  val n = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val a = scala.io.StdIn.readLine.split(" ").map(_.toInt).toList
  var sum = 0.0
  a.foreach { aa =>
    sum += (1.0 / aa)
  }
  println(1 / sum)
}


Measured memory_bytes: 25516
#include <iostream>
#include <vector>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  std::vector<int> a(9);
  for (int i = 0; i < 9; i++) {
    std::cin >> a[i];
  }

  int n;
  std::cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    std::cin >> tmp;
    for (int j = 0; j < 9; j++) {
      if (a[j] == tmp) {
        a[j] = -1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 3; i++) {
    int row = i * 3;
    if ((a[row] == a[row + 1]) && (a[row + 1] == a[row + 2])) {
      std::puts("Yes");
      return 0;
    }
  }
  for (int i = 0; i < 3; i++) {
    if ((a[i] == a[i + 3]) && (a[i + 3] == a[i + 6])) {
      std::puts("Yes");
      return 0;
    }
  }
  if ((a[0] == a[4]) && (a[4] == a[8])) {
    std::puts("Yes");
    return 0;
  }
  if ((a[2] == a[4]) && (a[4] == a[6])) {
    std::puts("Yes");
    return 0;
  }
  std::puts("No");

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 210000

int N, Q;
vector<pair<char,char> > golem;
string s;

int check(int num){
	if(num >= N) return 1;
	else if(num < 0)return -1;
	
	for(int i = 0; i < Q; i++){
		if(s[num] == golem[i].first){
			if(golem[i].second == 'R') num++;
			else num--;
		}
		// cout<<num<<" ";
		if(num >= N) return 1;
		if(num < 0) return -1;
	}
	return 0;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	char t, d;
	
	cin>>N>>Q;
	
	cin>>s;
	
	for(int i = 0; i < Q; i++){
		cin>>t>>d;
		golem.push_back(make_pair(t,d));
	}
	
	int low = -1, high = N+1, m, ans = 0;
	
	// for(int i = 0; i < N; i++){
	//	cout<<"i = "<<i<<" "<<check(i)<<endl;
	//	 }
	
	while(low + 1 < high){
		m = (low+high)/2;
		if(check(m) == -1) low = m;
		else high = m;
	}
	ans = high;
	low = -1, high = N+1;
	
	while(low + 1 < high){
		m = (low+high)/2;
		if(check(m) != 1) low = m;
		else high = m;
	}
	//cout<<ans<<" "<<N-high<<endl;
	
	ans = N-(ans+N-high);
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1100
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(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 (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

//繰り返し二乗
ll RepeatSquaring(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        return t*t;
    }
    return N * RepeatSquaring(N, P-1);
}
signed main() {
    SS(int,n,P)
    SV(ll,a,n);
    rep(i,n){
        if(a[i]%2!=0){
            p(RepeatSquaring(2,n-1));
            return 0;
        }
    }
    P==1?p(0):p(RepeatSquaring(2,n));
}

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

int main()
{
	int flag,flag2;
	string s,sub;
cin>>s;
	int l=sizeof(s);
	for(int i=0;i<s.size();i++)
	{
		flag=0;
		sub=s.substr(i,1);
//		cout<<sub<<endl;
		if(sub=="U"||sub=="D")
		flag=0;
		else{
		
		if((i+1)%2!=0)
		{
			if(sub!="R")
			{
				flag=1;
				break;
			}
		}else 
			if(sub!="L")
			{
				flag=1;
				break;
			}

}}
if(flag==0)
	cout<<"Yes"<<endl;
else
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

string f(string str,int n){
	int a,b;
	cin>>a>>b;
	--a;--b;
	if(n>1)str=f(str,n-1);
	str[a]=(str[a]-'a'+b-a)%26+'a';
	str[b]=(str[b]-'a'+b-a)%26+'a';
	swap(str[a],str[b]);
	return str;
}

int main() {
	int n;
	IL{
		string str;
		cin>>n;
		if(n==0)break;
		cin>>str;
		cout<<f(str,n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0