akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    n%=10;

    string ans = "hon";
    if (n==0 || n==1 || n==6 || n==8) ans = "pon";
    if (n==3) ans = "bon";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

#define EPS 1e-8
#define EQ(a, b) (abs((a)-(b)) < EPS)
const double PI = acos(-1.0);

inline int signum(double x) { return (abs(x) < EPS) ? 0 : (x > 0) ? 1 : -1; }

typedef complex<double> P;
typedef vector<P> Poly;

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

double toRadian(double degree) {
    return degree * PI / 180.0;
}

double toDegree(double radian) {
    return radian * 180.0 / PI;
}

int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    int sign = signum(cross(b, c));
    if (sign != 0) return sign;
    if (signum(dot(b, c)) == -1) return 2;
    if (abs(b) < abs(c)) return -2;
    return 0;
}

double dis_p_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return abs(cross(b, c)) / abs(b);
}

double dis_p_li_ss(P a, P b, P c) {
    P x1 = b - a;
    P y1 = c - a;
    P x2 = a - b;
    P y2 = c - b;
    if (signum(dot(x1, y1)) < 0) return abs(y1);
    if (signum(dot(x2, y2)) < 0) return abs(y2);
    return dis_p_li(a, b, c);
}

bool is_intersected_li_ss(P a1, P a2, P b1, P b2) {
    return (ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0) &&
           (ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0);
}

double dis_li_s_li_s(P a1, P a2, P b1, P b2) {
    if (is_intersected_li_ss(a1, a2, b1, b2)) return 0.0;
    return min({
                       dis_p_li_ss(a1, a2, b1),
                       dis_p_li_ss(a1, a2, b2),
                       dis_p_li_ss(b1, b2, a1),
                       dis_p_li_ss(b1, b2, a2)
               });
}

double area_tri(double a, double b, double c) {
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

double area_tri(P a, P b, P c) {
    double x = abs(b - a);
    double y = abs(c - b);
    double z = abs(a - c);
    return area_tri(x, y, z);
}

double area_poly(Poly poly) {
    double ans = 0.0;
    for (int i = 0; i < poly.size(); i++) ans += cross(poly[i], poly[(i + 1) % poly.size()]);
    return abs(ans) / 2.0;
}

int main() {

    int N;
    cin >> N;

    Poly poly(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        poly[i] = P(x, y);
    }


    cout << fixed << setprecision(1) << area_poly(poly) << endl;

}














































Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (0 == r && n == 0)
				break;
			int[] yama = new int[n];
			for (int i = 0; i < yama.length; i++) {
				yama[i] = i + 1;
			}
			while (r-- != 0) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				for (int i = yama.length - p + 1; i < yama.length; i++) {
					for (int j = i; j > i - c; j--) {
						int w = yama[j];
						yama[j] = yama[j - 1];
						yama[j - 1] = w;
						// System.out.println(Arrays.toString(yama));
					}

				}
			}
			System.out.println(yama[n - 1]);
		}

		sc.close();

	}

}

Measured memory_bytes: 38376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, n; cin >> x >> n;
    map<int,int> m;
    rep(i,n) {
        int p; cin >> p;
        m[p]++;
    }
    int ans = INF;
    int mi = INF;
    REP(i,x,105) {
        if(m[i]==0) {
            if(abs(i-x)<=mi) {
                mi = abs(i-x);
                ans = min(ans,i);
            }
        }
    }
    for(int i = x; i > -5; i--) {
        if(m[i]==0) {
            if(abs(i-x)<=mi) {
                mi = abs(i-x);
                ans = min(ans,i);
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
"""this is python work script"""

def solver(H1, M1, H2, M2, K):
    """solve this problem"""
    min1 = H1 * 60 + M1
    min2 = H2 * 60 + M2
    diff = min2 - min1
    answer = diff - K
    return answer

def main():
    """main function"""
    H1, M1, H2, M2, K = list(map(int, input().rstrip().split(' ')))
    answer = solver(H1, M1, H2, M2, K)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
n,k=map(int,input().split())
teleport=list(map(int,input().split()))
double_counter=set()
# mojiretu="1"
mojiretu=["1"]
index=1
double_counter.add(index)
flag=False
for i in range(k):
    tmp=teleport[index-1]
    if tmp in double_counter:
        flag=True
        break
    else:
        double_counter.add(tmp)
        # mojiretu+=str(tmp)
        mojiretu.append(str(tmp))
        index=tmp
else:
    print(tmp)

if flag:
    # index=mojiretu.find(str(tmp))
    # roop_str=mojiretu[index:]
    # length=k%len(roop_str)-len(mojiretu[:index])%len(roop_str)
    # print(roop_str[length])

    Li = mojiretu.index(str(tmp))
    Ri = len(mojiretu)
    idx = Li + (k - Li) % (Ri - Li)
    print(mojiretu[idx])


Measured memory_bytes: 40280
#include <iostream>
#include <string>

using namespace std;

class job {
  string name;
  int time;
public:
  job(){
    this->name = "";
    this->time = 0;
  }
  job(string name, int time){
    this->name = name;
    this->time = time;
  }
  job(job const &j){
    this->name = j.name;
    this->time = j.time;
  }
  void timeSubtract(int q){
    if (time < q){
      time = 0;
    }
    time = time - q;
  }
  int getTime(){
    return time;
  }
  string getName(){
    return name;
  }
};

class que {
  job data[100001];
  int topIndex;
  int tailIndex;
  void inc(int &idx){
    idx++;
    idx %= sizeof(data)/sizeof(data[0]);
  }
public:
  que(){
    topIndex = 0;
    tailIndex = 0;
  }
  void enque(job &j){
    data[tailIndex] = j;
    inc(tailIndex);
  }
  job deque(){
    int index = topIndex;
    inc(topIndex);
    return data[index];
  }
  bool isEmpty(){
    return tailIndex == topIndex;
  }
};

int main(int argc, char const *argv[]) {

  int n; //?????????????????°
  int q;//???????????????
  que jobque;
  cin >> n;
  cin >> q;
  for (int i = 0; i < n; i++) {
    int jobtime;
    string jobname;
    std::cin >> jobname;
    std::cin >> jobtime;
    job j(jobname, jobtime);
    jobque.enque(j);
  }
  int t = 0;
  while (!jobque.isEmpty()) {
    job j = jobque.deque();
    if (j.getTime() > q){
      j.timeSubtract(q);
      jobque.enque(j);
      t += q;
    }else {
      t += j.getTime();
      std::cout << j.getName() << ' ' << t << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 6980
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1e9;
const int MOD = 1000000007;


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

  int n;
  cin >> n;

  int ans = 0;
  multiset<int> ms;
  rep(i, n) {
    int x;
    cin >> x;
    multiset<int>::iterator it;
    //! EMPTY      <-- 2 => 2               //! when empty, insert x
    //! 2, 2, 4, 4 <-- 1 => 1, 2, 2, 4, 4   //! when lb(x) == begin(), insert x
    //! 2, 2, 4, 4 <-- 2 => 2, 2, 2, 4, 4   //! when lb(x) == begin(), insert x
    //! 2, 2, 4, 4 <-- 3 => 2, 3, 4, 4      //! when lb(x) != begin(), replace the prev number with x
    //! 2, 2, 4, 4 <-- 4 => 2, 4, 4, 4      //! when lb(x) != begin(), replace the prev number with x
    //! 2, 2, 4, 4 <-- 5 => 2, 2, 4, 5      //! when lb(x) != begin(), replace the prev number with x
    if (ms.empty() || (it = ms.lower_bound(x)) == ms.begin()) {
      ++ans;
      ms.insert(x);
    } else {
      --it;
      ms.erase(it);
      ms.insert(x);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  long n;
  cin >> n;
  string ans = "";
  while(n){
    if(n%2==0){
      ans.push_back('0');
    }else{
      ans.push_back('1');
      n -= 1;
    }
    n /= (-2);
  }
  if(int(ans.size())==0)ans.push_back('0');
  rep(i,int(ans.size())){
    cout << ans[int(ans.size())-1-i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main(){

  string s,t; cin >> s;

  for (int i = 0; i < s.length(); i++) {
    for (int j = i+1; j < s.length(); j++) {
      if(s[i] == s[j])  {
        puts("no"); return 0;
      }
    }
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import math

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

a=math.ceil(A/10)
b=math.ceil(B/10)
c=math.ceil(C/10)
d=math.ceil(D/10)
e=math.ceil(E/10)

z = max(a*10-A, b*10-B, c*10-C, d*10-D, e*10-E)
print((a+b+c+d+e)*10-z)

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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'	

using namespace std;

const int MOD = 1e9+7;
const int N = 2e5;

int main() {
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cout.tie(0);
 	string s;
 	cin >> s;
 	int ans = 0, c = 0;
 	for (int i = 0; i < s.size(); ++i) {
 		if (s[i] == 'R') {
 			++c;
 			ans = max(ans, c);

 		}
 		else {
 			c = 0;
 		}
 	}
 	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <string>
#include <stdlib.h>
#include <iomanip>
#include <utility>
 
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define iii pair<ii,int >
#define ff first
#define ss second
#define vi vector<int>
#define vc vector<char>
 
using namespace std;


int main(){
	int n;
	cin >> n;
	double p[n];
	FOR(i,n)cin >> p[i];
	double dp[n+3][n+3];//heads
	FOR(i,n)FOR(j,n+1)dp[i][j] = 0;
	dp[0][0] = 	1-p[0];
	dp[0][1] = p[0];
	FOR(i,n){
		if(i == 0)continue;
		FOR(j,n+1){
			dp[i][j] = (( j>0)?p[i]*dp[i-1][j-1]:0) + (1-p[i])*dp[i-1][j];
		}
	}
	FOR(i,n){
		FOR(j,n+1){
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}


	double sum = 0;
	for(int i = n/2+1;i<=n;i++)sum += dp[n-1][i];

	cout << setprecision(10) << sum << endl;

	return 0;
}


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

int main(void){
	int a,b,c;
	char op;
	
	while(scanf("%d %c %d", &a, &op, &b),op!='?'){
		switch(op){
			case '+':
			c = a+b;
			break;
			
			case '-':
			c = a-b;
			break;
			
			case '*':
			c = a*b;
			break;
			
			case '/':
			c = a/b;
			break;
		}
		printf("%d\n",c);
	}
	
	return 0;
}

Measured memory_bytes: 600
in1 = list(input().split())
nx = int(in1[0])
ny = int(in1[1])
x = list(input().split())
y = list(input().split())
sx = sum([ int(x[i])*(2*i - nx + 1) for i in range(nx) ])
sy = sum([ int(y[i])*(2*i - ny + 1) for i in range(ny) ])
print(sx*sy%(10**9 + 7))

Measured memory_bytes: 22756
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	ll n=s.size(),t=1;
	for(int i=0;i<n;i++) t*=10;
	ll x=atoll(s.c_str());
	vi a(10);
	for(int i=0;i<10;i++) a[i]=i;
	ll res=INF,mx=0;
	do{
		ll tmp=0;
		for(int i=0;i<n;i++) tmp=10*tmp+a[i];
		ll c=min(abs(x-tmp),t-abs(x-tmp));
		if(c>=mx){
			if(c==mx){
				res=min(res,tmp);
			}
			else{
				mx=c;
				res=tmp;
			}
		}
	}while(next_permutation(a.begin(),a.end()));
	s=to_string(res);
	while(s.size()<n) s='0'+s;
	cout<<s<<endl;
}


Measured memory_bytes: 3292
#include<iostream>
#include<set>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int in;
	set<int> st;
	rep(i,3){
		cin>>in;
		st.insert(in);
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<stdio.h>
#include<string>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main()
{
	int A,B,X;
	cin>>A>>B>>X;
	if((A<=X)&&((A+B)>=X))
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s;
   cin >> s;
   n = 0;
   rep(i,3){
      if (s[i] == '1') n++;
   }
   cout << n << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<string> se;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		se.insert(s);
	}
	cout<<se.size()<<endl;
	return 0;
}

Measured memory_bytes: 19256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N,x;
	cin>>N>>x;
	if(2*N-1==x || 1==x){
		cout<<"No";
		return;
	}
	cout<<"Yes\n";
	if(x==N){
		rep(i,0,2*N-1)cout<<i+1<<" ";
		return;
	}
	else if(x>N){
		rep(i,1,N)cout<<i<<" ";
		rep(i,x,2*N)cout<<i<<" ";
		rep(i,N,x)cout<<i<<" ";
	}
	else{
		rep(i,x+1,N+1)cout<<i<<" ";
		rep(i,1,x+1)cout<<i<<" ";
		rep(i,N+1,2*N)cout<<i<<" ";
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1536
N, M, X, Y = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

z1 = x.max + 1
z2 = y.min

puts (z1..z2).any?{|z| X < z && z <= Y} ? "No War" : "War"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int a,b,ans;
    cin>>a>>b;
    if(b%a==0){
        ans=a+b;
    }
    else{
        ans=b-a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
ll N, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B;

    if (A > B || (N == 1 && A != B)) {
        printf("0\n");
        return;
    }

    ll ma = A + B * (N - 1);
    ll mi = A * (N - 1) + B;

    ll ans = ma - mi + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int n, n1, n2, n3, n4;
  cin >> n;
  
  n1 = n / 1000;
  n2 = (n % 1000) / 100;
  n3 = (n % 100) / 10;
  n4 = n % 10;
  
  if ((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
	string s; cin >> s;
	int n = (int)s.size();
	long long ans = 0, cnt = 0;
	for (int i = 0; i < n - 2; ++ i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans += cnt + 1, s[(++ i) + 1] = 'A';
		else if (s[i] == 'A') ++ cnt;
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()	{
  int n, k;
  cin >> n >> k;
  int x[n];
  for (int i = 0; i < n; i++)	{
    cin >> x[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++)	{
    res += min(2 * abs(x[i]), 2 * abs(x[i] - k));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
bool possible(int goal, VEC<int> &path) {
  int n = path.size();
  sort(ALL(path), greater<int>());
  DUMP(goal, path);
  int sum = 0;
  REP(i, 0, n) {
    if (sum < goal)
      sum += path[i];
    else
      sum -= path[i];
  }
  if(sum==goal)return 1;
  else return 0;
}

int main() {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  VEC<int> X;
  VEC<int> Y;
  int n = s.length();
  DUMP(n);
  bool flagX = 1;
  int tmpSum = 0;
  REP(i, 0, n) {
    if (s[i] == 'F') {
      ++tmpSum;
    } else {
      if (flagX)
        X.push_back(tmpSum);
      else
        Y.push_back(tmpSum);
      flagX = !flagX;
      tmpSum = 0;
    }
  }
  if (flagX)
    X.push_back(tmpSum);
  else
    Y.push_back(tmpSum);
  x-=X[0];
  X[0]=0;
  bool px = possible(x, X);
  bool py = possible(y, Y);
  if(px && py) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long 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;}



int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i<=n;i++) {
        for(int j = i;j<=n;j += i) {
            ans += j;
        }
    }
    cout << ans << endl;
}



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


int main() {
	int X, Y;
	int Total = 0;
	const int NUM[] = { 300000,200000,100000 };
	const int plus = 400000;

	cin >> X >> Y;
	if (X == 1 && Y == 1)Total = plus;
	if (X <= 3)Total += NUM[X - 1];
	if (Y <= 3)Total += NUM[Y - 1];


	cout << Total;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=105;
int a[maxn],n,f[maxn][maxn][maxn];
const int mod=1e9+7;
inline void add(int &x,int y){
	x=((x+y)>=mod?(x+y-mod):(x+y));
}
int main(){
	read(n);
	rep(i,1,2*n-1)read(a[i]);
	if(n==1){
		puts("1");
		return 0;
	}
	sort(a+1,a+n+n);
	int l=(a[n-1]!=a[n]);
	int r=(a[n+1]!=a[n]);
	f[n][1+l+r][1+l]=1;
	per(i,n,2){
		int L=(a[(i-1)-1]!=a[(i-1)]);
		int R=(a[n+n-(i-1)]!=a[n+n-(i-1)+1]);
		rep(j,1,2*n-1)rep(k,1,j)if(f[i][j][k]){
			rep(l,1,k-1){
				// < b[i]
				add(f[i-1][j-(k-l-1)+L+R][l+L],f[i][j][k]);
			}
			// = b[i]
			add(f[i-1][j+L+R][k+L],f[i][j][k]);
			// > b[i]
			rep(l,k+1,j){
				add(f[i-1][j-(l-k-1)+L+R][k+1+L],f[i][j][k]);
			}
		}
	}int ans=0;
	rep(j,1,2*n+1)rep(k,1,j)add(ans,f[1][j][k]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000002


int main(){
	int N;
	cin>>N;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	long long ans = 1000;
	for(int i=0;i+1<A.size();i++){
		if(A[i]>=A[i+1])continue;
		long long t = ans/A[i];
		ans -= t*A[i];
		ans += t*A[i+1];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

const double EPS = 1e-10;
double add(double a, double b) {
    if(abs(a+b) < EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y):x(x), y(y) {}
    Vector operator+(Vector v) {return Vector(add(x, v.x), add(y, v.y));}
    Vector operator-(Vector v) {return Vector(add(x, -v.x), add(y, -v.y));}
    Vector operator*(double d) {return Vector(x*d, y*d);}
    Vector operator/(double d) {return Vector(x/d, y/d);}
    double dot(Vector v) {return add(x*v.x, y*v.y);}
    double cross(Vector v) {return add(x*v.y, -y*v.x);}
};
istream &operator>>(istream &is, Vector &v) {return is >> v.x >> v.y;}
ostream &operator<<(ostream &os, const Vector &v) {return os << v.x << ' ' << v.y;}
double sqdist(Vector &v, const Vector &u) {return (v-u).dot(v-u);}
//線分v2-v1上にあるか
bool on_seg(Vector &v1,Vector &v2, const Vector &p) {
    return (v1-p).cross(v2-p) == 0 && (v1-p).dot(v2-p) <= 0;
}
//v1-v2とu1-u2の交点
Vector intersection(Vector &v1,Vector &v2,Vector &u1,Vector &u2) {
    assert((v1-v2).cross(u1-u2)); //2直線が平行だとだめ
    return v1 + (v2-v1)*((u2-u1).cross(u1-v1)/(u2-u1).cross(v2-v1));
}
//p2-p1へのQの投影
Vector projection(Vector &p1,Vector &p2,Vector &Q) {
    return p1+(p2-p1)*(Q-p1).dot(p2-p1)/sqdist(p1, p2);
}
//p1-p2を軸としたQの線対称移動
Vector reflection(Vector &p1,Vector &p2,Vector &Q) {
    return projection(p1, p2, Q)*2-Q;
}
bool cmp_x(const Vector &v, const Vector &u) {
    if(v.x != u.x) return v.x < u.x;
    return v.y < u.y;
}
//頂点数nの頂点集合vv
vector<Vector> convex_hull(vector<Vector> &vv, int n) {
    sort(vv.begin(), vv.end(), cmp_x);
    int k = 0;
    vector<Vector> res(n*2);
    for(int i = 0; i < n; i++) {
        while(k > 1 && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    for(int i = n-2, t = k; i >= 0; i--) {
        while(k > t && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    res.resize(k-1);
    return res;
}

signed main() {
    Vector p0, p1, p2, p3;
    int q;
    cin >> q;
    while(q--) {
        cin >> p0 >> p1 >> p2 >> p3;
        if((p0-p1).cross(p2-p3) == 0) {
            if(on_seg(p1, p0, p2) or on_seg(p1, p0, p3) or on_seg(p2, p3, p0) or on_seg(p2, p3, p1)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else {
            Vector p = intersection(p0, p1, p2, p3);
            cout << (on_seg(p0, p1, p) and on_seg(p2, p3, p)?1:0) << endl;
            //cout << p << endl;
        }
    }

}


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

 int main()
     {
  int x[3];
  cin>>x[0]>>x[1]>>x[2];
  sort(x,x+3);
  cout<<x[0]+x[1];
   return 0;
     }


Measured memory_bytes: 3548
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    map<char, vector<ll>> mp;
    for(ll i=0; i<n; ++i) {
        mp[s[i]].pb(i+1);
    }
    ll r = mp['R'].size();
    ll g = mp['G'].size();
    ll b = mp['B'].size();
    ans = r*g*b;
    for(ll i=0; i<n; ++i) {
        for(ll j=i+1; j<n; ++j) {
            ll k=j+j-i;
            if (k<n&&s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]) {
                ans--;
            }
        }
    }
    ct(ans);
}



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

int main(){
    int n;
    cin>>n;
    
    vector<int> dp(n+1,0); //min cost to reach i dp[i].
    
    vector<int> h(n);

    for(int i=0; i<n; i++) cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    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]));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
    
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

template <typename T>
ostream& operator<<(ostream& os, vector<T> v)
{
  os << "(";
  each (i, v)
    os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char* argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    int g[h][w];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }

    vector<pair<pair<int, int>, pair<int, int>>> v;
    for (int i = 0; i < h; ++i) {
      vector<int> odd;
      for (int j = 0; j + 1 < w; ++j) {
        if (g[i][j] % 2) {
          odd.push_back(j);
          v.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1)));
          --g[i][j];
          ++g[i][j + 1];
        }
      }
      if (i + 1 < h && g[i][w - 1] % 2) {
        v.push_back(make_pair(make_pair(i, w - 1), make_pair(i + 1, w - 1)));
        --g[i][w - 1];
        ++g[i + 1][w - 1];
      }
    }

    cout << v.size() << endl;
    each (i, v) {
      int a = i.first.first;
      int b = i.first.second;
      int c = i.second.first;
      int d = i.second.second;
      cout << a + 1 << ' ' << b + 1 << ' ' << c + 1 << ' ' << d + 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int main() {
    string s;
    int K;
    set<string> set_;

    cin >> s;
    cin >> K;

    for(int i = 0; i < s.size(); i++) {
        for(int j = K; j > 0 ; j--) {
            set_.insert(s.substr(i, j));
        }
    }

    auto  itr = set_.begin();
    for(int i = 1; i < K; i++ ) {
        itr++;
    }
    cout << *(itr)<< endl;
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

multiset <int> S;
int n,tot,ans;
int main() {
	n=rd(), tot=rd();
	for(int i=1;i<=n;i++) S.insert(rd());
	while(S.size()!=1 && tot>=*S.begin()) ++ans, tot-=*S.begin(), S.erase(S.begin());
	if(S.size()==1 && tot==*S.begin()) ++ans;
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long attack(long n) {
  if (n == 1) {
    return 1;
  }
  else {
    return 2*attack(n/2) + 1;
  }
}
 
int main() {
  long h;
  
  cin >> h;

  cout << attack(h) << endl;
  
}

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

int k[39];

int main(){
  int n,m;
  cin >> n >> m;
  for(int i=0;i<39;i++){
    k[i] = 0;
  }
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    for(int j=0;j<x;j++){
      int y;
      cin >> y;
      y--;
      k[y]++;
    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(k[i]==n){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
base = input().split()
num = []
for i in base:
    num.append(int(i))
x = 0
y = 0
for s in num:
    if s%2==0:
        x += 1
        if s%3==0 or s%5==0:
            y += 1
if x==y:
    print("APPROVED")
else:
    print("DENIED")

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

signed main() 
{
   // haha
    int n;
    cin>>n;
    int s=0;
    int t=pow(n,3);
    int c=0;
    for(int i=2;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            for(int z=i;z<=n;z+=i)
            {
                int l=__gcd(j,z);
                for(int h=i;h<=n;h+=i)
                {
                    if(__gcd(l,h)==i)
                    {
                    c++;
                    s+=i;
                    }
                    
                }
            }
        }
       // cout<<s<<endl;
    }
   // cout<<s<<endl;
    cout<<t-c+s;
    
   
}
    
    

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int m = 100000+100;
    int n;cin>>n;
    VL a(n);
    VL x(m);
    LL result = 0;
    REP(i,n){
        int tmp;cin>>tmp;
        a[i] = tmp;
        result += tmp;
        x[tmp]++;
    }

    int q;cin>>q;
    REP(qq,q){
        int b,c;cin>>b>>c;
        result -= x[b]*b;
        result += x[b]*c;
        x[c] += x[b];
        x[b] = 0;
        cout<<result<<endl;
    }

    
	return;
}

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

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

using namespace std;

#define mod 1000000007
#define inf 1e18


int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int a, b, c, d, e;
  cin >> a >> b >>  c >> d >> e;
  if (a == 0) {
    cout << "1" << endl;
  } else if (b == 0) {
    cout << "2" << endl;
  } else if (c == 0) {
    cout << "3" << endl;
  } else if (d == 0) {
    cout << "4" << endl;
  } else {
    cout << "5" << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

int main()
{
	ll n, m, x;
	ll sum = 0;
	scanf("%lld %lld", &n, &m);
	for (ll i = 0; i < m; i++)
	{
		scanf("%lld",&x);
		sum += x;
	}
	if (sum > n)
		printf("-1\n");
	else
		printf("%lld\n",n - sum);
	return 0;	
}

Measured memory_bytes: 3824
k,a,b = (int(i) for i in input().split())
res = 1
if k >= a-1:
    res += a-1
    k -= a-1
else:
    res += k
    k = 0
if k > 0:
    if b-a > 2:
        res += (b-a) * (k//2)
        if k%2==1:
            res += 1
    else:
        res += k

print(res)

Measured memory_bytes: 3060
from sys import stdin
rr = lambda: stdin.readline().strip()
rrI = lambda: int(rr())
rrM = lambda: map(int, rr().split())

X = rrI()
def solve(X):
    i = 0
    a = X
    while a > 0:
        i += 1
        a -= i
    return i
print solve(X)


Measured memory_bytes: 28652
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i, j;
		int work;
		int[] x = new int[3];
		
		for (i = 0; i < x.length; i++) {
			x[i] = scanner.nextInt();
		}
		
		for (i = 0; i < x.length; i++) {
			for (j = 0; j < x.length-1 - i; j++) {
				if (x[j] > x[j+1]) {
					work = x[j];
					x[j] = x[j+1];
					x[j+1] = work;
				}
			}
		}
		
		for (i = 0; i < x.length; i++) {
			if (i != 0)
				System.out.print(" ");
			System.out.print(x[i]);
		}
		System.out.print("\n");
		scanner.close();
	}
}

Measured memory_bytes: 17164
//04
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  for(;;){
    int h[5];
    int k[4]={};
    for(int i=0;i<5;i++){
      cin>>h[i];
      if(h[i]==0)return 0;
      k[h[i]]=1;
    }
    if(count(k,k+4,1)!=2){
      for(int i=0;i<5;i++){
	cout<<3<<endl;
      }
    }else{
      int n=find(k+1,k+4,0)-k;
      for(int i=0;i<5;i++){
	cout<<((n%3+1==h[i])?1:2)<<endl;
      }
    }
  }
  return 0;
}
      

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    long long c[1000][3];
    for(int i = 0; i < n; i++){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }
    long long sum1[1000];
    long long sum2[1000];
    long long sum3[1000];
    long long sum4[1000];
    long long sum5[1000];
    long long sum6[1000];
    long long sum7[1000];
    long long sum8[1000];

    for(int i = 0; i < n; i++){
        sum1[i] = c[i][0] + c[i][1] + c[i][2];
        sum2[i] = c[i][0] + c[i][1] - c[i][2];
        sum3[i] = c[i][0] - c[i][1] + c[i][2];
        sum4[i] = -c[i][0] + c[i][1] + c[i][2];
        sum5[i] = -c[i][0] + c[i][1] - c[i][2];
        sum6[i] = -c[i][0] - c[i][1] + c[i][2];
        sum7[i] = c[i][0] - c[i][1] - c[i][2];
        sum8[i] = -c[i][0] - c[i][1] - c[i][2];
    }
    sort(sum1,sum1+n);
    sort(sum2,sum2+n);
    sort(sum3,sum3+n);
    sort(sum4,sum4+n);
    sort(sum5,sum5+n);
    sort(sum6,sum6+n);
    sort(sum7,sum7+n);
    sort(sum8,sum8+n);
    long long ans = 0;
    long long tmp[8];
    for(int i = 1; i <= m; i++){
        tmp[0] += sum1[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[1] += sum2[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[2] += sum3[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[3] += sum4[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[4] += sum5[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[5] += sum6[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[6] += sum7[n-i];
    }
    for(int i = 1; i <= m; i++){
        tmp[7] += sum8[n-i];
    }
    for(int i = 0; i < 8; i++){
        ans = max(ans, tmp[i]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, t, mini = 1e9;
	cin >> n >> t;
	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		if(b <= t)
			mini = min(mini, a);
	}
	if(mini == 1e9)
		return cout << "TLE", 0;
	cout << mini;
}

Measured memory_bytes: 256
def main():
    N,M=map(int,input().split())
    pS=[list(input().split()) for i in range(0,M)]
    atcoderresult=[[0,0] for i in range(0,N+1)]
    for i in range(0,M):
        if pS[i][1]=='WA' and atcoderresult[int(pS[i][0])][0]==0:
            atcoderresult[int(pS[i][0])][1]=atcoderresult[int(pS[i][0])][1]+1
        if pS[i][1]=='AC':
            atcoderresult[int(pS[i][0])][0]=1
    ac=0
    penalty=0
    for i in range(1,N+1):
        if atcoderresult[i][0]==1:
            ac=ac+1
            penalty=penalty+atcoderresult[i][1]
    print(ac,penalty)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36184
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

x = ii()
mon = 100
for i in range(1,10000):
    mon *= 1.01
    mon = int(mon)
    if mon >= x:
        ans = i
        break
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main(){
    int n;cin >> n;
    double sm=0.0;
    for(int i=0;i<n;i++){
        string s;
        double x;
        cin >> x >> s;
        if(s=="JPY"){
            sm+=x;
        }
        else{
            sm+=x*380000.0;
        }
    }
    cout << sm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 300005

ll n,k;
ll arr[MAXN];

ll cnt=0;
ll startr[MAXN];
ll rs[MAXN];

vi ans;

set<ll> ind[MAXN];

void brute(int u){
	bool occ[MAXN];
	
	forn(i,u,n)
	{
		if(!occ[arr[i]]){
			ans.pb(arr[i]);
			occ[arr[i]]=1;
		}
		
		else{
			while(occ[arr[i]]){
				occ[ans.back()]=0;
				ans.pop_back();
			}
		}
	}
}

int next(int u){
	startr[u]=cnt;
	
	set<ll>::iterator it = ind[arr[u]].upper_bound(u);
	if(it!=ind[arr[u]].end()) return *it;
	
	cnt++;
	return *ind[arr[u]].lower_bound(0);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	mset(startr,-1);
	
	cin>>n>>k;
	forn(i,0,n){
		cin>>arr[i];
		ind[arr[i]].insert(i);
	}
	
	int cur=0;
	while(cnt<k && startr[cur]==-1){
		rs[cnt]=cur;
		
		cur=next(cur);
		cur++;
		if(cur==n){
			cnt++;
			cur-=n;
		}		
	}
	
	//forn(i,0,n) cout<<"startr["<<i<<"]="<<startr[i]<<'\n';
	//forn(i,0,n) cout<<"rs["<<i<<"]="<<rs[i]<<'\n';
	//watch(cnt); watch(cur);
	
	if(cnt>=k){
		if(rs[cnt-1]<n) brute(rs[cnt-1]);
	}
	else{
		ll period=cnt-startr[cur]; //watch(period); watch(startr[cur]);
		k-=startr[cur];
		k%=period;
		k--;
		if(k<0) k+=period;
		brute(rs[startr[cur]+k]);
	}
	
	forn(i,0,ans.size()) cout<<ans[i]<<" ";
	cout<<'\n';
	
	return 0;
}


Measured memory_bytes: 32624
s = input()
K = int(input())
lst = []
for end in range(1, min(K+1, len(s)+1)):
    start = 0
    while end < len(s)+1:
        if s[start:end] not in lst:
            lst.append(s[start:end])
        start += 1
        end += 1
lst.sort()
print(lst[K-1])

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

using namespace std;

int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<long long>v(4,0);
    v[0]=a*c;
    v[1]=a*d;
    v[2]=b*c;
    v[3]=b*d;
    long long max=v[0];
    for(int i=1;i<4;i++){
        if(v[i]>max)
            max=v[i];
    }
    cout<<max;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



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

    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[1 << 18], b[1 << 18], c[1 << 18], d[1 << 18], e[1 << 18], dist[1 << 18]; vector<pair<int, int>>x[1 << 18], y[1 << 18];
int main() {
	scanf("%d%d%d", &n, &m, &q); for (int i = 1; i <= m; i++) { d[i] = (1 << 30); e[i] = 0; }
	for (int i = 1; i <= m; i++) { scanf("%d%d", &a[i], &b[i]); }
	for (int i = 1; i <= q; i++) { scanf("%d", &c[i]); d[c[i]] = i; }
	for (int i = 1; i <= m; i++) { x[a[i]].push_back(make_pair(b[i], d[i])); x[b[i]].push_back(make_pair(a[i], d[i])); }
	fill(dist, dist + n + 1, -1); dist[1] = 0; queue<int>Q1; Q1.push(1);
	while (!Q1.empty()) { int a1 = Q1.front(); Q1.pop(); for (pair<int, int>i : x[a1]) { if (dist[i.first] == -1) { dist[i.first] = dist[a1] + 1; Q1.push(i.first); } } }
	for (int i = 1; i <= n; i++) { for (pair<int, int>j : x[i]) { if (dist[i] < dist[j.first]) { y[i].push_back(j); } } }
	priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>>Q; Q.push(make_pair(1 << 30, 1)); e[1] = (1 << 30);
	while (!Q.empty()) {
		int a1 = Q.top().first, a2 = Q.top().second; Q.pop();
		for (int i = 0; i < y[a2].size(); i++) {
			if (e[y[a2][i].first] < min(y[a2][i].second, a1)) {
				e[y[a2][i].first] = min(y[a2][i].second, a1);
				Q.push(make_pair(e[y[a2][i].first], y[a2][i].first));
			}
		}
	}
	sort(e + 1, e + n + 1); int T = 1;
	for (int i = 1; i <= q; i++) {
		while (e[T] <= i) { T++; }printf("%d\n", T - 1);
	}
	return 0;
}

Measured memory_bytes: 28548
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

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

Measured memory_bytes: 3652