akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000003;
using ll = long long;
using namespace std;

ll modPow(ll a, int n){
	ll res = 1;
	int i = 1;
	while( i <= n ) {
		if( n & i ){
			res *= a;
			res %= mod;
		}
		i <<= 1;
		a = a*a%mod;
	}
	return res;
}

ll mf[3000100];
ll dvf[3000100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q; cin >> q;
	mf[0] = 1; dvf[0] = 1;
	for( int k = 1; k <= 3000000; ++k ){
		mf[k] = (k*mf[k-1]) % mod;
		dvf[k] = (modPow(k, mod-2)*dvf[k-1]) % mod;
	}
	while( q-- ){
		ll x, d, n; cin >> x >> d >> n;
		if( d != 1 ){
			if( d == 0 ){
				cout << modPow(x, n) << endl;
				continue;
			}
			x = (x*modPow(d, mod-2))%mod;
		}
		if( n >= mod ) cout << 0 << endl;
		else cout << ( modPow(d, n) * ( mf[x+n-1]*dvf[x-1] % mod ) ) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 47744
n=int(input())
a=list(map(int,input().split()))
b=sorted(a);c=0
for i in range(n-1):
    t=cnt=0;x=a.index(b[i])
    while x!=i:
        y=a.index(b[x])
        a[x],a[y]=b[x],b[i];cnt+=1
        t+=b[x]+b[i]
        x=y
    c+=min(t,(b[i]+b[0])*2+t-(b[i]-b[0])*cnt)
print(c)

Measured memory_bytes: 7800
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;

//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    int n;
    std::cin >> n;
    VEC(string,s,n);
    int a=0,b=0,ab=0;
    int ans=0;
    rep(i,n){
        if(s[i][0]=='B'){
            if(s[i][s[i].size()-1]=='A')ab++;
            else b++;
        }
        else{
            if(s[i][s[i].size()-1]=='A')a++;
        }
        rep(j,s[i].size()-1)if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
    }
    int mi=1;
    if(ab){
        if(b){
            ans++;
            b--;
            mi=0;
        }
        
    }
    if(ab){
        if(a){
            ans++;
            a--;
            mi=0;
        }
    }    
    ans+=max(ab-1,0);
    ans+=min(a,b);
    std::cout << ans << std::endl;
    
    
}



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

int main (int argc, char **argv) {
  int x, y;
  while (cin >> x >> y) {
    if (x==0 && y==0) break;
    if (x < y) {cout << x << " " << y << endl;}
    else       {cout << y << " " << x << endl;}
  }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn = 5e5 + 50;
typedef pair<int, int> P;

void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=0; i<t; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

// type below

void solve()
{
	int a, b; cin >> a >> b;
	if(b & 1)
	{
		cout << "No";
		return;
	}
	else if(b < 2 * a || b > 4 * a)
	{
		cout << "No";
		return;
	}
	cout << "Yes";
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll K, std::vector<ll> h) {
  vector<ll> dp(N);
  dp.at(0) = 0;

  rep(i, N - 1) {
    dp.at(i + 1) = LINF;
    rep(j, K) {
      if (i - j >= 0) {
        ll a = abs(h.at(i + 1) - h.at(i - j)) + dp.at(i - j);
        dp.at(i + 1) = min(dp.at(i + 1), a);
      }
    }
  }

  cout << dp.at(N - 1) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll K;
  scanf("%lld", &K);
  std::vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  solve(N, K, std::move(h));
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N, K;
	cin >> N >> K;
	
	vector< set< int > > boat(K, set< int >());
	
	for_(i,0,K) {
		int m;
		cin >> m;
		
		for_(j,0,m) {
			int b;
			cin >> b;
			boat[i].insert(b);
		}
	}
	
	int R;
	cin >> R;
	
	vector< int > tsu_ra_i(N, 0);
	
	for_(i,0,R) {
		int p, q;
		cin >> p >> q;
		
		bool flag = false;
		for_(j,0,K) flag |= (boat[j].count(p) && boat[j].count(q));
		if (flag) tsu_ra_i[p - 1] = tsu_ra_i[q - 1] = 1;
	}
	
	cout << accumulate(tsu_ra_i.begin(), tsu_ra_i.end(), int()) << endl;
}

Measured memory_bytes: 1200
import sys
from collections import defaultdict
from queue import deque

readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


sys.setrecursionlimit(10**5)


def main():
    n, d, a = geta(int)
    mon = []
    ans = 0

    for _ in range(n):
        x, h = geta(int)
        mon.append([x, (h + a - 1) // a])

    mon.sort()

    bom = deque()
    cur = 0
    for i, mi in enumerate(mon):

        while len(bom) != 0 and bom[0][0] < mi[0]:
            b = bom.popleft()
            cur -= b[1]

        if mi[1] <= cur:
            continue
        else:
            b1 = mi[1] - cur
            bom.append((mi[0] + 2 * d, b1))
            cur += b1
            ans += b1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 51400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 998244353

ll extended_gcd(ll a, ll b, ll &x, ll &y)
{
    if(a==0)
    {
        x = 0;
        y = 1;
        return b;
    }
    
    ll x1,y1;
    ll g = extended_gcd(b%a, a, x1, y1);
    
    x = y1-(b/a)*x1;
    y = x1;
    return g;
}

ll powe(ll x,ll n) {
  if(x==0) return 0;
  if(n==0) return 1;
  ll val = powe(x,n/2);
  if(n%2) return (((val*val)%N)*x)%N;
  return (val*val)%N;
}

// ll comb(ll n, ll k) { 
//     if(k==0) return 1;
//     if(k==n) return 1;
//     return (((mods[n]*invmods[n-k])%N)*invmods[k])%N;
// }

ll cofac(vector<vector<ll> > &adj) {
  ll tot = 1, idx;
  ll res = 1;

  for(ll i=1;i<adj.size();i++) {
    idx = i;

    while(idx<adj.size() && !adj[idx][i])
      idx++;

    if(idx==adj.size())
      return 0;

    if(idx!=i) {
      swap(adj[i],adj[idx]);
      if((idx-i)%2)
        res = -res;
    }

    vector<ll> temp(adj[i].begin(),adj[i].end());

    ll val = temp[i];
    for(ll j=i+1;j<adj.size();j++) {
      ll curr = adj[j][i];

      for(ll k=i+1;k<adj.size();k++) {
        adj[j][k] = ((val*adj[j][k])%N - (curr*temp[k])%N + 2*N)%N;
      }

      tot = (tot*val)%N;
    } 
  }

  for(ll i=1;i<adj.size();i++)
    res = (res * adj[i][i])%N;
  
  ll x,y;
  extended_gcd(tot,N,x,y);
  // cout<<(res*x)%N<<endl;
  return (2*N+(res*x)%N)%N;
}

int main() {

  ll n;
  cin>>n;

  std::cout << std::fixed;
  std::cout << std::setprecision(6);
  double sum=0;
  for(int i=0;i<n;i++){
    double a;
    cin>>a;
    sum += 1/a;
  }

  cout<<(1.0/sum)<<endl;


  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int R,C,n,r1,r2,c1,c2;
bool go(){
	if(r1 && r1<R && c1 && c1<C)
		return true;
	if(r2 && r2<R && c2 && c2<C)
		return true;
	return false;
}
vector<ii> v;
void add(int r, int c, int d){
	if(!r){
		v.pb(ii(c,d));
		return;
	}
	if(!c){
		v.pb(ii(2*R+2*C-r,d));
		return;
	}
	if(r==R){
		v.pb(ii(R+2*C-c,d));
		return;
	}
	if(c==C){
		v.pb(ii(C+r,d));
		return;
	}
}
bool vis[N];
int main(){
	cin>>R>>C>>n;
	for(int i=0; i<n; ++i){
		scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
		if(go())
			continue;
		add(r1,c1,i);
		add(r2,c2,i);
	}
	sort(all(v));
	stack<int> st;
	for(int i=0; i<v.size(); ++i){
		int d=v[i].second;
		if(!vis[d]){
			vis[d]=true;
			st.push(d);
		}else if(st.top()!=d)
			return cout<<"NO",0;
		else
			st.pop();
	}
	cout<<"YES";
}




Measured memory_bytes: 2420
/**
 * Created By: Anonyman637
 * Created On: 3/5/2020 9:00:33 PM
 */

/* =============================================================================
   ================================== HEADERS ==================================
   ========================================================================== */

#include <cstdio>
#include <string>
#include <cmath>

/* =============================================================================
   ================================= TYPEDEFS ==================================
   ========================================================================== */

typedef char i8;
typedef short i16;
typedef int i32;
typedef long long i64;

typedef unsigned char ui8;
typedef unsigned short ui16;
typedef unsigned int ui32;
typedef unsigned long long ui64;

using namespace std;

/* =============================================================================
   ================================== MACROS ===================================
   ========================================================================== */

#ifdef DEBUG
#define debug(format, ...) printf(format, __VA_ARGS__)
#else
#define debug(format, ...) 
#endif

#ifdef FILEIO
#define INFILE "fileio\\"__FILE__"In.txt"
#define OUTFILE "fileio\\"__FILE__"Out.txt"
#endif

/* =============================================================================
   ================================== GLOBALS ==================================
   ========================================================================== */


/* =============================================================================
   =================================== SETUP ===================================
   ========================================================================== */

i32 setup() {

#ifdef FILEIO
        if(freopen(INFILE, "r", stdin) == NULL) return 401;
        if(freopen(OUTFILE, "w", stdout) == NULL) return 402;
#endif

        return 0;
}


/* =============================================================================
   ================================= FUNCTIONS =================================
   ========================================================================== */

i32 main() {

        i32 errorInSetup = setup();
        if (errorInSetup) exit(errorInSetup);

        i32 i, t;
        i32 n, k;
        double digits;
        scanf("%d %d", &n, &k);
        if (n == 0) {
                digits = 1;
        } else {
                digits = (i32) ((double) log2(n) / log2(k)) + 1;
        }
        printf("%.0lf", digits);
        
        return 0;
}


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

using namespace std;

void Main() {
    int X;
    cin >> X;
    int k = 0;

    while (true) {
        ++k;
        if ((k * X) % 360 == 0) {
            break;
        }
    }
    cout << k << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n, l[110], r[110];
vector<int> a, b;

int main() {
    cin >> n;
    a.resize(n); b.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    l[0] = a[0];
    r[n-1] = b[n-1];
    for (int i = 1; i < n; i++) l[i] = l[i-1] + a[i];
    for (int i = n-2; i >= 0; i--) r[i] = r[i+1] + b[i];

    int ans = 0;
    rep(i, n) {
        int tmp = l[i] + r[i];
        if (tmp > ans) ans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    string str;
    cin >> str;
    if(str.at(0) == 'a' || str.at(0) == 'i'
        || str.at(0) == 'u' || str.at(0) == 'e' || str.at(0) == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;


ll dp[1001][1001];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin >> n >> k;
	FOR(i,0,k+1){
		dp[i][0]=1;
		FOR(j,1,n+1){
			if((j-i)>=0)
				dp[i][j]+=dp[i][j-i];
			if(i>=1)
				dp[i][j]+=dp[i-1][j];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[k][n] << endl;
}


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

int main () {
    int n;
    cin >> n;
    vector<long long> score(1000001, 0);
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        score[t] += t;
    }

    for (int i = 1; i < score.size(); i++) {
        score[i] += score[i-1];
    }

    int m; cin >> m;
    vector<int> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i];
    }

    for (int i = 0; i < m; i++) {
        long long c; cin >> c;
        string str = (score[v[i]] >= c) ? "Yes" : "No";
        cout << str << endl;
    }

    return 0;
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[30][30];
int x[N];
int32_t main()
{
    IOS;
    int n,m,xx;
    cin>>n>>m>>xx;
    int mn=MOD;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1LL<<n);i++)
    {
        int ok=1;
        int ans[20]={0};
        int sum=0;
        for(int j=0;j<n;j++)
        {
            if(i&1LL<<j)
            {
                sum+=x[j];
                for(int k=0;k<m;k++)
                {
                    ans[k]+=a[j][k];
                }
            }
        }
        for(int j=0;j<m;j++)
        {
            if(ans[j]<xx)
                ok=0;
        }
        if(ok)
            mn=min(mn,sum);
    }
    if(mn==MOD)
        mn=-1;
    cout<<mn<<endl;

    
}

Measured memory_bytes: 3616
#include<stdio.h>

int w,h,sx,sy,cnt;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char mas[50][50];

void start(void);
void fbs(int x,int y);

main(){
  int i;
  while(1){
    scanf("%d %d",&w,&h);
    if(w==0 && h==0){
      break;
    }
    for(i=0;i<h;i++){
      scanf("%s",mas[i]);
    }
    cnt=0;
    start();
    fbs(sx,sy);
    printf("%d\n",cnt);
  }
  return 0;
}

void start(void){
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(mas[i][j]=='@'){
	sx=j;
	sy=i;
	break;
	break;
      }
    }
  }
  return;
}

void fbs(int x,int y){
  int i;
  cnt++;
  mas[y][x]='#';
  for(i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx>=0 && nx<w && ny>=0 && ny<h && mas[ny][nx]=='.'){
      fbs(nx,ny);
    }
  }
  return ;
}

Measured memory_bytes: 616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		double h[] = new double[N];
		Double min = Double.MAX_VALUE;

		int ans = 0;

		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
			double tmp = Math.abs(T - h[i]*0.006 - A);
			if (tmp <= min) {
				min = tmp;
				ans = i+1;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b;
  cin>>a;
  b=pow(a,0.5)/1;
  cout<<b*b;

}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<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;}

#define P (1'000'000'007)

class UnionFind {
public:
    UnionFind(int n) {
        for (int i = 0; i < n; i++) parent.push_back(i);
    }

    int find(int index) {
        if (is_root(index)) return index;
        return parent[index] = find(parent[index]);
    }

    bool is_root(int index) {
        return parent[index] == index;
    }

    bool has_same_root(int lhs, int rhs) {
        return find(lhs) == find(rhs);
    }

    void unite(int lhs, int rhs) {
        int l = find(lhs);
        int r = find(rhs);
        if (has_same_root(l, r)) return;
        parent[r] = l;
    }

private:
    vector<int> parent;
};

signed main() {
    int n, c;
    cin >> n >> c;

    vector<vector<int>> vd(c, vi());

    rep(i, c) {
        rep(j, c) {
            capi(x);
            vd[i].push_back(x);
        }
    }

    int m[3][30] = {0};

    rep(i, n) {
        rep (j, n) {
            capi(x); --x;

            ++m[(i + j) % 3][x];
        }
    }

    int ans = INT_MAX;

    rep(i, c) {
        for (int j = 0; j < c; ++j) {
            if (i == j) continue;
            for (int k = 0; k < c; ++k) {
                if (i == k || j == k) continue;
                int res = 0;
                rep(l, c) {
                    res += vd[l][i] * m[0][l];
                    res += vd[l][j] * m[1][l];
                    res += vd[l][k] * m[2][l];
                }

                chmin(ans, res);
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str;
		char ch[],kako[];
		while(true){
			str=sc.nextLine();
			if(str.equals(".")) break;
			ch=str.toCharArray();
			kako=new char[ch.length];

			boolean flag=true;
			int k=0;
			for(int i=0;i<ch.length;i++){
				if(ch[i]=='('){
					kako[k]='(';
					k++;
				}
				if(ch[i]==')'){
					if(k>0 && kako[k-1]=='('){
						k--;
					}
					else{
						flag=false;
						break;
					}
				}
				if(ch[i]=='['){
					kako[k]='[';
					k++;
				}
				if(ch[i]==']'){
					if(k>0 && kako[k-1]=='['){
						k--;
					}
					else{
						flag=false;
						break;
					}
				}
			}
			if(flag && k==0)
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,s;
	cin>>a>>b;
	if(a%2==1&&b%2==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<double, double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a) int((a).size())
#define pb push_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n)               \
  for (int vari = 0; vari < (n)-1; ++vari) \
    for (int varj = vari + 1; varj < (n); ++varj)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define found(s, e) ((s).find(e) != (s).end())
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
#define cons make_pair

int main() {
  int N;
  cin >> N;
  switch (N) {
    case 1:
      cout << "Hello World" << endl;
      break;
    case 2: {
      int A, B;
      cin >> A >> B;
      cout << (A + B) << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n;
    cin >> n;
    VI p(n);
    for (Int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    Int result = 0;
    Int min_left = LLONG_MAX;
    for (Int i = 0; i < n; ++i) {
        if (p[i] <= min_left) {
            ++result;
            min_left = p[i];
        }
    }
    cout << result << endl;
    return 0;
}



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

int main() {
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='?')cout<<'D';
    else {
      cout<<a.at(i);
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3744
n = int(input())
r = 0

for i in range(0, n, 2):
    c = 0

    for j in range(0, i + 1, 2):
        if (i + 1) % (j + 1) == 0:
            c += 1

    if c == 8:
        r += 1

print(r)


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

void my_push_front(char *str, char c)
{
    if( c == '\0' ) return;
    const int len = strlen(str);
    for(int i = len; i >= 0; --i) {
        str[i+1] = str[i]; //  文字列を1文字後ろにずらす
    }
    *str = c;      // 先頭に1文字挿入
}

int main(void){
	char s[101];
	char t[101];
	char tmp;
	int len;
	scanf("%s",s);
	scanf("%s",t);
	len = strlen(s);
	int flag= 0;
	int i;
	if( strcmp(s,t)==0){
		flag =1;
	}
	for(int j=0;j<len;j++){
		for(i=len;i>=0;i--){
			s[i+1] = s[i];//これを行うと文字列が右に一つずれる。
		}
		s[0] = s[len];
		s[len] ='\0';
		if( strcmp(s,t)==0){
		flag =1;
		}
	}
	if( flag == 1){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>K;
    N=pow(2,K);
    multiset<int> ms;
    for(int i=0;i<N;i++){
        int curr;
        cin>>curr;
        ms.insert(curr*-1);
    }
    vector<int> vals;
    vals.push_back(*ms.begin());
    ms.erase(ms.begin());
    for(int i=0;i<K;i++){
        vector<int> newval;
        for(int j=0;j<vals.size();j++){
            if(ms.upper_bound(vals[j])==ms.end()){
                cout<<"No"<<endl;
                return 0;
            }
            newval.push_back(*ms.upper_bound(vals[j]));
            ms.erase(ms.upper_bound(vals[j]));
            if(ms.empty()){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        //vals.erase(vals.begin(),vals.end());
        for(int j=0;j<newval.size();j++){
            vals.push_back(newval[j]);
        }
        sort(vals.begin(),vals.end());
    }
    cout<<"Yes"<<endl;
    return 0;
    
}

Measured memory_bytes: 13984
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    if (n == 1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }


    return 0;
}

Measured memory_bytes: 384
s = raw_input()

l = 0
r = len(s)-1

ans = 0
while l <= r and -1 < l < len(s) and -1 < r < len(s):
	if s[l] == s[r]:
		l += 1
		r -= 1

	else :
		if s[l] == "x":
			l += 1
			ans += 1
		elif s[r] == "x":
			r -= 1
			ans += 1

		else :
			print -1
			quit()
	
print ans 


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int n,a,ans=0;
	map<int,int>m;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(m[a]==0)m[a]++;
		else m[a]--;
	}
	for(auto i=m.begin();i!=m.end();i++) 
	{
		if(i->second>0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int X, ans = 1;
    cin >> X;
    for (int b = 2; b * b <= X; b++) {
        int Y = 1;
        while (Y <= X) {
            ans = max(ans, Y);
            Y *= b;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;
	vi arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.rbegin(),arr.rend());
	ll sum=0;
	for(int i=0;i<k;i++)sum+=arr[i];
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3524
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
 
void solve() {
    int n; cin >> n;
    ll h_list[n];
    ll dp[n];
    
    rep(i,n) cin >> h_list[i];
    dp[0] = 0;
    dp[1] = abs(h_list[1] - h_list[0]);

    for (int i = 2; i < n; i++)
    {
        dp[i] = min( dp[i-1] + abs(h_list[i] - h_list[i-1]), dp[i-2] + abs(h_list[i] - h_list[i-2]));
    }
    cout << dp[n-1];
    
}

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

Measured memory_bytes: 1792
import java.lang.Math.abs
import java.lang.Math.max
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use {
        val n = it.nextInt()
        val x = mutableListOf<Int>()
        val y = mutableListOf<Int>()
        val h = mutableListOf<Int>()
        var chi = -1

        for (i in 0 until n) {
            x.add(it.nextInt())
            y.add(it.nextInt())
            val hh = it.nextInt()
            h.add(hh)
            if (chi == -1 && 0 < hh) {
                chi = i
            }
        }

        for (cx in 0..100) {
            for (cy in 0..100) {
                val ch = h[chi] + abs(x[chi] - cx) + abs(y[chi] - cy)
                var r = true

                for (k in 0 until n) {
                    if (k != chi) {
                        r = r && max(ch - abs(x[k] - cx) - abs(y[k] - cy), 0) == h[k]
                        if (!r) {
                            break
                        }
                    }
                }

                if (r) {
                    println("%d %d %d".format(cx, cy, ch))
                    return
                }
            }
        }
    }
}


Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int v[n];
    rep(i, 0, n) cin >> v[i];

    int ans = 0;
    for (int l = 0; l <= k; l++) {
        for (int r = 0; r <= k - l; r++) {
            if (l + r > n) continue;
            int sum = 0;
            vector<int> got;
            rep(i, 0, l) {
                sum += v[i];
                got.push_back(v[i]);
            }
            rep(i, 0, r) {
                sum += v[n - 1 - i];
                got.push_back(v[n - 1 - i]);
            }

            //cout << l << " " << r << " " << sum << endl;

            sort(all(got));
            for (int i = 0; i < min(k - l - r, (int)got.size()); i++) {
                if (got[i] >= 0) break;
                sum -= got[i];
            }
            ans = max(ans, sum);
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if (A==1) A=14;
  if (B==1) B=14;
  if (A>B) cout<<"Alice"<<endl;
  if (A==B) cout<<"Draw"<<endl;
  if (A<B) cout<<"Bob"<<endl;
  system("pause");
  return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    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 (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int N,M;cin>>N>>M;
  UnionFind UF(N);
  set<int>se;
  for(int X=0;X<M;X++){
    int A,B,C;cin>>A>>B>>C;A--;B--;
    UF.merge(A,B);
  }
  for(int X=0;X<N;X++){
    se.insert(UF.root(X));
  }
  cout<<se.size()<<endl;
}

Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y)
{
    int res = 1;
    x = x % M;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % M;
        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
int main()
{
	IOS;
	string s;
	cin>>s;
	rep(i,0,s.size())s[i]='x';
	cout<<s;
}


Measured memory_bytes: 256
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
int N, L;
int a[100000];
void solve(){
	int ptr = -1;
	rep(i, N - 1){
		if(a[i] + a[i + 1] >= L){
			ptr = i + 1;
			break;
		}
	}
	if(ptr == -1){
		cout << "Impossible" << endl;
		return;
	}
	
	cout << "Possible" << endl;
	reps(i, ptr - 1){
		cout << i << endl;
	}
	for(int i = N - 1; i >= ptr; i--){
		cout << i << endl;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> L;
	rep(i, N) {
		cin >> a[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 1280
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
A = III()

k = format(K,'b')
k = k.zfill(50)

B = ['0']*N
for i in range(N):
    B[i] = str(format(A[i],'b')).zfill(50)

val = str()
flag = False
for i in range(50):
    count0 = 0
    count1 = 0
    for j in range(N):
        if B[j][i]=='0':
            count0 += 1
        else:
            count1 += 1
    if k[i]=='1':
        if count0 > count1:
            val += '1'
        else:
            val += '0'
            flag = True
    else:
        if count0 >= count1:
            if flag:
                val += '1'
            else:
                val += '0'
        else:
            val += '0'

val = int(val,2)
ans = 0
for i in range(N):
    ans += val^A[i]

print(ans)

Measured memory_bytes: 86332
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
    for(int i = g;i<n;i++){
        int v = A[i];
        int j = i-g;
        while(j>=0 && A[j]>v){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shellSort(int A[],int n){
    for(int h = 1; ;){
        if(h>n) break;
        G.push_back(h);
        h=3*h+1;
    }
    
    for(int i = G.size()-1;i>=0;i--){
        insertionSort(A,n,G[i]);
    }
}

int main(){
    cin>>n;
    for(int i = 0;i<n;i++) scanf("%d",&A[i]);
    cnt=0;
    
    shellSort(A,n);
    
    cout << G.size() << endl;
    for(int i = G.size()-1;i>=0;i--){
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i = 0;i<n;i++) printf("%d\n",A[i]);
    
    return 0;
}


Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    double d,e,f,g;
    cin >> a >> b >> c;
    d = (acos(-1.0)*c)/180.0;
    e = a * b * sin(d) / 2.0;
    f = a * a + b * b - a * b * cos(d) * 2;
    g = e * 2 / a;
    cout << fixed << setprecision(8) << e << endl;
    cout << fixed << setprecision(8) << sqrt(f) + a + b << endl;
    cout << fixed << setprecision(8) << g << endl;
    
}


Measured memory_bytes: 3508
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

ll eval(vector<list<ll>> &e,ll s){
    vector<bool> used(e.size(),false);
    ll ret = 1;
    queue<pair<ll,ll>> q;
    q.push({s,1});
    used[s] = true;
    while(!q.empty()){
        auto t = q.front();
        q.pop();
        ret = max(ret,t.second);
        for(auto v:e[t.first]){
            if(!used[v]){
                q.push({v,t.second+1});
                used[v] = true;
            }
        }
    }
    return ret;
}

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

    vector<string> s;
    for(int i = 0; i < n; i++){
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

    vector<list<ll>> edge(n);

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(s[i][j] == '1'){
                edge[i].push_back(j);
            }
        }
    }

    vector<ll> state(n,0);
    queue<ll> q;
    q.push(0);
    state[0] = 1;

    while(!q.empty()){
        ll t = q.front();
        q.pop();
        ll nexts = (state[t] ^ 2);
        for(auto v:edge[t]){
            if(state[v] == 0){
                state[v] = nexts;
                q.push(v);
            }else if(state[v] != nexts){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ll ans = 0;

    for(int i = 0; i < n; i++){
        ans = max(ans,eval(edge,i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    char c; cin >> c;
    if (c-'a'>=0) cout << 'a' << endl; else cout << 'A' << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x;
    cin >> x;
    if(x == 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    

    return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	int b=a[2]*2-(a[1]+a[0]);
	if(b%2==0)
	b/=2;
	else
	b=b/2+2;
	cout<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, B;
  cin >> A >> B;
  cout <<  max(A + B, max(A+A-1, B+B-1)) << endl;
  return 0;
}

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

void fnInput(int& rnSpcNum, int& rnMinSum, int& rnMaxSum)
{
  cin >> rnSpcNum >> rnMinSum >> rnMaxSum;
}

int fnDigitsSum(int nNum)
{
  int nDigitsSum = 0;
  while ( nNum )
  {
    nDigitsSum += nNum % 10;
    nNum /= 10;
  }
  return nDigitsSum;
}

int fnSomeSums(int nSpcNum, int nMinSum, int nMaxSum)
{
  int nTotal = 0;

  for (int n = 1; n <= nSpcNum; n++)
  {  
    int nDigitsSum = 0;

    nDigitsSum += fnDigitsSum(n);
    if (nMinSum <= nDigitsSum && nDigitsSum <= nMaxSum)
      nTotal += n;
  }
  return nTotal;
}

int main()
{
  int nSpcNum, nMinSum, nMaxSum;
  fnInput(nSpcNum, nMinSum, nMaxSum);

  cout << fnSomeSums(nSpcNum, nMinSum, nMaxSum)  << endl;
  return 0;
}
 


Measured memory_bytes: 256
n = int(input())

s = []
for i in range(n):
    s.append("".join(sorted(input())))
s.sort()

a = 0
r = 0
i = 1
l = len(s)
while i < l:
    if s[i] == s[i-1]:
        r = r+1
    else:
        a = a + sum(range(r+1))
        r = 0
    i = i+1

if r > 0: a = a + sum(range(r+1))
print(a)


Measured memory_bytes: 10640
K = int(input())

C = [[0]*10 for _ in range(10)]
C[0] = [1]*10
D = {0: [0, 1], 1: [0, 1, 2], 2: [1, 2, 3], 3: [2, 3, 4], 4: [3, 4, 5], 5: [4, 5, 6], 6: [5, 6, 7], 7: [6, 7, 8], 8: [7, 8, 9], 9: [8, 9]}

for i in range(1, 10):
  for j in range(10):
    if j == 0:
      C[i][j] = C[i-1][j] + C[i-1][j+1]
    elif j == 9:
      C[i][j] = C[i-1][j-1] + C[i-1][j]
    else:
      C[i][j] = C[i-1][j-1] + C[i-1][j] + C[i-1][j+1]

ans = []
temp = K
Flag = True

for i in range(10):
  if Flag:
    for j in range(1, 10):
      temp -= C[i][j]
      if temp <= 0:
        temp += C[i][j]
        r = i
        ans.append(j)
        Flag = False
        break
  else:
    break

def f(x, r):
  temp = x
  r -= 1
  for j in D[ans[-1]]:
    temp -= C[r][j]
    if temp <= 0:
      temp += C[r][j]
      ans.append(j)
      break
  return temp, r

while r >= 1:
  temp, r = f(temp, r)

print("".join([str(i) for i in ans]))

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
set<int> st;
string s;
int n,m,p[maxn],re1,re2;
bool vis[maxn];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x>>s;
		if(s=="AC")if(!vis[x])
		{
			vis[x]=1;
			re1++;
			re2+=p[x];
		}
		if(s=="WA"&&!vis[x])
		{
			p[x]++;
		}
	}
	cout<<re1<<' '<<re2;
	return 0;
}

Measured memory_bytes: 768
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
    }
    println!("{}", if a * b % 2 == 1 { "Odd" } else { "Even" });
}


Measured memory_bytes: 4352
def main():
    N = int(input())
    tasks = []

    for _ in range(N):
        a, b = map(int, input().split())
        tasks.append((a, b))

    tasks = sorted(tasks, key=lambda x:x[1])

    time = 0
    for task in tasks:
        time += task[0]
        if time > task[1]:
            print("No")
            return 0

    print("Yes")
    return 0

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for(int j = 0; j < n - 1; j++){
        sum = sum + p[j];
    }
    sum = sum + (p[n - 1] / 2);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

char s[10];
int main()
{
	int a = 0, b = 0, i = 0, j = 0;
	scanf ("%s",s);
    a = strlen(s);
    if (a == 2) printf ("%s\n",s);
	else { for (i = 0,j = a - 1;i < j;i++,j--)
		 { char c = s[i];
		  s[i] = s[j];
		  s[j] = c;
		}
		printf ("%s",s);
		}
	
    return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	long long ans=0;
	ans+=n/(a+b)*a;
	n%=(a+b);
	ans+=min(a,n);
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
nums = [int(x) for x in input().split()]
ops = 0
cont = 1
while cont:
	for x in range(n):
		if nums[x] % 2 == 0:
			nums[x] = nums[x]/2
		else:
			cont = 0
			break
	ops += cont
print(ops)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3644