akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001

typedef struct _n {
  int deg;
  int right;
  int left;
  int r;
  int parent;
  int sib;
  int depth;
  int height;
} node;

node tree[100000];
int n;
void setDepth(int);
int setHeight(int);
int main() {
  int i;
  int  j, k, l, r;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    tree[i].parent = -1;
    tree[i].sib = -1;
    tree[i].depth = 0;
    tree[i].height = 0;
    tree[i].deg = 0;
  }

  for(k = 0; k < n; k++) {
    scanf("%d", &i);
    scanf("%d %d", &tree[i].left, &tree[i].right);
    if(tree[i].left != -1) tree[tree[i].left].sib = tree[i].right;
    if(tree[i].right != -1) tree[tree[i].right].sib = tree[i].left;
    if(tree[i].left != -1)tree[tree[i].left].parent = i;
    if(tree[i].right != -1) tree[tree[i].right].parent = i;
    if(tree[i].left != -1) tree[i].deg++;
    if(tree[i].right != -1) tree[i].deg++;
  }

  for(i = 0; i < n; i++) {
    if(tree[i].parent == -1) {k = i;}
  }
  setDepth(k);
  setHeight(k);

  for(i = 0; i < n; i++) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i, tree[i].parent, tree[i].sib, tree[i].deg, tree[i].depth, tree[i].height);
    if(tree[i].parent == -1) {printf("root\n");}
    else if(tree[i].deg == 0) {  printf("leaf\n");}
    else {  printf("internal node\n");}
  }
  return 0;
}

void setDepth(int r) {
  if(tree[r].right != -1 )tree[tree[r].right].depth += 1 + tree[r].depth;
  if(tree[r].left != -1) tree[tree[r].left].depth += 1 + tree[r].depth;
  if(tree[r].left != -1) setDepth(tree[r].left);
  if(tree[r].right != -1) setDepth(tree[r].right);
}

int setHeight(int r) {
  int i, h, x, y, n;
  h=0;
  if(tree[r].deg == 0) {
    tree[r].height = 0;
    return 0;
  }
  if(tree[r].left != -1) {x = setHeight(tree[r].left);}
  else {x = 0;}
  if(tree[r].right != -1) {y = setHeight(tree[r].right);}
  else {y = 0;}
  h = (x < y)? y: x;
  h++;
  tree[r].height = h;
  return h;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  string S;
cin>>S;
int a,i,c;
long b;
b=0;
c=0;
a=S.size();
for(i=0;i<a;i++){
if(S[i]=='W'){
b=b+i-c;
c++;
}
}
cout<<b<<endl;
}

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



int main(void)
{
    char s[100001];
    scanf("%s", s);
    int n;
    n = strlen(s);
    
    int i,j,k,plus,z,last;
    long long ans[2][13];
    int amari[100000];
    int now=1;
    for(i=0; i<100000; i++){
        amari[i] = now;
        now = (now * 10) % 13;
    }
    
    char ch;
    ans[0][0] = 1;
    
    for(i=0; i<n; i++){
        ch = s[n-1-i];
        for(j=0; j<13; j++){
            ans[(i+1)%2][j] = 0;
        }
        if(ch=='?'){
            for(k=0; k<10; k++){
                plus = (amari[i] * k)%13;
                for(j=0; j<13; j++){
                    ans[(i+1)%2][(j+plus)%13] += ans[i%2][j];
                }
            }
            for(j=0; j<13; j++){
                ans[(i+1)%2][(j+plus)%13] %= 1000000007;
            }
        }else{
            z = (int)ch-(int)'0';
            plus = (amari[i] * z)%13;
            for(j=0; j<13; j++){
                ans[(i+1)%2][(j+plus)%13] = ans[i%2][j];
            }
        }
        last = (i+1)%2;
    }
    
        
        
    printf("%lld",ans[last][5]);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]=='A')
        {
            i++;
            if(str[i]=='B')
            {
                i++;
                if(str[i]=='C')
                {
                    count++;
                }
                else i--;
            }
            else i--;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                a[i][j] = sc.nextInt();
            }
        }
        int n = sc.nextInt();
        int[] outSpot = new int[n];
        for(int i=0; i<n; i++){
            outSpot[i] = sc.nextInt();
        }
        
        int[] tate = new int[3];
        int[] yoko = new int[3];
        int[] naname = new int[2];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<n; k++){
                    if(a[i][j] == outSpot[k]){
                        yoko[i]++;
                        tate[j]++;
                        if(i==0&&j==0 || i==2&&j==2){
                            naname[0]++;
                        }
                        else if(i==0&&j==2 || i==2&&j==0){
                            naname[1]++;
                        }
                        else if(i==1&&j==1){
                            naname[0]++;
                            naname[1]++;
                        }
                    }
                }
            }
        }
        
        for(int i : tate){
            if(i == 3){
                System.out.println("Yes");
                return;
            }
        }
        for(int i : yoko){
            if(i == 3){
                System.out.println("Yes");
                return;
            }
        }
        for(int i : naname){
            if(i == 3){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 22100
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    
}

signed main()
{
    fast;

    int n;cin>>n;
    map<string,int>x;
    forall(i,0,n) {string t;cin>>t;x[t]++;}

    vector<string>b = {"AC","WA","TLE","RE"};
    
    for(string i:b)
    {
        cout<<i<<" x "<<x[i];br;
    }


    return 0;
}

Measured memory_bytes: 3612
import numpy as np


a,b = map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

lisa = prime_factorize(a)
lisb = prime_factorize(b)
lis = set(lisa) & set(lisb)
lis.add(1)
lis = sorted(list(lis))
devil = (max(a,b)/lis[-1])
if len(prime_factorize(devil)) == 1:
  if min(a,b) % devil == 0:
    lis.append(devil)
print(len(set(lis)))

Measured memory_bytes: 14544
using System;
using System.Collections.Generic;
using System.Linq;
class ilds_1_1_d{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int max = -(int)Math.Pow(10,9);
    int min = int.Parse(Console.ReadLine());
    for(int i=1; i<n; i++){
      int cur = int.Parse(Console.ReadLine());
      if(max < cur-min)
        max = cur-min;
      if(min > cur)
        min = cur;
    }
    Console.WriteLine(max);
  }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
	return b == 0 ? a : gcd(b, a % b);
}

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

int main(){
	ll n, m;
	cin >> n >> m;
	cout << lcm(n,m) << endl;
	return 0;	
} 

Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = map read . words <$> getLine >>= print . f                                                                          
                                                                                                                           
f :: [Int] -> Int                                                                                                          
f [a,b,c,d]                                                                                                                
  | a <= c && b < c = 0                                                                                                    
  | a <= c && b >= c && b <= d = b - c                                                                                     
  | a <= c && b > d = d - c                                                                                                
  | c <= a && d < a = 0                                                                                                    
  | c <= a && d >= a && d <= b = d - a                                                                                     
  | c <= a && d > b = b - a

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> explode(string const & s, char delim) {
    vector<ll> result;
    string token;
    for (istringstream iss(s); getline(iss, token, delim);) result.push_back(stoll(token));
    return result;
}

void solve() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = n; i > 0; i--) {
        bool ok = true;
        REP(j, i) {
            // cout << n - i + j << "-" << j << endl;
            if (s[n - i + j] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << n * 2 - i << endl;
            return;
        }
        // cout << "----" << endl;
    }
    cout << n * 2 << endl;
}


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

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#endif
//}}}

int solve(){
  int n,m;cin>>n>>m;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  sort(all(a));
  // dump(a);

  // dump(n,m);
  vector<pair<int, int>> E;
  rep(i, m){
    int b,c;
    cin>>b>>c;
    E.pb(mp(c, b));
  }
  sort(all(E), [](auto &left, auto &right){return left.first > right.first;});
  // dump(E);

  int idx=0;
  each(e, E){
    int v = e.first;
    int cou = e.second;
    while(cou>0){
      if (a[idx]<v){
        a[idx]=v;
      }
      else{
        cout << accumulate(all(a), 0LL) << endl;
        return 0;
      }
      idx++;
      cou--;
    }
  }
  cout << accumulate(all(a), 0LL) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))

BC = [tuple(map(int, input().split())) for _ in range(M)]
BC_append = BC.append
for a in A:
    BC_append((1, a))

BC.sort(key = lambda x: x[1])

ans = 0
while N > 0:
    bc = BC.pop()
    b = bc[0]
    c = bc[1]
    if b > N:
        ans += c * N
        N = 0
    else:
        ans += c * b
        N -= b

print (ans)
    


Measured memory_bytes: 31964
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;
  vector<string> ve(h);
  for(int i=0;i<h;i++){
    cin >> ve.at(i);
  }
  for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<h;i++){
    cout << "#" << ve.at(i) << "#" << endl;
  }
    for(int i=0;i<w+2;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
X = [int(input()) for _ in range(M)]

MOD = 10 ** 9 + 7
dp = [-1] * (N + 1)
dp[0] = 1
for i in range(M):
    dp[X[i]] = 0

for i in range(N):
    if dp[i + 1] < 0:
        if i == 0:
            dp[i + 1] = dp[i]
        else:
            dp[i + 1] = (dp[i] + dp[i - 1]) % MOD

print(dp[-1])


Measured memory_bytes: 80696
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;

  int n;
  cin>>n;

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

  for(int i=2;i<n;i++){
    if(d[i][0]==d[i][1] and d[i-1][0]==d[i-1][1] and d[i-2][0]==d[i-2][1]){
      cout<<"Yes\n";
      return 0;
    }
  }

  cout<<"No";

}



Measured memory_bytes: 3664
#!/usr/bin/env python3

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

    for i in range(10**4):
        if n <= i * (i + 1) / 2:
            tmp = i
            break
    tmpsum = tmp * (tmp + 1) / 2
    if n == tmpsum:
        for i in range(1, tmp + 1):
            print(i)
    else:
        for i in range(1, tmp + 1):
            if i == tmpsum - n:
                continue
            print(i)


if __name__ == "__main__":
    main()


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int a[26] = {0};
  string s;
  cin >> s;
  bool flag = true;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != s[0])flag = false;
  }
  if(flag){
    cout << 0 << endl;
    return 0;
  }
  int ans = INF;
  for(int i = 0; i < s.size(); i++){
    string tmp = s;
    char a = s[i];
    for(int j = 0; j < s.size(); j++){
      bool flag = true;
      if(tmp.size() == 1)break;
      for(int k = 0; k < tmp.size()-1; k++){
        if(tmp[k] == a || tmp[k + 1] == a)tmp[k] = a;
        else flag = false;
      }
      tmp.erase(tmp.begin() + tmp.size() - 1);
      if(flag == true)ans = min(ans, j + 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        double r = in.nextDouble();
        out.println(2.0 * Math.PI * r);
        out.close();
    }
}

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

int main(void){
  char ban[10];
  while(cin >> ban[1]){
    char ans = 'd';
    for(int i = 2; i <= 9; i++) cin >> ban[i];
    for(int i = 0; i <= 2; i++){
      if(ban[1+i*3] == ban[2+i*3] && ban[2+i*3] == ban[3+i*3] && ban[1+i*3] != 's') ans = ban[1+i*3];
      if(ban[1+i] == ban[4+i] && ban[4+i] == ban[7+i] && ban[1+i] != 's') ans = ban[1+i];
    }
    if(ban[1] == ban[5] && ban[5] == ban[9] && ban[1] != 's') ans = ban[1];
    if(ban[3] == ban[5] && ban[5] == ban[7] && ban[3] != 's') ans = ban[3];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1132
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int H =sc.nextInt();
    int N =sc.nextInt();
    int A[] =new int[N];
    int x=0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      x=x+A[i];}
    if(x>=H){System.out.println("Yes");}
    else{System.out.println("No");}
  }
}

Measured memory_bytes: 48988
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  ll ok = 0;
  ll ng = 100000*n+1;

  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    ll num = 0;
    REPR(i,n-1){
      num += a.end() - lower_bound(ALL(a), mid-a[i]);
    }
    if(m<=num)
      ok = mid;
    else
      ng = mid;
    //cout << ok << ' ' << ng << '\n';
  }
  vector<ll> sum(n+1,0);
  REP(i,n) sum[i+1] = sum[i] + a[i];
  ll ans = 0;
  ll cnt = 0;
  REP(i,n){
    ll v = upper_bound(ALL(a), ok-a[i]) - a.begin();
    cnt += n-v;
    ans += a[i] * (n-v) + sum[n] - sum[v];
  }
  ans += ok * (m - cnt);
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1920
// AOJ 0200 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0200)
#include<cstdio>
#include<algorithm>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_M = 100, INF = std::numeric_limits<int>::max()>>4;

int n, m;
int d[2][MAX_M][MAX_M];

int main()
{
	while( scanf( "%d%d", &n, &m ), n|m )
	{
		rep( k, 2 ) rep( i, m ) rep( j, m )
			d[k][i][j] = i==j?0:INF;

		rep( i, n )
		{
			int a, b, c, t;
			scanf( "%d%d%d%d", &a, &b, &c, &t );
			--a; --b;
			d[0][a][b] = d[0][b][a] = c;
			d[1][a][b] = d[1][b][a] = t;
		}

		rep( r, 2 ) rep( k, m ) rep( i, m ) rep( j, m )
			d[r][i][j] = std::min( d[r][i][j], d[r][i][k]+d[r][k][j] );

		int k;
		scanf( "%d", &k );

		rep( i, k )
		{
			int p, q, r;
			scanf( "%d%d%d", &p, &q, &r );

			printf( "%d\n", d[r][p-1][q-1] );
		}
	}

	return 0;
}

Measured memory_bytes: 1104
#include<stdio.h>
#define N 1000
int main(){
int i,j,k,n,v,A[N];

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

for(i=0;i<n;i++){
  v = A[i];
  j = i-1;
  while(j>=0 && A[j] > v){
    A[j+1] = A[j];
    j--;
  }
  A[j+1] = v;
  for(k=0;k<n;k++){
    if(k!=n-1) printf("%d ",A[k]);
    else printf("%d\n",A[k]);
  }
}
return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
const int maxn = 27+10 ;
int b[maxn] , q= 1 ;
char s[maxn];
string p ;
int main()
{
	cin >> p ;
	for ( int i = 0 ; i<p.size() ; i++)
		s[i] = p[i] ;
	for(int i=0; i < p.size() ; i++)
		b[s[i]]=1 , q++;
	for(int c='z'; c>='a'; c--)
		if(!b[c])
			s[q++] = c;
	if( next_permutation ( s , s+q ) )
		cout<< s << endl;
	else
		cout<<-1 << endl;

}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c,sum,n,m;

int main(){
  cin>>n;
  m=n+2;
  int spot[m]={};
  for(int i=1;i<n+1;i++){
    cin>>spot[i];
  }
  for(int i=0;i<n+1;i++){
    sum+=abs(spot[i]-spot[i+1]);
    debug(i,abs(spot[i]-spot[i+1]));
  }
  debug(sum);
  for(int i=1;i<n+1;i++){
    dump(sum-abs(spot[i-1]-spot[i])-abs(spot[i]-spot[i+1])+abs(spot[i-1]-spot[i+1]));
  }
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while((line = br.readLine()) != null) {
			if(line.equals("0")) break;
			
			char[] c = line.toCharArray();
			int result = 0;
			
			for(char a: c) {
				result += a - '0';
			}
			
			System.out.println(result);
 		}
	}
}


Measured memory_bytes: 24368
using System;

namespace B___Bitter_Alchemy
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var x = int.Parse(input[1]);
            var m=new int[n];
            var sum = 0;
            var min = int.MaxValue;
            for(var i=0; i<n; i++)
            {
                m[i] = int.Parse(Console.ReadLine());
                sum += m[i];
                min = Math.Min(min, m[i]);
            }
            x = x - sum;
            Console.WriteLine(n + (x / min));
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[3];
cin>>n;
a[0]=n%10;
a[1]=n/10%10;
a[2]=n/100;
for(int i=0;i<3;i++){
	if(a[i]==7){
		cout<<"Yes";
		return 0;
	}
} 
cout<<"No";
return 0;
}

Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	lines, _ := scanLongIntSlices(1, 11*200000)
	as := lines[0]
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	xs := map[int]struct{}{}
	for _, a := range as {
		xs[a] = struct{}{}
	}

	ys := []int{}
	for a, _ := range xs {
		ys = append(ys, a)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(ys)))

	edge := map[int]int{}
	tmpMaxIdx := 0
	edge[ys[tmpMaxIdx]] = 1

	score := 0
	for i := 1; i < n; i++ {
		for edge[ys[tmpMaxIdx]] <= 0 {
			tmpMaxIdx++
		}
		score += ys[tmpMaxIdx]
		edge[ys[tmpMaxIdx]]--
		edge[as[i]] += 2
	}

	fmt.Printf("%d\n", score)
}

func scanLongIntSlices(lines int, maxBufSize int) ([][]int, error) {

	res := [][]int{}

	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, bufio.MaxScanTokenSize)
	sc.Buffer(buf, maxBufSize)

	for sc.Scan() {
		line := sc.Text()
		strs := strings.Split(line, " ")
		ints := make([]int, len(strs))
		for i, c := range strs {
			n, err := strconv.Atoi(c)
			if err != nil {
				return nil, err
			}
			ints[i] = n
		}
		res = append(res, ints)
	}

	if err := sc.Err(); err != nil {
		return nil, err
	}

	return res, nil
}


Measured memory_bytes: 26320
/*
She came from the past
She was never meant to last
Her destiny was fatal
From the start
A messenger from hell
She cast a deadly spell
On all of those who dare
To cross her heart
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
History foretold of a circle
Cast in gold
An evil seed of power
Sealed within
But fate has lent a hand
Destroyed the golden band
And freed her soul
To wash the land with sin
Ain't no use in you trying to run
Fate has taken it's toll
Just one look and the damage is done
Burn your eyes
Turn your heart into stone
She cast a deadly spell
She put a spell on you
She's got evil in her heart
Turn your heart into stone
Turn your heart into stone
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	string st;
	int ans=12345;
	cin>>st;
	for (int i=0;i+2<st.size();i++){
		int here=0;
		for (int j=i;j<i+3;j++){
			here=here*10+st[j]-48;
		}
		ans=min(ans,abs(here-753));
	}
	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int i, n;
    cin >> n;
    int ans = 0;
    for (i = 1; i <= n; i++){
        if (i % 5 != 0 && i % 3 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using i64 = long long;

vector<i64> divisor_list(i64 N){
    vector<i64> dl;
    int nsqrt = floor(sqrt(N) + 0.0625);
    for (int i = 1; i <= nsqrt; i++){
        if (N % i == 0){
            dl.push_back(i);
            if (N / i != i) dl.push_back(N / i);
        }
    }
    return dl;
}

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

    auto dl1 = divisor_list(n);
    auto dl2 = divisor_list(n - 1);

    i64 ans = 0;
    for (auto &&div : dl1){
        if (div == 1) continue;
        i64 N = n;
        while (N % div == 0) N /= div;
        if (N % div == 1) ans++;
    }
    ans += dl2.size() - 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  int N, M, K;
  std::cin >> N >> M >> K;
  std::vector<std::int64_t> A(N + 1), B(M + 1);
  for (int i = 0; i < N; ++i) {
    std::int64_t time;
    std::cin >> time;
    A[i + 1] = A[i] + time;
  }
  for (int i = 0; i < M; ++i) {
    std::int64_t time;
    std::cin >> time;
    B[i + 1] = B[i] + time;
  }
  int max_books = 0;
  for (int i = 0; i <= N; ++i) {
    if (A[i] > K) break;
    const int j = std::upper_bound(B.begin(), B.end(), K - A[i]) - B.begin() - 1;
    max_books = std::max(max_books, i + j);
  }
  std::cout << max_books << std::endl;
  return 0;
}


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

int main(int argc, char *argv[]) {
  int N, K;
  cin >> N >> K;
  if(N % K == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)

# 区間の和を使うので累積和を前計算
# （しゃくとりだと各境界を1ずらすたびに区間和を増減できるので必須ではないが、
#  計算しておいたほうがコードが簡単）
accum = as.dup
(N-1).times do |i|
    accum[i+1] += accum[i]
end

ans = 10**20

# [0, div1], [div1+1, div2], [div2+1, div3], [div3+1, N-1] に分ける
div1, div3 = 0, 2
(1..(N-3)).each do |div2|

    # [0, div1]と[div1+1, div2]が半分に分かれるようにdiv1移動（しゃくとり）
    while div1+1 < div2
        diff1 = (accum[div2] - 2*accum[div1]).abs
        diff2 = (accum[div2] - 2*accum[div1+1]).abs
        if diff1 > diff2
            div1 += 1
        else
            break
        end
    end

    # [div2+1, div3]と[div3+1, N-1]が半分に分かれるようにdiv3移動（しゃくとり）
    while div3+1 < N-1
        diff1 = (accum[N-1] - 2*accum[div3] + accum[div2]).abs
        diff2 = (accum[N-1] - 2*accum[div3+1] + accum[div2]).abs
        if diff1 > diff2
            div3 += 1
        else
            break
        end
    end

    parts = [
        accum[N-1]  - accum[div3],
        accum[div3] - accum[div2],
        accum[div2] - accum[div1],
        accum[div1]
    ]

    result = parts.max - parts.min
    ans = result if ans > result
end
puts ans

Measured memory_bytes: 22028
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	std::string S;
	std::cin >> S;
	std::unordered_map<char, int> counts;

	for (auto ch : S) {
		++counts[ch];
	}

	if (counts.size() == 2 && counts.begin()->second == 2) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9 + 5;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> h(n);
  for (int i = 0; i < n; ++i) scanf("%d", &h[i]);

  int dp[n];
  fill(dp, dp + n, INF);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
    if (i > 1) {
      dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
    }
  }
  printf("%d\n", dp[n - 1]);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=1e5+5;
int n,a[N]; ll ans=0;

int main() {
//    file_put();
    
    scanf("%d",&n);
    rep(i,1,n+1) scanf("%d",&a[i]);
    rep(i,1,n+1) {
        ans+=a[i]/2;
        a[i]%=2;
        if (a[i] && a[i+1]) ans++,a[i]--,a[i+1]--;
    }
    printf("%lld\n",ans);
    
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main()
{
int p[4][3][10];
int n, r, g, f,v;
 
for(int i=0;i<4;i++)
for(int j=0;j<3;j++)
for(int k=0;k<10;k++)
p[i][j][k]=0;
 
scanf("%d",&n);
for(int ii=0;ii<n;ii++)
{
scanf("%d",&r);scanf("%d",&g);scanf("%d",&f);scanf("%d",&v);
p[r-1][g-1][f-1]+=v;
}
for(int iii=0;iii<4;iii++)
{
for(int jj=0;jj<3;jj++)
{
for(int kk=0;kk<10;kk++)
 
{
printf(" %d",p[iii][jj][kk]);
}
printf("\n");
}
if(iii<3)printf("####################\n");
 
}
return 0;
}

Measured memory_bytes: 1040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);
		
		int count = 0;
		for(int i = a; i <= b ; i++){
			if(c % i == 0){
				count++;
			}
		}
		System.out.println(count);
		/*
		int i = 1;
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int a = Integer.parseInt(tmpArray[0]);
			int b = Integer.parseInt(tmpArray[1]);
			if(a == 0 && b == 0){
				break;
			}
			if(a > b){
				int tmp = a; 
				a = b;
				b = tmp;
			}
			System.out.println(a + " "+b);
			
		}*/

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

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

int main()
{
    int n ;
    cin>>n;
    int cnt=0;
    int el;
    for(int i=0 ; i<n ; ++i)
    {
        cin>>el;
        if(el%2==1 && (i+1)%2==1)
        ++cnt;
    }
    cout<<cnt;

    return 0;
}



Measured memory_bytes: 3632
def initialize():
    global head, tail


def isEmpty():
    global head, tail
    return head == tail


def isFull():
    global head, tail, MAX
    return head == (tail + 1) % MAX


def enqueue(x):
    global head, tail, Q, MAX
    if isFull():
        print("?????????????????????")
    else:
        Q[tail] = x
        if tail + 1 == MAX:
            tail = 0
        else:
            tail += 1


def dequeue():
    global head, tail, Q, MAX
    if isEmpty():
        print("??¢??????????????????")
    else:
        t = Q[head]
        if head + 1 == MAX:
            head = 0
        else:
            head += 1
        return t


if __name__ == "__main__":
    n, q = map(int, input().split())
    head = 0
    tail = n
    MAX = 100000
    Q = [0]*MAX
    runtime = 0
    for i in range(n):
        name, time = input().split()
        Q[i] = ([name, int(time)])
    while head != tail:
        t_list = dequeue()
        if t_list[1] > q:
            t_list[1] -= q
            runtime += q
            enqueue(t_list)
        else:
            runtime += t_list[1]
            t_list[1] = 0
            print(t_list[0] + " " + str(runtime))

Measured memory_bytes: 16084
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector <vector <int> > st(3,vector <int> (n));
  for(int i =0;i<n;i++)
  {
    cin>>st[0][i]>>st[1][i]>>st[2][i];
  }
  int dp[3][n];
  dp[0][0] = st[0][0];
  dp[1][0] = st[1][0];
  dp[2][0] = st[2][0];
  for(int i =1;i<n;i++)
  {
    dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + st[0][i];
    dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + st[1][i];
    dp[2][i] = max(dp[1][i-1],dp[0][i-1]) + st[2][i];
  }
  cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
  return 0;
}

Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2;
	return 0;
}












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

using namespace std;

int main()
{   
    int i , n ;
    string str;
    cin>>n;
    set<string> s;
    for( i = 0 ; i <n ; i++)
    {
        cin>>str;   
        s.insert(str);
    }
    cout<<s.size()<<endl;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<bool> judge(N+1, false);
    vector<int> penalty(N+1, 0);
    int ans = 0;
    int pen = 0;
    for (int i = 0; i < M; i++) {
        int p; string s;
        cin >> p >> s;
        if (!judge[p]) {
            if (s == "AC") {
                judge[p] = true;
                ans++;
                pen += penalty[p];
            } else {
                penalty[p]++;
            }
        }
    }
    cout << ans << ' ' << pen << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut n: i64
    }

    let mut ans = Vec::new();

    while n > 0 {
        let c = ((n + 25) % 26) as u8 + b'a';
        ans.push(c);
        n = (n - 1) / 26;
    }
    ans.reverse();
    for b in ans {
        print!("{}", b as char);
    }
}


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

using namespace std;

void f(int n, char s){
    for(int i = 0; i < n;i++){
        s += 1;
        
        if(s >= 91){
            s = 65;
        }
    }

    cout << (char)s ;
}

int main(){
    string s;
    int n;

    cin >> n;
    cin >> s;

    
    for(int i = 0; i < s.length(); i++){
        f(n, s[i]);
    }

    cout << endl;
}

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  vector<int> dp(N);
  dp.at(0)= 0;
  for(int n=1; n<N; n++){
    dp.at(n)= (n==1) ? dp.at(n-1)+ abs(data.at(n)- data.at(n-1))
                     : min(dp.at(n-1)+ abs(data.at(n)- data.at(n-1)), dp.at(n-2)+ abs(data.at(n)- data.at(n-2)));
  }

  cout << dp.back() << endl;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int r,g;
  cin >> r >> g;

  cout << 2*g-r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	sort(v.begin(),v.end(),greater<ll>());
	ll res=v[0],k=n-2;
	for(ll i=1;i<n;i++)
	if(k==1){
		res+=v[i];
		k--;
	}
	else if(k>1){
		res+=2*v[i];
		k-=2;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 4784
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

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


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

    vi a(20, 0);
    a[0] = 1;

    int l = 1;
    for (int i=2; i <= n; i++) {
        //cout << a << endl;

        bool f = false;
        for (int j=0; j<l-1; j++) {
            if (abs(a[j] + 1 - a[j+1]) <= 1 && a[j] < 9) {
                f = true;
                a[j]++;
                for (int ii = j-1; ii>=0; ii--) {
                    a[ii] = max(0, a[ii+1]-1);
                }
                break;
            }
        }
        if (!f) {
            a[l-1]++;
            if (a[l-1] > 9) {
                a[l-1] = 0;
                a[l] = 1;
                l++;
            }
            for (int j = l-2; j>=0; j--) {
                a[j] = max(0, a[j+1]-1);
            }
        }
    }

    for (int i=l-1; i>=0; i--) {
        cout << a[i];
    }
}

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

    if (0) {
        int tests;
        cin >> tests;
        for (int i=1; i<= tests; i++) {
            //cout << "Case #" << i << ": ";
            solve();
            cout << endl;
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

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

int main() {
  int A,B,C,D,x,y;

  cin >> A >> B >> C >> D;
  x=A+B;
  y=C+D;
 

  if (x<y){
    cout << "Right" <<endl;
  }
  else if (x>y){
    cout << "Left" <<endl;
  }
  else{
    cout << "Balanced" <<endl;
  }
  
}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

vector<int> count_divisor(int n) {
  vector<int> c(n + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) ++c[j];
  }
  return c;
}

int main() {
  int n, c = 0;
  cin >> n;
  auto v = count_divisor(n);
  for (int i = 1; i <= n; i += 2) {
    if (v[i] == 8) ++c;
  }
  cout << c << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b;
    cin>>a>>b;
    if(a+b>=10)
        cout<<"error"<<endl;
    else
        cout<<a+b<<endl;

    return 0;
}


Measured memory_bytes: 3560