akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

string s;
LL ans = 0;

void dfs(int x, LL now, LL sum) {
  if (x == s.size()) {
    ans += sum + now;
    return;
  }

  LL next_now = now * 10 + (s[x] - '0');
  dfs(x + 1, next_now, sum);
  dfs(x + 1, s[x] - '0', sum + now);
}

int main() {
  cin >> s;
  dfs(1, s[0]-'0', 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=1&&a<=9&&b>=1&&b<=9)
        printf("%d",a*b);
    else
        printf("-1");
    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;
typedef pair<int,int> P;


const int MAXN = 1005;

int main() {
  int k,n;
  cin>>k>>n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  rep(i,n-1){
    b[i]=a[i+1]-a[i];
  }
  b[n-1]=k-a[n-1]+a[0];
 
  sort(b.begin(),b.end());
  int ans=k-b.back();
  cout<<ans;

}


Measured memory_bytes: 1792
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

if n < 1000:
    print('ABC')
else:
    print('ABD')

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

using namespace std;

int main()
{
    int n, d, e;
    long long ans=0;
    cin>>n;
    vector<int> a(n), b(n), c(n);
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=0; i<n; i++) cin>>b[i];
    for (int i=0; i<n; i++) cin>>c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    for (int i=0; i<n; i++)
    {
        auto itr=lower_bound(a.begin(), a.end(), b[i]);
        d=itr-a.begin();
        itr=upper_bound(c.begin(), c.end(), b[i]);
        e=c.end()-itr;
        ans+=(long long)d*e;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1408
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    loop(n,i,0)
        cin>>arr[i];
    sort(all(arr,n));
    ll res=0;
    loop(k,i,0)
        res+=arr[i];
    cout<<res<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
	char str[1201] = {0}, x;
	int i, count[50] = {0}, plus;
	while (gets(str) != NULL)
	{
		for (i = 0; str[i] != '\0'; i++)
		{
			if ('a' <= str[i] && str[i] <= 'z' || 'A' <= str[i] && str[i] <= 'Z')
			{
				if ('A' <= str[i] && str[i] <= 'Z')
					count[str[i]-'A']++;
				else
					count[str[i]-'a']++;
			}
		}
	}
	for (i = 'a'; i <= 'z'; i++)
	{
		printf("%c : %d\n", i, count[i - 'a']);
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define N 200002
using namespace std;
vector<int> v[N],vv[2],nr[3];
int c[N],l[N];
void dfs(int i)
{
    vv[l[i]%2].push_back(i);
    for(auto it:v[i])
        if(!l[it])
            l[it]=l[i]+1,dfs(it);
}
void ad(int i,int j)
{
    c[vv[i].back()]=nr[j].back();
    vv[i].pop_back();
    nr[j].pop_back();
}
int main()
{
    int n,i,j,k;
    cin>>n;
    for(k=1;k<n;k++)
    {
        cin>>i>>j;
        v[i].push_back(j);
        v[j].push_back(i);
        nr[k%3].push_back(k);
    }
    nr[n%3].push_back(n);
    l[1]=1;
    dfs(1);
    if(vv[0].size()<=n/3)
    {
        while(vv[0].size())
            ad(0,0);
        while(vv[1].size())
            ad(1,nr[0].size()?0:(nr[1].size()?1:2));
    }
    else if(vv[1].size()<=n/3)
    {
        while(vv[1].size())
            ad(1,0);
        while(vv[0].size())
            ad(0,nr[0].size()?0:(nr[1].size()?1:2));
    }
    else
    {
        while(vv[0].size())
            ad(0,nr[1].size()?1:0);
        while(vv[1].size())
            ad(1,nr[0].size()?0:2);
    }
    for(i=1;i<=n;i++)
        cout<<c[i]<<" ";
    return 0;
}

Measured memory_bytes: 20500
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    cout<<n*180-360<<endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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 INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> table(N, 0);
    for (int i = 2; i <= N; i++) {
        int Ai;
        cin >> Ai;
        table[Ai - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << table[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int LL;
const int maxn = 1e6 + 10;
const int mod = 998244353;
const LL inf = 1e15;
LL n, a[maxn], sum[maxn];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) sum[i] = sum[i-1] + a[i];
    LL ans = inf;
    for(int i=2; i<n-1; i++){
        int st = lower_bound(sum+1, sum+1+i, sum[i]/2) - sum;
        st = max(st-1, 1);
        LL mi = abs(sum[i]-sum[st]*2);
        for(;st<i;st++){
            LL val = abs(sum[i]-sum[st+1]*2);
            if(val > mi) break;
            mi = val;
            if(st == i-1) break;
        }
        a[0] = sum[st]; a[1] = sum[i] - sum[st];
        st = lower_bound(sum+1+i+1, sum+1+n, (sum[n]-sum[i])/2+sum[i]) - sum;
        st = max(st-1, i+1);
        mi = abs(sum[n]-sum[st]-sum[st]+sum[i]);
        for(;st<n;st++){
            LL val = abs(sum[n]-sum[st+1]-sum[st+1]+sum[i]);
            if(val > mi) break;
            mi = val;
            if(st == n-1) break;
        }
        a[2] = sum[st] - sum[i]; a[3] = sum[n] - sum[st];
        sort(a, a+4);
        ans = min(ans, a[3] - a[0]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5888
#include<stdio.h>

int main(void){
	char f=1;
	char i=0;
	char c;
	while((c=getchar())!=10){
		if(i&&c=='R'||(!i&&c=='L')){
			f=0;
			break;
		}
		i=!i;
	}
	if(f){
		puts("Yes");
	}else{
		puts("No");
	}
}


Measured memory_bytes: 128
#include <stdio.h>

#define N 10000
#define Q 500

int main(){

  int i, j;
  int s[N], t[Q];
  int n, q;
  int count = 0;

  scanf("%d", &n);

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

  }

 scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &t[i]);

  }

  /*for(i = 0; i < n; i++){//S
    for(j = 0; j < q; j++){//T

      if(s[i] == t[j]){
	count++;
	break;
      }

    }
    }*/

  for(i = 0; i < q; i++){//T
    for(j = 0; j < n; j++){//S

      if(t[i] == s[j]){
	count++;
	break;
      }

    }
  }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    int A[M] = {0};

    int K, a;
    for (int i = 0; i < N; ++i) {
        std::cin >> K;
        for (int j = 0; j < K; ++j) {
            std::cin >> a;
            ++(A[a -1]);
        }
    }

    int ans = 0;
    for (int i = 0; i < M; ++i) {
        if (A[i] == N) {
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());//段数
	int m = Integer.parseInt(sc.next());//破損数
	int[] a = new int[n+1];//破損配列all(01)
	long[] s = new long[n+1];//到達パターン
	boolean flag = true;//到達可能性
	
	for(int i = 0; i<n+1; i++){
		a[i] = 1;
	}
	if(m!=0){
		int b = 0;
		for(int i = 0; i<m; i++){
			b = Integer.parseInt(sc.next());
			if(a[b-1] != 0){
				a[b] = 0;
			}else{
				flag = false;
				System.out.println(0);
				break;
			}
		}
	}
	
	if(flag){
		s[0] = 1;
		s[1] = 1;
		if(n!=1){
			for(int i = 2; i < n+1; i++){
				s[i] += (s[i-1]*a[i-1] + s[i-2]*a[i-2])%1000000007;
			}
		}
	System.out.println(s[n]);
	}
	
	}
}

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

using namespace std;

int main() {

	int n;
	cin >> n ;

	int a;
	a = n;

	int m=0;
	
	while (n != 0) {
		m += n % 10;
		n /= 10;
	}

	cout << (a%m==0? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
vector<ll>q[200003];
ll l[200003],r[200003];
ll ans;
ll k[200003];
void dfs(ll a,ll fa)
{ l[a]=++ans;k[ans]=a;
    for(ll i=0;i<q[a].size();i++)
    { ll ii=q[a][i];
        if(ii==fa)continue;
        dfs(ii,a);
    }
    r[a]=ans;
}
ll sum[200003],p[200003];
int main()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1,0);
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        sum[l[a]]+=b;
        sum[r[a]+1]-=b;
    }
    for(ll i=1;i<=n;i++)
    {
        sum[i]+=sum[i-1];
       p[k[i]]=sum[i];
    }
      for(ll i=1;i<=n;i++)
    printf(i==n?"%lld\n":"%lld ",p[i]);
return 0;
}

Measured memory_bytes: 30464
s = input()
x, y = map(int, input().split())

count = [[], []]
now = 0
for f in s.split('T') :
    count[now].append(len(f))
    now ^= 1

def solve() :
    dp = set([count[0][0]])
    for c in count[0][1:] :
        if c == 0 :
            continue
        dp_ = set()
        for xi in dp :
            dp_.add(xi+c)
            dp_.add(xi-c)
        dp = dp_
    if not x in dp :
        return 'No'
    
    dp = set([0])
    for c in count[1] :
        if c == 0 :
            continue
        dp_ = set()
        for yi in dp :
            dp_.add(yi+c)
            dp_.add(yi-c)
        dp = dp_
    if not y in dp :
        return 'No'
    return 'Yes'

print(solve())

Measured memory_bytes: 47196
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

int main() {
#ifdef WYXLOCAL
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif // WYXLOCAL
	int n;
	scanf("%d", &n);
	if (n == 1) {
		puts("Hello World");
	} else {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%d\n", a+b);
	}
	
	return 0;
}


Measured memory_bytes: 760
#include<iostream>
using namespace std;
int main()
{
  int money,count = 0,oturi[1000] = {};
  int money2[6] = {500,100,50,10,5,1};

  for(int i = 0;i >= 0;i++){
    cin >> money;
    count++;
    if(money == 0)
      break;
    oturi[i] = 1000 - money;
  }

  for(int j = 0;j < count;j++){
    int maisu = 0;
    for(int i = 0;i < 6;i++){
      maisu += oturi[j] / money2[i];
      oturi[j] %= money2[i];
    }
    if(maisu > 0)
      cout << maisu << endl;
  }
    return 0;
  }
    

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
    
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> a(n+1, 0);
    for(ll i = 0; i < n; ++i){
        if(s[i] == '<') chmax(a[i+1], a[i]+1); 
    }
    for(ll i = n-1; i >= 0; --i){
        if(s[i] == '>') chmax(a[i], a[i+1]+1);
    }
    ppp(max(accumulate(a.begin(), a.end(), 0LL), 0LL));

    return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

int N, K;
Graph G;
int ans;

// returns depth
int dfs(int v, int pre) {
    // cout << v << " " << pre << " " << ans << endl;
    int depth = 0;
    for (auto nxt : G[v]) {
        depth = max(depth, dfs(nxt, v));
    }
    if (v != 0 && depth >= K - 1 && pre > 0) {
        ans++;
        depth = -1;
    }
    return depth + 1;
}

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

    cin >> N >> K;
    vi a(N);
    rep(i, N) {
        cin >> a[i];
        a[i]--;
    }

    ans = 0;
    if (a[0] != 0) {
        a[0] = 0;
        ans++;
    }

    G.resize(N);
    rep2(i, 1, N) {
        G[a[i]].emplace_back(i);
    }

    dfs(0, -1);
    cout << ans << endl;
}


Measured memory_bytes: 11264
#include <cstdio>

using namespace std;

int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (a+b < c+d)
		printf("Right\n");
	else if(a+b > c+d)
		printf("Left\n");
	else
		printf("Balanced\n");

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int s,w;
  cin >> s >> w;

  if(w>=s){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
  char x;
  cin >> x;
  if (x == 'A') {
    cout << 'T' << '\n';
  } else if (x == 'T') {
    cout << 'A' << '\n';
  } else if (x == 'C') {
    cout << 'G' << '\n';
  } else {
    cout << 'C' << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

fn solve() {
    input! {
        n: usize, k: usize,
        mut av: [i64; n]
    };

    av.sort();
    let res = bsearch(10.pow(18) + 1, -10.pow(18) - 1, |x| {
        let mut count = 0;
        for i in 0..n {
            let a = av[i];
            if a >= 0 {
                let j = bsearch(i as i64, n as i64, |j| {
                    let j = j as usize;
                    let b = av[j];
                    a * b <= x
                });
                if let Some(j) = j {
                    count += j as usize - i;
                }
            } else {
                let j = bsearch(n as i64, i as i64, |j| {
                    let j = j as usize;
                    let b = av[j];
                    a * b <= x
                });
                if let Some(j) = j {
                    count += n - j as usize;
                }
            }
        }
        count >= k
    });
    println!("{}", res.unwrap());
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 5156
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    int m; cin >> m;
    
    ll sum = 0, keta = 0;
    for (int i = 0; i < m; i++) {
        ll a, b; cin >> a >> b;
        sum += a*b;
        keta += b;
    }
    cout << keta-1 + (sum-1)/9 << endl;
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

c =0 
for n in range(0,10000):
    taxa = int(n*8/100)
    taxb = int(n*10/100)
    if a == taxa and b == taxb:
        print(n)
        break
    else:
        c += 1
if c > 9999:
    print(-1)

Measured memory_bytes: 3060
#include <iostream>
const int MAX_N = 50;
using namespace std;

int dp[MAX_N];

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

    dp[0] = dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i-1] + dp[i-2];
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
#include <atcoder/all>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

using namespace atcoder;
int main() {
    static char buf[500'001];
    scanf("%s", buf);
    string s = buf;
    vector<int> sa = suffix_array(s);
    long long answer = 1LL * s.size() * (s.size() + 1) / 2;
    for (auto x : lcp_array(s, sa)) {
        answer -= x;
    }
    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 16180
#include <cstdio>

int main(void){
    int i,n,tmp,min=1000000001;
    int cnt=0;
    long int sum = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<0){
            cnt++;
            tmp = -tmp;
        }
        sum += tmp;
        if(min>tmp)min=tmp;
    }
    if(cnt%2){
        sum -= 2*min;
    }
    printf("%ld\n",sum);
    return 0;
}


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

//2のn乗をMODで割った余りを返す
long long mod_2pow(int n){
  long long ans = 1;
  for(int i=0; i<n; i++)
    ans = (ans*2)%MOD;
  return ans;
}


int main(){
  int N;
  cin >> N;
  //firstがsecond回登場したことを表す
  map<int, int> m;
  int a;
  rep(i, N){
    cin >> a;
    m[a]++;
  }
  //ここまで入力

  //数え始める数字
  int s;
  
  //Nが偶数ならばa[i]は奇数になる
  //よって初めは1からスタート
  if(N%2 == 0)
    s = 1;
  //Nが奇数なら2からスタート
  else{
    //0の登場回数は1以外だと並び順が存在しない
    if(m[0] != 1){
      cout << 0 << endl;
      return 0;
    }
    s = 2;
  }

  //対称の人とペアになるはず
  for(; s<=N; s+=2)
    if(m[s] != 2){
      cout << 0 << endl;
      return 0;
    }

  cout << mod_2pow(N/2) << endl;

  return 0;
}


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

using namespace std;

int main() {
	int A;
	int B;
	int min_length;

	cin >> A >> B;

	min_length = A - B * 2;

	if (min_length > 0) {
		cout << min_length << endl;

	}
	else {
		cout << 0 << endl;
	}


	system("pause");
	return 0;
}



Measured memory_bytes: 504
/************************************************
*Author        :  xzj213
*Created Time  :  2019.10.27.20:12
*Mail          :  xzj213@qq.com
*Problem       :  C
************************************************/
#include <bits/stdc++.h>
#define int long long
using namespace std;
int ask;
int read() {
    int x=0,f=1;
    char ch=getchar();
    while(ch>57 || ch<48){if(ch==45)f=-1;ch=getchar();}
    while(ch<=57 && ch>=48){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
signed main() {
    ask=read();
	for(int i=sqrt(ask);i>=0;i--){
		if(ask%i==0){
			cout<<i+ask/i-2<<endl;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;
  double x[4],y[4];

  cin >> n;
  while(n--){
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
    y[1]-=y[0];
    x[1]-=x[0];
    y[3]-=y[2];
    x[3]-=x[2];
    if(fabs(y[1]*x[3] - y[3]*x[1]) < 10e-12)cout << "YES";
    else cout << "NO";
    cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==7&&(b==5&&c==5)){
    cout<<"YES"<<endl;
  }
  else if(b==7&&(a==5&&c==5)){
    cout<<"YES"<<endl;
  }
  else if(c==7&&(a==5&&b==5)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    map<string,int> mp;
    int N;  cin >> N;
    for(int i=0; i<N; i++){string S; cin >> S; mp[S]++;}
    int m = 0;
    for(auto it=mp.begin(); it!=mp.end(); it++) m = max(m,it->second);
    for(auto it=mp.begin(); it!=mp.end(); it++) if(it->second == m) print(it->first);
}

Measured memory_bytes: 19148
#include <iostream>
#include <string>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;

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

	ll l, r, m;
	l = 0; r = 1e17;
	ll cnt;
	while(l <= r) {
		m = (l+r)/2;
		ll mn, mx;
		ll add = 1;
		cnt = 0;
		mn = 0; mx = 9;
		while(mx <= m) {
			cnt += add * (mx-mn - ((mx/3+mx/5) - (mn/3+mn/5))
					+ (mx/15 - mn/15));
			mn = mx;
			mx = mx * 10 + 9;
			add++;
		}
		mx = m;
		cnt += add * (mx-mn - ((mx/3+mx/5) - (mn/3+mn/5))
				+ (mx/15 - mn/15));
		cnt += 4 * (m/3+m/5);
		assert(cnt>=0);
//		cout << mx << "," << mn << "," << m << "," << cnt << endl;

		if(s-20 < cnt && cnt < s)
			break;
		if(cnt < s) {
			l = m+1;
		}
		else {
			r = m-1;
		}
	}
	string str = "";
	for(ll i = m+1; i < m+100; i++) {
		string nu;
		stringstream sstr;
		sstr << i;
		sstr >> nu;
		if(i%15==0)
			str += "FizzBuzz";
		else if(i%3==0)
			str += "Fizz";
		else if(i%5==0)
			str += "Buzz";
		else
			str += nu;
	}
	cout << str.substr((s-1)-cnt,20) << endl;
}

Measured memory_bytes: 1232
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H = int(input())

    if H == 1:
        print(1)
        sys.exit()

    now = H
    num = 1
    res = 0

    while True:
        if now == 1:
            res += num
            break
        res += num
        now = now // 2
        num *= 2

    print(res)



main()


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

int main() {
    int X; cin >> X;
    int k = 1;
    if (X == 1) cout << 1 << endl;
    else {
        for (int i = 2; i < X; i++) {
            for (int j = 2; pow(i, j) <= X; j++) {
                int l = pow(i, j);
                k = max(k, l);
            }
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
using namespace std;

int main() {
	string S; cin >> S; int cnt = 0;
	for (int i = 0; i < 6; i++) {
		if (S[i] == '1')cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) sort((a).rbegin(),(a).rend());
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n,m;


struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};





signed main(){
    cin >> n;
    vector<P> a(n);
    REP(i,n){
        int s,t;
        cin >> s >> t;
        a[i] = make_pair(s,t);
    }
    int ans = 1;
    Sort(a);
    REP(i,n-2){
        FOR(j,i+1,n-1){
            int x = a[j].first - a[i].first;
            int y = a[j].second - a[i].second;
            int count = 0;
            FOR(k,0,n-1){
                FOR(l,k+1,n){
                    if(a[l].first-a[k].first == x && a[l].second - a[k].second == y){
                        count++;
                    }
                }
            }
            ans = max(ans,count);
        }
    }
    
    cout << max(n-ans,(int)1) << endl;

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

    int snack[1000] = {0};

    int n, k; cin >> n >> k;

    int d, a;

    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            snack[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (snack[i] == 0) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3656
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

a, b, n = MAP()
x = min(n, b - 1)
print((a * x) // b - a * (x // b))

Measured memory_bytes: 68412
#include<iostream>
#include<cassert>
using namespace std;
int n,k,f[3000][3000],s[3000][3000];
inline int S(int i,int j){return i>=0&&j>=0?s[min(2*k-1,i)][min(2*k-1,j)]:0;}
inline int get(int i,int j){return S(i,j)-S(i,j-k)-S(i-k,j)+S(i-k,j-k);}
int main()
{
	//freopen("C:\\a.txt","r",stdin);
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		char s[5];
		int x,y;
		scanf("%d%d%s",&x,&y,s);
		if(s[0]=='B')x+=k;
		x%=k<<1;
		y%=k<<1;
		f[x][y]++;
	}
	for(int i=0;i<2*k;i++)
		for(int j=0;j<2*k;j++)s[i][j]=S(i,j-1)+f[i][j];
	for(int i=0;i<2*k;i++)
		for(int j=0;j<2*k;j++)s[i][j]+=S(i-1,j);
	int ans=0;
	for(int i=0;i<2*k;i++)
		for(int j=0;j<2*k;j++)ans=max(ans,get(i,j)+get(i-k,j-k)+get(i-k,j+k)+get(i+k,j-k)+get(i+k,j+k)+get(i+k*2,j)+get(i,j+k*2));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 49408
# coding: utf-8
# Your code here!
I =int(input())


# if I ==0:
#     print(I)
    
if I>=500:
    J=I//500
    
    K=J*500*2#
    
    
    P=I-500*J
    if P==0:
        print(K)
    
    if P>=5:
        Q=P//5
        R=Q*5#
        
        A=K+R
        print(A)

if I<500:
        M=I//5
        A=M*5#
        
        
        print(A)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int main(){
	//freopen("in","r",stdin);
	int a=read(),b=read();
	if(a<b)
		puts("0");
	else
		puts("10");
	return 0;
}



Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			
			final int SIZE = 10000000;
			boolean[] isPrime = new boolean[SIZE + 1];
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			
			for(int i = 2; i <= SIZE; i++) {
				if(!isPrime[i]) { continue; }
				
				for(int j = 2 * i; j <= SIZE; j += i) {
					isPrime[j] = false;
				}
			}
			
			long A_rest_prime = A, B_rest_prime = B;
			long A_B_common_primes = 0;
			for(int i = 2; i <= SIZE; i++) {
				if(!isPrime[i]) { continue; }
				
				final boolean isA = A_rest_prime % i == 0;
				final boolean isB = B_rest_prime % i == 0;
				
				while(A_rest_prime > 0 && A_rest_prime % i == 0) { A_rest_prime /= i; }
				while(B_rest_prime > 0 && B_rest_prime % i == 0) { B_rest_prime /= i; }
				
				if(isA && isB) {
					//System.out.println(i + " " + A_rest_prime + " " + B_rest_prime);
					A_B_common_primes += 1;
				}
			}

			System.out.println((A_B_common_primes + 1) + ((A_rest_prime >= 2 && B_rest_prime >= 2 && A_rest_prime == B_rest_prime) ? 1 : 0));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 32468
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int n;
  cin >> n;
  int oddCnt = 0, mult2 = 0, mult4 = 0;
  rep(i,n){
    int input;
    cin >> input;
    if(input % 4 == 0){
      mult4 ++;
    }else if(input % 2 == 0){
      mult2 ++;
    }else{
      oddCnt ++;
    }
  }

  long long prev;
  rep(i,n){
    if(i == 0 && oddCnt > 0){
      prev = 1;
      oddCnt--;
    }else if(prev % 4 == 0){
      if(oddCnt > 0){
        prev = 1;
        oddCnt--;
      }else if(mult2 > 0){
        prev = 2;
        mult2 --;
      }else if(mult4 > 0){
        prev = 4;
        mult4 --;
      }
    }else if(prev % 2 == 0){
      if(mult4 > 0){
        prev = 4;
        mult4--;
      }else if(mult2 > 0){
        prev = 2;
        mult2 --;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }else if(prev % 2 == 1){
      if(mult4 > 0){
        prev = 4;
        mult4--;
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
if sys.version_info[0]>=3: raw_input=input

def main(roman):
	m={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
	r=0
	for i in range(len(roman)):
		r+=m[roman[i]]*(1 if i==len(roman)-1 or m[roman[i]]>=m[roman[i+1]] else -1)
	print(str(r))

if __name__=='__main__':
	try:
		while True:
			main(raw_input().rstrip())
	except EOFError:
		pass

Measured memory_bytes: 4228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007
#define INF 100000000000000000LL

vector<P> vec[100005];
ll dp[100005];

void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		l--, r--;
		vec[l].push_back(P(r, d));
		vec[r].push_back(P(l, -d));
	}
	for (int i = 0; i < n; i++) dp[i] = INF;
	for (int i = 0; i < n; i++) {
		if (dp[i] == INF) {
			queue<int> que;
			que.push(i);
			dp[i] = 0;
			while (!que.empty()) {
				int v = que.front(); que.pop();
				for (int j = 0; j < vec[v].size(); j++) {
					P p = vec[v][j];
					int to = p.first, c = p.second;
					if (dp[to] == INF) {
						dp[to] = dp[v] + (ll)c;
						que.push(to);
					}
					else if (dp[to] != dp[v] + (ll)c) {
						cout << "No" << endl;
						return ;
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
	return;
}

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

Measured memory_bytes: 9728
#include "iostream"

using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = -1LL * n * (n + 1) / 2;
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    ans += v;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, h, w, dsu[2 * N], nodes[2 * N], edges[2 * N];
vector <pair <int, pair <int, int> > > e;

int find(int x){
    if(dsu[x] == x) return x;
    return dsu[x] = find(dsu[x]);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> h >> w;
    for(int i = 0 ; i < 2 * n ; i++){
        dsu[i] = i;
        nodes[i] = 1;
    }
    e.resize(n);
    for(auto &i : e){
        cin >> i.second.first >> i.second.second >> i.first;
        i.second.second += h;
    }
    map <int, int> mp;
    for(auto &i : e) mp[i.second.first], mp[i.second.second];
    int com = 0;
    for(auto &i : mp) i.second = com++;
    for(auto &i : e){
        i.second.first = mp[i.second.first];
        i.second.second = mp[i.second.second];
    }
    sort(e.rbegin(), e.rend());
    ll ans = 0;
    for(auto &i : e){
        int x = i.second.first;
        int y = i.second.second;
        x = find(x);
        y = find(y);
        if(x != y){
            if(nodes[x] + nodes[y] == edges[x] + edges[y]) continue;
            dsu[y] = x;
            nodes[x] += nodes[y];
            edges[x] += edges[y];
            edges[x]++;
            ans += i.first;
        }
        else{
            if(nodes[x] == edges[x]) continue;
            edges[x]++;
            ans += i.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

struct node
{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};


struct node *treeInsert(struct node *T, struct node *z)
{
    struct node *r, *x, *y;
    r = T;
    y = NULL;
    x = r;
    while (x != NULL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NULL)
    {
        r = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
    return r;
}

void inorder_tree_work(struct node *T)
{
    if (T != NULL)
    {
        inorder_tree_work(T->left);
        printf(" %d", T->key);
        inorder_tree_work(T->right);
    }
}

void preorder_tree_work(struct node *T)
{
    if (T != NULL)
    {
        printf(" %d", T->key);
        preorder_tree_work(T->left);
        preorder_tree_work(T->right);
    }
}

struct node *treeSearch(struct node *T, int a)
{
    struct node *x = T;

    while (x != NULL && x->key != a)
    {
        if (a < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    return x;
}

int main(void)
{
    struct node *Tree = NULL;
    struct node *y, *z;
    int n;
    int key;
    char command[10];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", command);
        if (command[0] == 'i')
        {
            scanf("%d", &key);
            z = (struct node *)malloc(sizeof(struct node));
            z->key = key;
            z->left = NULL;
            z->right = NULL;
            Tree = treeInsert(Tree, z);
        }
        else if (command[0] == 'p')
        {
            inorder_tree_work(Tree);
            printf("\n");
            preorder_tree_work(Tree);
            printf("\n");
        }
        else if (command[0] == 'f')
        {
            scanf("%d", &key);
            z = (struct node *)malloc(sizeof(struct node));
            z->key = key;
            z->left = NULL;
            z->right = NULL;
            y = treeSearch(Tree, z->key);
            if (y != NULL)
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 25212