akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
#include <iostream>
#include <vector>
using namespace std;

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

  // trace
  vector<int> p(n, k-q); // point (upcount)
  // increment: 正解者
  for (int i=0; i<q; i++)
  {
    p[a[i] - 1]++;
  }

  // output
  for (int i=0; i<n; i++)
  {
    if (DEBUG) cout << p[i] << endl;
    if (p[i] <= 0)
    {
      cout << "No" << endl;
    }
    else
    {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    vector<int> a(5), b(5);
    int sum = 0;
    REP(i, 5) {
        cin >> a[i];
        if(a[i] % 10 == 0){
            sum += a[i];
        }else{
            sum += (int)(a[i] / 10 + 1) * 10;
        }
        b[i] = a[i] % 10;
    }
    sort(ALL(b));
    if (b[4] == 0){
        cout << sum << "\n";
    }else {
        REP(i, 5){
            if (b[i] != 0) {
                cout << sum - 10 + b[i] << "\n";
                break;
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

//拡張ユークリッド
//ax+by=1となるx,y
ll extgcd(int a, int b, int&x, int& y) {
	int d = a;
	if (b != 0) {
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

//逆元
ll mod_inverse(int a, int m) {
	int x, y;
	extgcd(a, m, x, y);
	return (m + x%m) % m;
}

//n!=a p^eとしたときのa mod p
ll fact[200001]; //n! mod pのテーブルO(p)
ll mod_fact(int n, int p, int& e) {
	e = 0;
	if (n == 0)return 1;
	//pの倍数部分
	ll res = mod_fact(n / p, p, e);
	e += n / p;
	if (n / p % 2 != 0)return res*(p - fact[n%p]) % p;
	return res*fact[n%p] % p;
}

//nCk mod p O(log_p n)
ll mod_comb(int n, int k, int p) {
	if (n<0 || k<0 || n<k)return 0;
	int e1, e2, e3;
	ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	if (e1>e2 + e3)return 0;
	return a1*mod_inverse(a2*a3%p, p) % p;
}


int main() {
	cin.sync_with_stdio(false);
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	ll k = 1;
	rep(i, H + W + 1) {
		if (i == 0)fact[i] = 1;
		else {
			k *= i;
			fact[i] = k%mod;
			k %= mod;
		}
	}
	ll ans = 0;
	reps(i, 1,H - A+1) {
		ans += mod_comb(B - 1 + i - 1, B - 1, mod)*mod_comb(W - B - 1 + H - i, W - B - 1, mod);
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;
int num,i=0;
double m,kg;
int main(void){
	while(~scanf("%d,%lf,%lf",&num,&kg,&m)){
		if(kg/(pow(m,2))>=25)printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    bool f = true;

    if (s[0] != 'A') f = false;
    int c = 0;
    for (int i = 2; i < s.size()-1; i++) if (s[i] == 'C') c++;
    if (c != 1) f = false;

    if (f) {
        rep(i, s.size()) {
            if (i == 0) continue;
            if (s[i] == 'C') continue;
            if (s[i] >= 'A' && s[i] <= 'Z') { 
                f = false;
            }
        }
    }

    if (f) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!
    val t = readLine()!!
    var ans = 0
    for (i in s.indices) {
        if (s[i] != t[i]) {
            ans++
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 40584
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  int N;
  cin >> N;
  int A = N/15;
cout <<  800 * N - 200 * A  << endl;
  return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
const int maxd = 12800;
const int kk = 6400;

int H,W;
int R[85][85];
int B[85][85];

bool dp[85][85][maxd];



int main()
{
    memset(dp,0,sizeof(dp));
    int H,W;
    cin >> H >> W;
    _for(i,0,H){
        _for(j,0,W){
            cin >> R[i][j];
        }
    }
    _for(i,0,H){
        _for(j,0,W){
            cin >> B[i][j];
        }
    }

    dp[0][0][kk+R[0][0]-B[0][0]] = true;
    dp[0][0][kk+B[0][0]-R[0][0]] = true;

    _for(i,0,H){
        _for(j,0,W){
            int r = R[i][j];
            int b = B[i][j];

            int p = r - b;
            int p2 = b - r;

            if(i){
                _for(k,0,maxd){
                    if(dp[i-1][j][k]){
                        int pp = p + k;
                        if(pp < maxd && pp >= 0) dp[i][j][pp] = true;
                        pp = p2 + k;
                        if(pp < maxd && pp >= 0) dp[i][j][pp] = true;
                    }
                }

            }
            if(j){
                _for(k,0,maxd){
                    if(dp[i][j-1][k]){
                        int pp = p + k;
                        if(pp < maxd && pp >= 0) dp[i][j][pp] = true;
                        pp = p2 + k;
                        if(pp < maxd && pp >= 0) dp[i][j][pp] = true;
                    }
                }
            }
        }
    }

    int ans = kk;
    _for(i,0,maxd){
        if(dp[H-1][W-1][i]){
            ans = min(ans,abs(i-kk));
        }
    }

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


Measured memory_bytes: 90624
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << x*min(k, n) + y*max(0, n - k) << endl;
	return 0;
}

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

typedef long long ll;

ll N;
vector<ll> D;

int main() {
  cin >> N;
  D.resize(N);
  for (ll i = 0; i < N; ++i) cin >> D[i];
  sort(D.begin(), D.end());
  cout << D[N / 2] - D[N / 2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  string S;
  cin>>S;
  vector<char>alf{'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'};
  
  rep(i,S.size()){
ll num=S[i]-'A'+N;
    num%=26;
    cout<<alf[num];
}
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

int main(){
    ll n;cin >> n;
    ll t=1;
    while(n>=t){
        t*=2;
    }
    cout << t/2 <<endl;
}

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

long long n,a,b,c,d;
int t;
map<long long,long long>s;

long long dfs(long long n=1e18)
{
	if(!n)
		return 0;
	if(s.count(n))
		return s[n];
	long long &ans=s[n];
	ans=(1e15)/n<d?1e15:n*d;
	ans=min(ans,dfs(n/2)+a+(n%2)*d);
	ans=min(ans,dfs(n/3)+b+(n%3)*d);
	ans=min(ans,dfs(n/5)+c+(n%5)*d);
	ans=min(ans,dfs(n/2+1)+a+(2-n%2)*d);
	ans=min(ans,dfs(n/3+1)+b+(3-n%3)*d);
	ans=min(ans,dfs(n/5+1)+c+(5-n%5)*d);
	return ans;
}

void work()
{
	cin>>n>>a>>b>>c>>d;
	s.clear();
	cout<<dfs(n)<<endl;
}

int main()
{
	cin>>t;
	while(t--)
		work();
}


Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll h,w;
  cin >> h >> w;
  vector<string> a(h);
  vector<bool> hb(h);
  vector<bool> wb(w);
  for(int i = 0;i < h;i++)hb[i] = true;
  for(int i = 0;i < w;i++)wb[i] = true;
  for(int i = 0;i < h;i++){
    cin >> a[i];
    for(int j = 0;j < w;j++){
      if(a[i][j] == '#')hb[i] = false,wb[j] = false;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(!hb[i] && !wb[j])cout << a[i][j];
    }
    if(!hb[i])cout << endl;
  }
}

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


using namespace std;


int main(void){
  
  string s,ans="No";

  cin >> s;
  
    if(s[0]!=s[1]){
      ans ="Yes";
    }
    if(s[2]!=s[1]){
      ans ="Yes";
    }

 
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<std::pair<int, int>> a;
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		
		a.push_back({x, i});
	}
	sort(begin(a), end(a));
	
	int L = n / 2, A = a[L - 1].first, B = a[L].first;
	std::vector<int> ans(n);
	for(int i = 0; i < n; i++) {
		if(i < L) ans[a[i].second] = B;
		else ans[a[i].second] = A;
	}
	for(auto v : ans) printf("%d\n", v);
	return 0;
}


Measured memory_bytes: 4592
a,b,k=map(int,raw_input().split())
a,b=min(a,b),max(a,b)
n=0
ans=1
for i in xrange(a,0,-1):
	if a%i==b%i==0:
		n=n+1
	if n==k:
		ans=i
		break
print ans

Measured memory_bytes: 2568
#include<bits/stdc++.h>
char name[100005][15];
int main(){
	int n;
	long long int m=0, a=0, r=0, c=0, h=0;
	long long int ans=0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%s", name[i]);
		if(name[i][0] == 'M') m++;
		if(name[i][0] == 'A') a++;
		if(name[i][0] == 'R') r++;
		if(name[i][0] == 'C') c++;
		if(name[i][0] == 'H') h++;
	}
	n = m+a+r+c+h;
	if(n<3){
		printf("0");
		return 0;
	}
	ans = m*a*(r+c+h) + m*r*(c+h) + m*c*h + a*r*(c+h) + a*c*h + r*c*h;
	printf("%lld", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k, a, b;
	cin >> k >> a >> b;
	if (k <= a || b <= a + 2) {
		dunk(k + 1);
		return 0;
	}
	k -= a - 1;
	ll ans = a;
	ans += (k / 2ll) * (b - a);
	if (k % 2 >= 1)ans++;
	dunk(ans);
	return 0;
}

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;
//using pint = pair<int,int>;
typedef pair<int,int> pint;

int n;
vector<vector<pint> > v;

bool judge(int bit){
    for(int i = 0; i < n; i++){
        if(!(bit & (1<<i)))continue;
        for(pint xy : v[i]){
            int x = xy.first;
            int y = xy.second;
            if(y==1 && !(bit&(1<<x)))return false;
            if(y==0 &&  (bit&(1<<x)))return false;
        }
    }
    return true;
}

int main(){
    cin >> n;
    v.resize(n);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        v[i].resize(a);
        for(int j = 0; j < a; j++){
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }
    int res = 0;
    for(int bit=0;bit<(1<<n);++bit){
        if(judge(bit)){
            int count = 0;
            for(int i = 0; i < n; i++){
                if(bit & (1<<i))count++;
            }
            res = max(res, count);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();

        // 処理
        int out = 0;

        //a
        int[] aa = new int[a];
        aa[0] = sc.nextInt();
        int aa_min = aa[0];
        for(int i = 1; i < a; i++){
            aa[i] = sc.nextInt();
            aa_min = (aa[i] < aa_min) ? aa[i] : aa_min;
        }

        //b
        int[] bb = new int[b];
        bb[0] = sc.nextInt();
        int bb_min = bb[0];
        for(int i = 1; i < b; i++){
            bb[i] = sc.nextInt();
            bb_min = (bb[i] < bb_min) ? bb[i] : bb_min;
        }

        //min
        int min = aa_min + bb_min;

        //m
        for(int i = 0; i < m; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();

            min = ((aa[x-1] + bb[y-1] - c) < min) ? (aa[x-1] + bb[y-1] - c) : min;
        }
        out = min;

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 130768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int turnNum = sc.nextInt();
        int tPoint = 0;
        int hPoint = 0;

        for(int i = 0; i < turnNum; i++) {
        	String tStr = sc.next();
        	String hStr = sc.next();

        	int check = tStr.compareTo(hStr);
        	if(check < 0) {
        		hPoint += 3;
        	} else if(check == 0) {
        		tPoint += 1;
        		hPoint += 1;
        	} else if(check > 0) {
        		tPoint += 3;
        	}

        }

        System.out.println(tPoint + " " + hPoint);

    }
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
vector<pair<pair<string,ll>,ll> > v;
bool comp(pair<pair<string,ll>,ll> x,pair<pair<string,ll>,ll> y)
{
    if(x.first.first<y.first.first)
    return true;
    else if(x.first.first>y.first.first)
    return false;
    if(x.first.second>y.first.second)
    return true;
    return false;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
        string s;
        ll val;
        cin>>s>>val;
        v.pb(mp(mp(s,val),i+1));
    }
    sort(all(v),comp);
    for(i=0;i<n;i++)
    cout<<v[i].second<<endl;
    return 0;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
nn = 0
while l = $stdin.gets do
  if lc == 0
    nn = l.chomp.to_i
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p inputs
end

if nn == 1
  puts 1
  exit
end

inputsy = inputs.clone
inputs.sort_by! {|x, y| x}
inputsy.sort_by! {|x, y| y}

comb = [*(0..nn-1)].combination(2).to_a

pd inputs
pd inputsy
pd comb

$statis = {}
comb.each do |c|
  pv = inputs[c[1]][0] - inputs[c[0]][0]
  qv = inputs[c[1]][1] - inputs[c[0]][1]

  if $statis["#{pv},#{qv}"] != nil
    $statis["#{pv},#{qv}"] += 1
  else
    $statis["#{pv},#{qv}"] = 1
  end
  
end

$statisy = {}
comb.each do |c|
  pv = inputsy[c[1]][0] - inputsy[c[0]][0]
  qv = inputsy[c[1]][1] - inputsy[c[0]][1]

  if $statisy["#{pv},#{qv}"] != nil
    $statisy["#{pv},#{qv}"] += 1
  else
    $statisy["#{pv},#{qv}"] = 1
  end
  
end


pd $statis
pd $statisy

tmp_max = 0
$statis.each do |k, v|
  if v > tmp_max
    tmp_max = v
  end
end

$statisy.each do |k, v|
  if v > tmp_max
    tmp_max = v
  end
end

puts (nn - tmp_max)


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

typedef long long LL;
const int inf=2000000000;
const LL INF=LL(inf)*inf;
const LL mod=1000000000+7;
#define sc(x) scanf("%d",&(x))
const int maxn = 300000 + 5;

string s;
int leftwest[maxn],righteast[maxn];
int main()
{
	string s;
	int t,n;	
	cin>>n;
	cin>>s;
	leftwest[0]=0;
	righteast[n-1]=0;
	for(int i=1;i<n;i++)
	{
		leftwest[i]=leftwest[i-1];
		if(s[i-1]=='W')
			leftwest[i]++;
	}
	for(int i=n-2;i>=0;i--)
	{
		righteast[i]=righteast[i+1];
		if(s[i+1]=='E')
			righteast[i]++;
	}
	int ans=inf;
	for(int i=0;i<n;i++)
	{
		ans=min(ans,leftwest[i]+righteast[i]);
	}
	printf("%d\n", ans);
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;


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

  int c[n], s[n], f[n];
  for(int i = 0; i < n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for(int i = 0; i < n; i++){
    int t = 0;
    for(int j = i; j < n-1; j++){
      int a = max(0, (t - s[j] + f[j] - 1) / f[j]);
      t = a*f[j] + s[j] + c[j];
    }
    cout << t << endl;
  }

  return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

template<class T>
T gcd(T a, T b)
{
	if (a < b) gcd(b, a);
	T r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

template<class T>
T lcm(T a, T b)
{
	T g = gcd<T>(a, b);
	return a / g * b;
}

ll a, b, c, d;
int main() {
	std::cin >> a >> b >> c >> d;

	auto g = lcm(c, d);

	std::cout << b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d - (b / g - (a - 1) / g)) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    sort(A.rbegin(),A.rend());
    int ans_n = A[0];
    int d = 1001001001;
    int ans_r = A[1];
    for(int i=1;i<n;i++){
        if(abs(A[i] - ans_n / 2) < d){
            d = abs(A[i] - ans_n / 2);
            ans_r = A[i];
        }
    }
    cout << ans_n << " " << ans_r << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#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 REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  cin >> n;
  ll maxi = -1;
  vector<ll> a(n);
  rep(i, n) cin >> a[i], maxi = max(maxi, a[i]);
  double ave = maxi / 2;

  ll index = 0, diff = LLONG_MAX;
  for(int i = 0; i < n; i++){
    if(maxi == a[i])continue;
    // cout << i << " " << a[i] << endl;
    if(abs(ave-a[i]) < diff){
      diff = abs(ave-a[i]);
      index = i;
    }
  }
  
  cout << maxi << " " << a[index] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000 + 100;
int e, Begin[Maxn], To[Maxn * 2], Next[Maxn * 2];
int Ans[Maxn],Vis[Maxn], Cnt, Tmp[Maxn];
int N, M;
inline void add_edge (int x, int y)
{
	To[++e] = y;
	Next[e] = Begin[x];
	Begin[x] = e;
}
inline void dfs(int x)
{
	Tmp[++Cnt] = x;
	Vis[x] = 1;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (Vis[y]) continue;
		dfs(y);
		return ;
	}
}
inline void dfs2(int x)
{
	Ans[++Cnt] = x;
	Vis[x] = 1;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (Vis[y]) continue;
		dfs2(y);
		return ;
	}
}
int main()
{
	scanf("%d%d", &N, &M);
	int x, y;
	for (int i = 1; i <= M; ++i)
	{
		scanf("%d%d",&x, &y);
		add_edge(x, y);
		add_edge(y, x);
	}
	dfs(1);
	for (int i = 1; i <= Cnt; ++i)
		Ans[i] = Tmp[Cnt - i + 1];
	Ans[Cnt--] = 0;
	dfs2(1);
	cout<<Cnt<<endl;
	for (int i = 1; i <= Cnt; ++i)
		printf("%d ", Ans[i]);
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    double a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;

    double slope, intercept;
    bool slopeinf=false;
    if(a1==a2) slopeinf = true;
    else if(b1==b2) slope = 0;
    else slope = (b1-b2) / (a1-a2);
    intercept = b1 - (slope*a1);

    double dist, sl_inv, x, y, xx, yy;
    
    int n; cin >> n;
    rep(i, n){
        cin >> x >> y;
        dist = abs(slope*x - y + intercept) / sqrt(slope*slope + 1);
        if(slopeinf){
            yy = y;
            if(a1<x) xx = a1;
            else xx = a1;
        }else{
            xx = (slope*slope*a1 - slope*b1 + x + slope*y) / (slope*slope+1);
            if(slope==0) yy = 0;
            else yy = (x - xx) / slope + y;
        }
        printf("%.12lf %.12lf\n", xx, yy);
    }
    return 0;
}


Measured memory_bytes: 3284
//pair
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K;cin >> K;
    int count = 0;
    vector<int> za(K);
    for(int i = 1 ; i <= K; i++){
        za.at(i - 1) = i;
    }

    for(int i = 0; i < K - 1; i++){
        for(int j = 0; j < K;j++){
            if(za.at(i) * za.at(j) % 2 == 1){
                count ++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N;
    cin >> N;
    vector<ll> C(N-1),S(N-1), F(N-1);
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i,N-1){
        ll cur = 0;
        for(int j=i;j<N-1;j++){
            cur = max(((cur + F[j] - ll(1))/F[j])*F[j] ,S[j]);
            cur += C[j];
        }
        cout << cur << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)

int main() {
  char s;
  cin >> s;
  s  += 1;
  cout << s << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1];

            Console.WriteLine(A%3==0||B%3==0||(A+B)%3==0? "Possible" : "Impossible");
        }
    }
}


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

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;
struct Sieve {
  int          n;
  vector <int> f, primes;
  Sieve(int n=1) : n(n), f(n + 1)
  {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) { continue; }
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) { f[j] = i; }
        // cout << j << '\n';
      }
    }
  }

  bool isPrime(int x)
  {
    return f[x] == x;
  }

  vector <int> factorList(int x)
  {
    vector <int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }

    return res;
  }

  vector <P> factor(int x)
  {
    vector <int> fl = factorList(x);
    if (fl.size() == 0) { return { }; }
    vector <P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }

    return res;
  }

  vector <ll> factorList(ll x)
  {
    vector <ll> res;
    for (int p : primes) {
      while (x % p == 0) {
        res.push_back(p);
        x /= p;
      }
    }
    if (x != 1) { res.push_back(x); }

    return res;
  }

  vector <pair <ll, int> > factor(ll x)
  {
    vector <ll> fl = factorList(x);
    if (fl.size() == 0) { return { }; }
    vector <pair <ll, int> > res(1, P(fl[0], 0));
    for (ll p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }

    return res;
  }
};

int main()
{
  ll n;
  cin >> n;
  Sieve s(1000005);
  ll    ans = 1;
  for (int i = 2; i < n; i++) {
    auto fs  = s.factor(i);
    ll   tmp = 1;
    for (auto p : fs) {
      tmp *= (p.second + 1);
    }
    ans += tmp;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7832
#include<cstdio>
#include<vector>
using namespace std;
#define LL long long

int n,m;
vector<int>a[100001];
char b[100001][2];
LL ans,sum[3];

inline char readc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=readc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=readc();
	return a;
}
void Dfs(int x,int d){
	b[x][d]=1;
	for(int i=0;i<a[x].size();++i)
		if(b[a[x][i]][d^1]==0)
			Dfs(a[x][i],d^1);
	return;
}
int main(void){
	n=read(),m=read();
	register int i,x,y;
	for(i=1;i<=m;++i)
		x=read(),y=read(),a[x].push_back(y),a[y].push_back(x);
	Dfs(1,0);
	for(i=2;i<=n;++i){
		if(b[i][0]&&!b[i][1])
			++sum[0];
		if(b[i][1]&&!b[i][0])
			++sum[1];
		if(b[i][1]&&b[i][0])
			++sum[2];
	}
	ans=sum[1]+sum[2];
	ans+=sum[2]*(sum[2]-1)>>1;
	ans+=sum[2]*sum[1];
	ans+=sum[2]*sum[0];
	ans+=sum[0]*sum[1];
	printf("%lld\n",ans-m);
	return 0;
}

Measured memory_bytes: 7936
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val list = listOfInt().sortedDescending()
    println(list[0] - list[1] + list[1] - list[2])
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33868
#include<stdio.h>
int main(){

int w,h;
int x,y,r;

scanf("%d%d",&w,&h);

scanf("%d%d%d",&x,&y,&r);

if(0<=x-r&&0<=y-r&&x+r<=w&&y+r<=h)printf("Yes\n");
else printf("No\n");

return 0;
}


Measured memory_bytes: 2592
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n;
        cin>>n;
        LL x=1000;
        LL y=n/x;
        LL z=n%x;
        if(z==0){
            cout<<0<<endl;
        }
        else{
            cout<<(y+1)*x-n<<endl;
        }
    return 0;
}

Measured memory_bytes: 3672
n = int(input())
h = list(map(int, input().split()))
INF = 10**18

dp = [INF]*n
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(2, n):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
    dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13924
mod = 10**9+7
def func(A, n, k):
    A.sort()
    product = 1
    if (A[n - 1] == 0 and (k & 1)):
        return 0
    if (A[n - 1] <= 0 and (k & 1)) :
        for i in range(n - 1, n - k - 1, -1):
            # print(A[i])
            product = (product*A[i])%mod
        return product%mod
    i = 0
    j = n - 1
    if (k & 1):
        product = (product*A[j])%mod
        j-= 1
        k-=1
    k >>= 1
    for itr in range( k):
        left_product = (A[i] * A[i + 1])
        right_product = (A[j] * A[j - 1])
        if (left_product > right_product):
            product = (product*(left_product)%mod)%mod
            i += 2
        else:
            product = ((right_product%mod)*product)%mod
            j -= 2
    return product%mod 

n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))
ans = func(arr,n,k)
print(ans)
# print(-6%mod)

Measured memory_bytes: 31692
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld Pi = 3.14159265359;

const ll Mod = 1000 * 1000 * 1000 + 7;
const ll MaxN = 2e5 + 10;
ll n;
ll k;
ll a[MaxN];
ll abss(ll x){
	if (x < 0) return x *= -1;
	return x;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	ll koj = 0;
	for (int i = 0; i < n; i++){
		if (a[i] <= 0) koj = i;
	} 
	ll Min = 1e9 + 10;
	ll Min1 = 1e9 + 10;
	for (int i = 0; i < n - k + 1; i++){
		//cout << i <<" " << i + k - 1<< endl;
		Min1 = min(abss(a[i] - 0ll) + abss(a[i + k - 1] - a[i]), abss(a[i + k - 1] - 0ll) + abss(a[i + k - 1] - a[i]));
		Min = min(Min1, Min);
	}
	cout << Min;

}



Measured memory_bytes: 1024
#include<stdio.h>

int main(){

    int s;
    scanf("%d",&s);

    int a[1000000];
    a[1] = s;

    int i = 2;
    while(1){
        if(a[i-1]%2 != 0)a[i] = 3*a[i-1]+1;
        else a[i] = a[i-1]/2;
        int j = 1;
        for(j=1;j<i;j++){
            if(a[i] == a[j]){
                printf("%d",i);
                return 0;
            }
        }
        i++;
    }


    return 0;
}


Measured memory_bytes: 128
#include <cstdio> 
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;
using ll = long long;

#define REP(i,s,N) for(ll i=s;i<N;++i)

int main() {
	ll n; scanf("%lld", &n);
	unordered_set<string> set;
	vector<string> ans;
	char cmd[9], val[14];
	REP(i,0,n) {
		scanf("%s %s", cmd, val);
		if (cmd[0] == 'i') {
			set.insert(val);
		} else if (cmd[0] == 'f') {
			ans.push_back((set.end() == set.find(val)) ? "no" : "yes");
		}
	}
	REP(i,0,ans.size()) cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 51960
def get_input():
    while True:
        try:
            yield "".join(input())
        
        except EOFError:
            break
            
def calcGCD(a,b):#?????§??¬?´???°????±?????????????????????????????????????????????¨?????????
    if a>b:
        large = a
        small = b
    elif a<b:
        large = b
        small = a
    else:
        return a
        
    
    while True:
        
        if large == small:
            return large
        
        temp_small = large - small
        
        if temp_small < small:
            large = small
            small = temp_small 
        else:
            large = temp_small
            small = small

def calcLCM(a,b,gcd):#????°???¬?????°????±??????????
    lcm = a*b/gcd
    
    return lcm
    


if __name__  == "__main__":
    array = list(get_input())
    for i in range(len(array)):
    
        temp_a,temp_b = array[i].split()
    
        a,b = int(temp_a),int(temp_b)
    
        gcd = calcGCD(a,b)
        lcm = calcLCM(a,b,gcd)
        lcm = int(lcm)
        
        print("{} {}".format(gcd,lcm))

Measured memory_bytes: 7676
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuffer p = new StringBuffer();
		StringBuffer q = new StringBuffer();
		for (int i = 0; i < n; i++) {
			p.append(sc.nextInt());
		}
		for (int i = 0; i < n; i++) {
			q.append(sc.nextInt());
		}
		sc.close();

		List<String> list = new ArrayList<String>();
		create(n, "", list);
		int pi = list.indexOf(p.toString());
		int qi = list.indexOf(q.toString());
		System.out.println(Math.abs(pi - qi));
	}

	public static void create(int n, String text, List<String> texts) {
		if (text.length() == n) {
			texts.add(text);
		}

		for (int i = 1; i <= n; i++) {
			if (!text.contains(String.valueOf(i))) {
				create(n, text + i, texts);
			}
		}
	}
}


Measured memory_bytes: 42732
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] c1, c2;
		int f = 0;

		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			c1 = new int[a];
			c2 = new int[b];
			int tmp;
			int s1 = 0, s2 = 0;
			f = 0;
			if (a == 0 && b == 0)
				return;

			for (int i = 0; i < a; i++) {
				c1[i] = sc.nextInt();
			}
			for (int i = 0; i < b; i++) {
				c2[i] = sc.nextInt();
			}

			for (int i = 0; i < a && f == 0; i++) {
				for (int j = 0; j < b && f == 0; j++) {
					s1 = 0;
					s2 = 0;
					tmp = c1[i];
					c1[i] = c2[j];
					c2[j] = tmp;

					for (int k = 0; k < a; k++)
						s1 += c1[k];
					for (int k = 0; k < b; k++)
						s2 += c2[k];
					//System.out.println(s1);
					//System.out.println(s2);
					if(s1 == s2) {
						System.out.println(c2[j] + " " + c1[i]);
						f = 1;
						break;
					}
					else {
						tmp = c1[i];
						c1[i] = c2[j];
						c2[j] = tmp;
					}
				}
			}
			if (f == 0)
				System.out.println("-1");
		}
	}
}


Measured memory_bytes: 29380
#include <iostream>

using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;

	int alen, blen;
	if (x-a < 0) alen = a-x;
	else alen = x-a;

	if (x-b < 0) blen = b-x;
	else blen = x-b;

	cout << (alen < blen ? "A" : "B") << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e2 + 5;

int x[maxn];
int ans[maxn];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
        scanf("%d", x + i);
    for (int i = 0; i < n; i++) {
        if (i == 0)
            ans[i] = x[i];
        else if (i < n - 1) {
            ans[i] = min(x[i - 1], x[i]);
        } else {
            ans[i] = x[i - 1];
        }
    }
    int fuck = 0;
    for (int i = 0; i < n; i++)
        fuck += ans[i];
    cout << fuck;
}

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

#define DUMP(x)  cerr << #x << " = " << (x) << endl;


void rotate(int *a, int *b, int *c, int *d) {
  int temp;

  temp = *d;
  *d = *c;
  *c = *b;
  *b = *a;
  *a = temp;
}

int main(int argc, char const* argv[])
{
  int i, n, total;
  string input;

  int up = 1, bottom = 6, left = 4, right = 3, front = 2, back = 5;

  while (true) {
    cin >> n;
    if (n == 0) { break; }

    up = 1;
    bottom = 6;
    left = 4;
    right = 3;
    front = 2;
    back = 5;
    total = 1;

    for (i = 0; i < n; i++) {
      cin >> input;

      if (input == "North") {
        rotate(&up, &back, &bottom, &front);
      } else if (input == "East") {
        rotate(&up, &right, &bottom, &left);
      } else if (input == "West") {
        rotate(&up, &left, &bottom, &right);
      } else if (input == "South") {
        rotate(&up, &front, &bottom, &back);
      } else if (input == "Right") {
        rotate(&front, &left, &back, &right);
      } else if (input == "Left") {
        rotate(&front, &right, &back, &left);
      }

      total += up;
    }

    cout << total << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define lint long long
#define pb(a) push_back(a)

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;

using namespace std;

int n;
int a[200000];
lint ans;

int main(){
  cin >> n;
  REP(i,n){
    int k;
    cin >> k;
    a[k]++;
  }
  for(int i = n-1; i>=0 ; i=i-2){
    //dump(i);
    //dump(a[i]);
    if(i==0){
      if(a[i]!=1){
        cout << 0 << endl;
        return 0;
      }
    }
    else if(a[i]!=2){
      cout << 0 << endl;
      return 0;
    }
  }
  ans = 1;
  REP(i,n/2){
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(){
	for(;;){
		int n,b,t,m,ab;
		float y,r,g[2],ag=0;
		scanf("%d",&n);
		if(n==0)break;
		scanf("%f",&y);
		for(m=0;m<n;m++){
			scanf("%d%f%d",&b,&r,&t);
			if(t==1)g[m]=1+y*r/100;
			else g[m]=pow(1+r/100,y);
			if(g[m]>ag){
				ag=g[m];
				ab=b;
			}
		}
		printf("%d\n",ab);
	}
	return 0;
}



Measured memory_bytes: 2828
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    H, W = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for i in range(H):
        c = 0
        for j in range(W):
            if S[i][j] == '#':
                c = 0
            else:
                L[i][j] = c
                c += 1
        c = 0
        for j in range(W - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                R[i][j] = c
                c += 1

    for j in range(W):
        c = 0
        for i in range(H):
            if S[i][j] == '#':
                c = 0
            else:
                U[i][j] = c
                c += 1
        c = 0
        for i in range(H - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                D[i][j] = c
                c += 1

    ans = 0
    for i in range(H):
        for j in range(W):
            if ans < L[i][j] + R[i][j] + U[i][j] + D[i][j] + 1:
                ans = L[i][j] + R[i][j] + U[i][j] + D[i][j] + 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 204148
#include<stdio.h>
int main(void){//float?????????double???
int a,b,r,i;
char op;
i=1;
while(i=1){
scanf("%d %c %d",&a,&op,&b);//??????????????¨??????%c?????§char??§??£?¨?
if(op=='+'){
r=a+b;
printf("%d\n",r);
}
if(op=='-'){
r=a-b;
printf("%d\n",r);
}
if(op=='*'){
r=a*b;
printf("%d\n",r);
}
if(op=='/'){
r=a/b;
printf("%d\n",r);
}
if(op=='?'){
 return 0;
}
}
return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
#define R(i,n) for(int i = 1; i<=n; i++)
typedef long long ll;
using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i =a; i <= b;i++){
    if(i<=a+k-1||b-k+1<=i)cout << i << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w;
int t[1000][1000];
int u[1000][1000];
char str[1001];
int q[1000000],l,r;

void init(){
  l=r=0;
}

void push(int x){
  q[r++]=x;
}

int pop(){
  return q[l++];
}

int main(){
  init();
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++){
    scanf("%s",str);
    for(int j=0;j<w;j++){
      if(str[j]=='.'){
        t[i][j]=0;
        u[i][j]=0;
        push(i*w+j);
      }else{
        t[i][j]=str[j]-'0';
      }
    }
  }
  int ans=0;
  while(l!=r){
    int x=pop();
    int i=x/w,j=x%w;
    /*
    cout<<u[i][j]<<endl;
    for(int a=0;a<h;a++){
      for(int b=0;b<w;b++){
        printf("%3d",t[a][b]);
      }
      cout<<endl;
    }
    cout<<endl;
    */
    for(int a=i-1;a<=i+1;a++){
      for(int b=j-1;b<=j+1;b++){
        if(0<=a&&a<h&&0<=b&&b<w){
          t[a][b]--;
          if(t[a][b]==0){
            ans=u[a][b]=u[i][j]+1;
            push(a*w+b);
          }
        }
      }
    }    
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 12912
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int A = 0, Z = 0;
		for(int i = 0; i < s.length; i++) {
			if(s[i] == 'A') {
				A = i;
				break;
			}
		}
		for(int i = s.length; i > A; i--) {
			if(s[i - 1] == 'Z') {
				Z = i;
				break;
			}
		}
		System.out.println(Z - A);
	}

}


Measured memory_bytes: 26660
import math
a, b, x = list(map(int, input().split()))
if (a * a * b) / 2 <= x:
    res = math.atan(2 * (b * a * a - x) / (a * a * a))
    print(res * 180 / math.pi)
else:
    res = math.atan((a * b * b) / (2 * x))
    print(res * 180 / math.pi)


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

int main ()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) % 2 == 0)
    {
      if ((A.at(i)%3 != 0) && (A.at(i)%5 != 0))
      {
        cout << "DENIED" << endl;
        break;
      }
    }
    if (i == N-1) cout << "APPROVED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import heapq

N,M = map(int, raw_input().split())
job = [[] for _ in range(M)]
for i in range(N):
    a,b = map(int, raw_input().split())
    if a > M:
        continue
    job[M-a].append(b)

ans = 0
h = []
for d in range(M-1,-1,-1):
    for b in job[d]:
        heapq.heappush(h, (-b,b))
    if len(h) > 0:
        ans += heapq.heappop(h)[1]

print ans

Measured memory_bytes: 49692