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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n, alice, bob;
    alice = 0, bob = 0;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dsort(a, int);

    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200000;
int ans;
int ai[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        int a;
        cin >> a;
        ai[a + 5] ++;
    }
    for (int i = -1; i <= 100005; ++ i)
        ans = max(ans, ai[i + 5 - 1] + ai[i + 5] + ai[i + 5 + 1]);
    cout << ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,W;
    cin>>n>>W;
    vector<int> w(n);
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>w[i]>>p[i];
    }
    vector<vector<long long>> dp(n+1,vector<long long>(W+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=W;j++){
            if(w[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],p[i-1]+dp[i-1][j-w[i-1]]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W]<<"\n";
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

char back(char ch, int a){
  int p = ch - 'a';
  p = ( p + a + 26) % 26;
  return 'a' + p;
}

int a[200];
int b[200];

int main(){
  int n;
  string s;
  while(cin >> n && n){
    cin >> s;
    rep(i, n){
      cin >> a[i] >> b[i];
      a[i]--, b[i]--;
    }
    rep(i, n){
      int dif = abs(a[n-i-1] - b[n-1-i]);
      swap(s[a[n-i-1]], s[b[n-i-1]]);

      s[a[n-i-1]] = back(s[a[n-i-1]], dif);
      s[b[n-i-1]] = back(s[b[n-i-1]], dif);

    }

    cout << s << endl;
  }
  return 0;
}

      

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
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()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
using CostType = long long;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return cost <= rhs.cost; }
  inline bool operator>(const Edge &rhs) const {
    return cost != rhs.cost ? cost > rhs.cost : dst != rhs.dst ? dst > rhs.dst : src > rhs.src;
  }
  inline bool operator>=(const Edge &rhs) const { return cost >= rhs.cost; }
};

struct BellmanFord {
  vector<CostType> dist;

  BellmanFord(const vector<vector<Edge> > &graph, const CostType CINF = LINF) : graph(graph), CINF(CINF) {}

  bool has_negative_cycle(int s) {
    int n = graph.size();
    dist.assign(n, CINF);
    dist[s] = 0;
    prev.assign(n, -1);
    REP(step, n) {
      bool is_updated = false;
      REP(i, n) for (Edge e : graph[i]) {
        if (dist[i] != CINF && dist[e.dst] > dist[i] + e.cost) {
          dist[e.dst] = dist[i] + e.cost;
          prev[e.dst] = i;
          is_updated = true;
        }
      }
      if (!is_updated) return false;
    }
    return true;
  }

  vector<int> build_path(int t) {
    vector<int> res;
    for (; t != -1; t = prev[t]) {
      res.emplace_back(t);
      if (res.size() > graph.size()) {
        res.clear();
        break;
      }
    }
    reverse(ALL(res));
    return res;
  }

private:
  vector<vector<Edge> > graph;
  const CostType CINF;
  vector<int> prev;
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m, p; cin >> n >> m >> p;
  vector<vector<Edge> > graph(n);
  while (m--) {
    int a, b, c; cin >> a >> b >> c; --a; --b;
    graph[a].emplace_back(Edge(a, b, p - c));
  }
  BellmanFord bf(graph);
  if (bf.has_negative_cycle(0)) {
    vector<int> path = bf.build_path(n - 1);
    if (path.empty()) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << max(-bf.dist[n - 1], 0LL) << '\n';
  return 0;
}


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

int n, m;
int c[100000];

bool yes_no(){
  for(int i = 0; i < n; i++){
    if(c[i] % 2 == 1){
      return false;;
    }
  }
  return true;
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    c[a]++;
    c[b]++;
  }

  if(yes_no()){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int one = N%10;
  if(one ==2||one==4||one==5||one==7||one==9) printf("hon");
  else if(one==0||one==1||one==6||one==8) printf("pon");
  else printf("bon");
  
	return 0;
}

Measured memory_bytes: 1728
from math import hypot
def dijkstra(s,n,cost):
    d=[float("inf")]*n
    used=[False]*n
    d[s]=0
    while True:
        v=-1
        for i in range(n):
            if(not used[i])and v==-1:
               v=i
            elif(not used[i])and d[i]<d[v]:
                v = i
        if v==-1:
            break
        used[v]=True
        for j in range(n):
            d[j]=min(d[j],d[v]+cost[v][j])
    return d
xs,ys,xt,yt,n,*t=map(int,open(0).read().split())
e=[(xs,ys,0)]+list(zip(t[::3],t[1::3],t[2::3]))+[(xt,yt,0)]
cost=tuple([float('inf')]*(n+2)for i in range(n+2))
for i,(x,y,z)in enumerate(e):
    for j,(a,b,c)in enumerate(e):
        cost[i][j]=max(0,hypot(x-a,y-b)-z-c)
print(dijkstra(0,n+2,cost)[-1])

Measured memory_bytes: 36724
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())


int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll x=n/(a+b);
  if(n%(a+b)<=a){
    cout<<x*a+n%(a+b)<<endl;
  }
  else{
    cout<<(x+1)*a<<endl;
  }
}


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

int main(void){
  int room[4][3][10];
  int n;
  int b, f, r, v;

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
	room[i][j][k] = 0;
      }
    }
  }

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    room[b - 1][f - 1][r - 1] += v;
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
	cout << " " << room[i][j][k];
      } // k
      cout << endl;

    } // j
    if(i != 4 - 1){
      cout << "####################" << endl;
    }

  } // i

  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<math.h>
int main(){
  int sosu[100001],n,p,q,i,j,count;
//  FILE *fo;

//  fo=fopen("data.txt","r");
//  fscanf(fo,"%d",&n);
  for(i=0;i<=100000;i++)sosu[i]=i;
  for(i=2;i<=316;i++)
    if(sosu[i]!=0)
      for(j=i*i;j<=100000;j=j+i)sosu[j]=0;
//  for(i=2;i<=50000;i++)
//    if(sosu[i]!=0)printf("%d ",sosu[i]);

  scanf("%d",&n);
  while(n!=0){
    count=0;
    for(p=2;p<=(n/2);p++){
      q=n-p;
      if(sosu[p]!=0 && sosu[q]!=0){
//        printf("%d %d\n",p,q);
        count++;
      }
    }

    printf("%d\n",count);
    scanf("%d",&n);
  } 
  return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int INF = int(2e9);
int L[111111];
int R[111111];
ii ID[111111];
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int dp[111111];
bool cmp(ii a, ii b)
{
	if(a.fi!=b.fi) return a.fi<b.fi;
	return a.se>b.se;
}
struct Fenwick
{
	vector<ll> t;
    Fenwick(int n)
    {
        t.assign(n+1,0);
    }
    void reset(int n)
    {
		t.assign(n+1, 0);
	}
    void update(int p, int v)
    {
		p++;
        for (; p < (int)t.size(); p += (p&(-p))) t[p] = add(t[p], v);
    }
    int query(int r) //finds [1, r] sum
    {         
		if(r<0) return 0;            
        int sum = 0;
        r++;
        for (; r; r -= (r&(-r))) sum = add(sum, t[r]);
        return sum;
    }
};
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	vi a,b;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; a.pb(x);
	}
	for(int i=0;i<m;i++)
	{
		int x; cin>>x; b.pb(x);
	}
	vector<ii> vec;
	for(int i=0;i<n;i++)
	{
		int lb = lower_bound(b.begin(),b.end(),a[i])-b.begin();
		L[i]=R[i]=INF;
		if(lb<b.size()) R[i]=b[lb]-a[i];
		lb--;
		if(lb>=0) L[i]=a[i]-b[lb];
		if(L[i]<INF&&R[i]<INF) vec.pb(mp(L[i],R[i]));
	}
	sort(vec.begin(),vec.end());
	vi coorda,coordb;
	for(int i=0;i<vec.size();i++)
	{
		coorda.pb(vec[i].fi); coordb.pb(vec[i].se);
	}
	sort(coorda.begin(),coorda.end()); sort(coordb.begin(),coordb.end());
	coorda.erase(unique(coorda.begin(),coorda.end()),coorda.end()); coordb.erase(unique(coordb.begin(),coordb.end()),coordb.end());
	for(int i=0;i<vec.size();i++)
	{
		vec[i].fi=lower_bound(coorda.begin(),coorda.end(),vec[i].fi)-coorda.begin();
		vec[i].se=lower_bound(coordb.begin(),coordb.end(),vec[i].se)-coordb.begin();
	}
	sort(vec.begin(),vec.end(),cmp);
	Fenwick fen(n+5);
	for(int i=0;i<vec.size();i++)
	{
		if(i>0&&vec[i].fi==vec[i-1].fi&&vec[i].se==vec[i-1].se) continue;
		dp[i]=add(fen.query(vec[i].se-1),1);
		fen.update(vec[i].se,dp[i]);
	}	
	int ans=add(fen.query(n+1),1);
	cout<<ans<<'\n';
}


Measured memory_bytes: 5044
#include<iostream>
#include<string>
using namespace std;
int main(){

int H=0;//縦
int W=0;//横

int i=0;
int j=0;

string a[101];
string b[201];

cin>>H>>W;

for(i=0;i<H;i++){
	cin>>a[i];
}

for(i=0;i<H;i++){
	cout<<a[i]<<endl;
	cout<<a[i]<<endl;
}



}

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

signed main(){
    string s;cin>>s;
    map<char,int> mp;
    REP(i,s.size()) mp[s[i]]++;
    if((mp['N']>0&&mp['S']==0)||(mp['S']>0&&mp['N']==0)||
       (mp['W']>0&&mp['E']==0)||(mp['E']>0&&mp['W']==0)){
           cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}

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

int main() {
    int n, m, sum = 0;
    ll cnt = 0;
    map<int,ll> mp;
    cin >> n >> m;
    mp[0]++;
    REP(i,n){
        int a;
        cin >> a;
        sum = (sum+a)%m;
        cnt += mp[sum];
        mp[sum]++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4224
a, b, c, x, y = list(map(int, input().split()))

cost = []
if x < y:
    cost.append(y*c*2)
    cost.append(c*x*2+(y-x)*b)
else:
    cost.append(x*c*2)
    cost.append(c*y*2+(x-y)*a)

cost.append(x*a+y*b)
    
print(min(cost))

Measured memory_bytes: 3060
// Created by  Ambesh kumar
#include "bits/stdc++.h"

#define  ll  long long  
# define  loop(x,n)  for(int x = 0; x < n; ++x)  
#define   constloop(x,a,n) for(int x = a; x < n; ++x)  
#define  revloop(x,a,n)  for(int x = a; x > n; x--) 

using namespace std;

int main()
{

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


    ios::sync_with_stdio(0);
    cin.tie(0);

    int k,a,b;
    cin>>k>>a>>b;

bool y=false;
constloop(i,a,b+1)
{

if(i%k==0)
{
y=true;
break;

}

}

if(y)
	cout<<"OK"<<"\n";
else
	cout<<"NG"<<"\n";

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
  	cout << max(0, a-b*2) << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_c
#include <bits/stdc++.h>
using namespace std;

int main(void){
  string S;
  cin >> S;

  int res = S.size();
  for (int i = 0; i <= 1; i++){
    int value = i;
    int count = 0;
    for (int i = 0; i < S.size(); i++){
      if (S[i] - '0' == value)  // 文字->数値
        count++;
      value = 1 - value;
    }
    res = min(res, count);
  }

  cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == '1')ans++;
    }
    cout << ans << endl;
	return 0;
}

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

namespace SandboxCSharp
{
    class Solver
    {
        public void Solve()
        {
            string str = io.ScanString();
            int n = str.Length;
            int xok = 0, yok = 0;

            foreach (char c in str)
            {
                if (c == 'N')
                    yok |= 1;
                if (c == 'S')
                    yok |= 2;
                if (c == 'W')
                    xok |= 1;
                if (c == 'E')
                    xok |= 2;
            }
            if ((xok == 0 || xok == 3) && (yok == 0 || yok == 3))
                io.WriteLine("Yes");
            else
                io.WriteLine("No");
        }

        // =================================================
        // =================================================

        Stdio io;
        bool isjdg;
        static void Main()
        {
            var s = new Solver();
            s.Solve();
            s.io.Flush();
        }
        public Solver(Stdio _io = null)
        {
            isjdg = _io == null;
            io = _io == null ? new Stdio() : _io;
        }

        void Exit()
        {
            if (isjdg)
            {
                io.Flush();
                Environment.Exit(0);
            }
            else
                throw new HaltException();
        }
    }
    class Stdio
    {
        protected string[] stack = new string[0];
        protected int stackptr = 0;
        protected StringBuilder outbuff = new StringBuilder();

        public virtual int ScanInt()
        {
            return Check() ? int.Parse(stack[stackptr++]) : 0;
        }
        public virtual long ScanLong()
        {
            return Check() ? long.Parse(stack[stackptr++]) : 0;
        }
        public virtual string ScanString()
        {
            return Check() ? stack[stackptr++] : string.Empty;
        }
        public virtual double ScanDouble()
        {
            return Check() ? double.Parse(stack[stackptr++]) : 0;
        }
        protected virtual bool Check()
        {
            if (stackptr < stack.Length) return true;
            var l = Console.ReadLine();
            if (l == null) return false;
            stack = l.Split(' ').ToArray(); stackptr = 0;
            return Check();
        }
        public Stdio Write(long v) { return Write($"{v}"); }
        public Stdio WriteLine(long v) { return WriteLine($"{v}"); }
        public Stdio Write(string str)
        {
            outbuff.Append(str);
            return this;
        }
        public Stdio WriteLine(string str = "")
        {
            outbuff.AppendLine(str);
            return this;
        }
        public virtual Stdio Flush()
        {
            Console.Write(outbuff.ToString());
            outbuff.Clear();
            return this;
        }
    }
    class HaltException : Exception { }

}


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

int N;
int A[250];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    while (true) {
        bool exist_odd = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    string s;
    cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    


    return 0;
}

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

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;
  vector<pair<int, int>> A(N); // value, index
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    A[i] = make_pair(a, i);
  }

  sort(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
    if (i != A[N-1].second) {
      cout << A[N-1].first << endl;
    } else {
      cout << A[N-2].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main(){
    while (1){
        int n, r, cards[51], i, k;
        scanf("%d %d", &n, &r);
        if (n == 0)
            return 0;
        for (i=0; i<n; i++)
            cards[i] = n-i;
        for(k = 0; k < r; k++){
            int p, c, tmp[50];
            scanf("%d %d", &p, &c);
            for (i=0; i<c; i++)
                tmp[i] = cards[p+i-1];
            for (; i<c+p-1; i++)
                tmp[i] = cards[i-c];
            for (i = 0; i < c + p - 1; i++)
                cards[i] = tmp[i];
        }
        printf("%d\n", cards[0]);
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  long long Q = K;
  long long S = 0;
  long long H = 0;
  if(K > A) {
    Q = A;
    S = K - A;
  }
  if(S > B) {
    H = S - B;
  }
  if(H > C) {
    H = C;
  }
  cout << Q * 1 + S * 0 + H * -1 << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if(a<=b)
    if(b<=c) printf("%d %d %d\n",a,b,c);
    else if(a<=c&&c<=b) printf("%d %d %d\n",a,c,b);
    else printf("%d %d %d\n",c,a,b);

else
    if(a<=c) printf("%d %d %d\n",b,a,c);
    else if(b<=c&&c<=a) printf("%d %d %d\n",b,c,a);
    else printf("%d %d %d\n",c,b,a);

return 0;



}

Measured memory_bytes: 1024
#include <cstdio>

int main() {
    int a[3], b[3];
    int c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &c[i][j]);
        }
    }
    a[0] = 0;
    for (int i = 0; i < 3; i++) {
        b[i] = c[0][i];
    }
    for (int i = 1; i < 3; i++) {
        a[i] = c[i][0]-b[0];
    }

    for (int i = 1; i < 3; i++) {
        for (int j = 1; j < 3; j++) {
            if (c[i][j] != a[i] + b[j]) {
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
void swap(long *x,long *y){
    long tmp;
    tmp=*x;
    *x=*y;
    *y=tmp;
}
int main(void){
    long numcity,start;
    long *x;
    long mindistance=1000000000,*distance;
    scanf("%ld %ld",&numcity,&start);
    x=(long *)malloc(sizeof(long)*numcity);
    distance=(long *)malloc(sizeof(long)*numcity);
    long i,j;
    for(i=0;i<numcity;i++){
        scanf("%ld",&x[i]);
        distance[i]=labs(x[i]-start);
        if(distance[i]<mindistance){
            mindistance=distance[i];
        }
    }
    long MP;
    for(i=0;i<numcity;i++){
        if(distance[i]%mindistance!=0){
            for(j=0;j<numcity-1;j++){
                if(j==0){
                    if(distance[j]<distance[j+1]){
                        swap(&distance[j],&distance[j+1]);
                    }
                    long r=distance[j]%distance[j+1];
                    while(r!=0){
                        distance[j]=distance[j+1];
                        distance[j+1]=r;
                        r=distance[j]%distance[j+1];
                    }
                    MP=distance[j+1];
                }
                else{
                    if(MP<distance[j+1]){
                        swap(&MP,&distance[j+1]);
                    }
                    long r=MP%distance[j+1];
                    while(r!=0){
                        MP=distance[j+1];
                        distance[j+1]=r;
                        r=MP%distance[j+1];
                    }
                    MP=distance[j+1];
                }
            }
            printf("%ld",MP);
            return 0;
        }
    }
    printf("%ld",mindistance);
    return 0;
    
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string t; cin >> t;
  for(int i = 0; i < 7; ++i){
    if(t == s[i]){
      cout << 7-i << endl;
      break;
    }
  }
  
  return 0;
}


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

int main(){
  int N;
  long int pow = 1;
  int MOD = 1000000007;
  cin >> N;
  
  for(int i=1;i<=N;i++){
    pow = i * pow % MOD;
  }
  
  cout << pow << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    cout << x / (y + z) << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (void)
{
    long x, a, b;

    cin >> x >> a >> b;

    if (x + a >= b) {
        if (x >= b) {
            cout << "delicious" << endl;
        } else {
            cout << "safe" << endl;
        }
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int a , b ;
	cin >> a >> b ;
	//参加回数a,表示b
	if(a >= 10){
		cout << b << endl;
	} else {
		cout <<  b+(100 *(10- a)) << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int r;
  cin>>r;
  if(r<1200)ou("ABC");
  else if(r>=1200&&r<2800)ou("ARC");
  else ou("AGC");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
vector<pair<int,int>> P, T;
vector<int> cvh;

long long CCW(pair<int,int> base, pair<int,int> a, pair<int,int> b)
{
	return 1LL*(a.first-base.first)*(b.second-base.second)-1LL*(a.second-base.second)*(b.first-base.first);
}

long long get_dist_square(pair<int,int> a, pair<int,int> b)
{
	long long dx=a.first-b.first, dy=a.second-b.second;
	return dx*dx+dy*dy;
}

void convex_hull()
{
	for(int i=0;i<T.size();i++) if(T[i]<T[0]) swap(T[0],T[i]);
	sort(T.begin()+1,T.end(),[&](pair<int,int> a, pair<int,int> b) {
		long long temp=CCW(T[0],a,b);
		if(temp!=0) return temp>0;
		return get_dist_square(T[0],a)<get_dist_square(T[0],b);
	});
	cvh.clear();
	cvh.push_back(0);
	cvh.push_back(1);
	for(int i=2;i<T.size();i++) {
		while(cvh.size()>1) {
			int temp=cvh.back();
			cvh.pop_back();
			if(CCW(T[cvh.back()],T[temp],T[i])>0) {
				cvh.push_back(temp);
				break;
			}
		}
		cvh.push_back(i);
	}
	P.clear();
	for(auto c: cvh) P.push_back(T[c]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, dx[4]={}, dy[4]={}, idx=0, c=1;
	long long ans=0;
	cin>>N;
	P.emplace_back(0,0);
	for(int i=0;i<N;i++) {
		int x, y;
		cin>>x>>y;
		T.clear();
		for(int i=0;i<P.size();i++) {
			T.push_back(P[i]);
			T.emplace_back(P[i].first+x,P[i].second+y);
		}
		convex_hull();
	}
	for(int i=0;i<P.size();i++) ans=max(ans,get_dist_square(make_pair(0,0),P[i]));
	cout.precision(12);
	cout<<fixed<<sqrt(ans)<<'\n';
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
max_num = int(-(-(math.sqrt(1 + 8*n) - 1) // 2))

s = int(max_num * (1 + max_num) / 2)

d = s - n

for i in range(max_num):
    if i+1 != d:
        print(i+1)

Measured memory_bytes: 9192
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
vi d;
vi v;
int N,k;
void dfs(int n) {
    if(n>100000) return;
    d.pb(n);
    for(auto p:v) dfs(n*10+p);
}
signed main() {
    cin >> N >> k;
    {
        set<int> st;
        rep(i, k) {
            int a;cin >> a;
            st.insert(a);
        }
        rep(i, 10) if(!st.count(i)) v.pb(i);
    }
    for(auto p:v) if(p!=0)dfs(p);
    sort(all(d));
    // for(auto p:d)cout << p << ' ';cout << char(10);
    cout << *lower_bound(all(d),N) << endl;
    return 0;
}

Measured memory_bytes: 4072
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let n:usize = scan.next();
	let a:Vec<usize> = (0..n).map(|_| scan.next()).collect::<Vec<usize>>();

	let mut history = (0..n).map(|_| false).collect::<Vec<bool>>();

	let mut i = 1;
	let mut count = 1;

	history[0] = true;

	while !history[a[i-1]-1] {
		if a[i-1] == 2 {
			println!("{}",count);
			return;
		}
		i = a[i-1];

		count += 1;

		history[i-1] = true;
	}

	println!("-1");
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  int ans = 0;
  FOR(i, 1, n + 1) {
    int digitSum = 0;
    int tmp = i;
    while (tmp != 0) {
      digitSum += tmp % 10;
      tmp /= 10;
    }
    if (digitSum >= a && digitSum <= b)
      ans += i;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    int a[x],b[y],c[z];
    r(i,x)cin>>a[x-i-1];
    r(i,y)cin>>b[y-i-1];
    r(i,z)cin>>c[z-i-1];

    sort(a,a+x,greater<int>());
    sort(b,b+y,greater<int>());
    sort(c,c+z,greater<int>());

    priority_queue<P>q;
    q.push(P(a[0]+b[0]+c[0],0));

    set<int>s;

    r(i,k){
        //while(s.count(q.top().S))q.pop();
        P p=q.top();q.pop();
        cout<<p.F<<endl;
        int A=p.S/100000000;
        int B=(p.S/10000)%10000;
        int C=p.S%10000;

        int AA=(A+1)*100000000+B*10000+C;
        int BB=(A+0)*100000000+(B+1)*10000+C;
        int CC=(A+0)*100000000+B*10000+C+1;


        if(A+1<x && !s.count(AA))q.push(P(a[A+1]+b[B]+c[C],AA));
        if(B+1<x && !s.count(BB))q.push(P(a[A]+b[B+1]+c[C],BB));
        if(C+1<x && !s.count(CC))q.push(P(a[A]+b[B]+c[C+1],CC));

        s.insert(AA);
        s.insert(BB);
        s.insert(CC);
    }
}

Measured memory_bytes: 768
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a%2==0||b%2==0||c%2==0){printf("0\n");}
    else{printf("%lld\n",llmin(a*b,llmin(a*c,b*c)));}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    string S; cin >> S;
    if (N % 2 == 0) {
        string f = S.substr(0, S.size() / 2);
        string l = S.substr(S.size() / 2, S.size() / 2);
        cout << (f == l ? "Yes" : "No") << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int x,int y){
  if(x<y) swap(x,y);
  int b;
  while(x%y!=0){
    b=x;
    x=y;
    y=b%y;
  }
  return y;
}
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) <<endl;
  return 0;
}


Measured memory_bytes: 3120
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>

int main() {
	int n, x = 0, max = 0;
	char s[101];
	max = 0;
	scanf("%d", &n);
	scanf("%s", &s);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')
			x++;
		else
			x--;
		if (max < x)
			max = x;
	}
	printf("%d\n", max);

	return 0;
}

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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	long[] n1=long_arr();
	        		  	int n=(int)n1[0];long k=n1[1];
	        		  	int[] a=int_arr();
	        		  	int[][] dp=new int[n+1][64];
	        		  	for(int i=1;i<=n;i++){
	        		  		dp[i][0]=a[i-1];
	        		  	}
	        		  	for(int j=1;j<64;j++){
	        		  		for(int i=1;i<=n;i++){
	        		  			dp[i][j]=dp[dp[i][j-1]][j-1];
	        		  		}
	        		  	}
	        		  	int cc=1;
	        		  	for(int i=0;i<64;i++){
	        		  		if((k&1l<<i)!=0){
	        		  			cc=dp[cc][i];
	        		  		}
	        		  	}
		  	        	out.write(cc+"");
	
                      out.flush();
	        		 
	}
}
	       
	          



	
  





	
  





Measured memory_bytes: 107792
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	int botton[N+1] = {};
	for (int i = 1; i < N+1; i++) {
		cin >> botton[i];
	}
	int count = 0;
	int n = 1;
	while (1) {
		if (n == 2) {
			cout << count << endl;
			return 0;
		}
		n = botton[n];
		count++;
		if (count >= N + 1)break;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 4024
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] num = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				num[i] = scanner.nextInt();
				sum += num[i];
			}
			int mod = n % m;
			Arrays.sort(num);

			for (int i = mod; i < n; i += m) {
				sum -= num[i];
			}
			System.out.println(sum);
		}
	}
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    ll n,k;
    cin >> n >> k;

    ll min_num = n;

    min_num = min(min_num,n%k);
    n = min_num;
    min_num = min(min_num,abs(n-k));

    cout << min_num << endl;


}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map { it.toInt() }

    val parent = IntArray(N)
    val ans = IntArray(N)

    repeat(N - 1) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        parent[b - 1] = a - 1
    }

    repeat(Q) {
        val (p, x) = readLine()!!.split(" ").map { it.toInt() }
        ans[p - 1] += x
    }

    for(i in 1 until N) {
        ans[i] += ans[parent[i]]
    }

    println(ans.joinToString(" "))
}

Measured memory_bytes: 113408
import heapq

n, m = map(int, input().split())
A = [int(x) * -1 for x in input().split()]
heapq.heapify(A)

for i in range(m):
    tmp = heapq.heappop(A) / 2
    heapq.heappush(A, tmp)

ans = sum([int(x * -1) for x in A])
print(ans)


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio;
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<(a-c)*(b-d)<<endl;
    
    return 0;
}








Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a=0;
	
	scanf("%d",&a);
	for (int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++){
			if(a==i*j) {
				printf("Yes");
			return 0;
			}
			
		}
	}
	 printf("No");
	return 0;
} 

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

const int MOD = (int)1e9+7;

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	priority_queue<long long> pq;
	for(int i=0;i<N;i++){
		pq.push(A.at(i));
	}
	for(int i=0;i<M;i++){
		long long x=pq.top()/2;
		pq.pop();
		pq.push(x);
	}

	long long ans=0;
	for(int i=0;i<N;i++){
		ans+=pq.top();
		pq.pop();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2168