akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, ans = 0;

    cin >> n;

    int a[n], b[n], c[n-1];

    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-1; i++) cin >> c[i];

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

        ans += b[a[i]-1];
        if (i < n-1 && a[i] == a[i+1]-1) ans += c[a[i]-1];
    }

    cout << ans;

    return 0;
}


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

using namespace std;

typedef long long	ll;
const int N = 210;
ll dp[N];

int main(){
	ll k;

	scanf("%lld", &k);

	ll sum = 0LL;

	for(ll i = 1LL ; i <= k ; i++){
		for(ll j = 1LL ; j <= k ; j++){
			ll g = __gcd(i, j);

			if(dp[g]){
				sum += dp[g];
				continue;
			}

			for(ll d = 1LL ; d <= k ; d++){
				ll gg = __gcd(d, g);

				dp[g] += gg;
			}

			sum += dp[g];
		}
	}

	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 3828
s = input()
t = input()
flag1 = 0
tmp = ""
for i in range(len(s) - len(t) + 1):
    u = s[i:i + len(t)]
    flag2 = 1
    for j in range(len(t)):
        if u[j] != t[j] and u[j] != "?":
            flag2 = 0
            break
    if flag2 == 1:
        flag1 = 1
        tmp = s[:i] + t + s[i + len(t):]

print(tmp.replace("?", "a")) if flag1 else print("UNRESTORABLE")

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ng = 1;
  rep(i, n) if (a[i] % 2 == 0) ng *= 2;
  int ans = pow(3, n) - ng;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4060
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 int n, i, j, k;
 int b;
 int count = 0;
 
 

 while(cin >> n){
  int a[n+1];
  for(i = 2;i < n+1;i++){
    a[i] = i;
  }


  for(i = 2;i*i < n+1;i++){
    if(a[i] != 0){
      b = a[i];
     }
    for(j = 2;j*b < n+1;j++){
      a[j*b] = 0;
    }
  }
  for(i = 2;i < n+1;i++){
    if(a[i] != 0){
      count++; 
    }
  }
  cout << count << endl;
  count = 0;
  
  
 }

 return 0; 
}

Measured memory_bytes: 5064
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i <= s.length()-3; i++) {
            int num = Integer.parseInt(s.substring(i, i+3));
            min = Math.min(min, Math.abs(num - 753));
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define     mod             1e9+7
#define     MOD             998244353
#define     ll             long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     pb              emplace_back
#define     pf              emplace_front
#define     all(p)          p.begin(), p.end()
#define     rep(i,a,b)      for( i=a;i<b;++i)
#define     repr(i,a,b)     for( i=a;i>=b;i--)
#define     up              upper_bound
#define     lb              lower_bound
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     mii             map<int,int>
#define     vi              vector<int>
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int> >
#define     vii             vector<ii>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output 3.txt", "w", stdout);
    #endif

    IOS;
   ll int a,b,c,k;
   cin>>a>>b>>c>>k;
   ll int sum=0;
   sum+=min(k,a);
   k-=min(k,a);
   if(k>0)
   {
      k-=min(b,k);
   }
   if(k>0)
   {
     sum-=k;
     k=0;
   }
   cout<<sum<<endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    int n;
    double memo = 0;
    cin >> n;
    
    double x[n],y[n];
    
    rep(i,0,n){
        cin >> x[i];
    }
    
    rep(i,0,n){
        cin >> y[i];
    }
    
    rep(i,1,4){
        memo = 0;
        rep(j,0,n){
            memo += (double)pow(abs(x[j]-y[j]),i);
            
        }
        memo = (double)pow(memo,(1.0/(double)i));
        
        cout << setprecision(10) << memo << endl;
    }
    
    memo = 0;
    rep(i,0,n){
        memo = (double)max(memo,abs(x[i]-y[i]));
    }
    
    cout << setprecision(10) <<  memo << endl;
    
    
  	
    return 0;
}


Measured memory_bytes: 3496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, s;　 //人数、必要な個数
            int i;


        　　//人数を入力
         　 n = int .Parse(Console.ReadLine());

            //必要な個数を求める
            //（合計を求めるアルゴリズム）
            s = 0;　　　　　//合計を０に初期化



            for ( i = 1; i <= n; i++)　
                

            {
                s = s + i; //s+= 1でもよい

            }


            //ｓを出力（表示）
            Console.WriteLine(s);




            Console.ReadKey();


        }
    }
}


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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main(){
	fastio
	int n;
	cin >> n;
	cout << (1000-(n%1000))%1000 << "\n";
}

Measured memory_bytes: 3648
MOD = 10**9 + 7
n, m = map(int, input().split())
dp = [0] * (n + 10)
a = [True] * (n + 10)
for _ in range(m):
    a[int(input())] = False
dp[0] = 1
for i in range(n):
    if a[i + 1]:
        dp[i + 1] = (dp[i + 1] + dp[i]) % MOD
    if a[i + 2]:
        dp[i + 2] = dp[i]
print(dp[n])

Measured memory_bytes: 7644
def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    #exception
    if a < b or d < b:
        print("No")
        continue

    if c >= b:
        print("Yes")
        continue

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")

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

int main(){
  string s;
  cin >> s;
  int m[9][9];
  while(s != "#"){
    int a = 0;
    int b = 0;
    int p = 0;
    for(int i = 0; i < s.length(); i++){
      if(s[i] == '/'){
	b = p;
	p = 0;
	a++;
      }else if(s[i] == 'b'){
	m[a][p] = 1;
	p++;
      }else{
	for(int j = 0; j < s[i]-'0'; j++){
	  m[a][p+j] = 0;
	}
	p += s[i] - '0';
      }
    }
    a++;
    int c,d,e,f;
    cin >> c >> d >> e >> f;
    m[c-1][d-1] = 0;
    m[e-1][f-1] = 1;
    for(int i = 0; i < a; i++){
      int g = 0;
      for(int j = 0; j < b; j++){
	if(m[i][j] == 1){
	  if(g == 0){
	    cout << 'b';
	  }
	  else{
	  cout << g << 'b';
	    g = 0;
	  }
	}
	else{
	  g++;
	  }
      }
      if(g != 0) cout << g;
      if(i != a-1)cout << "/";
      }
    cout << endl;
    cin >> s;
  }
  return 0;
}



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

int main() {
    long N;
    cin >> N;
    for (int h=1; h<=3500; h++)
        for (int n=1; n<=3500; n++) {
            long t1 = N * h * n;
            long t2 = 4*h*n - N*n - N*h;
            if (t2 > 0 &&  t1 % t2 == 0) {
                printf("%d %d %ld\n", h, n, t1/t2);
                return 0;
            }
        }
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as ST
import Control.Monad

collect :: B.ByteString -> Int -> [String]
collect bs i
    | B.length bs < i = []
    | otherwise = (B.unpack $ B.take i bs) : (collect (B.tail bs) i)

main = do
    s <- B.getLine
    k <- readLn
    xs <- ST.fromList . concat <$> (forM [1..k] $ \i -> (return $ collect s i)) :: IO (ST.Set String)
    putStrLn $ ST.elemAt (k-1) xs

Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        print(abs(n - m));
    }
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;
int main(){
    cin>>h>>n;
    rep(i,n){
    cin>>tmp; sum+=tmp;
    }
    p((h<=sum)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str1 = lines[0];
        int n = Integer.parseInt(str1);
        int tower1[][] = new int[3][10];
        int tower2[][] = new int[3][10];
        int tower3[][] = new int[3][10];
        int tower4[][] = new int[3][10];
        for(int i = 1; i <= n; ++i){
            String[] tinfo = lines[i].split(" ");
            int b = Integer.parseInt(tinfo[0]);
            int f = Integer.parseInt(tinfo[1]);
            int r = Integer.parseInt(tinfo[2]);
            int v = Integer.parseInt(tinfo[3]);
            if(b == 1){
                tower1[f - 1][r - 1] += v;
            } else if(b == 2){
                tower2[f - 1][r - 1] += v;
            } else if(b == 3){
                tower3[f - 1][r - 1] += v;
            } else if(b == 4){
                tower4[f - 1][r - 1] += v;
            }
        }
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 10; ++j){
                System.out.print(" ");
                System.out.print(tower1[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 10; ++j){
                System.out.print(" ");
                System.out.print(tower2[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 10; ++j){
                System.out.print(" ");
                System.out.print(tower3[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 10; ++j){
                System.out.print(" ");
                System.out.print(tower4[i][j]);
            }
            System.out.println();
        }
    }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}



Measured memory_bytes: 27096
#include<cstdio>
#include<iostream>
#include<vector>
int main(){
  int N;
  scanf("%d",&N);
  std::vector<int> a(N);
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  int r=0;
  for(int &x:a){
    while(x%2==0){
      r++;
      x/=2;
    }
  }
  std::cout<<r<<std::endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N,R = inputMap()
	if N >= 10:
		print(R)
	else:
		ans = 100 * (10 - N)
		print(R+ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int a=0, b=0;
		for(int j=0; j<10; j++){
			int m;
			cin >> m;
			if(m > a){
				a = m;
			}else if(m > b){
				b = m;
			}else{
				a = 100;
			}
		}
		if(a==100){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3076
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    int dp[n];
    dp[0]=0;dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
from math import factorial


def main():
    MOD = 1000000007
    inp = input().split()
    n = int(inp[0])
    k = int(inp[1])
    r = n - k
    for i in range(1, k + 1):
        if r + 1 < i:
            print(0)
            continue
        elif r + 1 == i:
            rr = 1
        else:
            rr = cmb(r + 1, i)

        if i == 1:
            bb = 1
        elif i == k:
            bb = 1
        else:
            bb = cmb(k - 1, i - 1)
        print(((rr % MOD) * (bb % MOD)) % MOD)


def cmb(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r))


if __name__ == '__main__':
    main()


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

int n, p, tmp;
long long a, b;

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

	for (int i = 0; i < n; ++i) {
		scanf("%d", &tmp);
		if (tmp % 2) b++;
		else a++;
	}

	cout << (1LL << a)*(1LL << (!b && !(p%2) ? 0 : b-1));
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int n, m, win[10], match[10][10];
int dfs(int x, int y) {
    if (y == n) {
        x += 1;
        y = x;
    }

    if (x == n - 1 && y == n - 1) {
        return 1;
    }

    int res = 0;

    if (x == y || match[x][y] != -1) {
        res += dfs(x, y + 1);
        return res;
    }

    if (win[x] < (n - 1) / 2) {
        match[x][y] = 1;
        match[y][x] = 0;
        win[x] += 1;
        res += dfs(x, y + 1);

        match[x][y] = match[y][x] = -1;
        win[x] -= 1;
    }

    if (win[y] < (n - 1) / 2) {
        match[x][y] = 0;
        match[y][x] = 1;
        win[y] += 1;
        res += dfs(x, y + 1);

        win[y] -= 1;
        match[x][y] = match[y][x] = -1;
    }

    return res;
}

void solve() {
    memset(match, -1, sizeof(match));
    memset(win, 0, sizeof(win));
    REP(i, m) {
        int x, y;
        cin >> x >> y;
        match[x - 1][y - 1] = 1;
        match[y - 1][x - 1] = 0;
        win[x - 1] += 1;
    }

    REP(i, n) {
        if (win[i] > (n - 1) / 2) {
            cout << 0 << endl;
            return;
        }
    }

    cout << dfs(0, 0) << endl;
    return;
}

int main() {
    while(cin >> n >> m && n) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3084
#include<cstring>
#include<cstdio>
#include<iostream>
#define SORT(a,n) for(int i=0;i<n-1;i++)for(int j=i+1,t;j<n;j++)if(a[i]<a[j]){t=a[i];a[i]=a[j];a[j]=t;}

 
using namespace std;

int main(){
	int a[5];
	cin >> a[0] >> a[1]>> a[2]>> a[3]>> a[4];

	SORT(a,5);

	cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl;

	return 0;
}

Measured memory_bytes: 1164
x = int(input())

break_loop = False
for a in list(map(lambda x: x-64, list(range(200)))):
    for b in list(map(lambda x: x-64, list(range(200)))):
        ans = (a-b)*(a**4 + (a**3)*b + a*a*b*b + a*(b**3) + b**4)
        if x == ans:
            break_loop = True
            print(a,b)
            break
    if break_loop:
        break 


Measured memory_bytes: 9072
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, k;
	cin >> n >> k;
	VI p(n);
	REP(i, n) { cin >> p[i]; }
	sort(ALL(p));
	int result = 0;
	REP(i, k) { result += p[i]; }
	cout << result << endl;
	return 0;
}


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

int main() {
  int w,h,x,y,r;

  cin >>w>>h>>x>>y>>r ;
  if (((x-r<0) || (x+r>w)) || ((y+r > h)||(y-r < 0))) {
    /* code */
    cout << "No" << '\n';
  }else{
    cout << "Yes" << '\n';
  }


  return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>

using namespace std;

int main(void){
	int x, y;
	cin >> x >> y;
	cout << x + (y/2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h){
    cin>>s[i];
  }
  rep(i,h*2){
    rep(j,w){
      cout<<s[((i+2)/2)-1][j];
    }
    cout<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;



int main() {
  int A,B;
  cin >> A >> B;
  if(A==1)A+=13;
  if(B==1)B+=13;

  if(A>B)cout << "Alice";
  else if(B>A)cout << "Bob";
  else cout << "Draw";
}

Measured memory_bytes: 384
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        mut ab:[(i64,i64);n],
    }
    ab.sort();
    ab.reverse();
    println!("{}", ab[0].0 + ab[0].1);
}


Measured memory_bytes: 6288
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
using namespace std;

#define ios ios::sync_with_stdio(false)
#define ll long long
#define pa pair<int,int>
#define mk make_pair
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define of(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, b) memset(a, b, sizeof a)
#define copy(a,b) memcpy(a, b, sizeof b)
#define pi acos(-1)
#define in freopen("input.in", "r", stdin);
#define out freopen("output.out", "w", stdout);

const ll inf = 0x3f3f3f3f;
const ll mod = 998244353;
const ll N = 2e5 + 10;
const ll M = 1e4 + 10;
const double eps = 1e-10;

int n, m, t;
double f[20][20];
int x[20], y[20];
int a[20];

int main()
{
	cin >> n;
	cout << n * n << endl;
	return 0;
}

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

int main(){
    ll n,a[200005],k,sum=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum=sum ^ a[i];
    }
    rep(i,n){
        k=sum^a[i];
        cout<<k;
        if(i<n-1){
            cout<<" ";
        }
    }
}

Measured memory_bytes: 5076
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int n, k;
double a[202020];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i] = a[i]+1;
		a[i] /= 2.0;
	}
	
	double ans = 0, cnt = 0;
	for(int i = 0; i < k; i++){
		cnt += a[i];
	}
	ans = cnt;
	for(int i = k; i < n; i++){
		cnt += a[i] - a[i-k];
		chmax(ans,cnt);
	}
	printf("%.10f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
double ac;
double TLE(){return (double)(clock() - ac) / CLOCKS_PER_SEC;}
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
int divisibilityCheck(int arr[], int n) 
{ 
    unordered_set<int> s; 
    int max_ele = INT_MIN; 
    for (int i = 0; i < n; i++) { 
        s.insert(arr[i]);  
        max_ele = max(max_ele, arr[i]); 
    }  
    unordered_set<int> res; 
    for (int i = 0; i < n; i++) {  
        if (arr[i] != 0) { 
            for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) { 
                if (s.find(j) != s.end()) 
                    res.insert(j); 
            } 
        } 
    } 
    unordered_map<int, int> mp; 
    for (int i = 0; i < n; i++) 
        mp[arr[i]]++; 
  
    unordered_map<int, int>::iterator it; 
    vector<int> ans; 
    for (it = mp.begin(); it != mp.end(); it++) {  
        if (it->second >= 2) { 
            if (res.find(it->first) == res.end()) { 
                int val = it->second;  
                while (val--) 
                    ans.push_back(it->first); 
            } 
        }  
        if (res.find(it->first) != res.end()) { 
            int val = it->second;  
            while (val--) 
                ans.push_back(it->first); 
        } 
    } 
    int v = ans.size();
    return v; 
}

int main(){
 ios::sync_with_stdio(0),cin.tie(0);
 int n;
 scanf("%d",&n);
 int a[n];
 for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
 }
 int k = divisibilityCheck(a,n);
 printf("%d\n",(n-k));
}

Measured memory_bytes: 30576
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int a = readInt(), b = readInt(), c = readInt(), k = readInt();
        for (int i = 0; i < k; i++) {
            if (a >= b) b *= 2;
            else if (b >= c) c *= 2;
            else break;
        }

        if (a < b && b < c) System.out.print("Yes");
        else System.out.print("No");

    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32476
P,C = map(int,input().split())
pref = [[] for _ in range(P)]
city = []
for ci in range(C):
  p,y = map(int,input().split())
  city.append([p-1])
  pref[p-1].append([y,ci])
cinp = []
for pi in range(P):
  pref[pi].sort()
  for j in range(len(pref[pi])):
    citycode = pref[pi][j][1]
    city[citycode].append(j)
for ci in range(C):
  pnow = city[ci][0]
  inow = city[ci][1]
  try:
    ans = (pnow+1) * 10 ** 6 + (inow+1)
  except:
    print(pnow,inow,p,cinp)
  ANS = str(ans)
  print( '0' * (12 - len(ANS)) + ANS)

Measured memory_bytes: 50040
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int max = Math.max(a, Math.max(b, c));
    int d = max * 3 - (a + b + c);
    if(d % 2 == 0){
      System.out.println(d / 2);
    }else{
      System.out.println(d / 2 + 2);
    }
  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t r, g, b, n;
    cin >> r >> g >> b >> n;

    int64_t count = 0;
    for (int ir = 0; ir * r <= n; ir++)
    {
        for (int ig = 0; ir * r + ig * g <= n; ig++)
        {
            const auto ball = ir * r + ig * g;
            if ((n - ball) % b == 0)
            {
                count++;
            }
        }
    }
    cout << count << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,nrred,nrwhite,minim=1e9;
char v[300001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(v[i]=='R')
            nrred++;
        else
            nrwhite++;
    }
    ll lred=0,rred=0;
    for(int i=0;i<=n;i++)
    {
        if(v[i]=='R')
            lred++;
        rred=nrred-lred;
        ll lwhite=i-lred;
        ll nrop=min(rred,lwhite);
        ll ans=nrop+rred-nrop+lwhite-nrop;
        minim=min(ans,minim);
    }
    cout<<minim;
    return 0;
}


Measured memory_bytes: 3848
import heapq
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = []
    heapq.heapify(q)
    frnt = [None]*3*n
    back = [None]*3*n
    heapq.heappush(q, a[0])
    frnt[0] = a[0]
    for i in range(1, 2*n+1):
        frnt[i] = a[i]
        frnt[i] += frnt[i-1]
        heapq.heappush(q, a[i])
        if n <= i:
            frnt[i] -= heapq.heappop(q)
    q = []
    heapq.heapify(q)
    heapq.heappush(q, -1*a[3*n-1])
    back[3*n-1] = a[3*n-1]
    for i in reversed(range(n-1, 3*n-1)):
        back[i] = a[i]
        back[i] += back[i+1]
        heapq.heappush(q, -1*a[i])
        if i < 2*n:
            back[i] += heapq.heappop(q)
    ans = -float("inf")
    for i in range(n-1, 2*n):
        ans = max(ans, frnt[i] - back[i+1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39076
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_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 repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#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 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))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
   COMinit();
    int X,Y;
    int time,xtime,ytime;
    ll ans=0;
    cin>>X>>Y;
    if((X+Y)%3!=0){
        Out(0);
        return 0;
    }
    time=(X+Y)/3;
    xtime=X-time;
    ytime=Y-time;
    ans=COM(time,xtime);

    Out(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

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

ll N, M;
ll ans = (ll)1e18;

void solve() {
    cin >> N;
    ll A[N];
    ll sum1, sum2 = 0;
    rep(i,N) {
        cin >> A[i];
        if (A[i] - (i+1) > 0) sum1 += A[i] - (i+1);
        else if (A[i] - (i+1) < 0) sum2 += -(A[i] - (i+1));
    }
    // ll b = (ll)(1. * sum / N) - (N / 2LL);
    // for (ll k = b - 100LL; k <= b + 100LL; ++k){
    //         ll t = 0;
    //         rep(i,N) t += abs(A[i] - (i + k));
    //         if (t < ans) {
    //             ans = t;
    //         }
    //     }
    // if (sum1 > sum2) b = 
    // ans = 0;
    // rep(i,N) ans += abs(A[i] - (b + i));
    ll lo = -(ll)1e9, hi = (ll)1e9;
    rep(i,1000) {
        ll a = (lo + lo + hi) / 3;
        ll b = (lo + hi + hi) / 3;
        ll sum1 = 0, sum2 = 0;
        rep(j,N) sum1 += abs(A[j] - (a + j));
        rep(j,N) sum2 += abs(A[j] - (b + j));
        if (sum1 > sum2) lo = a;
        else hi = b;
    }
    for (ll i = lo-10LL; i < lo+10LL; ++i) {
        ll sum = 0;
        rep(j,N) sum += abs(A[j] - (i + j));
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1792
// 障害物'#'の場所(Xi,Yi)を辞書順ソートして、
// Xi <= X(i+1) かつ Yi <= Y(i+1)がすべてのiにおいて成り立つならば"Possible"
// そうでないなら"Impossible"
#include <bits/stdc++.h>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> Map(H);
    for (int i = 0; i < H; ++i) {
        cin >> Map[i];
    }
    vector<pair<int, int>> obst;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (Map[i][j] == '#') {
                obst.emplace_back(i, j);
            }
        }
    }
    sort(obst.begin(), obst.end());

    for (int i = 1; i < obst.size(); ++i) {
        if (obst[i - 1].first <= obst[i].first && obst[i - 1].second <= obst[i].second) {
            continue;
        }
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int x; cin >> x;
  cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << '\n';
  return 0;
}


Measured memory_bytes: 256
<?php
  
 $s = str_split(trim(fgets(STDIN)));
//var_dump($s);
foreach($s as $key => $val){
if($key%2==0&&$val=='L'){
echo 'No';
 exit ;
}
  if($key%2==1&&$val=='R'){
echo 'No';
 exit ;
}
}
echo 'Yes' ;

Measured memory_bytes: 3700
color = input().split()
 
num = input().split()

stock = {}
stock[color[0]] = num[0]
stock[color[1]] = num[1]
 
u = input().split()
 
stock[u[0]] = int(stock[u[0]]) - 1
 
print('{col1} {col2}'.format(col1=stock[color[0]],col2=stock[color[1]]))

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


string s;
ll k;

int main(){
	cin >> s >> k;
	
	for(int i = 0; i < k; i++){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << s[k-1] << endl;
	
	return 0;
}

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

int main() {
    string s; cin >> s;
    int n = s.size();
    int flag = 1;
    for (int i = 0; i < (n-3)/2; i++) {
        if (s[i] != s[(n-3)/ 2 - i]) { flag = 0; break; }
    }

    for (int i = (n+1) / 2; i < n; i++) {
        if (s[i] != s[n-i-1]) { flag = 0; break; }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int n; cin >> n;
    long long numTeam = n * 3;
    vector<long long> a(numTeam);
    for (long long i = 0; i < numTeam; i++) cin >> a.at(i);
    
    sort(a.begin(), a.end());
    
    long long ans = 0;
    for (long long i = 3 * n - 2; i >= n; i = i - 2) {
        ans += a.at(i);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 2560
#include<iostream>

int f(int);

int main(){

    int cnt = 1;
    int s1;

    std::cin >> s1;

    if(s1 == 4 || s1 == 2 || s1 == 1){
        std::cout << 4 << std::endl;
        return 0;
    }

    while(s1 != 4){
        s1 = f(s1);
        cnt++;
    }

    std::cout << cnt + 3 << std::endl;
    
    return 0;
}

int f(int n){
    return n % 2 ? 3 * n + 1 : n / 2;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0); 
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     string s;
     while(cin>>s){
        if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

int A,B,C,D,E,F;

double calc(int na,int nb,int nc,int nd){
  return double(C*nc+D*nd)/(100*A*na+100*B*nb+C*nc+D*nd);
}

bool check_constraint(int na,int nb,int nc,int nd){
  return (100*A*na+100*B*nb+C*nc+D*nd <= F) && ((C*nc+D*nd) <= E*(A*na+B*nb));
}

int main(){
  cin >> A >> B >> C >> D >> E >> F;
  double max_concentration = -1;
  int max_amount = 0 , max_sugar = 0;
  for(int na = 0; na <= 30 ; ++na){
    for(int nb = 0; nb <= 30 ; ++nb){
      for(int nc = 0; nc <= 3000; ++nc){
        for(int nd = 0;check_constraint(na,nb,nc,nd); ++nd){
          double concentration = calc(na,nb,nc,nd);
          if(concentration>max_concentration){
            // cout << na << " " << nb << " " << nc << " " << nd << endl;
            max_concentration = concentration;
            max_sugar = C*nc+D*nd;
            max_amount = 100*A*na+100*B*nb+max_sugar;
          }
        }
      }
    }
  }

  cout << max_amount << " " << max_sugar << endl;

  return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int val=(n-1)/2;
    string s1,s2;
    for(int i=0;i<val;i++){
        s1.push_back(s[i]);
    }
    for(int i=val+1;i<n;i++){
        s2.push_back(s[i]);
    }
    if(equal(s.begin(), s.begin() + s.size()/2, s.rbegin())&&equal(s1.begin(), s1.begin() + s1.size()/2, s1.rbegin())&&( equal(s2.begin(), s2.begin() + s2.size()/2, s2.rbegin()) ) )
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
N=gets.to_i
D=*$<
(N-1).times do
#p D
t=0
D.map{|l|c,s,f=l.split.map &:to_i
if s>=t
  t=s+c
elsif t%f==0
  t+=c
else
  t+=c+f-(t%f)
end
}
p t
D.shift
end
print("0")

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

int main() {
  int n,m;
  cin>>n>>m;
  int p; string s;
  map <int, string> x;
  REP(i,m) {
    cin >> p >> s;
    x[p-1] += (s == "AC" ? "A" : "W");
  }
  int ans1=0,ans2=0;
  REP(i,n) {
    int tmp=0;
    REP(j,x[i].size()) {
      if (x[i][j] == 'A') {
        ans2+=tmp;
        ans1++;
        break;
      } else { tmp++; }
    }
  }

  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    string s; cin >> s;
    rep(i,s.size()){
        int x = s[i] - 'A';
        x = (x+n) %26;
        char y = 'A' + x;
        cout << y;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,l,l1;
  cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  for(i=0;i<n;i++)
  {
    cout<<s1[i]<<s2[i];
  }
}

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

int main()
{
    int N; cin >> N;
    string s; cin >> s;
    int cnt = 1;
    char c = s[0];
    for(int i = 1; i < N; i++)
    {
        if(c != s[i])
        {
            c = s[i];
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512