akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

void dfs(vector<ll> *adj, bool *visited, ll *dp, ll node)
{
    visited[node] = true;
    for(ll j = 0; j < adj[node].size(); j++)
    {
        if(visited[adj[node][j]] == false)
        {
            dfs(adj,visited,dp,adj[node][j]);
        }
        dp[node] = max(dp[node],1 + dp[adj[node][j]]);
    }
}
int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<ll> adj[100001];
        ll parent,child;
        for(ll i = 0; i < m ; i++)
        {
            cin>>parent>>child;
            adj[parent].push_back(child);
        }
        bool visited[100001] = {false};
        ll dp[100001]={0};
        for(ll i = 1; i <= n; i++)
        {
            if(visited[i] == false)
            {
                dfs(adj,visited,dp,i);
            }
        }
        ll longestPath = 0;
        //finding max value in dp
        for(ll i = 1; i <=n ; i++)
        {
            longestPath = max(longestPath,dp[i]);
        }
        cout<<longestPath<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const double eps = 0.00001;
const int MOD = 1000000007;
const int INF = 2147480555;
const ll LINF = 9223372000000000555;
const int N = 1550555;
const int M = 525;

void solve() {
    int n, x, t;
    cin >> n >> x >> t;

    cout << (n+x-1) / x * t;

}


int main() {
    ios_base::sync_with_stdio(false);
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int count=0;
    int sum=1;
    while(sum<b){
        sum=sum+a-1;
        ++count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int
#define N 200100
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	int x=1;
	while(x<10000){
		float c=x*0.08;
		float d=x*0.1;
		// cout<<c<<" "<<d<<endl;
		int w=floor(c);
		int y=floor(d);
		if(w==a && y==b){
			cout<<x<<endl;
			return 0;
		}
		x++;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
char mp[4]={'R','G','Y','B'};
int main ()
{
	int n,m,d,cx,cy;
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			cx=i+j+500,cy=i-j+500,printf("%c",mp[cx/d%2+cy/d%2*2]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

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

using namespace std;

typedef pair<int ,int > P;

ull n;
ull ans=1;
int main()
{
	cin>>n;
	for(ull i=1;i<=n;i++)
		ans*=i;
	cout<<ans<<endl;

	


	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
  ll x,y,z,k,a[1005],b[1005],c[1005];
  cin>>x>>y>>z>>k;
  for (int i=0; i<x; i++) cin>>a[i];
  for (int i=0; i<y; i++) cin>>b[i];
  for (int i=0; i<z; i++) cin>>c[i];

  ll ab[1000005];
  for (int i=0; i<x; i++) {
    for (int j=0; j<y; j++) {
      ab[y*i+j]=(a[i]+b[j]);
    }
  }
  sort(ab,ab+(x*y));
  reverse(ab,ab+(x*y));
  ll abc[3000005];
  int l=min(x*y,k);
  for (int i=0; i<l; i++) {
    for (int j=0; j<z; j++) {
      abc[z*i+j]=ab[i]+c[j];
    }
  }
  sort(abc,abc+l*z);
  reverse(abc,abc+l*z);
  for (int i=0; i<k; i++) {
    cout<<abc[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 31488
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

vector<int> prime;
vector<int> p;
void sieve(int n){
    prime.resize(n + 1, 1);
    for(int i = 2; i <= n; i++){
        if(prime[i] == 1){
            p.push_back(i);
            prime[i] = i;
        }
        for(int j : p){
            if((ll)i * j > n || j > prime[i]) break;
            prime[i * j] = j;
        }
    }
}

int main(){
    StarBurstStream

    int n;
    cin >> n;
    sieve(n);

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ll cnt = 1;
        int tmp = i;
        while(tmp > 1){
            int now = prime[tmp];
            int c = 0;
            while(tmp % now == 0) tmp /= now, c++;
            cnt *= c + 1;
        }
        ans += i * cnt;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 46396
fun main() {
    val n = readLine()!!.toInt()
    val xs = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a to b
    }

    val ans = if (n % 2 == 0) {
        val l = xs.sortedBy { it.first }.let { it[n / 2 - 1].first + it[n / 2].first }
        val r = xs.sortedBy { it.second }.let { it[n / 2 - 1].second + it[n / 2].second }
        r - l + 1
    } else {
        val l = xs.sortedBy { it.first }[n / 2].first
        val r = xs.sortedBy { it.second }[n / 2].second
        r - l + 1
    }

    println(ans)
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << '1' << endl;
  else if (a == b || b == c || c == a)
    cout << '2' << endl;
  else
    cout << '3' << endl;

}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n m ->
    let a = Array.init n (fun _ -> Scanf.scanf " %s" (fun a -> a)) in
    let b = Array.init m (fun _ -> Scanf.scanf " %s" (fun a -> a)) in

    let o = n - m in
    let rec loop_oy oy =
        let rec loop_ox ox =
            let rec loop_y y =
                let rec loop_x x =
                    if x = m then true else
                        if a.(oy + y).[ox + x] <> b.(y).[x] then false
                            else loop_x (x + 1)
                in
                if y = m then true else
                    if loop_x 0 then loop_y (y + 1) else false
            in
            if ox > o then false else
                if loop_y 0 then true else loop_ox (ox + 1)
        in
        if oy > o then false else
            if loop_ox 0 then true else loop_oy (oy + 1)
    in
    print_endline @@ if loop_oy 0 then "Yes" else "No"
)

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
long long int power(long long int a,long long int n,long long int m) ;
 long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}


int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o;
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  string s ;
   cin>>s ;
   if(s=="ABC")
    cout<<"ARC" ;
  else cout<<"ABC" ;
  return 0; }


Measured memory_bytes: 3604
#! python3
# printFrame.py - 長方形を描くプログラム

flag = True
rectangles = []
while flag:
    size = [int(i) for i in input().split()]
    H = size[0]
    W = size[1]
    if H == 0:
        flag = False
        break

    rectangle = []
    for h in range(H):
        row = []
        if h == 0 or h == H-1:
          for w in range(W):
              row.append('#')
        else :
          for w in range(W):
              if w == 0 or w == W-1:
                row.append('#')
              else :
                row.append('.')
        rectangle.append(row)
    rectangles.append(rectangle)

for rectangle in rectangles:
    for row in rectangle:
        print(''.join(row))
    print('')


Measured memory_bytes: 6008
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int c1, c2, c3;
	while (cin >> c1 >> c2 >> c3) {
		VB b(11, true); b[c1] = false; b[c2] = false; b[c3] = false;

		int cnt = 0;
		FOR(i, 1, 11) {
			if (b[i] && c1 + c2 + i <= 20)cnt++;
		}

		puts(3 < cnt ? "YES" : "NO");
	}
}


Measured memory_bytes: 2908
s = int(input())
n = input()
ans = 0
r_set = set()
g_set = set()
b_set = set()

for _ in range(s):
    if n[_] == 'R':
        r_set.add(_)
    elif n[_] == 'G':
        g_set.add(_)
    else:
        b_set.add(_)

len_b = len(b_set)

for r in r_set:
    for g in g_set:
        diff = abs(r - g)
        minus = set()
        if r < g:
            if g + diff in b_set:
                minus.add(g+diff)
            if r - diff in b_set:
                minus.add(r-diff)
        else:
            if r + diff in b_set:
                minus.add(r+diff)
            if g - diff in b_set:
                minus.add(g-diff)
        if (r + g) / 2 in b_set:
            minus.add((r+g)/2)
        ans += len_b - len(minus)

print(ans) 


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

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

    rep(i, n)rep(j, n)rep(k, n){
        if(i < j && j < k){
            if(a[i] == a[j]) continue;
            if(a[i] == a[k]) continue;
            if(a[k] == a[j]) continue;
            if((long long)a[i]+a[j]+a[k] <= max({a[i], a[j], a[k]}) * 2) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
S = list(rs())
ans = 0
tmp = 0
cnt = 0
f = 1
for i in range(len(S)):
    if S[i] == '<':
        if f:
            cnt += 1
        else:
            ans += cnt * (cnt - 1) // 2
            ans += max(tmp, cnt)
            cnt = 1
            f = 1
    else:
        if f:
            ans += cnt * (cnt - 1) // 2
            tmp = cnt
            cnt = 1
            f = 0
        else:
            cnt += 1
ans += cnt * (cnt - 1) // 2
if f:
    ans += cnt
else:
    ans += max(tmp, cnt)
print(ans)

Measured memory_bytes: 111176
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int count[9]={0};
    int num[]={400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 9999};
    int N;
    cin >> N;
    REP(i, N){
        int d;
        cin >> d;
        REP(j, 9){
            if(num[j]>d){
                ++count[j];
                break;
            }
        }
    }
    int sum = 0;
    REP(i, 8){
        if(count[i])++sum;
    }
    if(sum==0){
        cout << (count[8]!=0) << " " << count[8] <<  endl;
    }else
        cout << sum << " " << sum + count[8] << endl;
    return 0;
}



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

main(){
	int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int d,e,f;
  d=x*a+y*b;
  f=max(x,y)*c*2;
  if(x>=y) e=y*c*2+(x-y)*a;
  else e=x*c*2+(y-x)*b;
  cout<<min(d,min(f,e))<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
using namespace std;
typedef long long ll;
typedef int Def;
//typedef int ll;
typedef pair<Def,Def> pii;
typedef vector<string> vs;
typedef vector<Def> vi;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#include<tuple>
#include<queue>
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
class DIJ{
public:
  struct edge {
    Def to,cost,tim,r;
  };
  vector<vector<edge> > G;
  Def n,L;
  Def d[110][25][300];////
 
  DIJ(Def size){
    n=size;
    G=vector<vector<edge> >(n);
  }
  void add_edge(Def a, Def b,Def c,Def d,Def e){///
    edge E={b,c,d,e},ee={a,c,d,e};///
    G[a].push_back(E);
    G[b].push_back(ee);
  }
  void dij(Def s){///
    rep(i,110)rep(j,25)rep(k,300)d[i][j][k]=inf;///
    d[s][0][0]=0;
 
    int p;cin>>p;
    vi pa(p);
    vi dd(p);
    rep(i,p){
      int l;cin>>l>>dd[i];
      int t=0;
      rep(j,l){
    int a;cin>>a;
    t|=1<<(a-1);
      }
      pa[i]=t;
    }
    rep(i,p)for(int j=255;j>=0;j--){
      d[s][0][j|pa[i]]=min(d[s][0][j|pa[i]],d[s][0][j]+dd[i]);
    }
     
    priority_queue<tp>q;
 
    rep(i,256)if(d[s][0][i]!=inf){
      q.push(tp(-d[s][0][i],s,0,i));
    }
    while(!q.empty()){
      Def cost,pos,tim,pas;
      tie(cost,pos,tim,pas)=q.top();
      cost*=-1;
      q.pop();
      //      cout<<pos<<" "<<tim<<" "<<pas<<" "<<cost<<endl;
      if(cost>d[pos][tim][pas])continue;
      rep(i,G[pos].size()){
    edge e=G[pos][i];
    Def to=e.to;
    Def ncost=cost;
    if(pas&(1<<e.r));
    else ncost+=e.cost;
     
    Def nt=tim+e.tim;
    if(ncost<d[to][nt][pas]&&nt<=24){
      d[to][nt][pas]=ncost;
      q.push(tp(-ncost,to,nt,pas));
    }
      }
       
    }
  }
  void solve(int s,int t,int h){
    dij(s);
    int out=inf;
    rep(i,h+1)rep(j,300)
      out=min(out,d[t][i][j]);
    if(out==inf)out=-1;
    cout<<out<<endl;
  }
};
 
int main(){
  int n,m,h,k;
  while(cin>>n>>m>>h>>k,n){
    DIJ dij(n);
    rep(i,m){
      int a,b,c,d,e;
      cin>>a>>b>>c>>d>>e;
      a--;b--;e--;
      dij.add_edge(a,b,c,d,e);
    }
    int s,t;cin>>s>>t;
    s--;t--;
    dij.solve(s,t,h);
     
  }
}


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

int main() {
    int N, K;
    vector<int> v;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    std::sort(v.begin(), v.end());

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += v[i];
    }
    cout << sum << endl;

    return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int gcd=(__gcd(a,b));
    if(c%gcd==0)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int t = 0;
  while(A > 0 && C > 0) {
    if(t == 0) {
      C -= B;
    } else {
      A -= D;
    }
    t ^= 1;
  }
  if(t == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


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

int main()
{
	int n;
	int x[100], y[100];
	long s;
	long h[100];
	bool f;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i] >> h[i];

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			for (int k = 0; k < n; k++) {
				if (h[k] > 0) {
					s = h[k] + abs(x[k] - i) + abs(y[k] - j);
					break;
				}
			}
			f = 1;
			for (int k = 0; k < n; k++) {
				if ((h[k] > 0 && h[k] + abs(x[k] - i) + abs(y[k] - j) != s) ||
					(h[k] == 0 && abs(x[k] - i) + abs(y[k] - j) < s)) {
					f = 0;
					break;
				}
			}
			if (f) {
				cout << i << " " << j << " " << s << endl;
				break;
			}
		}
		if (f)
			break;
	}

	return 0;
}

Measured memory_bytes: 256
n=input()
l=len(n)
K=int(input())
dp=[[[0]*2 for i in range(4)]for j in range(105)]
dp[0][0][0]=1
for i in range(l):
    for j in range(4):
        for k in range(2):
            nd=int(n[i])
            for d in range(10):
                ni=i+1
                nj=j
                nk=k
                if d!=0:
                    nj+=1
                if nj>K:
                    continue
                if k==0:
                    if nd>d:
                        nk=1
                    if nd<d:
                        continue
                dp[ni][nj][nk]+=dp[i][j][k]
print(dp[l][K][1]+dp[l][K][0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    int c[n],ans,kai,con=0;
    rep(i,n){
        c[i]=i+1;
    }
    do{
        con++;
        rep(i,n){
            if(a[i]!=c[i]){
                break;
            }
            if(i==n-1){
                ans=con;
            }
        }
        rep(i,n){
            if(b[i]!=c[i]){
                break;
            }
            if(i==n-1){
                kai=con;
            }
        }
    }while(next_permutation(c,c+n));
    cout<<abs(ans-kai)<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    total = 0
    for i in count(1):
        total += i
        if total >= X:
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define maxn 200010
#define fi first
#define se second
#define LL long long 
#define pb push_back
#define Pii pair<LL,int>
#define mp make_pair
#define M 100000
using namespace std;
bool vis[maxn];
int n, l, r, Q;
void phi_table(){
	memset(vis, false, sizeof(vis));
	int m = (int)(sqrt(M) + 0.5);
	vis[1] = true;
	for(int i = 2; i <= m; i ++){
		if(!vis[i]){
			for(int j = i * i; j <= M; j += i){
				vis[j] = true;
			}
		}
	}
}
int sum[maxn];
int main(){
	phi_table();
	for(int i = 1; i <= M; i ++){
		sum[i] = sum[i - 1];
		if(i % 2 == 0){
			continue;
		}
		if(!vis[i] && !vis[(i + 1) / 2]) sum[i] ++;
	}
	cin >> Q;
	for(int i = 1; i <= Q; i ++){
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

void read(int &x,int &y){read(x),read(y);}

void read(int &x,int &y,int &z){read(x,y);read(z);}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
string s;
int f[55][55];
int main()
{
	int n,m;
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		cin>>s;
		for (int j=1;j<=m;j++)
			if (s[j-1]=='#') f[i][j]=1;
	}
	for (int i=1;i<=n;i++,cout<<endl)
		for (int j=1;j<=m;j++) f[i][j]?(cout<<"#"):(cout<<f[i-1][j-1]+f[i-1][j+1]+f[i+1][j-1]+f[i+1][j+1]+f[i][j-1]+f[i][j+1]+f[i-1][j]+f[i+1][j]);
	
	return 0;
}










Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    B = [0] * (N+1)
    ans = []
    for i in range(N,0,-1):
        x = sum(B[i::i])
        if x%2==A[i]:
            continue
        else:
            B[i] = 1
            ans.append(str(i))
    print(len(ans))
    print(' '.join(ans))




if __name__ == '__main__':
    main()

Measured memory_bytes: 17192
a[200],b[200],c[1000],d[1000],n,m,i,j,k,t,w,q;main(){for(;;){scanf("%d",&n);if(!n)break;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);scanf("%d",&m);for(i=0;i<m;i++){scanf("%d%d",&c[i],&d[i]);}for(i=0;i<m;i++){w=c[i]-a[0];q=d[i]-b[0];for(j=1;j<n;j++){for(k=0;k<m;k++){if(a[j]+w==c[k]){if(b[j]+q==d[k]){t++;break;}}}}if(t==n-1){printf("%d %d\n",w,q);t=0;break;}t=0;}}return 0;} 

Measured memory_bytes: 608
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(); 
		Set<String> set = new HashSet<String>();
		scanner.nextLine();
		String s;
		for(int i =0;i<n;i++) {
			s = scanner.nextLine();
			set.add(s);
		}
	
		System.out.println(set.size());
	}
}

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

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

    int n;
    cin >> n;

    int d = 0, t = n;
    while(t > 0){
        d += t % 10;
        t /= 10;
    }

    cout << (n % d == 0 ? "Yes" : "No") << endl;

    return 0;
}

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

const int MAX = 50;
int main() {
	int K, N, l[MAX];
	cin >> N >> K;
	for (int i = 0;i < N;i ++) cin >> l[i];
	sort(l, l + N); 
	int sum = 0;
	for (int i = N - 1;i > N - K - 1;i --) sum += l[i];
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

各l_iについてi<jならl_i>=l_jであるとする
この時、明らかにl_1からl_Kまでの棒を繋げると良い
オーダーはソート時間なのでO(NlogN)
なお、値の範囲が明らかに小さいのでバケットソートをするならO(max(l_1...l_N)+K)
*/

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a >= b)
    printf("No\n");
  else{
    if(b >= c)
      printf("No\n");
    else
      printf("Yes\n");
  }

  return 0;
}



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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/




signed main()
{
	int a; cin >> a;
	int b; cin >> b;
	int c; cin >> c;
	int cap = (a-b);
	int res = c-cap;
	if(cap >= c){
		cout << 0 << endl;
	}
	else{
		cout << res << endl;
	}
}

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

int main()
{
  int N, A;
  map<int, bool> a;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> A;
    if (a.count(A))
      a.erase(A);
    else
      a[A] = true;
  }
  cout << a.size() << endl;
}

Measured memory_bytes: 4864
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

ll N, K, R, S, P;
ll get_win(char c);

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	cin >> N >> K >> R >> S >> P;
	string T;
	cin >> T;

	vector<string> list(K);
	for (ll i = 0; i < N; i++) {
		list[i % K] += T[i];
	}

	ll ans = 0;
	for (ll i = 0; i < K; i++) {

		for (ll j = 0; j < list[i].size(); j++) {

			ans += get_win(list[i][j]);

			if (j + 1 < list[i].size() && list[i][j] == list[i][j + 1]) {
				j++;
			}

		}

	}


	cout << ans;


}

ll get_win(char c) {

	if (c == 'r') {
		return P;
	}
	else if (c == 's') {
		return R;
	}
	else {
		return S;
	}

}

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll t,i,x,j,y,z=0,k=0,n;
string s;
cin>>n;		ll a[n];
// n=s.size();
rep(i,0,n,1)	cin>>a[i];

sort(a,a+n);
t=0;
rep(i,0,n-1,1){
	t+=a[i];
	if(2*t<a[i+1])	z=i+1;
}

z=n-z;
ce(z)

}




Measured memory_bytes: 1024
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
v = na()
v = sorted(v)
a = v[0]
for i in range(1,n):
    a = (a+v[i])/2
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
int main (){
  
  int a,b[510],c[510],d[510],t;
  cin >> a;
  for(int i =0;i<a-1;i++){
    cin >> b[i]>>c[i]>>d[i];
  }
   
  for(int i=0;i<a;i++){
    t =0;
     for(int j =i;j<a-1;j++){
       
       if(t<c[j])
         t = c[j];
       
       else if(t%d[j] ==0) t =t;
         
        else   t = t+d[j]-t%d[j];
         
       
       
       t += b[j];
     }
    cout << t << endl;
  }
  
}
         


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int main() {
	long long N, K; std::cin >> N >> K;
	long long ans = K;
	for (int i = 0; i < N - 1; ++i) {
		ans *= K - 1;
	}
	std::cout << ans << std::endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> a(N, 0);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> dlist;
    double r = sqrt(sum);
    for (int i = 1; i <= r; i++) {
        if (sum % i == 0) {
            dlist.push_back(i);
            dlist.push_back(sum / i);
        }
    }
    ll ans = 1;
    for (ll d : dlist) {
        vector<ll> b(N);
        ll dsum = 0;
        for (int i = 0; i < N; i++) {
            b[i] = a[i] % d;
            dsum += b[i];
        }
        sort(b.begin(), b.end());
        ll cnt = 0;
        for (int i = 0; i < N-dsum/d; i++) cnt += b[i];
        if (cnt <= K) ans = max(ans, d);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define	fast						ios::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
#define rep(i,n)						for(int i = 1; i<=n; i++)
#define all(p)						p.begin(),p.end()
#define	mem(ar,val)					memset(ar, val, sizeof(ar))
#define sz(c)						(int)c.size()
#define pb(x)						push_back(x)
#define mkp(x,y)					make_pair(x,y)
#define SS(a,b)						scanf("%lld%lld",&a,&b)
#define SSS(a,b,c)						scanf("%lld%lld%lld",&a,&b,&c)
#define S(a)						scanf("%lld",&a)
#define PP(a,b)						printf("%lld %lld\n",a,b)
#define PPP(a,b,c)						printf("%lld %lld %lld\n",a,b,c)
#define P(a)						printf("%lld\n",a)
#define ff						first
#define ss						second
#define ll						long long
#define nl						"\n"
#define MAX(a, b)					((a) > (b) ? (a) : (b))
#define MIN(a, b)					((a) < (b) ? (a) : (b))
#define FI						freopen("input.txt", "r", stdin);
#define FO						freopen("output.txt", "w", stdout);
using namespace std;
const int INF = 0x7f7f7f7f;
const int modu = 998244353;
const int N = 1e5+1;
int dr[] ={0, 1};
int dc[] = {1, 0};
int ans[102][102];
int main()
{
//	fast
	int h, w;
	cin>>h>>w;
	char ar[h+1][w+1];
	for(int i = 0; i<h;i++)
	{
		for(int j = 0; j<w; j++)
		{
			cin>>ar[i][j];
			ans[i][j] = INT_MAX;
		}
	}
//	if(ar[0][0] == '#') ans[0][0] = 1;
//	else ans[0][0] = 0;
	ans[0][0] = 0;
	for(int i = 0; i<h;i++)
	{
		for(int j = 0; j<w; j++)
		{
			if(ar[i][j] =='.' && ar[i+dr[0]][j+dc[0]] == '#' && (j+dc[0])<w)
			{
				ans[i+dr[0]][j+dc[0]] = min(ans[i+dr[0]][j+dc[0]], ans[i][j]+1);
			}
			else
			{
				ans[i+dr[0]][j+dc[0]] = min(ans[i+dr[0]][j+dc[0]], ans[i][j]);
			}
			if(ar[i][j] =='.' && ar[i+dr[1]][j+dc[1]] == '#' && (i+dr[1])<h)
			{
				ans[i+dr[1]][j+dc[1]] = min(ans[i+dr[1]][j+dc[1]], ans[i][j]+1);
			}
			else
			{
				ans[i+dr[1]][j+dc[1]] = min(ans[i+dr[1]][j+dc[1]], ans[i][j]);
			}
		}
	}
	if(ar[0][0]=='#')
		cout<<ans[h-1][w-1] + 1<<nl;
	else
		cout<<ans[h-1][w-1]<<nl;
	//cout<<ans[h-1][w-1]<<nl;
//	for(int i = 0; i<h;i++)
//	{
//		for(int j = 0; j<w; j++)
//			cout<<ans[i][j]<<" ";
//		cout<<nl;
//	}
	
    return 0;
}


Measured memory_bytes: 256
n=int (input())
A=list(map(int,input().split()))
q=int (input())
m=list(map(int,input().split()))

box=[]
for i in range(2**n):
	b = '{0:0{1}b}'.format(i,n)
	tmp=[]
	for j in range(n):
		if b[j]=='1':
			if b[j]=='1':
				tmp.append(A[j])
	box.append(sum(tmp))
	
for k in m:
	if k in box:
		print("yes")
	else:
		print("no")


Measured memory_bytes: 42920
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int bubbleSort(int A[], int N) {
    int c = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = 1; j < N-i; j++) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = true;
                c++;
            }
        }
    }
    return c;
}

int main()
{
    int A[101], N;
 
    cin >> N;
 
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
 
    int c = bubbleSort(A, N);
 
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N-1)
            cout << " ";
        else
            cout << "\n";
    }
 
    cout << c << endl;
 
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,ans = 0;
  cin >> A >> B >> C;
  if(A < B)swap(A,B);
  if(B < C)swap(B,C);
  if(A < B)swap(A,B);
  if(A%2 != B%2 || B%2 != C%2 || C%2 != A%2){
    if(A%2 != B%2 && C%2 != A%2)A--;
    if(A%2 != B%2 && B%2 != C%2)B--;
    if(B%2 != C%2 && C%2 != A%2)C--;
    ans = 1;
  }
  if(A < B)swap(A,B);
  if(B < C)swap(B,C);
  if(A < B)swap(A,B);
  cout << ans + A - B + (A - (C + (A - B)))/2 << endl;
}


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


int main() {
	int n;
	cin >> n;
	vector<bool*> f(n);
	for (int i = 0; i < n; i++) {
		f[i] = new bool[10];
		for (int j = 0; j < 10; j++) {
			int k;
			cin >> k;
			f[i][j] = k;
		}
	}
	
	vector<int*> p(n);
	for (int i = 0; i < n; i++) {
		p[i] = new int[11];
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	long long ans = 0;
	for (int i = 1; i < (1 << 10); i++) {
		long long tmp = 0;
		for (int j = 0; j < n; j++) {
			int same = 0;
			for (int k = 0; k < 10; k++) {
				if (f[j][k] && (i & (1 << k))) same++;
			}
			tmp += p[j][same];
		}
		if (i == 1) ans = tmp;
		else if (ans < tmp) ans = tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int r,D, x;cin>>r>>D>>x;

    for(int i=0; i<10;i++){
      int ans = r*x-D;
      cout<<ans<<endl;
      x=ans;
    }

    return 0;
}


Measured memory_bytes: 256
<?php
define('MOD', 10 ** 9 + 7);
list($n, $k) = ints();
$a = ints();
$ap = $am = $az = [];
for ($i = 0; $i < $n; ++$i) {
    if ($a[$i] > 0) $ap[] = $a[$i];
    elseif ($a[$i] < 0) $am[] = abs($a[$i]);
    else $az[] = $a[$i];
}
// 0を選ぶしかない場合
if ((count($az) > 1 && $k > count($ap) + count($am)) || count($az) === $n) exit('0');
// マイナスを奇数個選ぶしかない場合（マイナスになる場合）
if (($k === count($ap) + count($am) && count($am) % 2) ||
    ($n === count($am) && $k % 2)
) {
    if (count($az) > 0) exit('0');
    $apm = array_merge($ap, $am);
    sort($apm);
    $ans = 1;
    for ($i = 0; $i < $k; ++$i) {
        $ans = modMul($ans, $apm[$i]);
    }
    echo modSub(0, $ans);
    exit;
}
rsort($ap);
rsort($am);
$q = new SplPriorityQueue();
for ($i = 1; $i < count($ap); $i += 2) {
    $q->insert([$ap[$i] * $ap[$i - 1], true], $ap[$i] * $ap[$i - 1]);
}
for ($i = 1; $i < count($am); $i += 2) {
    $q->insert([$am[$i] * $am[$i - 1], false], $am[$i] * $am[$i - 1]);
}
$i = 0;
$ans = 1;
while ($k > 1) {
    list($v, $f) = $q->extract();
    while ($k % 2 && $f && $i + 2 === count($ap))
        list($v, $f) = $q->extract();
    $k -= 2;
    $ans = modMul($ans, $v % MOD);
    if ($f) $i += 2;
}
if ($k === 1) $ans = modMul($ans, $ap[$i]);
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($n)
{
    global $fact, $ifact;
    $fact[0] = 1;
    for ($i = 1; $i <= $n; ++$i) $fact[$i] = modMul($fact[$i - 1], $i);
    $ifact[$n] = modDiv(1, $fact[$n]);
    for ($i = $n; $i >= 1; --$i)
        $ifact[$i - 1] = modMul($ifact[$i], $i);
}

// 順列（前処理）
function nPr2($n, $r)
{
    global $fact, $ifact;
    return modMul($fact[$n], $ifact[$n - $r]);
}

// 組み合わせ（前処理）
function nCr2($n, $r)
{
    global $fact, $ifact;
    return modMul(modMul($fact[$n], $ifact[$r]), $ifact[$n - $r]);
}


Measured memory_bytes: 76932
#include <iostream>
#include <vector>

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      std::cin >> b[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      long sum = 0;
      for (int k = 0; k < m; k++) {
        sum += a[i][k] * b[k][j];
      }
      std::cout << sum ;
      if (j<l-1)std::cout << " ";
      else std::cout << std::endl;
    }
  }
}




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

int main() {
  ll n, m; cin >> n >> m;
  m /= 2;
  if (n < m) cout << (n + m) / 2 << endl;
  else cout << m << endl;

  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include <iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<string.h>
#include<math.h>
#include<unordered_map>
#include <deque>
using namespace std;


typedef long long ll;


int main()
{
	int n;
	vector<ll> ar,ori;

	cin >> n;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		ar.push_back(a);
		ori.push_back(a);
	}
	sort(ar.begin(), ar.end());
	ll p = ar[(n - 1) / 2];

	for (int i = 0; i < n; i++) {
		if (ori[i] > p) {
			cout << ar[(n-1)/2] << endl;
		}
		else
		{
			cout << ar[(n - 1) / 2 +1] << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 7012
import sys


def resolve():
    import itertools
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N, M = map(int, readline().split())
    lst = [set(map(int, readline().split())) for _ in [0] * M]
    d = []
    ans = 0
    # for i in range(2, N + 1):
    #     d.append(i)
    for i in itertools.permutations(range(2, N + 1), N - 1):
        cnt = 0
        if {1, i[0]} in lst:
            cnt += 1
            for j in range(N - 2):
                if {i[j], i[j + 1]} in lst:
                    cnt += 1
                    pass
                else:
                    break
        if cnt == N - 1:
            ans += 1
    print(ans)
    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9120
#include <vector>
#include <iostream>
#include <stdio.h>

int main(){

	using namespace std;

	vector<int> array;
	int w,n;
	int a,b,i,j,k;
	
	scanf("%d %d\n",&w,&n);
	
	for(i=0;i<w;i++){
		array.push_back(i+1);
	}
	
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		k=array[a-1];
		array[a-1]=array[b-1];
		array[b-1]=k;
	}
	
	for(i=0;i<w;i++){
		cout << array[i] << endl;
	}
}

Measured memory_bytes: 1228
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

bool CanKill(int64_t exptime, int64_t a, int64_t b,
             std::vector<int64_t> enemy) {
  // cerr << "\033[93m" << exptime << "\033[m" << endl;
  int64_t range_damage = b * exptime;
  for (auto& e : enemy) {
    e -= range_damage;
  }
  for (auto& e : enemy) {
    // cerr << e << endl;
    if (e > 0) {
      int64_t single_damage = a - b;
      exptime -= ceil((double)e / (double)single_damage);
    }
    // cerr << "\033[93m" << exptime << "\033[m" << endl;
  }
  return exptime >= 0;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int64_t n, a, b;
  cin >> n >> a >> b;
  std::vector<int64_t> enemy(n);
  int64_t max_hp = 0;
  for (int i = 0; i < n; i++) {
    cin >> enemy[i];
    max_hp = std::max(enemy[i], max_hp);
  }

  //にぶたんをする
  int64_t min = 0, max = max_hp / b + 2;
  int64_t mid = (min + max) / 2;

  while (max - min > 1) {
    if (CanKill(mid, a, b, enemy)) {
      max = mid + 1;
      mid = (min + max - 1) / 2;
    } else {
      min = mid + 1;
      mid = (min + max - 1) / 2;
    }
    // cerr << "\033[93m" << min << " " << max << "\033[m" << endl;
  }
  cout << min << endl;

  return 0;
}


Measured memory_bytes: 1792