akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int a, b, c; cin >> a >> b >> c;
    if(b * c >= a) {
        cout << "Yes"; 
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 3620
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A=[]
for _ in range(N):
  A.append(list(map(int, input().split())))
  
#Aij = A[i][j]

answer=0
for i in range(N):
  answer += (sum([a*b for a, b in zip(A[i], B)]+[C]) > 0)
  
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    string s[] = {"AC", "WA", "TLE", "RE"};
    ll cnt[4] = {};
    rep(i, n){
        string s_i;
        cin >> s_i;
        rep(j, 4)if(s_i == s[j])cnt[j]++;
    }

    rep(i, 4){
        cout << s[i] << " x " << cnt[i] << endl;
    }
}

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

int main(){
  int n,count=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    while(a%2==0){
      count++;
      a/=2;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#!/snap/bin/pypy3

import operator

def main():
    S = input()

    count0 = 0
    count1 = 0

    for i, char in enumerate(S):
        bit = i % 2
        count0 += int(char) ^ bit
        count1 += int(char) ^ (not bit) 

    # print(count0, count1)
    print(min(count0, count1))


if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], b[N];
map <int, int> mm;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) b[i] = a[i];
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++) mm[b[i]] = i;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int pos = mm[a[i]];
        if ((pos - i) & 1) ans++;
    }

    printf("%d", ans / 2);
    return 0;
}


Measured memory_bytes: 5760
import sys

def cross(a, b):
	return (a.conjugate() * b).imag
def dot(a, b):
	return (a.conjugate() * b).real

def ccw(a, b, c):
	x = b - a
	y = c - a;
	cr = cross(x, y)
	if cr != 0: return cr
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0

def solve(l, p):
	x = cmp(ccw(l[0][0], l[0][1], p), 0)
	if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]):
		print "YES"
	else:
		print "NO"

for line in sys.stdin:
	t = map(float, line.split())
	if len(t) == 0: continue
	a, b, c, p = map(complex, t[0::2], t[1::2])
	solve([(a, b), (b, c), (c, a)], p)

Measured memory_bytes: 5300
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
long long x, y;
typedef long long LL;
int main(){
	scanf("%lld", &x);
	y = 1;
	while(y * (y + 1) / 2 < x) y++;
	printf("%lld", y);
}

		

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

int main() {
  int blue,red;//枚数指定
   cin >> blue;
  vector<string> S(blue);
 
  

  for(int i=0; i<blue; i++) {
    cin >> S.at(i);
  }
  
  cin >> red;
  vector<string> T(red);//文字列指定
  
  for(int i=0; i<red; i++) {
    cin >> T.at(i);
  }
  
  //入力完了
  
  vector<int> U(blue);
  for(int i=0; i<blue; i++){
    for(int j=0; j<blue; j++){
      if(S.at(i)==S.at(j)) {
      U.at(i)++ ;
      }       
    }
  } //Sを数値化 
  
  for(int i=0; i<blue; i++) {
    for(int j=0; j<red; j++) {
      if(S.at(i)==T.at(j)){
        U.at(i)-- ;
      }
    }
  } //Tを数値化
  
  int A = U.at(0);
  for(int i=0; i<blue; i++) {
   if(A<U.at(i)) {
     A = U.at(i);
   }
  } //最大値A判定
  
  if(A<0){
    A=0;
  }
  
  cout << A << endl;
  
}

Measured memory_bytes: 256
A, B, C, X, Y = (int(i) for i in input().split())

if A + B <= 2 * C:
    print(A * X + B * Y)

else:
    if X > Y:
        print(2 * Y * C + min(A * (X - Y), 2 * C * (X - Y))) 
    else:
        print(2 * X * C + min(B * (Y - X), 2 * C * (Y - X)))

Measured memory_bytes: 3060
open Hashtbl
let h, ans, a_s = create 0, ref 0, Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.iter (fun a -> replace h a @@ try find h a + 1 with _ -> 1) a_s; iter (fun a c -> ans := !ans + if a > c then c else min c @@ c - a) h; Printf.printf "%d\n" !ans

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll a;
string s;
cin >> a >> s;
if(a>=3200){
	cout << s << endl;
}
else if(a<3200){
	cout << "red" << endl;
}
return 0;
}



Measured memory_bytes: 256
# Problem E - Colorful Blocks

# input
N, M, K = map(int, input().split())

# initialization
MOD = 998244353
fact = [1, 1]
fact_inv = [1, 1]
inv = [0, 1]
pow_list = [1, M-1]
for i in range(2, N+1):
    fact.append((fact[-1] * i)%MOD)
    inv.append((-inv[MOD%i] * (MOD//i))%MOD)
    fact_inv.append((fact_inv[-1] * inv[-1])%MOD)
    pow_list.append(pow_list[i-1]*(M-1)%MOD)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n-r)
    return fact[n] * fact_inv[r] * fact_inv[n-r] % p

ans = 0

# calc
for i in range(K+1):
    tmp = ((M * cmb(N-1, i, MOD))%MOD * pow_list[N-(i+1)])%MOD
    ans = (ans + tmp)%MOD

# output
print(ans)


Measured memory_bytes: 40564
N = int(input())
H = list(map(int, input().split()))
while len(H) < N:
    H.append(0)
see = 1
for i in range(1, N):
    tall = True
    for j in range(i):
        if(H[j] > H[i]):
            tall = False
            break
    if tall:
        see += 1
print(see)



Measured memory_bytes: 3060
s = input()
n = len(s)-1
total=0
for i in range(2**n):
  pl=['']*n
  ans=''
  for j in range(n):
    if ((i>>j)&1):
      pl[n-1-j] = '+'
  for k in range(n):
    ans += s[k]+pl[k]
  ans+=s[-1]
  total += eval(ans)
 
print(total)

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

int main() {
int ans = 0;
  int N;
  cin >> N;
  vector<int> H(N)
  rep(i, N){
      cin >> H.at(i);
  }
  rep(i,N-1){
    int hypothesis;
      hypothesis = 0;
  rep2(j, i, N-1){
    if(H.at(j) >= H.at(j+1)){
    hypothesis++;
      if(j == N-2){
          if(hypothesis > ans){
    ans = hypothesis;
    }
        i = j;
        break;
      }
    }
    else{
    if(hypothesis > ans){
    ans = hypothesis;
    }
      i = j;
            break;
    }
  }
  }
  cout << ans << endl;
}


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

int main(){
int x, y;
cin >> x >> y;
  if(x == 2) x = 1;
  else if(x == 4 || x == 6 || x == 9 || x == 11) x = 2;
  else x = 3;
  
  if(y == 2) y = 1;
  else if(y == 4 || y == 6 || y == 9 || y == 11) y = 2;
  else y = 3;
  
  if(x == y) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
  
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, l;

int main(){
	cin >> n >> m >> l;
	cout << (n-l)/(m+l) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Yuan Lei
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task1002 solver = new Task1002();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task1002 {
        int[][] dp;
        ArrayList<Integer>[] edges;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            edges = new ArrayList[n + 1];
            for (int i = 1; i <= n; ++i) edges[i] = new ArrayList<>();
            for (int i = 0; i < m; ++i) {
                int x, y;
                x = in.nextInt();
                y = in.nextInt();
                edges[x].add(y);
                edges[y].add(x);
            }
            dp = new int[n + 1][2];
            dfs(1, 0);
            int[][] cnt = new int[2][2];
            long ans = 0;
            for (int i = 1; i <= n; ++i) {
                cnt[dp[i][0]][dp[i][1]]++;
            }
            ans += 1L * cnt[1][0] * cnt[0][1];
            ans += 1L * cnt[1][0] * cnt[1][1];
            ans += 1L * cnt[0][1] * cnt[1][1];
            ans += 1L * cnt[1][1] * (cnt[1][1] - 1) / 2;
            ans -= m;
            out.println(ans);
        }

        private void dfs(int node, int odd) {
            if (dp[node][odd] > 0) return;
            dp[node][odd] = 1;
            for (int y : edges[node]) {
                dfs(y, odd ^ 1);
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    final String line = reader.readLine();
                    if (line == null) return false;
                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }

        public String next() {
            if (hasNext()) return tokenizer.nextToken();
            return null;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 69388
/*
author：cmathpo8&&yuanchen&&qiyujun
date:2019/8/17 10:11 
*/
#include<bits/stdc++.h>
#define re register
using namespace std;
int h[100010],t,cnt;
char a[100010];
struct node{
    int fro;
    int to;
}el[100010];
int main(){
       scanf("%s",a+1);
       int cntl=0;
       int sst=strlen(a+1);
       memset(h,0,sizeof(h));
       t=-1;
    for(re int i=1;i<=sst;i++){
        if(a[i]=='L'){
            if(t==-1){
                el[++cnt].fro=i;
                el[cnt].to=i;
                t=0;
            }else el[cnt].to=i;
        }else t=-1;
    } 
    el[0].to=0;
    for(re int i=1;i<=cnt;i++){
        int dis=(el[i].fro-el[i-1].to-1);
        int disl=(el[i].to-el[i].fro+1);
        if(dis%2==1){
            h[el[i].fro]+=(dis/2);
            h[el[i].fro-1]+=(dis/2)+1;
        }else{
            h[el[i].fro]+=(dis/2);
            h[el[i].fro-1]+=(dis/2);
        }
        if(disl%2==1){
            h[el[i].fro-1]+=(disl/2);
            h[el[i].fro]+=(disl/2)+1;
        }else{
            h[el[i].fro-1]+=(disl/2);
            h[el[i].fro]+=(disl/2);
        }
    }
    for(re int i=1;i<=sst;i++){
        printf("%d ",h[i]);
    } 
    /*for(re int i=1;i<=cnt;i++){
        cout<<el[i].fro<<" "<<el[i].to<<" ";
    }*/
    return 0;
}

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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 1e6 + 7   ;
const int INF = 1e9 + 7;

int dp[N], h[N];
int n;

main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d", &h[i]);
    }
    dp[0] = INF;
    for (int i = 2; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    printf("%d", dp[n]);
}


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

int h, w;

int count_bom(vector<string> grid, int i, int j) {
  int count=0;
  for (int a=-1; a<2; a++) {
    for (int b=-1; b<2; b++) {
      if (i+a >= 0 && i+a < h && 
          j+b >= 0 && j+b < w && 
          !(a==0 && b==0)       ) {

        count += grid[i+a][j+b]=='#';
      }
    }
  }
  return count;
}

int main() {
  vector<string> grid;
  cin >> h >> w;

  grid = vector<string>(h);
  for (int i=0; i<h; i++) {
    cin >> grid[i];
  }
  
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (grid[i][j] == '.') {
          grid[i][j] = '0' + count_bom(grid, i, j);
      }
    }
  }

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
        cout << grid[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans = 0;
  while (X > 0 || Y > 0) {
    if ((X != 0 && Y != 0) && (2 * C < A + B)) {
      ans += 2 * C;
      X--, Y--;
    } else if (X != 0 && Y != 0) {
      ans += A + B;
      X--, Y--;
    } else if (X > 0) {
      if (2 * C < A) {
        ans += 2 * C;
      } else {
        ans += A;
      }
      X--;
    } else {
      if (2 * C < B) {
        ans += 2 * C;
      } else {
        ans += B;
      }
      Y--;
    }
  }

  cout << ans << endl;

  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll a=n%k;
  chmin(n,a);
  chmin(n,abs(a-k));
  cout<<n<<endl;
}

Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#define l first
#define r second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
const ll mod=998244353;
int n,k;
ll f[N],s[N];
pii a[N];
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>k;
        for(int i=1;i<=n;i++) cin>>a[i].l>>a[i].r;
        f[1]=1;
        s[1]=1;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=k;j++)
                f[i]=(f[i]+s[max(0,i-a[j].l)]-s[max(0,i-a[j].r-1)])%mod;;
            s[i]=(s[i-1]+f[i])%mod;
        }    
        cout<<(f[n]+mod)%mod<<'\n';
    }
    return 0;
}

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

int main() {
    int n;
    while (cin >> n) {
        vector<int> ps(n);
        fill(ps.begin(), ps.end(), 0);
        for (int i = 0, size = n * (n - 1) / 2; i < size; i++) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            a--; b--;
            if (c > d) {
                ps[a] += 3;
            } else if (c < d) {
                ps[b] += 3;
            } else {
                ps[a]++;
                ps[b]++;
            }
        }
        multimap<int, int, greater<int> > ts;
        for (int i = 0; i < n; i++) {
            ts.insert(make_pair(ps[i], i));
        }
        vector<int> rs(n);
        int c = 1;
        int p = -1;
        int rank = 0;
        for (multimap<int, int>::iterator it = ts.begin(); it != ts.end(); it++) {
            if (it->first == p) {
                rs[it->second] = rank;
                c++;
            } else {
                rank += c;
                rs[it->second] = rank;
                p = it->first;
                c = 1;
            }
        }
        for (int i = 0; i < n; i++) {
            cout << rs[i] << endl;
        }
    }
}

Measured memory_bytes: 1200
def dfs(i,s):
    if i==n-1:
        return sum(map(int,s.split('+')))
    return dfs(i+1,s+S[i+1])+dfs(i+1,s+'+'+S[i+1])

S=input()
n=len(S)
ans=dfs(0,S[0])
print(ans)

Measured memory_bytes: 3064
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<vector<int> > v;
vector<ll> c;
struct d
{
    int x,prev;
};
queue<d> que;
vector<ll> ans;
void bfs()
{
    int j=0;
    while (!que.empty())
    {
        d now = que.front();
        ans[now.x]=c[j];
        j++;
        que.pop();
        for (int i = 0; i < v[now.x].size(); i++)
        {
            if(now.prev==v[now.x][i])continue;
            d next = {v[now.x][i],now.x};
            que.push(next);
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    v.resize(n);
    ans.resize(n);
    vector<int>a(n),b(n);
    for (int i = 0; i < n-1; i++)
    {
        int temp,temp1;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        a[i]=temp;
        b[i]=temp1;
        v[temp].push_back(temp1);
        v[temp1].push_back(temp);
    }
    ll sum=0;
    ll maxc=0;
    rep(i,n){
        ll temp;
        cin>>temp;
        c.push_back(temp);
        chmax(maxc,temp);
        sum+=temp;
    }
    sort(ALL(c),greater<ll>());
    d start = {0,-1};
    que.push(start);
    bfs();
    cout<<sum-maxc<<"\n";
    rep(i,n){
        cout<<ans[i]<<"\n";
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    ll sum;
    ll mn = INF;
    REP(i,1,n){
        sum=0;
        ll a = i;
        ll b = n - i;
        while(a>0){
            sum += a % 10;
            a /= 10;
        }
        while(b>0){
            sum += b % 10;
            b /= 10;
        }
        mn = min(mn,sum);
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		if(N%2==0){
			System.out.println(N/2);
		}else{
			System.out.println(1+N/2);
		}

	}

}

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

long long int solver(vector<long long int>w, vector<long long int> v , long long int n , long long int m,long long int i,vector<vector<long long int>>& dp){
    if(m==0){
        return 0;
    }
    if(i==n){
        return 0;
    }
    long long int ans=0;
    if(dp[i][m]!=-1){
        return dp[i][m];
    }
    if(m-w[i]>=0){
        if(dp[i+1][m-w[i]]!=-1){
            ans=(long long int)v[i]+dp[i+1][m-w[i]];
        }
        else{
            ans=solver(w,v,n,m-w[i],i+1,dp);
            dp[i+1][m-w[i]]=ans;
          ans+=v[i];
        }
        
    }
     long long int bans;
    if(dp[i+1][m]!=-1){
            bans=(long long int)dp[i+1][m];
        }
        else{
            bans=(long long int)solver(w,v,n,m,i+1,dp);
            dp[i+1][m]=bans;
        }

    
    return dp[i][m]=max(bans,ans);
}

int main() {
    long long int n,m;
    
    cin>>n>>m;
    vector<long long int>w(n);
    vector<long long int>v(n);
    for(long long int i=0; i<n;i++){
        cin>>w[i]>>v[i];
    }
    vector<vector<long long int>> dp(101,vector<long long int> (100001));
    for(long long int i=0; i<=n ;i++){
        for(long long int j=0; j<=m;j++){
            dp[i][j]=-1;
        }
    }
    //cout<<dp[999][100000];
    cout<<solver(w,v,n,m,0,dp);
}


Measured memory_bytes: 83256
N, H = map(int, input().split())
A, B = [0] * N, [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
amax = max(A)
newb = sorted(b for b in B if b > amax)
cnt = 0
while H > 0 and newb:
    cnt += 1
    H -= newb.pop()
if H > 0:
    cnt += (H + amax - 1) // amax
print(cnt)

Measured memory_bytes: 12128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
using namespace std;
static const int MAX_N = 1000000;

int n, k;
int a [MAX_N];

int b[MAX_N];
int deq[MAX_N];

void solve(){
  int s = 0, t = 0;

  for ( int i = 0; i < n; i++ ){
    while( s < t && a[deq[t - 1]] >= a[i] ) t--;
    deq[t++] = i;

    if ( i - k + 1 >= 0 ){
      b[i - k + 1] = a[deq[s]];

      if ( deq[s] == i - k + 1 ){
        s++;
      }
    }
  }

  for ( int i = 0; i <= n-k; i++ ){
    if ( i ) printf(" ");
    printf("%d", b[i]);
  }
  printf("\n");


}

main(){
  cin >> n >> k;
  for ( int i = 0; i < n; i++ ) scanf("%d", &a[i]);
  solve();

  return 0;
}

Measured memory_bytes: 14896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		scanf("%d%d%d",&b,&c,&d);
		if(c+d>b){printf("No\n");return 0;}
		else if((c+d)%2==0&&b%2==1){printf("No\n");return 0;}
		else if((c+d)%2==1&&b%2==0){printf("No\n");return 0;}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args)throws Exception{

        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        String s = sc.next();

        if(k >= s.length()){
            System.out.println(s);
        }
        else{
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38688
#include<bits/stdc++.h>
#define LL long long
#define int LL
using namespace std;
const int N=1e5+50;
int n,m,v,p,ans,q,a[N];LL s[N];
bool cmp(int x,int y){return x>y;}
signed main(){
    // freopen("test.in","r",stdin);
    scanf("%d%d%d%d",&n,&m,&v,&p);ans=p;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
    for(int i=p+1;i<=n;i++){
        if(a[i]+m<a[p])continue;
        if(n-i+1+p-1>=v){ans++;continue;}
        int num=i-p;LL sum=s[i-1]-s[p-1];
        if(num*(a[i]+m)-sum>=m*(v-(n-num)))ans++;
    }
    printf("%d\n",ans);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, k;
string s;

vector<int> a;


void solve()
{
    for(int i = 1; i <= 5; i++)
    {
        int x;
        cin >> x;
        if(!x)
        {
            cout << i;
            return;
        }
    }

}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    cin >> T;

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




    return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
x1 = []
x2 = []
x4 = []
for i in range(n):
    if a[i] % 4 == 0:
        x4.append(a[i])
    elif a[i] % 2 == 0:
        x2.append(a[i])
    else:
        x1.append(a[i])
if len(x2) == 0:
    if len(x1) <= len(x4)+1:
        print("Yes")
    else:
        print("No")
else:
    if len(x1) <= len(x4):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 20136
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll mul(ll a, ll b, ll md){
	return a*b % md;
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}


const int N = 2e5+5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	string s; cin>>s;
	int bal = 0;
	int cikar = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'S') bal++;
		else if(s[i] == 'T' && bal){
			bal--;
			cikar += 2;
		}
	}
	cout<<s.size() - cikar<<endl;
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
#define INF 1000000000
//配列の要素数が大きすぎると実行時エラーが(MLE)
//てかそもそも制限時間で終わらんしな
//この要素数は環境依存
#define MAX 20000000
//MAXで多めに取っておく

//下降させていくのか、1オリジンに注意
//部分木をmax-heapにする
//hは集合の要素の数
void max_heapify(vector<int>& v,int i,int h){
  int l=2*i;int r=2*i+1;
  //左、自分、右でキーが最大のものを選ぶ(b)
  int b;
  //左にアクセスできるかも注意
  if(l<=h and v[l]>v[i]){b=l;}else{b=i;}
  //右にアクセスできるかも注意
  if(r<=h and v[r]>v[b]){b=r;}
  if(b!=i){
    swap(v[i],v[b]);
    max_heapify(v,b,h);
  }
}

//下降させる際下から順にやっていくと効率が良い
void make_maxheap(vector<int>& v,int& h){
  for(int i=floor(h/2);i>0;i--){
    max_heapify(v,i,h);
  }
}

//hは配列の大きさ
int extract_max(vector<int>& v,int& h){
  if(h<1) return -INF;
  int ma=v[1];
  v[1]=v[h];h--;
  //初めの要素からmaxheap
  max_heapify(v,1,h);
  return ma;
}

void set_key(vector<int>& v,int i,int k){//indにkeyを設定する、親より大きければ更新
  if(k<v[i]) return;//keyが初めのsetする際のkeyより大きいことを保証、これいるか？
  v[i]=k;
  while(i>1 and v[int(i/2)]<v[i]){
    swap(v[i],v[int(i/2)]);//v[int(i/2)]<v[i]なので、v[i]の部分木は成り立つことが保証→swapのみで良い
    i=int(i/2);
  }
}

//keyがkのものをinsertする
void insert_maxheap(vector<int>& v,int k,int& h){
  h+=1;
  v[h]=-INF;
  set_key(v,h,k);
}

int main(){
  string s;
  vector<int> v(MAX);
  int h=0;
  while(cin >> s and s!="end"){
    if(s=="insert"){
      int k;cin >> k;
      insert_maxheap(v,k,h);
    }else if(s=="extract"){
      cout << extract_max(v,h) << endl;
    }
  }
}



Measured memory_bytes: 80792
import Control.Applicative
import Control.Monad
import Data.List

nums :: Int -> Int
nums n = length $ filter judge $ concat $ take (length $ show n) $ iterate ([('7':), ('5':), ('3':)] <*>) ["7", "5", "3"]
  where
    judge s = elem '7' s && elem '5' s && elem '3' s && read s <= n

main = readLn >>= print . nums

Measured memory_bytes: 2428
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

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

    int N = 10*(S[0]-'0') + S[1]-'0';
    int M = 10*(S[2]-'0') + S[3]-'0';
    if (0<N&&N<=12&&0<M&&M<=12) cout << "AMBIGUOUS" << endl;
    else if (0<M&&M<=12) cout << "YYMM" << endl;
    else if (0<N&&N<=12) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x3 = x2 - (y2 - y1); 
  int y3 = y2 + (x2 - x1);
  int x4 = x3 - (x2 - x1);
  int y4 = y3 - (y2 - y1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();

		if (x == 1 || x == 2 || x == 3) {
			System.out.println(x);
			return;
		}

		while (true) {
			boolean prime = true;

			for (int i = 2; i <= x / 2; i++) {
				if (x % i == 0) {
					prime = false;
					break;
				}
			}

			if (prime) {
				System.out.println(x);
				return;
			}

			x++;
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli solve(vector <lli> a,vector <lli> b,vector <lli> c){
	lli ans=0;
	for(lli i=0;i<a.size();i++){
		vect_lli_it it;
		it=upper_bound(all(b),a[i]);
		if(it!=b.en()){
			for(lli j=it-b.bg();j<b.size();j++){
				vect_lli_it it2,it3;
				it2=upper_bound(all(c),b[j]+(b[j]-a[i]));
				if(it2!=c.en()){
					ans=ans+(c.size()-(it2-c.bg()));
				}
				it2=upper_bound(all(c),b[j]);
				it3=lower_bound(all(c),b[j]+(b[j]-a[i]));
				if(it2!=c.en() && it3!=c.en())
				ans=ans+(it3-c.bg())-(it2-c.bg());
				else if(it2!=c.en() && it3==c.en())
				ans=ans+(c.size()-(it2-c.bg()));
			}
		}
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    string s;
    cin>>s;
    vector <lli> red,green,blue;
    rep(i,s.length()){
    	if(s[i]=='R')
    	red.pb(i+1);
    	if(s[i]=='G')
    	green.pb(i+1);
    	if(s[i]=='B')
    	blue.pb(i+1);
	}
	lli ans=0;
	ans+=solve(red,green,blue);
	ans+=solve(red,blue,green);
	ans+=solve(blue,green,red);
	ans+=solve(blue,red,green);
	ans+=solve(green,red,blue);
	ans+=solve(green,blue,red);
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3748
while True:
    n, q = map(int, input().split())
    if n == 0: break

    c_dates = []

    for i in range(n):
        data = input().split()
        del data[0]
        for j in range(len(data)):
            data[j] = int(data[j])
        c_dates = c_dates + data
        
    c_dates.sort()
    #print(c_dates)
    #print("データの個数" + str(len(c_dates)))

    c_day = 0
    c_num = 1
    max_num = 0
    #print(str(q) + "人以上")

    if len(c_dates) == 1 and q == 1:
        print(c_dates[0])
        continue
    
    for i in range(len(c_dates) - 1):
        if c_dates[i] == c_dates[i + 1] and i != len(c_dates) - 1:
            c_num += 1
            if i != len(c_dates) - 2: continue
        if c_num >= q and c_num > max_num:
            c_day = c_dates[i]
            #print("c_day " + str(c_day))
            #print("c_num " + str(c_num))
            max_num = c_num
            c_num = 1
        else:
            c_num = 1

    print(c_day)
    #print("")



Measured memory_bytes: 5640
#include <stdio.h>
int main(void) {
  int X;
  int Y;
 
  scanf("%d", &X);
  scanf("%d", &Y);
 
  int kame = Y - 2 * X;
  int turu = 4 * X - Y;
  if (kame % 2 == 0 && turu % 2 == 0 && kame >= 0 && turu >= 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B), x(M), y(M), c(M);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    rep(i, M) cin >> x[i] >> y[i] >> c[i];
    int ans = *min_element(all(a)) + *min_element(all(b));
    rep(i, M) {
        ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    write(ans);
}

Measured memory_bytes: 2176
A,B,C,D,E,F = map(int,input().split())

ws = set()
for a in range(0,F+1,100*A):
    for b in range(0,F+1,100*B):
        if a+b > F: break
        ws.add(a+b)
ws.remove(0)

ss = set()
for c in range(0,F+1,C):
    for d in range(0,F+1,D):
        if c+d > F: break
        ss.add(c+d)

best_s = -1
best_w = 1
for w in ws:
    for s in ss:
        if w+s > F: continue
        if E*w < s*100: continue
        if best_s * (s+w) < s * (best_s + best_w):
            best_s = s
            best_w = w
print(best_s+best_w, best_s)

Measured memory_bytes: 9256
#include<iostream>

//関数の宣言
void mul(int n,int m,int A[100][100], int B[100]);

int main(){

	int n;
	int m;

	const int a = 100;
	const int b = 100;

	int A[a][b];
	int B[b];

	std::cin >> n >> m;

	for (int i = 0; i < n; ++i){
		for (int j = 0; j < m; ++j){
			std::cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; ++i){
		std::cin >> B[i];
	}
	mul(n,m,A, B);

	return 0;
}

//関数の定義
void mul(int n,int m,int A[100][100], int B[100]){
	for (int i = 0; i < n ; ++i){

		int x=0;
		int ans = 0;

		for (int j = 0; j < m; ++j){

			x = A[i][j] * B[j];
			ans += x;
		}
		std::cout << ans << std::endl;
		x = 0;
		ans = 0;
	}
}


Measured memory_bytes: 3100
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 120
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int n,m,p[M],tg,ct,tot,t[M];
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++) p[i]=read(),ct+=(p[i]&1);
	if(ct>2){puts("Impossible");return 0;}
	for(int i=2;i<=m;i++){
		if(!(p[i]&1)) continue;
		if(!(p[1]&1)) swap(p[1],p[i]);
		else swap(p[m],p[i]);
	}
	if(n==1){puts("1\n1\n1");return 0;}
	if(m==1){printf("%d\n2\n%d %d\n",p[1],1,p[1]-1);return 0;}
//	for(int i=1;i<=m;i++)  printf("I = %d   p[i] = %d\n",i,p[i]); 
	if(p[1]>1) t[tot=1]=p[1]-1;
	for(int i=2;i<=m;i++) t[++tot]=p[i]; t[tot]++;
	for(int i=1;i<=m;i++) printf("%d%c",p[i],i<m?' ':'\n');
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++) printf("%d%c",t[i],i<tot?' ':'\n');
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int w,n,ans[30];
	int c;
	int a,b,q;
	for(c=0;c<30;c++)ans[c]=c+1;
	scanf("%d%*c",&w);
	scanf("%d%*c",&n);
	for(c=0;c<n;c++){
		scanf("%d,%d",&a,&b);
		q=ans[a-1];ans[a-1]=ans[b-1];ans[b-1]=q;
	}
	for(c=0;c<w;c++)printf("%d\n",ans[c]);
	return 0;

}

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

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

using namespace std;

int main(){
	int n,p[20]; cin>>n;
	rep(i,n) cin>>p[i];

	int ans=0;
	rep(i,n-2) if((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1] && p[i+1]>p[i+2])) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    int N,M; cin >> N >> M;

    if(N>=13){
        cout << M << endl;
    }else if(6<=N &&N<=12){
        cout << M/2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int ans = 0;
    for (char c : S) {
        if (c == '+') ans++;
        else ans--;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3528
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> num;
	FOR(i, 0, n) {
		int tmp;
		cin >> tmp;
		num[tmp]++;
	}

	vector<int> mod(m, 0);
	vector<int> odd(m, 0);
	for (auto t : num) {
		mod[t.first%m] += t.second;
		if (t.second % 2) {
			odd[t.first%m]++;
		}

	}
	int cnt = 0;
	FOR(i, 0, m) {
		if (i == 0 || i * 2 == m)
			continue;
		int toadd = min(mod[i], mod[(m - i) % m]);
		cnt += toadd;
		odd[i] -= toadd, odd[(m - i) % m] -= toadd;
		mod[i] -= toadd, mod[(m - i) % m] -= toadd;
	}
	FOR(i, 0, m) {
		if (i == 0 || i * 2 == m) {
			cnt += mod[i] / 2;
		}
		else {
			if (odd[i] <= 0) {
				cnt += mod[i] / 2;
			}
			else {
				cnt += (mod[i] - odd[i]) / 2;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 5760
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int cnt = 0;
    int total = A + B + C;
    int max = Math.max(A, B);
    max = Math.max(max, C);
    int possibleA = max * 3;
    int possibleB = (max + 1) * 3;
    while (true) {
      if (total == possibleA) {
        System.out.println(cnt);
        break;
      }
      if (total == possibleB) {
        System.out.println(cnt);
        break;
      }
      total += 2;
      cnt++;
    }
  }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll k=1,s=0,n,m,min=100000000000,ans=1,max=0;
    string s3;
    cin >> n;
    for(int i=1;i<=n;i++){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;

    timer();
    return 0;
}


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

void Main() {
  int X;
  cin >> X;
  long long ans = 0;
  ans += (X / 500) * 1000;
  X %= 500;
  ans += (X / 5) * 5;
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::vector<int>> g(n);
	int s = -1, t = -1;
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		a--; b--; s = a; t = b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	std::deque<int> ans;
	ans.push_front(s); ans.push_back(t);
	std::queue<int> qu; qu.push(s); qu.push(t);
	std::vector<bool> used(n, false); used[s] = used[t] = true;
	while(!qu.empty()) {
		auto v = qu.front(); qu.pop();

		for(auto e: g[v]) {
			if(used[e]) continue;
			if(v == ans.front()) ans.push_front(e);
			if(v == ans.back()) ans.push_back(e);
			used[e] = true;
			qu.push(e);
			break;
		}
	}

	printf("%d\n", ans.size());
	while(!ans.empty()) {
		printf("%d ", ans.front() + 1);
		ans.pop_front();
	}
	return 0;
}


Measured memory_bytes: 6656