akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
	int count[101][101], r, c; //表の行数rと列数c
	cin >> r >> c;
	for (int k = 0; k < r+1; k++){
		for (int i = 0; i < c+1; i++){
			count[k][i] = 0;
		}
	}
	for (int k = 0; k < r; k++){
		for (int i = 0; i < c; i++){
			cin >> count[k][i];
		}
	}
	//output
	for (int k = 0; k < r; k++){
		for (int i = 0; i < c; i++){
			count[k][c] += count[k][i];
		}
	}
	//全ての合計値
	for (int i = 0; i < c; i++){
		for (int k = 0; k < r; k++){
			count[r][i] += count[k][i];
		}
	}
	for (int i = 0; i < c; i++){
		count[r][c] += count[r][i];
	}
	for (int k = 0; k < r+1; k++){
		for (int i = 0; i < c; i++){
			cout << count[k][i] << " ";
		}
		cout << count[k][c] << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

a, b = na()
print((a - 1) * (b - 1))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int ans = 1000000000;
    for(int i = -100; i <= 100; i++) {
      int t = 0;
      for(int j = 0; j < n; j++) {
        t += ((i - a[j]) * (i - a[j]));
      }
      ans = Math.min(ans, t);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=2e5+5;
bool fun(pair<int,string> a, pair<int,string> b){
    string x=a.second+b.second;
    int l=0;
    int g1=INT_MIN;
    for(int i=0;i<x.size();i++){
        if(x[i]==')') l++;
        else l--;
        g1=max(g1,l);
    }

    x=b.second+a.second;
    l=0;
    int g2=INT_MIN;
    for(int i=0;i<x.size();i++){
        if(x[i]==')') l++;
        else l--;
        g2=max(g2,l);
    }
    if(g1 < g2) return true;
    else if(g1 > g2) return false;
    else return false;
}
void solve(){
    int n;
    cin>>n;
    vector<pair<int,string>> v(n);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        int l=0;
        int g=INT_MIN;
        for(int i=0;i<s.size();i++){
            if(s[i]==')') l++;
            else l--;
            g=max(g,l);
        }
        v[i]={g,s};
    }
    sort(v.begin(),v.end());
    sort(v.begin(),v.end(),fun);
    string s="";
    for(auto x : v) s+=x.second;
    int l=0;
    int g=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='(') l++;
        else l--;
        if(l < 0) g=1;
    }
    if(g==1 || l!=0) cout<<"No\n";
    else cout<<"Yes\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 44376
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int[] list = {a, b, c};
            Arrays.sort(list);
            System.out.println(list[2] - list[0]);
            }
}

Measured memory_bytes: 23892
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> K;
  if (N%K  == 0) cout << 0 << endl;
  else cout << 1 << endl;


}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  fastio();

  ll n;
  cin >> n;

  ll ans = n - 1;
  for (ll i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      if (n/i + i < ans) {
        ans = n/i - 1 + i - 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define N (1<<18)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 0x5ADFACE5
#define LINF 0x51DEEFFEC7C0DECALL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second

using namespace std;

int main() {
	int n;
	cin>>n;
	ll v[n];
	for (int i = 0; i < n; i++) cin>>v[i];
	sort(v, v + n);
	ll s = 0;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		s += v[i];
		//cout<<s<<" "<<v[i + 1]<<" "<<ans<<endl;
		if (2 * s >= v[i + 1]) ans++;
		else ans = 0;
	}
	cout<<ans + 1<<endl;
}

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

#define MAX 100005

typedef struct{
char name[100];
int time;
}Process;

int isempty(void);
int isfull(void);
void enqueue(Process);
Process dequeue(void);

Process List[MAX+1];
int head, tail, n;

int main(){
  int sum = 0, c;
  int i, q;
  Process box;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", List[i].name);
    scanf("%d", &List[i].time);
  }

  head = 0;
  tail = n;
  while(head != tail) {
    box = dequeue();
    if(q > box.time)
      c = box.time;
    else
      c = q;
    box.time -= c;
    sum += c;
    if(box.time > 0)
      enqueue(box);
    else
      printf("%s %d\n", box.name, sum);
  }
  
  return 0;
}

int isempty() {
  return head == tail;
}

int isfull() {
  return head == (tail+1)%MAX;
}

void enqueue(Process x){
  if(isfull()) {
    fprintf(stderr, "エラー（オーバーフロー）\n");
    exit(1);
  }
  List[tail] = x;
  if(tail+1 == MAX)
    tail = 0;
  else
    tail++;
}

Process dequeue(){
  Process x;
  if(isempty()) {
    fprintf(stderr, "エラー（アンダーフロー）\n");
    exit(1);
  }
  x = List[head];
  if(head+1 == MAX)
    head = 0;
  else
    head++;
  return x;
}

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N), sum(N), diff(N);
    ll min_diff = 9999999999999;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i == 0) {
            sum[0] = a[i];
        } else {
            sum[i] = sum[i - 1] + a[i];
        }
    }

    for (int i = 1; i < N - 1; i++) {
        ll kuma = sum[N-1] - sum[i];
        min_diff = min(min_diff, abs(sum[i] - kuma));
    }

    if (N == 2) {
        min_diff = abs(a[0] - a[1]);
    }

    cout << min_diff << endl;

    return 0;
}

Measured memory_bytes: 4992
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
#define full(t) t.begin(),t.end()
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
void Inp_Out(){
    #ifndef ONLINE_JUDGE
    freopen("alchemy_input.txt", "r", stdin);
    freopen("alchemy_output.txt", "w", stdout);
    #endif
}
//unsigned cntBits(unsigned ll number)return (ll)log2(number)+1;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	//Inp_Out();
	
    din(x);
    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3628
from collections import deque
n,m=map(int,input().split())
path=[[] for i in range(n)]
start=[]
visited=[0]*n
visited[0]=1
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    start.append(b-1)
    visited[b-1]=1
  if b==1:
    start.append(a-1)
    visited[a-1]=1
  path[a-1].append(b-1)
  path[b-1].append(a-1)
que=deque(start)
while que:
  x=que.popleft()
  for i in path[x]:
    if visited[i]==0:
      visited[i]=x+1
      que.append(i)
print('Yes')
for i in range(n-1):
  print(visited[i+1])


Measured memory_bytes: 98624
n=int(input())
box=sorted(list(map(int,input().split())))
right=box.pop()
point=right//2

ans=0
left=10**9
for i in box:
    if abs(i-point)<=left:
        left=abs(i-point)
        ans=i
        if ans==point or ans==point+1:
            print(right,ans)
            exit()
print(right,ans)

Measured memory_bytes: 14428
n=int(input())
s=input()

from collections import defaultdict

def check(l):
    d = defaultdict(lambda: -1)
    for i in range(n-l+1):
        if d[s[i:i+l]] != -1:
            if d[s[i:i+l]] + l <= i:
                return True
        else:
            d[s[i:i+l]]=i
    return False

ok=0
ng=len(s)

while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if check(mid):
        ok=mid
    else:
        ng=mid

print(ok)

Measured memory_bytes: 9788
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	int n;
	long long a[100000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	long long ans=1;
	long long inf=1000000000000000000;
	for(int i=0;i<n;i++){
		if(ans>inf/a[i]){
			cout<<-1<<endl;
			return 0;
		}else{
			ans*=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4372
n, k, q = map(int, input().split())
last = []
initial = [k for x in range(n)]
initial.insert(0, 0)
for i in range(q):
    last.append(int(input()))
for i in last:
    initial[i] += 1
initial = [x - q for x in initial]
initial = initial[1:]
for i in initial:
    if i > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 13732
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;

typedef long long int64;
const int INF = 1 << 30;

int main(){
  int C, D, W, X;
  vector< vector< int > > E, F;
  vector< vector< vector< int > > > dp;

  while(cin >> C >> D >> W >> X, C){
    E  = vector< vector< int > >( C, vector< int >(D));
    F  = vector< vector< int > >( C, vector< int >(D));
    dp = vector< vector< vector< int > > >
      ( D + 1, vector< vector< int > >(W + 1, vector< int >( X + 1, 0)));

    cin >> E;
    cin >> F;


    for(int i = 0; i < D; i++) {
      for(int j = 0; j <= X; j++) {
        for(int k = 0; k < C; k++) {
          if(E[k][i] == 0) continue;
          for(int l = W; l >= F[k][i]; l--) {
            // 複数回ライブをやる
            if(j > 0) {
              int value = 0, futan = 0;
              for(int m = k; m >= 0; m--) {
                if(E[m][i] == 0) break;
                value += E[m][i]; futan += F[m][i];
                if(l - futan < 0) break;
                dp[i + 1][l - futan][j - 1] = max( dp[i + 1][l - futan][j - 1], dp[i][l][j] + value);
              }
              value = 0, futan = 0;
              for(int m = k; m < C; m++) {
                if(E[m][i] == 0) break;
                value += E[m][i]; futan += F[m][i];
                if(l - futan < 0) break;
                dp[i + 1][l - futan][j - 1] = max( dp[i + 1][l - futan][j - 1], dp[i][l][j] + value);
              }
            }
            // 一回だけ
            dp[i + 1][l - F[k][i]][j] = max( dp[i + 1][l - F[k][i]][j], dp[i][l][j] + E[k][i]);
          }
        }
      }
      for(int j = 0; j <= W; j++) {
        for(int k = 0; k <= X; k++){
          dp[i + 1][j][k] = max( dp[i + 1][j][k], dp[i][j][k]);
        }
      }
    }

    int ret = 0;
    for(int j = 0; j <= W; j++){
      for(int k = 0; k <= X; k++){
        ret = max( ret, dp[D][j][k]);
      }
    }
    cout << ret << endl;
  }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

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

    int n;
    cin >> n;
    vi v(n);
    REP(i, n) cin >> v[i];
    int j = 1;
    int ans = 0;
    bool f = false;
    REP(i , n) {
        if(v[i] == j) {
            f = true;
            ++j;
        } else {
            ans++;
        }
    }
    if(!f) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)
int main(){
  char t[200001];
  scanf("%s",t);
  int count=0;
  int len=strlen(t);
  rep(i,len){
    if(t[i]=='?'){
      t[i]='D';
    }
  }

  rep(j,len){
    printf("%c",t[j]);
  }
  return 0;
}


Measured memory_bytes: 1852
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,M;
	cin >> N >> M;
	vector<pair<ll,ll> > shops;

	REP(i,N){
		ll A,B;
		cin >> A >> B;
		shops.push_back(mp(A,B));
	}

	sort(shops.begin(),shops.end());
	ll count_sum=0,price_sum = 0;
	for(auto itr = shops.begin();
			itr != shops.end();
			itr++){
		ll count;
		if(count_sum + itr->second >= M){
			count = M - count_sum;
			price_sum += count * itr->first;
			break;
		}
		count = itr->second;
		price_sum += count * itr->first;
		count_sum += count;
	}
	println(price_sum);

	return 0;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int alice = 0, bob = 0;
    REP(i, n){
        if(i % 2 == 0){
            alice += a[i];
        }
        else{
            bob += a[i];
        }
    }
    cout << alice - bob << "\n";
}

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

Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int M=1000000;
int a[M]={0},b[M]={0};
int ans[M]={0},len;
void show(int xa,int x[]){for(int i=0;i<fabs(xa);i++) printf("%d",x[i]);printf("\n");}
//ÕýÕûÊý¼Ó·¨ 
int add(int ma,int mb){
	int len;
	for(int i=0;i<ma/2;i++) swap(a[i],a[ma-1-i]);
	for(int i=0;i<mb/2;i++) swap(b[i],b[mb-1-i]);
	for(len=0;len<ma||len<mb;len++){
		if(a[len]+b[len]+ans[len]>9) ans[len+1]++;
		ans[len]=(a[len]+b[len]+ans[len])%10;
	}
	if(ans[len]!=0) len++;
	for(int i=0;i<len/2;i++) swap(ans[i],ans[len-1-i]);
	return len;
} 
//ÕýÕûÊý¼õ·¨ 
int sub(int ma,int mb){
	int len,f=1;
	if(ma<mb) f=-1;
	else if(ma==mb){
		int i=0;
		while(a[i]==b[i]&&i<ma) i++;
		if(a[i]<b[i]) f=-1;
	}
	if(f==-1){swap(a,b);swap(ma,mb);}
	for(int i=0;i<ma/2;i++) swap(a[i],a[ma-1-i]);
	for(int i=0;i<mb/2;i++) swap(b[i],b[mb-1-i]);
	for(len=0;len<ma;len++){
		ans[len]=(ans[len]+a[len]-b[len]+10)%10;
		if(a[len]-b[len]<0) a[len+1]--;
	}
	while(len>1&&ans[len-1]==0) len--;
	for(int i=0;i<len/2;i++) swap(ans[i],ans[len-1-i]);
	return f*len;
}
inline int read(int x[]){
	int f=1,cnt=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x[cnt++]=ch-'0';ch=getchar();}
	return cnt*f;
} 
int main(){
	int ma=read(a);
	int mb=read(b);
	if(ma*mb>=0){
		int len=sub(fabs(ma),fabs(mb));
		if(ma*len<0&&ans[0]!=0) printf("-");
		show(fabs(len),ans);

	}else{
		int len=add(fabs(ma),fabs(mb));
		if(ma<0) printf("-");
		show(len,ans);
	}
	return 0;
}
//17 18



Measured memory_bytes: 11396
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){

 ll a,b, c ;
 cin >> a >> b >>c ;
 if(a==b && b==c ){cout << "No" <<endl; }
 else if(a==b||a==c){cout<< "Yes" <<endl ;}
 else if(b==a || b==c) {cout << "Yes" <<endl ;}
 else if(c==a||a==b){cout << "Yes"<<endl; }
 else {cout << "No" <<endl ;}
    return 0 ;
}


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

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

struct tile
{
    int x,y,t;
    tile(int x,int y,int t):x(x),y(y),t(t){};
};

const int MAX = 32;
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};
int T=3,B=2,R=0,L=1;


int checkable[MAX][MAX];
int wall[MAX][MAX][4];
int w,h,temp;

int main()
{
    while(cin >> w >> h &&(w || h))    {
        memset(checkable,1,sizeof(checkable));
        memset(wall,1,sizeof(wall));
        rep(j,h)
        {
            rep(i,w-1)
            {
                cin >> temp;
                if(!temp){wall[i][j][R] = 0;wall[i+1][j][L] = 0;}
            }
            if(j==h-1) break;
            rep(i,w)
            {
                cin >> temp;
                if(!temp){wall[i][j][B] = 0;wall[i][j+1][T] = 0;}
            }
        }
        //cout << "input fin" << w << h << endl;
        queue<tile> q;
        q.push(tile(0,0,1));
        int ans = 0;

        while(!(q.empty()))
        {
            tile t = q.front();q.pop();
            //cout << t.x << " " << t.y << endl;

            if(t.x == (w-1) && t.y ==( h-1)){ans = t.t; break;}

            REP(4)if(!(wall[t.x+dx[i]][t.y+dy[i]][i]) &&checkable[t.x+dx[i]][t.y+dy[i]])
            {
                checkable[t.x+dx[i]][t.y+dy[i]] = 0;
                q.push(tile(t.x+dx[i],t.y+dy[i],t.t + 1));
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 928
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    S = Scanner.string()
    N = len(S)
    sums = [0] * (N+1)
    for i in range(N):
        sums[i+1] = sums[i]
        if S[i] == "B":
            sums[i+1] += 1
    ans = 0
    for i in range(N):
        if S[i] == "W":
            ans += sums[i+1]
    print(ans)
    return


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  
  int x;
  x = N * 800;
  
  int y ;
  y = N / 15;
  
  int z;
  z = y * 200;
  
  int sum;
  sum = x - z;
  
  cout << sum << endl;

}

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

int main(void)
{
    char W[11];
    char T[1000];
    int n;
    int i;
    
    scanf("%s", W);
    
    n = 0;
    while (1){
        scanf("%s", T);
        if (strcmp(T, "END_OF_TEXT") == 0){
            break;
        }
    
        for (i = 0; T[i] != '\0'; i++){
            if ('A' <= T[i] && T[i] <= 'Z'){
                T[i] += 0x20;
            }
        }
        if (strcmp(T, W) == 0){
            n++;
        }
    }
    printf("%d\n", n);
    
    return (0);
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  vi odd; vi even;
  int n,x;
  cin>>n;
  rep(i,1,n+1)
    {
      cin>>x;
      if(i&1) odd.pb(x);
      else even.pb(x);
    }
  if(n%2==0) swap(odd,even);
  reverse(all(odd));
  for(int x:odd) cout<<x<<" ";
  for(int x:even) cout<<x<<" ";
  cout<<endl;
  return 0 ;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<llint> a(n);
    llint sum = 0;
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        a.at(in) -= (in+1);
    }
    sort(a.begin(), a.end());
    llint b = a.at(n/2);

    llint ans=0;
    for(int in=0;in<n;in++) {
        sum += abs(a.at(in)-b);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf =1e15;
const int maxn=1e5+7;
typedef long long ll;
int T;
int a,b,c,n;
ll la[maxn],lb[maxn],x,ans;
double pi=3.14159265359;
double d,r;
int main()
{
   scanf("%d%d%d",&a,&b,&c);

   for(int i=0;i<a;i++)
     scanf("%lld",&la[i]);
   for(int i=0;i<b;i++)
     scanf("%lld",&lb[i]);
   while(c--)
   {
       scanf("%lld",&x);
       ans=inf;
       int aa=lower_bound(la,la+a,x)-la;


       int bb=lower_bound(lb,lb+b,x)-lb;

       //cout<<bL<<"   "<<bR<<endl;
       if(aa<a&&bb<b)
          ans=min(ans,max(la[aa],lb[bb])-x);
       if(aa&&bb)
           ans=min(ans,x-min(la[aa-1],lb[bb-1]));
       if(aa&&bb<b)
           ans=min(ans,max(x-la[aa-1],lb[bb]-x)+2*min(x-la[aa-1],lb[bb]-x));
       if(aa<a&&bb)
           ans=min(ans,max(x-lb[bb-1],la[aa]-x)+2*min(x-lb[bb-1],la[aa]-x));
       printf("%lld\n",ans);
   }
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

const int MAX_N = 1e5 + 10;
int N;
int64_t H, a[MAX_N], b[MAX_N];

int main(int argc, char **argv){
    std::cin >> N >> H;

    int64_t ma = 0;
    rep (i, 1, N) {
        std::cin >> a[i] >> b[i];
        ma = std::max(ma, a[i]);
    }

    std::vector<int> vec;
    rep (i, 1, N) {
        if (ma < b[i]) {
            vec.push_back(b[i]);
        }
    }
    std::sort(vec.begin(), vec.end());

    int ret = 0;
    while (0 < H && 0 < vec.size()) {
        H -= vec.back();
        vec.pop_back();
        ret++;
    }

    if (0 < H) {
        ret += (H + ma - 1) / ma;
    }

    std::cout << ret << std::endl;

    return 0;
}



Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int temp;

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

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

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

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

}

Measured memory_bytes: 26132
// 2017/07/21 Tazoe

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
	map<int, bool> memo;		// ???????????§?????¢???

	int N;
	cin >> N;

	int cnt = 0;			// ?????????????????°

	for(int i=0; i<N; i++){
		int p[3];
		cin >> p[0] >> p[1] >> p[2];

		sort(p, p+3);			// ???????????????????????????

		int k = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
		// 3???????????????????????????-1??????????????°??????????????¨??????

		if(memo.find(k)!=memo.end()){	// ???????????????
			cnt++;
		}
		else{
			memo[k] = true;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>

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

	if (m == 1) {
		if (k == 0) puts("0 0 1 1");
		else puts("-1");
		return 0;
	}

	int max = (1<<m)-1;
	if (max < k) {
		puts("-1");
		return 0;
	}

	printf("%d ", k);
	for (int i = 0 ; i <= max; i++) {
		if (i == k) continue;
		printf("%d ", i);
	}
	printf("%d ", k);
	for (int i = max; i >= 0; i--) {
		if (i == k) continue;
		printf("%d ", i);
	}
	printf("\n");
}


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

using namespace std;

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

typedef long long ll;

const ll Inf = 1e9 + 7;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    ll inv = 0;
    ll small = 0;
    ll ans;
    rep (i, n) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b.begin(), b.end(), greater<int>());
    rep (i, n) {
      FOR (j, i, n) {
        if (b[i] > b[j]) small++;
      }
    }

    rep (i, n) {
      FOR (j, i, n) {
        if (a[i] > a[j]) {
          inv++;
        }
      }
    }
    ans = small * ((k * (k - 1) / 2) % Inf) + inv * (k % Inf);
    ans %= Inf;
    cout << ans << endl;

    return 0;
}


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

#define sz(a) (int)(a).size()
#define pb push_back
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

int main()
{

    //ifstream cin("input.txt");

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[a[i]] == i) {
            ++ans;
        }
    }
    cout << ans / 2 << '\n';

}


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


int main(){
    
    int n;
    while(cin >> n){
        if(n == 1){
            string hoge; cin >> hoge;
            cout << "Yes" << endl;
            continue;
        }
        vector<pair<int, int> > a(n);
        vector<int> count(7, 0);
        vector<bool> par(7, false);
        for(int i = 0; i < n; i++){
            string input; cin >> input;
            a[i].first = (int)(input[0] - '0');
            a[i].second = (int)(input[1] - '0');
            //cout << a[i].first << " " << a[i].second << endl;
            count[a[i].first]++;
            count[a[i].second]++;
            if(a[i].first == a[i].second) par[a[i].first] = true;
        }

        int cnt_odd = 0;
        for(int i = 0; i < 7; i++) cnt_odd += (count[i] % 2 == 1);

        if(cnt_odd != 0 && cnt_odd != 2){
            cout << "No" << endl;
            continue;
        }

        bool ok = true;

        for(int i = 0; i < 7; i++){
            


            if(par[i]){

                bool tmp = false;                

                for(int j = 0; j < n; j++){
                    if(a[j].first == a[j].second) continue;

                    if(i == a[j].first || i == a[j].second){
                        tmp = true;
                    }
                }

                if(!tmp){
                    ok = false;
                    continue;
                }
            }
        }

        //cout << "wahaha" << endl;
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

x = int(M // 2)

if M % 2 == 0:
  for i in range(x):
    print(i + 1, M + 1 - i)
    print(M + 2 + i, 2 * M + 1 - i)  
    
else:
  for i in range(x):
    print(i + 1, M - i)
  for j in range(x + 1):
    print(M + 1 + j, 2 * M + 1 - j)
    

Measured memory_bytes: 9264
#pragma GCC optimzie("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;
int H, W, K;
vector<vector<ll>> dp;

void input() {
	cin >> H >> W >> K;
	--K;
	dp.resize(H + 1, vector<ll>(W, 0));
	dp[0][0] = 1;
}

void DP() {
	for (int i = 1; i <= H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (j) { // 直前 j-1 にいる
				int cnt = 0;
				for (int f = 0; f < (1 << (W - 1)); ++f) {
					if ((f & (f >> 1)) || (f & (f << 1))) continue;
					if (f & (1 << (j - 1))) ++cnt;
				}
				dp[i][j] += cnt * dp[i - 1][j - 1] % mod;
			}
			if (j != W - 1) { // 直前 j+1 にいる
				int cnt = 0;
				for (int f = 0; f < (1 << (W - 1)); ++f) {
					if ((f & (f >> 1)) || (f & (f << 1))) continue;
					if (f & (1 << j)) ++cnt;
				}
				dp[i][j] += cnt * dp[i - 1][j + 1] % mod;
			}
			{ // 引かない
				int cnt = 0;
				for (int f = 0; f < (1 << (W - 1)); ++f) {
					if ((f & (f >> 1)) || (f & (f << 1))) continue;
					if (f & (1 << j)) continue;
					if (f & (1 << (j - 1))) continue;
					++cnt;
				}
				dp[i][j] += cnt * dp[i - 1][j] % mod;
			}
			dp[i][j] %= mod;
		}
	}
}

int main() {
	input();
	DP();
	cout << dp[H][K] << endl;
	return 0;
}

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

int main(){
  int x,y,z;
  int a,b,c;
  int a1,b1,c1;
  
  cin >> x >> y >> z;
  
  a = y;
  b = x;
  c = z;
  
  a1 = c;
  b1 = b;
  c1 = a;
  
  cout << a1 <<" "<< b1 <<" "<< c1 << endl;
  
  return 0;
}

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

bool iswstr( std::string s )
{
	bool isw = true;
	int len = ceil( s.size()/2.0 );
	if( false ) {
		std::cout << len << ":" << s << std::endl;
	}
	for( int i = 0; i < len; i++ ) {
		if( s[ i ] != s[ i + len ] ) {
			isw = false;
			break;
		}
	}
	return isw;
}

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

	bool isw = false;
	for( int i = s.size() - 1; i >= 0; i-- ) {
		s = s.substr( 0, i - 1 );
		isw = iswstr( s );
		if( isw ) {
			break;
		}
	}

	std::cout << s.size() << std::endl;
	return 0;
}



Measured memory_bytes: 504
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn mod_factorial(n : u64, md : u64) -> u64 {
    if n == 1 {return 1;}
    let mut t = mod_factorial(n-1, md) % md;
    t = (t * n) % md;
    return t;
}

fn main() {
    let md : u64 = 1000000007;
    let nm : Vec<u64> = get_vec();
    let n = std::cmp::max(nm[0], nm[1]);
    let m = std::cmp::min(nm[0], nm[1]);

    if n > m+1 {
        println!("{}", 0);
    }
    else if n == m+1{
        println!("{}", (mod_factorial(n,md) * mod_factorial(m,md)) % md );
    }
    else {
        println!("{}", (((mod_factorial(n,md).pow(2)) % md) * 2) % md);
    }
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  long double N,K;
  cin>>N>>K;
  long double ans=0;
  for(int i=1;i<=N;i++){
    int sum=i;
    int cnt=0;
    while(sum<K){
      cnt++;
      sum*=2;
    }
    ans=ans+1/N*pow((0.5),cnt);
  }
  cout<<fixed<<setprecision(15)<<ans<<endl;
  return 0;
}

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

map<pair<string,string>,int> ma;

int main() {

    int n,f;

    cin >> n >> f;

    for(int i=0; i<n;i++){

        int m;

        cin >> m;

        vector<string> vec;

        for(int j=0; j<m; j++){
            string s;
            cin >> s;
            vec.push_back(s);
        }



        int num = vec.size();

        for(int j=0; j<num-1; j++){
            for(int k=j+1; k<num; k++){
                if(vec[j]<vec[k]){
                    ma[make_pair(vec[j],vec[k])]++;
                }
                else{
                    ma[make_pair(vec[k],vec[j])]++;
                }
            }
        }

    }

    priority_queue<pair<string,string> > queue;

    for(map<pair<string,string>,int>::iterator itr = ma.begin(); itr != ma.end(); itr++){
        if(itr->second >= f){
            queue.push(itr->first);
        }
    }

    cout << queue.size() << endl;

    list<pair<string,string> > l;

    int size = queue.size();

    for(int i=0; i<size; i++){
        pair<string,string> p = queue.top();
        l.push_front(p);
        queue.pop();
    }

    for(list<pair<string,string> >::iterator itr = l.begin(); itr != l.end(); itr++){
        cout << itr->first << " " << itr->second << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;

namespace AOJ.Volume0
{
    class Program0013
    {
        static void Main(string[] args)
        {
            string line;
            Queue<string> operatingQueue = new Queue<string>();
            Stack<string> trainStack = new Stack<string>();

            while((line = Console.ReadLine()) != null)
            {
                operatingQueue.Enqueue(line);
                int.Parse("0");
            }

            foreach (var op in operatingQueue)
            {
                if (op == "0")
                {
                    Console.WriteLine(trainStack.Pop());
                }
                else
                {
                    trainStack.Push(op);
                }
            }
        }
    }
}

Measured memory_bytes: 5656
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <list>
#include <utility>
using namespace std;

#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)

list<pair<int, int> > lis;

inline void Write() {
	int l, s;
	cin >> l >> s;

	FOR(it, lis) {
		if(it->second == -1) {
			if(it->first > s) {
				it->first -= s;
				lis.insert(it, make_pair(s, l));
				break;
			}
			else if(it->first == s) {
				it->second = l;
				break;
			}
			else {
				it->second = l;
				s -= it->first;
			}
		}
	}
}

inline void Delete() {
	int l;
	cin >> l;

	FOR(it, lis) {
		if(it->second == l)
			it->second = -1;
	}
}

inline void Read() {
	int p;
	cin >> p;

	int cnt = 0;
	FOR(it, lis) {
		cnt += it->first;
		if(cnt >= p + 1) {
			cout << it->second << endl;
			break;
		}
	}
}

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

	for(int n; cin >> n, n;) {
		lis.clear();
		lis.push_back(make_pair(1000000001, -1));
		for(int i = 0; i < n; ++i) {
			char ope;
			cin >> ope;

			switch(ope) {
			case 'W':
				Write();
				break;
			case'D':
				Delete();
				break;
			case 'R':
				Read();
				break;
			}
		}

		cout << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

int main() {
    int a;
    int ans = 0;
    cin >> a;
    vector<int> n;
    for (int i=0;i<a;i++){
        int tmp;
        cin >> tmp;
        n.push_back(tmp);
    }
    for (int i=0;i<a;i++){
        int bai = 1;
        while(bai){
            if(n[i] % 2 == 0){
                n[i] = n[i] / 2;
                ans +=1;
            }else{
                bai = 0;
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,a[202020],b[202020],ans=0,z[202020];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	fo(i,0,n)cin>>b[i];
	fo(s,0,29){
		int h=0,x=(1<<s);
		fo(i,0,n)z[i]=b[i]%(x*2);
		sort(z,z+n);
		fo(i,0,n){
			int y=a[i]%(x*2);
			h+=lb(z,z+n,x*2-y)-lb(z,z+n,x-y)+lb(z,z+n,x*4-y)-lb(z,z+n,x*3-y);
			h%=2;
		}
		ans+=x*h;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import itertools

input = sys.stdin.readline
mod = 10**9 + 7

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())
A = list(map(int, input().split()))

cumA = list(itertools.accumulate(A[::-1]))[::-1]
# print(A, cumA)

ans = 0
for i in range(len(A)-1):
    ans += (A[i] * cumA[i+1]) % mod

print(ans % mod)


Measured memory_bytes: 114008
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main() {
    int N,K; cin>>N>>K;
    int array[N];
    for (int i=0; i<N; i++) cin>>array[i];
    sort(array, array + SIZE_OF_ARRAY(array));
    int sum=0;
    for (int i=0; i<K; i++) sum += array[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    double w,h,x,y;
   cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(9)<<(w*h)/2<<" ";
    if(x*2==w && y*2==h)
    cout<<1;
         else
         {
             cout<<0;
         }
    
  
   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;

int main() {
  int h,n;
  priority_queue<int> a; 
  cin >> h >> n;
  rep(i,n) {
    int t;
    cin >> t;
    a.push(t);
  }
  while(h>0 && a.size() > 0){
    h -= a.top();
    a.pop();
  }
  if (h>0) {
    cout << "No" << endl;
  }else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
 
    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = int(ceil((double(G - s) / s1)));
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

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

int main(){
  ll n,x,t;cin >> n >> x >> t;
  ll cnt = 0;
  ll time = 0;
  while( cnt < n ){
    time += t;
    cnt += x;
  }
  cout << time << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){
    char c;
    cin>>c;
    if(c-'Z'<=0) cout<<"A";
    else cout<<"a";

        
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 3648