akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (cin >> s) {
    auto f = [&](char c) {
      rep(i, 3) {
        if (s[i * 3] == c && s[i * 3 + 1] == c && s[i * 3 + 2] == c) {
          cout << c << endl;
          return true;
        }
        if (s[i] == c && s[i + 3] == c && s[i + 6] == c) {
          cout << c << endl;
          return true;
        }
      }
      return false;
    };
    auto g = [&](char c) {
      if (s[0] == c && s[4] == c && s[8] == c) {
        cout << c << endl;
        return true;
      }
      if (s[2] == c && s[4] == c && s[6] == c) {
        cout << c << endl;
        return true;
      }
      return false;
    };
    if (f('o') || f('x') || g('o') || g('x')) goto next;
    cout << 'd' << endl;
  next:;
  }
}

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

#define MAX_N 100
#define MAX_L 10

void set_words(int n);
int check_shiritori1(int n);
int check_shiritori2(int n);
  
char words[MAX_N][MAX_L+1];

int main(void) {

  int n;
  int result1, result2;
  
  scanf("%d", &n);
  set_words(n);

  result1 = check_shiritori1(n);

  result2 = check_shiritori2(n);

  if ( (result1 * result2) == 0) {
    printf("No");
  } else {
    printf("Yes");
  }
  
  return 0;
}

void set_words(int n) {

  int k;
  char str_temp[MAX_L+1];
  
  for (k = 0; k < n; k++) {
    scanf("%s", str_temp);
    strcpy(words[k], str_temp);
  }

}

int check_shiritori1(int n) {

  int k1,k2;

  for (k1 = 0; k1 < n; k1++) {
    for (k2 = 0; k2 < n; k2++) {
      if (k1 == k2) { continue; }
      if (strcmp(words[k1], words[k2]) == 0) {
	    return 0;
      }
    }
  }

  return 1;
}

int check_shiritori2(int n) {

  int k;

  for (k = 1; k < n; k++) {
    if (words[k][0] != words[k-1][strlen(words[k-1])-1]) {
      return 0;
    }
  }

  return 1;
}


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

int main()
{
    int n;
    cin>>n;
    vector<double> v(n+1);
    for(int i=1;i<=n;i++)   
        cin>>v[i];
    
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++)
            dp[i][j] = 0;
    }
    
    //dp[i][j] -> p-bility of getting j heads in first i coins
    dp[1][0] = (1-v[1]);
    for(int i=2;i<=n;i++)
        dp[i][0] = dp[i-1][0]*(1-v[i]);
    
    dp[1][1] = v[1];
    for(int i=2;i<=n;i++)
        dp[i][i] = dp[i-1][i-1]*v[i];
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            dp[i][j] = /* j heads from i-1 coins and cur is tail*/ dp[i-1][j]*(1-v[i]) + /* j-1 heads from i-1 coins and cur is head*/ dp[i-1][j-1] * v[i];
        }
    }
    
    //selecting dp where j > n/2
    double ans = 0;
    for(int i=n/2+1;i<=n;i++)
        ans += dp[n][i];
    
    cout<<fixed<<setprecision(10)<<ans<<"\n";
    
    return 0;
}



Measured memory_bytes: 70528
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int res=1,pos=k-1;
    while(true){
        if(pos>=n-1) break;
        pos+=k-1;
        res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(work => int.Parse(work)).ToArray();
            if (input[0] * input[1] > input[2] * input[3])
                Console.WriteLine("{0}", input[0] * input[1]);
            else
                Console.WriteLine("{0}", input[2] * input[3]);
        }
    }
}


Measured memory_bytes: 2776
#include <iostream>
#include <algorithm>
#define MAXN 100010

using namespace std;

int n,a,b;
string s;
int x,y;

int main() {
    cin >> n >> a >> b >> s;
    for (char c : s) {
        bool ok = 0;
        if (c == 'a') {
            if (x < a + b) ok = 1;
        } else if (c == 'b') {
            if (x < a + b && y < b) {
                y++;
                ok = 1;
            }
        }
        if (ok) {
            x++;
            cout << "Yes\n";
        } else cout << "No\n";
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ld a,b,h,w;
	cin >> a >> b >> h >> w;
	ld r = abs(h*30+30*w/60-w*6);
	ld ans = sqrt(a*a+b*b-2*a*b*cos(r*acos(-1)/180));
	cout << fixed << setprecision(20) << ans << endl; 
}

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

int main(void) {
    int n;
    string s;

    cin >> n;
    cin >> s;

    if ( n >= s.size() ) {
        cout << s << endl;
    } else {
        for ( int i = 0; i < n; i++ ) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int b=0,r=0;
    REP(i,n){
        char c;
        cin>>c;
        if(c == 'B')b++;
        else r++;
    }
    if(r > b){
        PUTS("Yes");
    }
    else{
        PUTS("No");
    }
}

Measured memory_bytes: 256
N = int(input())
N2 = int(N ** (1/2))
ans1 = N
ans2 = 1
for i in range(1, N2 + 1):
    if N % i == 0:
        ans2 = str(i)
        ans1 = str(N // i)

print(max(len(ans1), len(ans2)))



Measured memory_bytes: 38768
#include <iostream>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long int ll;
const ll INF = 100100100100100100;
using namespace std;

ll N,C;
ll x[100100],v[100100];
ll gain_r[100100],gain_l[100100];
ll rui_r[100100],rui_l[100100];
ll max_r[100100],max_l[100100];

int main(){
    cin >> N >> C;
    x[0] = 0;
    v[0] = 0;
    rep(i,N){
        cin >> x[i+1] >> v[i+1];
    }
    x[N+1] = C;
    v[N+1] = 0;
    N+=2;
    gain_r[0] = 0;
    rep(i,N-1){
        gain_r[i+1] = v[i+1] - (x[i+1] - x[i]);
        rui_r[i+1] = rui_r[i] + gain_r[i+1];
        max_r[i+1] = max(max_r[i],rui_r[i+1]);
    }
    gain_l[N] = 0;
    for(ll i=N-1; i>0;i--){
        gain_l[i-1] = v[i-1] - (x[i] - x[i-1]);
        rui_l[i-1] = rui_l[i] + gain_l[i-1];
        max_l[i-1] = max(max_l[i],rui_l[i-1]);
    }
    /*
    rep(i,N){
        cerr << " " << rui_r[i] << endl;;
    }
    cerr << endl;
    for(ll i=N-1; i>=0;i--){
        cerr << " " << rui_l[i] << endl;;
    }
    cerr << endl;
    */
    ll ans = 0;
    //non U turn
    ans = max(ans,max_r[N]);
    ans = max(ans,max_l[0]);

    //U turn
    rep(i,N-1){
        ll tmp_score = rui_r[i];
        tmp_score -= x[i];
        tmp_score += max_l[i+1];
        ans = max(ans,tmp_score);
    }
    for(ll i=N-1; i>0;i--){
        ll tmp_score = rui_l[i];
        tmp_score -= C-x[i];
        tmp_score += max_r[i-1];
        ans = max(ans,tmp_score);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;
const int NIL = -1;

struct Node{
    int p, l, r;
};

vector<Node> T(30, {NIL, NIL, NIL});
vector<int> D(30), H(30);

void setDepth(int u, int p){
    if(u == NIL) return;
    D[u] = p;
    if(T[u].l != NIL) setDepth(T[u].l, p + 1);
    if(T[u].r != NIL) setDepth(T[u].r, p + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].l != NIL){
        h1 = setHeight(T[u].l) + 1;
    }

    if(T[u].r != NIL){
        h2 = setHeight(T[u].r) + 1;
    }
    H[u] = max(h1, h2);
    return H[u];
}

void print(int u){
    cout << "node " << u << ": ";

    int parent = T[u].p;
    cout << "parent = " << parent << ", ";
    
    int sibling;
    if(parent == NIL) sibling = NIL;
    else if(T[parent].l == u) sibling = T[parent].r;
    else if(T[parent].r == u) sibling = T[parent].l;
    cout << "sibling = " << sibling << ", ";

    int degree = 0;
    if(T[u].l != NIL) degree++;
    if(T[u].r != NIL) degree++;
    cout << "degree = " << degree << ", ";

    cout << "depth = " << D[u] << ", ";

    cout << "height = " << H[u] << ", ";

    if(T[u].p == NIL) cout << "root" << endl;
    else if (T[u].l == NIL && T[u].r == NIL ) cout << "leaf" << endl;
    else cout << "internal node" << endl;
}

int main(){
    int N;
    cin >> N;
    rep(i, N){
        int id, left, right;
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        T[left].p = id;
        T[right].p = id;
    }

    int root;

    rep(i, N){
        if(T[i].p == NIL){
            root = i;
            break;
        }
    }

    setDepth(root, 0);
    setHeight(root);

    rep(i, N) print(i);
}


Measured memory_bytes: 3092
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    string s;
    cin>>s;

    if(s[s.size()-1]=='s') s +="es";
    else s+='s';

    cout<<s<<endl;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define N 200010
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
const int mod=1e9+7;
int n,m,a,b;
int fac[N],inv[N];
long long ksm(long long x,long long mc)
{
	long long tmp=x%mod;
	long long res=1;
	while(mc)
	{
		if(mc&1)res=res*tmp%mod;
		tmp=tmp*tmp%mod;
		mc>>=1;
	}
	return res;
}
void init(int maxn)
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=maxn;i++) fac[i]=(long long)fac[i-1]*i%mod;
	inv[maxn]=ksm(fac[maxn],mod-2);
	for(int i=maxn-1;i>=2;i--) inv[i]=(long long)inv[i+1]*(i+1)%mod;
}
long long C(int i,int j)
{
	if(i<j)return 0;
	return (long long)fac[i]*inv[j]%mod*inv[i-j]%mod;
}
int main()
{
//	freopen("ARC058D.in","r",stdin);
//	freopen("ARC058D.out","w",stdout);
	read(n);read(m);read(a);read(b);
	init(n+m);
	int ans=0;
	for(int i=1;i<=n-a;i++)
		(ans+=C(i+b-2,b-1)*C(n-i+m-b-1,n-i)%mod)%=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<pair<ll, ll> > v(n);
    rep(i, n){
        ll a, b;
        cin>>a>>b;
        v[i]=make_pair(a, b);
    }

    map<pair<ll, ll>, ll> mp;
    rep(i, n){
        for(int j=i+1;j<n;j++){
            ll a=(v[i].first-v[j].first);
            ll b=(v[i].second-v[j].second);
            if(a<0){
                a*=-1;
                b*=-1;
            }
            if(a==0){
                if(b<0) b*=-1;
            }
            mp[make_pair(a, b)]++;
        }
    }
    ll mx=0;
    for(auto p : mp){
        if(p.second>mx){
            mx=p.second;
        }
    }
    ll ans=n-mx;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
while line = STDIN.gets
  x1, y1, x2, y2, x3, y3, xp, yp = line.chomp.split(' ').map { |item| item.to_f }
  a = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)
  b = (xp-x1)*(y3-y1)-(x3-x1)*(yp-y1)
  c = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1)
  s = b/a
  t = c/a
  if s>0 and t>0 and 0<s+t and s+t<1 then
    puts "YES"
  else
    puts "NO"
  end
end

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ll a, b, c, d; rd(a, b, c, d);

	ll ans = LLONG_MIN;
	ans = max(ans, a * c);
	ans = max(ans, b * c);
	ans = max(ans, a * d);
	ans = max(ans, b * d);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3768
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
       Scanner stdIn=new Scanner(System.in);
       
       int N=stdIn.nextInt();
       int K=stdIn.nextInt();
       int []c=new int[N];
       int count=0;

       
       int []d=new int[K];
       for(int i=0; i<c.length; i++){
           c[i]=0;
       }

       for(int i=0; i<K; i++){
           d[i]=stdIn.nextInt();
           int []a=new int[d[i]];
           for(int j=0; j<d[i]; j++){
                a[j]=stdIn.nextInt();
           }
           for(int k=0; k<d[i]; k++){
                c[a[k]-1]++;
           }
        }
        for(int i=0; i<c.length; i++){
            if(c[i]==0){
                count++;
            }
        }
        System.out.println(count);
        
        
        
    }

}

Measured memory_bytes: 46032
#include <stdio.h>

#define MAX 5000

int main(void)
{
	int i, j;
	int num[MAX];
	int n;
	int max;
	int sum_ij;
	int max_i;
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
            scanf("%d",&num[i]);
        }
		max=-100000;
        for (i = 0; i < n; i++) {
        	max_i = sum_ij = num[i];
        	for (j = i + 1; j < n; j++) {
        		sum_ij += num[j];
                if (sum_ij > max_i) {
                    max_i = sum_ij;
                }
            }
            if (max_i > max) {
                max = max_i;
            }
        }

        printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 2592
#include <stdio.h>
#include <string.h>
int main()
{
    char str1[1000];
    int i;
    gets(str1);
    int len=strlen(str1);
    for(i=0; i<len; i++)
    {
        printf("x");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String agrs[]){
    Scanner sn = new Scanner(System.in);
    while(sn.hasNextBigInteger()){
    BigInteger a = sn.nextBigInteger(),
    b = sn.nextBigInteger();
    a = a.add(b);
    String s ="";
    s += a;
    System.out.println(s.length());
    }
  }
}

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

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

    int s[N];
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> s[i];
        sum += s[i];
    }

    if (sum % 10 != 0) {
        std::cout << sum << std::endl;
        return 0;
    }

    std::sort(s, s + N);
    for (int i = 0; i < N; ++i) {
        if (s[i] % 10 != 0) {
            std::cout << sum - s[i] << std::endl;
            return 0;
        }
    }

    std::cout << 0 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main()
{  int i,n,t,j,k,a[200000];
   scanf("%d",&n); 
   for(i=0;i<n;i++)
   scanf("%d",&a[i]);
   for(i=1;i<=n;i++)
   {  t=a[i];//抽出一个进行插入 
      j=i-1;
      for(k=0;k<n;k++)
      {  if(k>0)  printf(" ");
          printf("%d",a[k]);
      }
      while(j>=0&&a[j]>t)//与之前排过序的比较 
      {  a[j+1]=a[j];// 大的往后走 
         a[j]=t;//小的往前走 
         j--;
      }
      printf("\n");
   }
   return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char w[1000][1000];
    int n, flag=0, l, i, j;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%s",w[i]);
    
    for(i=0;i<n;i++){
        for(j=1;j<n;j++){
            if(strcmp(w[i],w[i+j])==0) flag=1;
        }
        if(i>0){
            l=strlen(w[i-1]);
            if(w[i-1][l-1]!=w[i][0]) flag=1;
        }
    }
    if(!flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;
  std::vector<int64_t> a(n);
  std::cin >> a;

  std::sort(a.begin(), a.end(), std::greater<int64_t>());

  const auto sum = summation(a.cbegin(), a.cend());

  if (a[m - 1] * 4 * m < sum) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }

  return 0;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    sort(v.begin(), v.end());

    if(sum % 10 != 0) cout << sum << endl;
    else{
        for (int i = 0; i < n; ++i) {
            if (v[i] % 10 != 0){
                cout << sum - v[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <set>
#include <map>
#include <complex>
#include <deque>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define inf 999999999
#define ll long long
#define sort(a,n) sort(a,a+n)
#define fi  first
#define se second
#define pb(a) push_back(a)

const ll MOD = 1000000007;
const double PI = 3.141592653589793238;

//--------------------------------------------------------------------------------------------//
int w, a, b;
int main() {
	cin >> w >> a >> b;
	int n = b - w - a;
	int m = a - w - b;
	if (n <= 0 && m <= 0) {
		cout << 0 << endl;
	}
	else {
		if (n > 0) {
			cout << n << endl;
		}
		else {
			cout << m << endl;
		}
	}
}


Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
if x >= a ** 2 * b / 2:
  theta = math.degrees(math.atan(2 * (a ** 2 * b - x) / a ** 3))
else:
  theta = 90 - math.degrees(math.atan(2 * x / a / b ** 2))
print(theta)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

#define MAX_N 100005
int n; string s[MAX_N];
map<string,int> occ;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n; list(i,n) cin >> s[i];
    int ans = 0;
    list(i,n){
        sort(s[i].begin(),s[i].end());
        ans += occ[s[i]];
        occ[s[i]]+=1;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main(){
 int n,m; cin >>n >>m;
 long long a[60],b[60],c[60],d[60];

 for(int i=0;i<n;i++)
 cin >>a[i]>>b[i];
 for(int i=0;i<m;i++)
 cin >>c[i]>>d[i];

 for(int i=0;i<n;i++){
   int index;
   long long min=1e09;
   for(int j=0;j<m;j++){
     if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min) {min=abs(a[i]-c[j])+abs(b[i]-d[j]);index= j;}
   }
   cout <<index+1<<endl;
 }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int d = scan.nextInt();
		int n = scan.nextInt();
		
		int ans = (int)Math.pow(100, d) * (n + n / 100);
		System.out.println(ans);
	}
}

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

const int N=200010;
int n,a[N],m;

bool check(int x){
	for(int i=x*2+1;i<=2*n;i++) if(a[i]+a[2*n-i+2*x+1]<m) return false;
	return true;
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	int l=0,r=n,ans=0;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)) r=(ans=mid)-1;
		else l=mid+1;
	}
	int mmax=0;
	for(int i=1;i<=ans;i++) mmax=max(mmax,a[i]+a[2*ans-i+1]);
	for(int i=2*ans+1;i<=2*n;i++) mmax=max(mmax,a[i]+a[2*n-i+2*ans+1]-m);
	printf("%d\n",mmax);
}

Measured memory_bytes: 1024
from operator import itemgetter

N = int(input())

P = []
for i in range(N):
  P.append(list(map(int, input().split())))

P.sort(key=itemgetter(2), reverse=True)

for i in range(101):
  for j in range(101):
    H = P[0][2] + abs(i-P[0][0]) + abs(j-P[0][1])
    for k in range(1,N):
      flg = True
      if P[k][2] == max(0, H - abs(P[k][0]-i) - abs(P[k][1]-j)):
        pass
      else:
        flg = False
        break
        
    if flg:
      print(i, j, H)
      exit(0)


Measured memory_bytes: 3064
H, W, K = map(int, input().split())
mod = 10 ** 9 + 7
dp = [[0] * W for i in range(H + 1)]

dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for k in range(1 << (W - 1)):
            flag = True
            if '11' in bin(k):
                flag = False
            if flag:
                if j >= 1 and (k >> (j - 1)) & 1:
                    dp[i + 1][j - 1] += dp[i][j]
                    dp[i + 1][j - 1] %= mod
                elif j <= W - 1 and (k >> j) & 1:
                    dp[i + 1][j + 1] += dp[i][j]
                    dp[i + 1][j + 1] %= mod
                else:
                    dp[i + 1][j] += dp[i][j]
                    dp[i + 1][j] %= mod
                    
print(dp[-1][K - 1])

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[1000005];
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	a[0] = 0;
	a[n+1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += abs(a[i]-a[i-1]);
	}
	sum += abs(a[n] - 0);
	ll ans;
	for (int i = 1; i <= n; i++) {
		ans = sum + abs(a[i - 1] - a[i + 1]) - (abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1]));
		cout << ans  << endl;
	}
	return 0;
}




Measured memory_bytes: 2048
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>

#define FOR(i,N) for(int i=0;i<N;i++)
#define REP(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int

using namespace std;

int main(){
	string str1,str2;
	bool bo=true;
	int n,ans=0;
	int i,j;
	cin>>n;
	cin>>str1;
	cin>>str2;
	FOR(i,n){
		FOR(j,n-i){
			if(str1[j+i]!=str2[j]){
			bo=false;
			break;
			}
		}
		if(bo==true){
			ans=n+i;
			break;
		}
		bo=true;
	}
	if(ans==0)
		ans=n+n;
	cout<<ans;

return 0;
}

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

int main(){
  string s;
  cin >> s;
  string arr[] = {"KIH", "B", "R", ""};
  bool ans = false;
  for(int i = 0 ; i < 1 << 4 ; i++){
    string t = "";
    for(int j = 0 ; j < 4 ; j++){
      if(i >> j & 1){
        t += "A";
      }
      t += arr[j];
    }
    if(s == t){
      ans = true;
      break;
    }
  }
  if(ans){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        R, S, P = map(int, input().split())
        T = input().rstrip()

        jyanken = {'r': 'p', 's': 'r', 'p': 's'}

        win = []
        for t in T:
            win.append(jyanken[t])

        pointer = len(T) - 1
        while pointer - K >= 0:
            if win[pointer] == win[pointer - K]:
                win[pointer - K] = 'x'
            pointer -= 1

        points = {'r': R, 's': S, 'p': P, 'x': 0}
        ans = 0
        for w in win:
            ans += points[w]

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


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

void solve(long long R) {
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

int main() {
    long long R;
    scanf("%lld", &R);
    solve(R);
    return 0;
}


Measured memory_bytes: 3772
import sys


N = int(input())
B = [inp for inp in map(int, input().split())]

if N == 2:
  print(B[0]*2)
  sys.exit()

A = []
A.append(B[0])

for i in range(1, N-1):
  b = min(B[i], B[i-1])
  A.append(b)

A.append(B[-1])
  
print(sum(A))

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 1000000000
#define mod 1000000007

typedef long long ll;

const int N = 2e5 + 5;

int a[N];

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

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

    int k = 1;

    for (int i = 0; i < n; i++)
        if (a[i] == k)
            k++;

    if (k == 1)
        cout << -1;
    else
        cout << n - k + 1;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
ll t[1005];
ll a[1005];
 
int main(){
    //freopen("c3.in", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lli %lli", &t[i], &a[i]);
    }
    ll currentT = 1, currentA = 1;
    for (int i = 0; i < n; ++i) {
        ll multiT = (currentT - 1LL) / t[i] + 1LL;
        ll multiA = (currentA - 1LL) / a[i] + 1LL;
        ll multi = max(multiT, multiA);
        currentT = t[i] * multi;
        currentA = a[i] * multi;
        //printf("%d %lli %lli %lli %lli\n", i, multiT, multiA, currentT, currentA);
    }
    printf("%lli\n", currentT + currentA);
    return 0;
}

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

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    ll a,b,c ;
    cin >> a >> b >> c;

    if(c-a-b<0){
      cout << "No" << endl ;
    }else{
        if((4*a*b)<(c-a-b)*(c-a-b))
          cout << "Yes" << endl ;
        else 
          cout << "No" << endl ;          
    }
        return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
ll A, B, C;
vector<int> vec;

int tA = 0, tB = 0, tC = 0;
int cA = 0, cB = 0, cC = 0;
int ans = INT_MAX;

void calc(int pos) {

	if (pos == N) {

		if (cA == 0 || cB == 0 || cC == 0) return;

		ll tmp = 0;
		int ttA = tA;
		int ttB = tB;
		int ttC = tC;
		if (ttA < ttB) swap(ttA, ttB);
		if (ttB < ttC) swap(ttB, ttC);
		if (ttA < ttB) swap(ttA, ttB);

		ans = min(ans,(int)(abs(A - ttA) + abs(B - ttB) + abs(C - ttC) + (cA+cB+cC-3)*10));

		return;
	}

	tA += vec[pos];
	cA++;
	calc(pos + 1);
	tA -= vec[pos];
	cA--;
	tB += vec[pos];
	cB++;
	calc(pos + 1);
	tB -= vec[pos];
	cB--;
	tC += vec[pos];
	cC++;
	calc(pos + 1);
	tC -= vec[pos];
	cC--;
	//使わない
	calc(pos + 1);
}

//解法
void solve() {

	calc(0);

	cout << ans;
	
	return;
}

int main() {

	//入力
	cin >> N >> A >> B >> C;
	vec.resize(N);
	rep(i, N) {
		cin >> vec[i];
	}

	solve();
	cout << endl;
	return 0;
}

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

class BIT{
public:
  int n,bit[500010];
  BIT(){fill(bit,bit+500010,0);}
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};

int main() {
  ll d[111111],mod=1000000007;
  d[0]=1;
  for(int i=1; i<111111; i++) {
    d[i]=d[i-1]*i;
    d[i]%=mod;
  }
  int n;
  while(cin >> n && n) {
    int a[n];
    for(int i=0; i<n; i++) a[i]=i+1;
    int T;
    cin >> T;
    while(T--) {
      int x,y;
      cin >> x >> y;
      x--,y--;
      swap(a[x],a[y]);
    }
    BIT b=BIT();
    b.n=n;
    for(int i=1; i<=n; i++) b.add(i+1,1);
    ll ans=0;
    for(int i=0; i<n; i++) {
      ll x=b.sum(a[i]);
      ans+=x*d[n-i-1];
      ans%=mod;
      b.add(a[i],-1);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6244
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int a[] = new int[n];
		long sum = 0;
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			sum += a[i];
		}

		Arrays.sort(a);
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(new Comparator<Integer>() {

			@Override
			public int compare(Integer n1, Integer n2) {
				// TODO 自動生成されたメソッド・スタブ
				return n2 - n1;
			}
		});

		long result = a[n - 1];
		pq.add(a[n - 2]);
		pq.add(a[n - 2]);

		for(int i = 2; i < n; i++){
			int tmp = pq.remove();
			result += tmp;
//			System.out.println("tmp "+tmp+" result "+result);

			pq.add(a[n - i - 1]);
			pq.add(a[n - i - 1]);
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 53296
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

using namespace std;


int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int a=0;
        cin >> a;
        if(a%2==1){
            cout<<"first";
            return 0;
        }
    }
    cout<<"second";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 3216
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF (1000000000000000)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll max_n = 100000;
ll a[max_n*3];
ll b[max_n*2];
ll c[max_n*2];
priority_queue<ll,vector<ll>,greater<ll>> front;
priority_queue<ll,vector<ll>,less<ll>> back;

int main(){
  ll n;
  cin >> n;
  b[0] = 0;
  c[n] = 0;
  REP(i,3*n){
    cin >> a[i];
    if(i>=0&&i<n) front.push(a[i]), b[0]+=a[i];
    if(i>=2*n&&i<3*n) back.push(a[i]), c[n]+=a[i];
  }
  for(ll k = 1; k <= n; k++){
    b[k] = b[k-1];
    front.push(a[n+k-1]);
    b[k]+=a[n+k-1];
    b[k]-=front.top();
    front.pop();
  }
  for(ll k = n-1; k >=0; k--){
    c[k]=c[k+1];
    back.push(a[n+k]);
    c[k]+=a[n+k];
    c[k]-=back.top();
    back.pop();
  }
  ll ans = -INF;
  REP(i,n+1){
    //cout << b[i] << c[i] << endl;
    ans = max(ans,b[i]-c[i]);
  }
  cout << ans << endl;
  return 0;
}


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

ll factorial(int N){
    int ans = 1;
    for(int i = 2; i <= N; ++i){
        ans *= i;
    }
    return ans;
}

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

    ll comb = factorial(N);
    ll constance = 2 * factorial(N-1);

    double ans = 0;

    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; ++j){
            double dis = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) * constance;
            ans += dis;
        }
    }
    ans /= comb;
    cout << fixed << setprecision(8);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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() {
  int Q;
  cin >> Q;

  const int D = 30;

  auto solve = [&](ll a, ll b, ll c, ll d) {
    ll ans = abs(c - a) + abs(d - b);
    ll s = 1;
    for (int i = 0; i < (int)(D); ++i) s *= 3;

    ans = abs(c - a) + abs(d - b);
    while (true) {
      s /= 3;
      if (s <= 0) break;

      ll ia = a / s, ic = c / s;
      if (ia != ic) break;

      ll jb = b / s, jd = d / s;
      if (abs(jb - jd) <= 1 || ia % 3 != 1) continue;

      ll r = (ia + 1) * s, l = ia * s - 1;
      ans += 2 * min(r - max(a, c), min(a, c) - l);
      break;
    }
    return ans;
  };

  for (int i = 0; i < (int)(Q); ++i) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c, --d;
    cout << max(solve(a, b, c, d), solve(b, a, d, c)) << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int f(string s){
    int n=s.size();
    int ret = 0;
    int t=1;
    for(int i=0;i<n;i++){
        if(s[i]>='0' && s[i]<='9'){
            t = s[i]-'0';
        }
        if(s[i]=='m'){
            ret += t*1000;
            t=1;
        }
        if(s[i]=='c'){
            ret += t*100;
            t=1;
        }
        if(s[i]=='x'){
            ret += t*10;
            t=1;
        }
        if(s[i]=='i'){
            ret += t*1;
            t=1;
        }
    }
    return ret;
}

string f2(int n){
    string ret;
    int m=n/1000;
    n %= 1000;
    int c=n/100;
    n %= 100;
    int x=n/10;
    n %= 10;
    int i=n;
    if(m!=0){
        if(m!=1)
            ret += m+'0';
        ret += "m";
    }
    if(c!=0){
        if(c!=1)
            ret += c+'0';
        ret += "c";
    }
    if(x!=0){
        if(x!=1)
            ret += x+'0';
        ret += "x";
    }
    if(i!=0){
        if(i!=1)
            ret += i+'0';
        ret += "i";
    }
    return ret;
}

void solve(){
    string s1,s2;
    cin >> s1 >> s2;
//    cout <<f(s1) << " : " << f(s2) << endl;
    int N = f(s1) + f(s2);
    cout << f2(N) << endl;
}


int main(){
    int n;
    cin >> n;
    rep(i,n){
        solve();
    }
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
#define PB push_back
const int N=2e4+10;
const long long int TOP=1e13;
struct bignum{
    int size;
    vector<long long int>val;
    void init(int n){
        val.clear();
        val.PB(n);
        pull();
        return ;
    }
    void pull(){
        int k=0;
        for(int i=0;i<val.size();i++){
            val[i]+=k;
            k=0;
            if(val[i]>=TOP){
                k=val[i]/TOP;
                val[i]%=TOP;
            }
        }
        if(k>0)val.PB(k);
        size=(int)val.size();
    }
    void out(){
        long long int now;
        reverse(val.begin(),val.end());
        printf("%lld",val[0]);
        for(int i=1;i<size;i++){
            now=TOP/10;
            while(val[i]<now){
                now/=10;
                printf("0");
            }
            printf("%lld",val[i]);
        }
        printf("\n");
        reverse(val.begin(),val.end());
        return ;
    }
    void operator *=(long long int n){
        for(int i=0;i<size;i++)val[i]*=n;
        pull();
        return ;
    }
};
void C(int a,int b){
    bignum ans;
    bitset<N> bs;
    vector<int> prime,mul;
    int temp;
    bs.reset();
    prime.PB(2);
    for(int i=3;i<N;i+=2)if(!bs[i]){
        prime.PB(i);
        for(int j=i*i;j<N;j+=(i<<1))bs[j]=true;
    }
    mul.resize(prime.size());
    for(int i=2;i<=a;i++){
        temp=i;
        for(int j=0;j<prime.size();j++){
            while(temp%prime[j]==0){
                mul[j]++;
                temp/=prime[j];
            }
            if(temp<=1)break;
        }
    }
    for(int i=2;i<=b;i++){
        temp=i;
        for(int j=0;j<prime.size();j++){
            while(temp%prime[j]==0){
                mul[j]--;
                temp/=prime[j];
            }
            if(temp<=1)break;
        }
    }
    for(int i=2;i<=a-b;i++){
        temp=i;
        for(int j=0;j<prime.size();j++){
            while(temp%prime[j]==0){
                mul[j]--;
                temp/=prime[j];
            }
            if(temp<=1)break;
        }
    }
    ans.init(1);
    for(int i=0;i<prime.size();i++){
        while(mul[i]>0){
            mul[i]--;
            ans*=prime[i];
        }
    }
    return ans.out();
}
void H(int a,int b){
    return C(a+b-1,b);
}
int main(){
    int n,m,r;
    scanf("%d%d%d",&n,&m,&r);
    if(n*m>r)printf("%d\n",0);
    else H(n,r-n*m);
}



Measured memory_bytes: 2840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 0X3F3F3F3F;
const ll N = 1e5+7;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

int main()
{
	IOS();
	int a,b;
	cin>>a>>b;
	cout<<6-a-b<<endl;
	return 0;
}



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

int cnt,M,D;

int main(){
    int i,j,d1,d2;

    cnt=0;

    cin >> M >> D;

    for(i=1;i<=M;++i){
        for(j=1;j<=D;++j){
            d1=j/10;
            d2=j%10;
            if(d1>=2&&d2>=2){
                if(d1*d2==i){
                    ++cnt;
                }
            }
        }
    }

    cout << cnt ;

    return 0;
}


Measured memory_bytes: 3616
n = int(input())
def checker(n):
    words = []
    last_one = []
    for i in range(n):
        word = input()
        wl = list(word)
        h = wl[0]
        l = wl[-1]
        if word in words:
            print('No')
            return
        if i>0 and  h != last_one[-1]:
            print('No')
            return
        words.append(word)
        last_one.append(l)
    print('Yes')
    return

checker(n)

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

/*** Template Begins ***/

typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
int a[3];


void solve() {
    
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0] + a[1] << endl;


}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if(s.equals("SUN")){
            System.out.println(7);
        }else if(s.equals("MON")){
            System.out.println(6);
        }else if(s.equals("TUE")){
            System.out.println(5);
        }else if(s.equals("WED")){
            System.out.println(4);
        }else if(s.equals("THU")){
            System.out.println(3);
        }else if(s.equals("FRI")){
            System.out.println(2);
        }else if(s.equals("SAT")){
            System.out.println(1);
        }
        sc.close();
    }
    
}

Measured memory_bytes: 22100