akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n, k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int sum = 0;
	sort(arr, arr+n);
	for(int i=0;i<k;i++){
		sum+=arr[i];
	}
	cout<<sum<<endl;

	return 0;
}


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

int main()
{
	string a,b,s;

	cin>>a;
cin>>b;
int i=0,j=0;

while(i<a.length() || j<b.length())
{
	s+=a[i];
	if(j<b.length())
	{
		s+=b[j];
	}
	i=i+1;
	j=j+1;
}

cout<<s;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>gr[1000001];
int vis[100001];
void dfs(int u)
{
    vis[u]=1;
    for(int v : gr[u])
    {
        if(!vis[v])dfs(v);
    }
}
int main()
{
  int n,m;
  cin >> n >> m;
  for(int i=0; i<m; i++)
  {
      int u,v;
      cin >> u >> v;
      gr[u].push_back(v);
      gr[v].push_back(u);
  }
  int cnt = 0;
  for(int i=1; i<=n; i++)
  {
      if(!vis[i])
      {
          dfs(i);
          cnt++;
      }
  }
  cout << cnt-1 << endl;
}



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

using namespace std ;

int main(){
    int N, K ;
    cin >> N >> K ;
    
    vector<int> a(N) ;
    for (int i=0 ; i<N ; i++)
        cin >> a[i] ;
    
    vector<int> dp (K+1, 0) ;
    
    for (int i=1 ; i<=K ; i++){
        for (int j=0 ; j<N ; j++){
            if (a[j] <= i)
                dp[i] = dp[i] || !dp[i-a[j]] ;
        }
    }
    
    if (dp[K])
        cout << "First\n" ;
    else
        cout << "Second\n" ;
    
    return 0 ;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		int dx = tx - sx;
		int dy = ty - sy;
		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < dx ; i++) sb.append("R");
		for(int i = 0 ; i < dy ; i++) sb.append("U");
		for(int i = 0 ; i < dx ; i++) sb.append("L");
		for(int i = 0 ; i < dy ; i++) sb.append("D");
		sb.append("D");
		for(int i = 0 ; i < dx + 1 ; i++) sb.append("R");
		for(int i = 0 ; i < dy + 1 ; i++) sb.append("U");
		sb.append("L");
		sb.append("U");
		for(int i = 0 ; i < dx + 1 ; i++) sb.append("L");
		for(int i = 0 ; i < dy + 1 ; i++) sb.append("D");
		sb.append("R");
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22228
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args){
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int[] p = new int[n];
        int[] c = new int[n];
        for(int i=0; i<n; i++){
            p[i] = Integer.parseInt(sc.next())-1;
        }
        for(int i=0; i<n; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        
        int[][] dbgp = new int[45][n];
        long[][] dbgc = new long[45][n];
        for(int i=0; i<n; i++){
            dbgp[0][i] = p[i];
            dbgc[0][i] = c[p[i]];
        }
        for(int i=0; i<43; i++){
            for(int j=0; j<n; j++){
                dbgp[i+1][j] = dbgp[i][dbgp[i][j]];
                dbgc[i+1][j] = dbgc[i][j]+dbgc[i][dbgp[i][j]];
            }
        }
        
        long max = -(long)1e18;
        for(int i=0; i<n; i++){
            long ans = 0;
            int now = i;
            for(int j=0; j<Math.min(5050, k); j++){
                ans += c[p[now]];
                now = p[now];
                max = Math.max(ans, max);
            }
        }
        
        for(int i=0; i<n; i++){
            long ans = 0;
            int idx = 0;
            int t = Math.max(k-n, 1);
            int now = i;
            while(t > 0){
                if(t%2==1){
                    ans += dbgc[idx][now];
                    now = dbgp[idx][now];
                }
                t/=2;
                idx++;
            }
            max = Math.max(max, ans);
            for(int j=0; j<k-Math.max(k-n, 1); j++){
                ans += c[p[now]];
                now = p[now];
                max = Math.max(ans, max);
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 46252
#include <stdio.h>

void change(int a[], int n){
  int i;
  for(i=0;i<n;i++){
    if(i > 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}

int Bubble(int A[], int n){
  int flag=1,i,j,cnt=0,swap;
  
  for(i=0;flag == 1;i++){
    flag = 0;
    for(j=n-1;j >= i+1;j--){
      if(A[j] < A[j-1]){
	swap = A[j];
	A[j] = A[j-1];
	A[j-1] = swap;
      flag = 1;
      cnt++;
      }
    }
  }
  return cnt;
}

int main(){
  int i,j,n,cnt;
  int A[100];

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

  
  cnt = Bubble(A,n);
  change(A,n);
  printf("%d\n",cnt);
  
}




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

int main(){
  int x,y;
  cin >> x >> y;
  priority_queue<int,vector<int>,greater<int> > pq;
  if(x<=y){
    pq.push(y-x);
  }
  if(-x<=y){
    pq.push(y+x+1);
  }
  if(x<=-y){
    pq.push(-y-x+1);
  }
  if(-x<=-y){
    pq.push(-y+x+2);
  }
  cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W, K; 
  cin >> H >> W >> K;

  vector<string> s(H);
  REP(i, H) cin >> s[i];


  int ans = INF;
  REP(bit, (1<<H-1)){
    int row = 1;
    REP(j, H-1) if((bit >> j)&1) row++;

    int ret = row-1;
    vector<int> now(row);

    bool flag = true;
    REP(j, W){
      int p = 0;
      vector<int> cost(row);
      REP(i, H){
        if(s[i][j] == '1') cost[p]++;
        if(cost[p] > K) flag = false;
        if((bit >> i)&1) p++;
      }

      bool ok = true;
      REP(k, row){
        if(cost[k]+now[k] > K) ok = false;
      }
      if(!ok){
        ret++;
        REP(k, row){
          now[k] = cost[k];
        }
      }else{
        REP(k, row){
          now[k] += cost[k];
        }
      }
    }
    if(flag) chmin(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
# input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


m = Mod(10**9 + 7)


def slv(N, M, A):
    dp = [0] * (N+10)
    b = [False] * (N+10)
    for a in A:
        b[a] = True

    dp[0] = 1
    for i in range(N):
        if not b[i+1]:
            dp[i+1] = m.add(dp[i+1], dp[i])
        if not b[i+2]:
            dp[i+2] = m.add(dp[i+2], dp[i])
    return dp[N]


def main():
    N, M = read_int_n()
    A = [read_int() for _ in range(M)]
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


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

int main(){
    vector<int> dis(5);
    for (int i = 0; i<5;i++)
    {
        cin >> dis.at(i);
    }
    int k;
    cin >> k;
    puts(dis.at(4) - dis.at(0) <= k ? "Yay!" : ":(");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A,B; cin >> A >> B;
    if(A>8 || B>8) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int sqsum = 0;
            for(int k = 0; k < d; k++){
                sqsum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            if(sqrt((double)sqsum) == (double)(int)sqrt((double)sqsum)){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  
  int r;

scanf("%d",&r);
  if(r<1200){
    printf("ABC\n");
  }
  else  if(r<2800){
      printf("ARC\n");
  }
else {
  printf("AGC\n");
}

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//とおしたいね
typedef long long int64;
//同じ商品で何回かタイムせーるしてる？
//うーん//
struct Sale{
  int g;
  int64 d;
  int s, e;
} sale[8];
struct State{
  unsigned char x, y, time;
  unsigned bit, used_pop; //used_pop: 使った商品
  State( unsigned char x, unsigned char y, unsigned bit, unsigned char time, unsigned used_pop):x(x),y(y),bit(bit),time(time),used_pop(used_pop){};
};

int W, H, N, sy, sx;
bool used[20][20][1 << 8][101];
char m[20][20];
int64 cost[1 << 8];
const int dy[] = { 0, 1, 0, -1, 0}, dx[] = { 1, 0, -1, 0, 0};
queue< State > que;
int64 BFS(){
  que.push(State( sx, sy, 0, 0, 0));
  used[sy][sx][0][0] = true;
  memset( used, false, sizeof(used));
  for(int i = 0; i < 1 << N; i++){
    cost[i] = 0;
    for(int j = 0; j < N; j++){
      if((i >> j) & 1){
        cost[i] += sale[j].d;
      }
    }
  }
  int64 ret = 0;
  while(!que.empty()){
    State p = que.front(); que.pop();
    ret = max( ret, cost[p.bit]);
    if(p.time > 100) continue;
    for(int i = 0; i < 4; i++){
      int ny = p.y + dy[i], nx = p.x + dx[i];
      if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if(isdigit(m[ny][nx])){
        for(int j = 0; j < N; j++){
          if(m[ny][nx] - '0' == sale[j].g && !((p.bit >> j) & 1) && !((p.used_pop >> sale[j].g) & 1)){
            if(sale[j].s <= p.time && p.time < sale[j].e){
              if(used[p.y][p.x][p.bit|(1 << j)][p.time]++) continue;
              que.push( State( p.x, p.y, p.bit|(1 << j), p.time,
                               p.used_pop|(1 << sale[j].g)));
            }
          }
        }
      }
    }
    for(int i = 0; i < 5; i++){
      int ny = p.y + dy[i], nx = p.x + dx[i];
      if(ny < 0 || ny >= H || nx < 0 || nx >= W || m[ny][nx] != '.') continue;
      if(used[ny][nx][p.bit][p.time + 1]++) continue;
      que.push( State( nx, ny, p.bit, p.time + 1, p.used_pop));
    }
  }
  return ret;
}

int main(){
  while(cin >> W >> H, W||H){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cin >> m[i][j];
        if(m[i][j] == 'P') m[i][j] = '.', sy = i, sx = j;
      }
    }
    cin >> N;
    for(int i = 0; i < N; i++){
      cin >> sale[i].g >> sale[i].d >> sale[i].s >> sale[i].e;
    }
    cout << BFS() << endl;
  }
  return 0;
}

Measured memory_bytes: 12188
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 19:24:24 2020

@author: liang
"""

key = 10**9 + 7
T, K = map(int, input().split())
N = list(range(T+1))
lower = sum(N[:K])
higher = sum(N[-K::1])
ans = 0
ans = (higher - lower + 1)%key
for i in range(K+1,T+2):
    lower += N[i-1]
    higher += N[-i]
    ans += higher - lower + 1
    ans %= key
print(ans)
#print(lower)
#print(higher)

Measured memory_bytes: 18360
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      // cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  set<string> s;
  int n;
  cin >> n;
  rep(i, 0, n) {
    string x;
    cin >> x;
    s.insert(x);
  }
  cout << sz(s) << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 19220
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007


int main(){
  string s;
  cin>>s;
  ll ans = 1;
  if(s=="RRR")ans = 3;
  if(s=="RRS")ans = 2;
  if(s=="SRR")ans = 2;
  if(s=="SSS")ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define bit(n,m)((n>>m)&1)
#define max(p,q)((p)>(q)?(p):(q))

ll n,d;
int dp[100010];
int v[20],w[20];
int f(int x){
	rep(i,0,x+5)dp[i]=0;
	rep(i,0,n)w[i]=v[i];
	rep(i,0,n)scanf("%lld",v+i);
	rep(i,0,n)rep(j,0,x-w[i]+1)dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
	int ans=0;
	rep(i,0,x+1)ans=max(ans,dp[i]-i+x);
	return ans;
}

int main(){
	ll x;
	scanf("%lld%lld%lld",&n,&d,&x);
	rep(i,0,n)scanf("%lld",v+i);
	rep(i,0,d-1)x=f(x);
	printf("%lld\n",x);
}


Measured memory_bytes: 2108
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

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



Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;

  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

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();
         
         if(c>=a && c<=b)
         System.out.println("Yes");
         else
         System.out.println("No");
         



}}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	ll N;
	std::cin >> N;
	if (N % 2 == 1) {
		std::cout << N / 2 + 1 << endl;
	}
	else {
		std::cout << N / 2 << endl;
	}


	return 0;

}


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

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

bool isprime(int64_t c){
  for(int64_t i = 2;i < std::sqrt(c);i++){
    if(c % i == 0) return false;
  }
  return true;
}

int main(){
  int64_t A,B;
  cin >> A;
  cin >> B;

  int64_t c = gcd(A,B);

  int64_t tmp = c;
  int64_t sq = std::sqrt(c);
  int count = 1;
  for(int64_t i = 2;i <= sq;i++){
    if(tmp % i == 0) {
      count++; 
      while(tmp % i == 0)
	tmp /= i;
    }
  }
  if(tmp > sq){
    count++;
  }

  std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    vector<int> a;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    cout << a[N - 1] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
arr = ["0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111"]
while true
    n = gets.to_i
    break if n == -1
    prev = "0000000"
    n.times{
        x = arr[gets.to_i]
        puts sprintf("%07b", prev.to_i(2) ^ x.to_i(2))
        prev = x
    }
end



Measured memory_bytes: 6872
'use strict';
(function(stdin) {
  //declare function

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var count = inputs[0];
  var num = inputs[1].split(' ').map(Number).sort(function(a, b) {
    return a - b;
  });
  var result = 0;
  for (var i = 0; i < count; i++) {
    result += num[i];
  }
  console.log(num[0], num[count - 1], result)
    //main
    //display
    //console.log(inputs);
})(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 17752
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int N=in.nextInt();
			int M=in.nextInt();
			if((N|M)==0)
				return;
			int p[]=new int[(N+1)*(N+1)+1];
			int cnt=0;
			int ans=0;
			//ArrayList<Integer> AL=new ArrayList<Integer>();
			int sum[]=new int[(N+1)*(N+1)+1];
			p[0]=0;
			for(int i=1;i<=N;i++)
				p[i]=in.nextInt();

			for(int i=0;i<=N;i++)
				for(int j=0;j<=N;j++)
				{
					//AL.add(p[i]+p[j]);
					sum[cnt++]=p[i]+p[j];
				}
			//Collections.sort(AL);
			Arrays.sort(sum);
			
			for(int i=0;i<cnt;i++)
			{
				
				int x=M-sum[i];
				if(x<0)
					continue;

				int right=cnt-1;
				int left=0;

				while(left<right)
				{
					int center=(left+right)/2;
					if(x>sum[center])
						left=center+1;
					else if(x<sum[center])
						right = center;
				}
				ans=Math.max(ans, sum[i]+sum[right-1]);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 56184
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''


def caluculate_score():
	return num_kind * num_kind + taste
	
	
N, K = map(int, input().split())
t, d = [0] * N, [0] * N
table = [[] for _ in range(N)]
eat_kind = [0] * N
num_kind = 0

for i in range(N):
	t[i], d[i] = map(int, input().split())
	table[i] = (d[i], t[i] - 1)
	
table.sort()

eat = []
taste = 0

for _ in range(K):
	tmp = table.pop()
	taste += tmp[0]
	eat_kind[tmp[1]] += 1
	if eat_kind[tmp[1]] == 1:
		num_kind += 1
	eat.append(tmp)
	
ans = caluculate_score()
ind_eat = K - 1
ind_table = N - K - 1

while ind_eat >= 0 and ind_table >= 0:
	while ind_eat >= 0 and eat_kind[eat[ind_eat][1]] <= 1:
		ind_eat -= 1
		
	while ind_table >= 0 and eat_kind[table[ind_table][1]] >= 1:
		ind_table -= 1
		
	if not(ind_eat >= 0 and ind_table >= 0):
		break

	eat_kind[eat[ind_eat][1]] -= 1
	eat_kind[table[ind_table][1]] += 1
	num_kind += 1
	taste += table[ind_table][0] - eat[ind_eat][0]
	eat[ind_eat], table[ind_table] = table[ind_table], eat[ind_eat]
	score = caluculate_score()
	if score > ans:
		ans = score
		
	ind_eat -= 1
	ind_table -= 1

print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>dp(n,INF);
    vector<ll>h(n);
    dp[0]=0;
    for (int i = 0; i < n; ++i) {
        cin >>h[i];
    }
    for (int i = 0; i < n; ++i) {
        if(i+1<n){
            dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        }
        if(i+2<n){
            dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
        }
    }
    cout <<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class A {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int n = s.size();
      vector<int> a(n+1);
      int cnt = 0;
      rep(i, n) {
        if (s[i] == '<') {
          cnt++;
          chmax(a[i+1], cnt);
        } else {
          cnt=0;
        }
      }
      cnt = 0;
      for(int i=n-1; i>=0; i--) {
        if (s[i] == '>') {
          cnt++;
          chmax(a[i], cnt);
        } else {
          cnt = 0;
        }
      }
      ll sum = 0;
      for(auto e: a) {
        sum += e;
      }
      cout << sum << endl;


    }
};

signed main() {
  A solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 2844
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, s,i;
	double m1 = 0, m2 = 0;

	while (1) {
		scanf("%d", &n);

		if (!n) break;

		for (i = 0; i < n; i++) {
			scanf("%d", &s);
			m1 += s;
			m2 += s*s;
		}

		printf("%.8lf\n", sqrt(m2 / n - m1*m1 / n / n));

		m1 = 0; m2 = 0;
	}

	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
using namespace std;
void solve(){
    ll n;
    cin>>n;
    ld pie=6.28318530717958623200;
    pie*=n;
    cout<<setprecision(10)<<fixed<<pie<<endl;
    
    
    
    }
    
int main(){
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
return 0;
}

Measured memory_bytes: 3772
function main(input) {
  input = input.trim();
  const a = input.split(" ");
  if(a[0]>a[1]){
  	console.log('>');
  }else if(a[0]<a[1]){
  	console.log('<');
  }else{
  	console.log('=');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29508
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m, s, t; cin >> n >> m >> s >> t;
  V<V<P<ll, ll> > > aedges(n), bedges(n);
  REP(i, m) {
    ll u, v, a, b; cin >> u >> v >> a >> b;
    aedges[u-1].push_back({a, v-1});
    aedges[v-1].push_back({a, u-1});
    bedges[u-1].push_back({b, v-1});
    bedges[v-1].push_back({b, u-1});
  }

  vll ad(n, HIGHINF), bd(n, HIGHINF);
  priority_queue<P<ll, ll> , V<P<ll, ll> >, greater<P<ll, ll> > > aq;
  priority_queue<P<ll, ll> , V<P<ll, ll> >, greater<P<ll, ll> > > bq;

  ad[s-1] = 0; aq.push({0, s-1});
  while (!aq.empty()) {
    P<ll, ll> q = aq.top(); aq.pop();
    ll fr = q.second;
    if (ad[fr] < q.first) continue;
    REP(to, aedges[fr].size()) {
      if (ad[aedges[fr][to].second] > ad[fr] + aedges[fr][to].first) {
        ad[aedges[fr][to].second] = ad[fr] + aedges[fr][to].first;
        aq.push({ad[aedges[fr][to].second], aedges[fr][to].second});
      }
    }
  }

  bd[t-1] = 0; bq.push({0, t-1});
  while (!bq.empty()) {
    P<ll, ll> q = bq.top(); bq.pop();
    ll fr = q.second;
    if (bd[fr] < q.first) continue;
    REP(to, bedges[fr].size()) {
      if (bd[bedges[fr][to].second] > bd[fr] + bedges[fr][to].first) {
        bd[bedges[fr][to].second] = bd[fr] + bedges[fr][to].first;
        bq.push({bd[bedges[fr][to].second], bedges[fr][to].second});
      }
    }
  }

  vll ans(n);
  ll minc = HIGHINF;
  for (ll i=n-1; i>-1; i--) {
    chmin(minc, ad[i] + bd[i]);
    ans[i] = 1e15-minc;
  }
  REP(i, n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 20216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define P pair<int,int>
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}

bool dp[MAX], dp2[MAX+1];
ll ans[MAX+1];
int main(){
	int q, x, y;
	scanf("%d", &q);
	fill(dp, dp+MAX, 1);
	dp[0] = dp[1] = 0;
	for(int i = 2;i <= MAX-1;i++){
		if(dp[i] != 0){
			for(int j = 2;i*j <= MAX;j++){
				dp[i*j] = 0;
			}
		}
	}
	for(int i = 2;i <= MAX;i++){
		if(dp[i] && i*2 <= MAX){
			dp2[i*2] = 1;
		}
	}
	for(int i = 1;i <= MAX-1;i++){
		if(dp[i] == 1 && dp2[i+1] == 1){
			ans[i]++;
		}
		ans[i] += ans[i-1];
	}
	for(int i = 0;i < q;i++){
		scanf("%d%d", &x, &y);
		printf("%d\n", ans[y]-ans[x-1]);
	}
	/*for(int i = 1;i <= 20;i++)printf("%d ", dp[i]);
	printf("\n");
	for(int i = 1;i <= 20;i++)printf("%d ", dp2[i]);
	printf("\n");
	for(int i = 1;i <= 20;i++)printf("%d ", ans[i]);*/
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, x[200000] = {};
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        v.push_back(x[i]);
    }
    sort(v.begin(), v.end());
    int l = v[n / 2-1], r = v[n / 2];
    for (int i = 0; i < n; i++) {
        if (x[i] <= l) cout << r << endl;
        else cout << l << endl;
    }
}

Measured memory_bytes: 3828
#include <stdio.h>

int main(void)
{
    int n;
    char house[4][3][32] = {0};
    int i, j;

    for (i = 0; i < 4; i++){
        for (j = 0; j < 3; j++){
            strcpy(house[i][j], " 0 0 0 0 0 0 0 0 0 0");
        }
    }
    scanf("%d", &n);
    while (n-- > 0){
        int b, f, r, v;

        scanf("%d %d %d %d", &b, &f, &r, &v);
        house[b - 1][f - 1][r * 2 - 1] += v;
    }
    for (i = 0; i < 4; i++){
        for (j = 0; j < 3; j++){
            puts(house[i][j]);
        }
        if (i < 3) puts("####################");
    }

    return 0;
}

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

int main() {
  int n;
  string x;
  cin >> n;
  while (n>0) {
    cin >> x;
    if (x=="Y") {
      cout << "Four";
      break;
    }
    n--;
  }
  if (n==0) cout << "Three";
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    P = [0] * M
    S = [""] * M
    for i in range(M):
        PS = input().split()
        P[i], S[i] = int(PS[0]), PS[1]

    AC = [False] * (N + 1)
    WA = [0] * (N + 1)
    n_AC = 0
    n_WA = 0
    for p, s in zip(P, S):
        if AC[p]:
            continue
        if s == "AC":
            n_AC += 1
            AC[p] = True
            n_WA += WA[p]
        else:
            WA[p] += 1

    print(n_AC, n_WA)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  string S;
  cin>>S;
  for(int i=0;i<S.size();i++)cout<<"x";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ll b,c,d,e;
    string s;
    bool flag = true;
    ll n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n)if(a[i]%2 ==0 &&!(a[i]%3 == 0 || a[i] % 5 == 0))flag = false;
    if(flag)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double p[100010];
int pre[100010];
double dp[100010];
int n;
int main()
{
	while(scanf("%d",&n)!=EOF && n)
	{
		for(int i=1;i<=n;i++)scanf("%lf",p+i),p[i]=1.0/p[i];
		for(int i=1;i<=n;i++)
		{
			if(p[i-1]!=1.0 || p[i]!=1.0)pre[i]=i-1;
			else pre[i]=pre[i-1];
		}
		for(int i=1;i<=n;i++)
		{
			int t=i;
			double sum=0,mul=p[i];
			dp[i]=1e16;
			for(int j=1;j<=100 && t && sum<=1e14;j++)
			{
				sum+=(t-pre[t])*mul;
				t=pre[t];
				mul*=p[t];
				dp[i]=min(dp[i],dp[t]+sum+1);
			}
		}
		printf("%.10lf\n",dp[n]-1);
	}
	return 0;
}


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

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

using namespace std;

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

  vector<int> a(n+1);
  rep(i,n)cin>>a[i+1];

  int c=1,result=0;

  rep(i,n){
    if(c==2){
      cout<<result;
      return 0;
    }
    c=a[c];
    result++;
  }
  cout<<-1;
  return 0;
}

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

int main(){
  int n,N=0,v,i,j;

  scanf("%d",&N);

  int A[N];

  if(N>100||N<1) exit(1);
  
  for(n=0; n<N; n++){
    scanf("%d",&A[n]);
    if(A[n]<0||A[n]>1000) exit(2);
  }

  for(n=0; n<N; n++){
    if(n!=0) printf(" %d",A[n]);
    else printf("%d",A[n]);
  }

  printf("\n");

  for(i=1; 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(n=0; n<N; n++){
      if(n!=0) printf(" %d",A[n]);
      else printf("%d",A[n]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2048
#include<cstdio>
#include<algorithm>

int main() {
	int a[3];
	for(int i=0;i<3;i++) scanf("%d", &a[i]);
	std::sort(a, a+3);
	int x = a[2] - a[1];
	int y = a[1] - a[0];
	printf("%d\n", (y % 2 == 0) ? x + y/2 : x + y/2 + 2);
	return 0;
}


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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    int a,b,c,k,res = 0;
    cin>>a>>b>>c>>k;
    if(a < k) {
        res += a;
        k -= a;
    } else {
        res = k;
        k = 0;
    }
    if(k != 0 && b != 0) {
        k -= b;
    }
    if(k != 0 && c != 0) {
        res -= k;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void){
  int ans[1024];
  int n;
  int k,i,j,tmp;
  for(k=0;k>=0;k++){
    int total=0;
    scanf("%d",&n);
    if(n==0)break;
    int point[n];
    for(i=0;i<n;i++){
      scanf("%d",&point[i]);
    }
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
	if(point[i]>point[j]){
	  tmp = point[i];
	  point[i] = point[j];
	  point[j] = tmp;
	}
      }
    }
    for(i=1;i<n-1;i++){
      total += point[i];
    }
    ans[k] = total/(n-2);
  }  
  for(i=0;i!=k;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int64_t N;
    cin >> N;
    string ans = "";
    while (N > 0) {
        N--;
        int r = N % 26;
        ans.push_back('a' + r);
        N /= 26;
    }
    Reverse(ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
#ifdef _WIN32
    #define getchar_unlocked getchar
#endif
inline void fin(int &x){ register char c=0;x=0;while(c<33)c=getchar_unlocked();do{x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}while(c>33);}
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define wypisz(x) cerr << #x << " " << x << "\n";
#define ll long long
#define ld long double
#define pii pair<int,int>
#define whole(c) (c).begin(), (c).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,m,t[505][505];
vector<vector<int> > res;
int main()
{   boost;
    cin >> n >> m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin >> t[i][j];
    int i = 1;
    while(1)
    {   if(i&1)
        {   for(int j=1;j<m;j++)
                if(t[i][j]&1)
                    t[i][j+1]++,
                    res.push_back({i,j,i,j+1});
            if(i==n)break;
            if(t[i][m]&1)
                t[i+1][m]++,
                res.push_back({i,m,i+1,m});
        }
        else
        {   for(int j=m;j>1;j--)
                if(t[i][j]&1)
                    t[i][j-1]++,
                    res.push_back({i,j,i,j-1});
            if(i==n)break;
            if(t[i][1]&1)
                t[i+1][1]++,
                res.push_back({i,1,i+1,1});
        }
        i++;
    }
    cout << res.size() << "\n";
    for(auto w : res)
        cout << w[0] << " " << w[1] << " " << w[2] << " " << w[3] << "\n";
}
// 1 1
// 1 1
//overflow??

Measured memory_bytes: 10032
#include <stdio.h>

int main(){
    int a[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    for(;;){
        for(int i=0;i<2;i++){
            if(a[i]>a[i+1]){
                int t=a[i]+a[i+1];
                a[i]=t-a[i];
                a[i+1]=t-a[i+1];
            }
        }
        if(a[0]<=a[1]<=a[2]){
            break;
        }
    }
    printf("%d",a[0]+a[1]);
    
    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())

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

check = [0] * n

start = 0
path = []
for i in range(n):
    if check[start] == 0:
        check[start] = 1
        path.append(start)
        start = A[start] - 1
path.append(start)

before_roop = path[:path.index(path[-1])]
B = before_roop
if before_roop == []:
    before_roop = 0
else:
    before_roop = len(before_roop)

roop = len(path) - before_roop - 1

if k <= before_roop:
    print(path[:before_roop+1][k] + 1)
else:
    k -= before_roop
    k = k % roop
    print(path[before_roop+1:][k-1] + 1)


Measured memory_bytes: 98248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,b;
    cin>>n>>d;
    int a[n][d];
    for(int i=0; i<n; i++)
    for(int j=0; j<d; j++)
    cin>>a[i][j];
    int ans=0;
    for(int i=0; i<n; i++)
    for(int j=i+1; j<n; j++)
    {
        int sum=0;
        for(int k=0; k<d; k++)
        sum+=pow(a[i][k]-a[j][k],2);
        b=sqrt(sum);
        if(b*b==sum)
            ans++;
    }
    cout<<ans<<endl;
}
/*
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,a;
    cin>>n>>d;
    int x[n][d];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<d; j++)
        {
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            int sum=0;
            for(int k=0; k<d; k++)
            {
                sum+=pow(x[i][k]-x[j][k],2);
            }
            a=sqrt(sum);
            if(a*a==sum)
                ans++;
        }
    }
    cout<<ans<<endl;
}
*/


Measured memory_bytes: 3628
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] x = new double[n];
        String[] u = new String[n];
        double sum = 0;

        for(int i = 0;i<n;i++){
            x[i] = sc.nextDouble();
            u[i] = sc.next();
            if(u[i].equals("BTC")){
                sum+=(x[i]*380000);
            }else{
                sum+=x[i];
            }
        }

        
System.out.println(sum);
             
    }
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001,mod=1e9+7;

int main(){
sync

    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,(a+b)-n)<<endl;

return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
MOD = 10**9 + 7
harmonic = [0 for _ in range(N+1)]
factorial = [1]
for i in range(1,N+1):
    im = pow(i,MOD-2,MOD)
    harmonic[i] = (harmonic[i-1] + im)%MOD
    factorial.append((factorial[i-1] * i)%MOD)
expectation = 0
for i in range(1,N+1):
    expectation += a[i-1]*(harmonic[i]+harmonic[N-i+1]-1)%MOD
    expectation %= MOD
answer = expectation*factorial[N]%MOD
print(answer)

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

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

    int s, t, c;
    vector<vector<int>> imos(35, vector<int>(100005, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> s >> t >> c;
        imos[c][s - 1]++;
        imos[c][t]--;
    }

    for (int i = 0; i < imos.size(); i++)
    {
        for (int j = 1; j < imos[i].size(); j++)
        {
            imos[i][j] += imos[i][j - 1];
        }
    }

    int ans = 0;
    for (int i = 0; i < 100005; i++)
    {
        int tmp = 0;
        for (int j = 0; j < imos.size(); j++)
        {
            tmp += min(1, imos[j][i]);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        cout<<"x";
    }
    cout<<endl;
}

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

using namespace std;


int main(int argc, char const *argv[])
{
  bool check = false;
  int n;
  cin >> n;
  for(int i = 0; i < 10; i ++){
    for(int j = 0; j < 10; j ++){
      if(i * 4 + j * 7 == n){
        check = true;
      }
    }
  }
  if(n > 40){
    check = true;
  }
  if(check){
    cout << "Yes"<<endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
PROGRAM-ID.                      PROGRAM_ID.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N            PIC 9(3).
    01 ans          PIC Z9.
 
PROCEDURE                        DIVISION.
    ACCEPT N.
    COMPUTE ans = (N + 1) / 2.
    DISPLAY ans.
    STOP RUN.


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

int gcd( int m, int n ){
	// 引数に０がある場合は０を返す
	if ((0 == m)||(0 == n))
		return 0;
	
	// ユークリッドの方法
	while(m != n){
		if(m > n) m = m - n;
		else      n = n - m;
	}
	return m;
};

int main(int argc, const char * argv[])
{
    int n, m;
    while(cin >> n >> m){
        //std::cout << n << "," << m << "\n";
        cout << gcd(m, n) << "\n";
    }
    return 0;
}

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

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= k) sum += x;
		else if (i > k)sum += y;
	}

	cout << sum << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MAXW = 100005;

int n, W, i, j, v, w;
LL res[MAXW];

int main() {
scanf("%d %d", &n, &W);
for (i=0;i<=W;i++) res[i] = 0;
for (i=0;i<n;i++) {
	scanf("%d %d", &w, &v);
	for (j = W - w;j>=0;j--) res[j + w] = max(res[j + w], res[j] + v);
}
printf("%lld\n", res[W]); 
return 0;
}

Measured memory_bytes: 1024