akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
void read(T&);
template<class T>
void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
  ll n;
  read(n);
  ll ans = n - 1;
  for (int i = 2; i * 1ll * i <= n; ++i) {
    if (n % i == 0) {
      ans = min(ans, i + (n / i) - 2);
    }
  }
  write(ans), EL;
  return 0;
}

template<class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template<class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin>>s;
	int l=s.length();
	int i=l-1;
	for (;i>=0;i--)
		if (s[i]!='9') break;
	if (i==-1) cout<<l*9<<endl;
	else if (i==0) cout<<(l-1)*9+s[0]-'0';
	else cout<<(l-1)*9+s[0]-'0'-1;
	return 0;
}

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

using namespace std;

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    else if (t == u) b--;
    cout << a << " " << b << endl;
    return 0;
}

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

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

long long modpow(long long b, long long p) {
  if (p == 0) {
    return 1;
  }
  long long ans = modpow(b * b % MOD, p / 2);
  if (p % 2 == 1) {
    ans = (ans * b) % MOD;
  }
  return ans;
}

vector<long long> fac((int) 1e5 + 1);

long long C(int n, int k) {
  return fac[n] % MOD * modpow(fac[k], MOD - 2) % MOD * modpow(fac[n - k], MOD - 2) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fac[0] = 1;
  for (int i = 1; i <= (int) 1e5; i++) {
    fac[i] = (i * fac[i - 1]) % MOD;
  }
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = k - 1; i < n; i++) {
    ans = (ans + a[i] * C(i, k - 1)) % MOD;
  }
  reverse(a.begin(), a.end());
  for (int i = k - 1; i < n; i++) {
    ans = ((ans - a[i] * C(i, k - 1)) % MOD + MOD) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    int N, M;
    cin >> N;
    vector<string> blueCard(N);
    map<string, int> countDict;
    for(int i = 0; i < N; i++){
        string str;
        cin >> str;
        auto itr = countDict.find(str);
        if(itr != countDict.end()) countDict[str] += 1;
        else countDict[str] = 1;
    }

    cin >> M;
    for(int i = 0; i < M; i++){
        string str;
        cin >> str;
        auto itr = countDict.find(str);
        if(itr != countDict.end()) countDict[str] -= 1;
        else countDict[str] = -1;
    }

    int maxPrice = 0;
    for(auto itr = countDict.begin(); itr != countDict.end(); ++itr) {
        if(maxPrice < itr->second) maxPrice = itr->second;
    }
    cout << maxPrice << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int n ;
const int N = 1e5 + 10 ;
int a[N] ;
signed main() {
  cin >> n ;
  for(register int i = 1 ; i <= n ; i ++) {
    int x ;
    cin >> x ;
    a[x] = i ;
  }
  for(register int i = 1 ; i <= n ; i ++) cout << a[i] << ' ' ;
  return 0 ;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:> 
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll solve(){
    ll res = 0;
    ll N,A,B; cin >> N >> A >> B;
    vector<ll> X(N); for(auto& in:X) cin >> in;
    for(int i = 0; i <N-1;i++){
        res += min(B,(X[i+1]-X[i])*A);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+10;
const int mod = 1e9+7;
ll dp[N];
ll a[N];
int main() {
	int n;
	cin>>n;
	int cnt=1;
	for(int i=3;i<=n;i++) {
		a[cnt++] = i; 
	}
	int sum = n;
	dp[0] = 1;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<cnt;j++) {
			if(i>=a[j]) {
				dp[i]  = (dp[i]+dp[i-a[j]])%mod;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int h = s.nextInt();
        int n = s.nextInt();
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int ai = s.nextInt();
            sum += ai;
        }
        System.out.println(sum >= h ? "Yes" : "No");
    }
}


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


int main() {
  int N, T, A;
  cin >> N >> T >> A;
  
  vector<int> H(N);
  
  for (int i=0; i<N; i++) {
    cin >> H[i];
  }
  
  vector<double> P(N);
  
  for (int i=0; i<N; i++) {
    P[i] = A - (T - H[i] * 0.006);
    if (P[i] < 0) P[i] = -P[i];
  }
  
  int best = 0;
  for (int i=0; i<N; i++) {
    if (P[i] < P[best]) best = i;
  }
  
  cout << best + 1 << endl;
    
  
 
}

Measured memory_bytes: 256
//(今までにパーを出した回数)≦(今までにグーを出した回数)　
fun main(arg: Array<String>) {
    val S = next()
    var p = 0
    var g = 0
    var w = 0
    var l = 0
    S.forEach { s ->
        if (s == 'g') {
            if (p < g) {
                w += 1
                p += 1
            } else {
                g += 1
            }
        } else if (s == 'p') {
            if (p < g) {
                p += 1
            } else {
                l += 1
                g += 1
            }
        }
    }
    val ans = w - l
    println(ans)
}
inline fun Long.ceilDiv(n: Long) = (this + n - 1) / n

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 34448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)

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

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

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

int h, w;
const int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
vector<string> donut;
bool visited[10][20];

inline unsigned long long hash(const string& s) {
	const unsigned long long base = 1000000007;
	long long res = 0;
	for(int i = 0; i < s.size(); ++i) {
		res *= base;
		res += s[i];
	}

	return res;
}

string spell(int x, int y, int d) {
	if(visited[y][x])
		return "";

	visited[y][x] = true;
	string res = donut[y][x] + spell((x + dx[d] + w) % w, (y + dy[d] + h) % h, d);
	visited[y][x] = false;
	return res;
}

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

	const string init(2, 'z' + 1);

	while(cin >> h >> w, h) {
		donut.clear();
		donut.resize(h);
		for(int i = 0; i < h; ++i)
			cin >> donut[i];

		string ans = init;
//		set<string> s;
		set<unsigned long long> s;
		map<string, int> cnt;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				for(int d = 0; d < 8; ++d) {
					const string str = spell(j, i, d);
					for(int i = ans.size(); i <= str.size(); ++i) {

						const string tmp = str.substr(0, i);
/*
						if(s.find(tmp) == s.end())
							s.insert(tmp);
*/

						const unsigned long long h = hash(tmp);
						if(s.find(h) == s.end())
							s.insert(h);

						else if(ans.size() < tmp.size() || (ans.size() == tmp.size() && tmp < ans))
							ans = tmp;
					}
				}
			}
		}

		cout << (ans != init ? ans : "0") << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 7412
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MMAX=2*1e5+3,NMAX=500+4;
int n,m,q,depart[MMAX],arrive[MMAX],l,r,prefixSum[NMAX][NMAX];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m >> q;
	
	for(int i=0;i<m;i++){
		cin >> depart[i] >> arrive[i];
		
		prefixSum[depart[i]][arrive[i]]++;
	}
	
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			prefixSum[i][j]+=prefixSum[i][j-1];
		}
	}
	
	for(int i=0;i<q;i++){
		cin >> l >> r;
		int ans=0;
		
		for(int d=l;d<=r;d++){
			ans+=prefixSum[d][r];
			
		}	
		cout << ans << '\n';
	}
	
}


Measured memory_bytes: 3456
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,i,j;
  int max,min;
  int *num;
  scanf("%d",&a);
  num=(int *)malloc(a * sizeof(int));
  for(i=0;i<a;i++){
    scanf("%d",&num[i]);
  }
  max=num[1]-num[0];
  min=num[0];
  for(j=1;j<a;j++){
    if(max>(num[j]-min))max=max;
    else if(max<(num[j]-min))max=num[j]-min;
    if(min<num[j])min=min;
    else if(min>num[j])min=num[j];
    }
  printf("%d\n",max);
  free(num);
  return 0;
}



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

int main() {
	int n,point,sum,ma,mi;
	
	while(cin>>n){
		if(n==0)break;
		sum=0;
		ma=0;
		mi=1000;
		for(int i=0;i<n;i++){
			cin>>point;
			sum+=point;
			if(ma<point)ma=point;
			if(mi>point)mi=point;
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;;
			}
	
	
	return 0;
}

Measured memory_bytes: 3096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#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>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int res=0;
    long long int num=0;
    while(res!=N){
        ++res;
        if(res<=K){
            num+=X;
        }
        else{
            num+=Y;
        }
    }
    cout << num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int A[10];

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int ans = INF;
    for (int i = 0; i < 3; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < 3; i++) {
        if (A[i] % 2) {
            chmin(ans, A[(i + 1) % 3] * A[(i + 2) % 3]);
        } else
            ans = 0;
    }
    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include <math.h>
long long int dp[100005];
int p;
long long int h[100005];

long long int least(int n);

long long int minn(long long int t1, long long int t2);

int main()
{
//    int n;
for(int i=0;i<100005;i++)
{
    dp[i]=-1;
}
    scanf("%d",&p);
    for(int i=0;i<p;i++)
    {
        scanf("%lld",&h[i]);
    }
    long long ans=least(0);
    printf("%lld\n",ans);
    return 0;
}

long long int least(int n)
{
    if(n==p-2)
    {
        long long t=fabs(h[p-2]-h[p-1]);
        return t;
    }
    if(n==p-1)
    {
        return 0;
    }
    if(dp[n]==-1)
    {
        long long int t1, t2;
        t1 = fabs(h[n] - h[n + 1]) + least(n + 1);
        t2 = fabs(h[n] - h[n + 2]) + least(n + 2);
        dp[n] = minn(t1,t2);
//        printf("Hi\n");
    }
    return dp[n];
}

long long int minn(long long int t1, long long int t2)
{
    if(t1>t2)
        return t2;
    else
        return t1;
    //return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int j = 11;
    bool y = 1;
    while (n) {
        bool y = 1;
        for (int k = 2 ; k < j ; k++) if (j % k == 0) y = 0;
        if (y && j % 5 == 1) n--, cout << j << ' ';
        j++;
    }
}


Measured memory_bytes: 3604
#include<iostream>
#include<queue>
#include<cstring>
#include<utility>
using namespace std;

/*
二次元格子上の幅優先探索。
点(gx,gy)への最小のコストはmin_cost[gx][gy],行けなければ-1を返す
startは点(sx,sy)
計算量O(WH)
*/
int h, w;
char grid[500][500];
int min_cost[500][500];

int bfs(int sx, int sy, int gx, int gy) {
	const int vx[] = { 0, 1, 0, -1 }, vy[] = { 1, 0, -1, 0 };
	memset(min_cost, -1, sizeof(min_cost));//min_costの初期化

	queue<pair<int, int>>que;
	que.emplace(sx, sy);
	min_cost[sx][sy] = 0;

	while (!que.empty()) {
		auto p = que.front(); que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + vx[i], ny = p.second + vy[i];
			if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
			if (min_cost[nx][ny] != -1) continue;//もう来た
			if (grid[ny][nx] == '#') continue;//進めない
			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
			que.emplace(nx, ny);
		}
	}
	return min_cost[gx][gy];
}

int main() {
	cin >> h >> w;
	int m = -1;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
		cin >> grid[i][j];
		if (grid[i][j] == '.')m++;
	}
	int a = bfs(0, 0, w - 1, h - 1);
	if (a == -1)cout << a << endl;
	else cout << m - bfs(0, 0, w - 1, h - 1) << endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int W, H;
    cin >> W >> H;
    ll P[W], Q[H];
    for (int i = 0; i < W; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < H; i++) {
        cin >> Q[i];
    }

    sort(P, P+W);
    sort(Q, Q+H);

    int p = 0, q = 0;
    ll ans = 0LL;
    for (int i = 0; i < W + H; i++) {
        if (q == H || (p < W && P[p] < Q[q])) {
            ans += P[p] * (H + 1 - q);
            p++;
        } else {
            ans += Q[q] * (W + 1 - p);
            q++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    if k==a[0]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    exit()
g=gcd(a[0],a[1])
mx=max(a)
for i in range(2,n):
    g=gcd(g,a[i])
if k%g==0 and k<=mx:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14252
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

pls give {
    AC;
    int arr[3];
    for (int i=0; i<3; i++) cin >> arr[i];
    sort(arr, arr+3);
    cout << arr[0] + arr[1];

}

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

int main() {
  // 塩基の入力
  char b;
  cin >> b;
  // 塩基の出力
  if(b == 'A'){
    b = 'T';
  }else if(b == 'T'){
    b = 'A';
  }else if(b == 'C'){
    b = 'G';
  }else{
    b = 'C';
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 2e5 + 1;
const ll INF = 1e18;
const ld pi = acos(-1);

ll n, ans = 1;
vector<int> a;

int main() {

    faster();
    
    cin >> n;

    for (int i = 0, x; i < n; i++) {
        cin >> x;
        if (a.empty() || x != a.back())
            a.push_back(x);
    }

    n = a.size();

    for (int i = 1; i + 1 < n; ++i) {
        if (a[i] > max(a[i - 1], a[i + 1]) || a[i] < min(a[i - 1], a[i + 1])) {
            ans++;
            i++;
        }
    }
    cout << ans;

    return 0;
}

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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];

  vector<int> x(3), y(3);
  x[0] = 0;
  rep(i, 3) y[i] = c[0][i] - x[0];
  rep(i, 3) x[i] = c[i][0] - y[0];

  bool good = true;
  rep(i, 3) rep(j, 3) if (x[i] + y[j] != c[i][j]) good = false;
  cout << (good ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int i,N;
  char S[10010];
  if(scanf("%d%s",&N,S)<2) return 1;
  for(i=0;S[i];i++){
    printf("%c",(S[i]+N-'A')%26+'A');
  }
  printf("\n");
  return 0;
  
}

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

int main() {
  int h,w;
  cin >>h>>w;
  vector<vector<char>>a(h,vector<char>(w));
  vector<bool>tate(h);
  vector<bool>yoko(w);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    yoko[i]=true;
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        yoko[i]=false;
        break;
      }
    }
  }
  for(int j=0;j<w;j++){
    tate[j]=true;
    for(int i=0;i<h;i++){
      if(a[i][j]=='#'){
        tate[j]=false;
        break;
      }
    }
  } 
  for(int i=0;i<h;i++){
    if(yoko[i]==true)continue;
    for(int j=0;j<w;j++){
      if(tate[j]==true)continue;
      cout<<a[i][j];
    }
    cout<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// 0-indexed 2部マッチング
class BM{
public:
	vector<vector<int> >G;
	vector<int>match;
	vector<int>used;
	BM(int n){
		G.resize(n);
	}
	void addEdge(int from, int to){
		G[from].push_back(to);
		G[to].push_back(from);
	}
	bool dfs(int v){
		used[v] = 1;
		for (int i = 0; i < G[v].size(); i++){
			int u = G[v][i];
			int w = match[u];
			if (w < 0 || (!used[w] && dfs(w))){
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
	int flow(){
		int res = 0;
		match.clear();
		match.resize(G.size(), -1);
		for (int v = 0; v < G.size(); v++){
			if (match[v] < 0){
				used.clear();
				used.resize(G.size(), 0);
				if (dfs(v)){
					res++;
				}
			}
		}
		return res;
	}
};

int main(){

    ll N;
    cin >> N;
    BM bm(N + N);
    vector<ll>X(N), Y(N);
    for(ll i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
    }
    for(ll i = 0; i < N; i++){
        ll x, y;
        cin >> x >> y;
        for(ll j = 0; j < N; j++){
            if(X[j] < x && Y[j] < y){
                bm.addEdge(j, N + i);
            }
        }
    }
    cout << bm.flow() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int ab = Math.abs(b - a);
    int bc = Math.abs(c - b);
    int ca = Math.abs(a - c);
    
    if (a <= b && b <= c) {
      System.out.println(ab + bc);
    } else if (a <= c && c <= b) {
      System.out.println(ca + bc);
    } else if (b <= a && a <= c) {
      System.out.println(ab + ca);
    } else if (b <= c && c <= a) {
      System.out.println(bc + ca);
    } else if (c <= a && a <= b) {
      System.out.println(ca + ab);
    } else if (c <= b && b <= a) {
      System.out.println(bc + ab);
    }
  }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int see = 2 * d + 1;
		int ans = n / see;
		if(n % see != 0)
			ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve()
{
	ll k;
	cin>>k;
	ll a = 7;
	map<ll,ll> m;
	ll cnt = 1;
	while(a%k!=0&&m[a%k]!=1)
	{
		m[a%k] = 1;
		a = (a*10+7)%k;
		cnt++;
		// cout<<a%k<<endl;
	}
	if(a%k==0)
	{
		cout<<cnt<<endl;
	}
	else
		cout<<-1<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 66096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
           
            var a = 1;
            while (true)
            {
                var b = int.Parse(Console.ReadLine());
                if(b == 0)
                {
                    break;
                }
                Console.WriteLine("Case {0}: {1}", a, b);
                a++;
            }
           
        }
    }
}

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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();

        while(true){
            String input = br.readLine();
            String[] strArray = input.split(" ");

            int x = Integer.parseInt(strArray[0]);
            int y = Integer.parseInt(strArray[1]);

            int changeBox;

            if(x == 0 && y == 0){
                break;
            }

            if(x > y){
                changeBox = x;
                x = y;
                y = changeBox;
            }
            output.append(Integer.toString(x)).append(" ").append(Integer.toString(y)).append("\n");
        }
            System.out.print(output);
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

struct Edge
{
    int to, cost, memo;
};

int n;
using Graph = vector<vector<Edge>>;
Graph g(10000);

int dfs(int cur, int pre)
{
    int ret = 0;
    for (auto &e : g[cur])
    {
        if (e.to == pre)
            continue;
        if(e.memo == -1){
            e.memo = dfs(e.to, cur);
        }
        ret = max(ret, e.memo + e.cost);
    }
    return ret;
}

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

    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int s, t, w;
        cin >> s >> t >> w;
        g[s].push_back(Edge{t, w, -1});
        g[t].push_back(Edge{s, w, -1});
    }
    for (int i = 0; i < n; i++)
    {
        cout << dfs(i, -1) << endl;
    }
}



Measured memory_bytes: 3900
n=int(input())
A=list(map(int,input().split()))[::-1]
B=[0]*n
for i in range(n):
  k=n-i
  if A[i]!=(B[k-1::k].count(1))%2:
    B[k-1]=1
    
o=B.count(1)
print(o)
P=[[i+1 for i, x in enumerate(B) if x ==1]]
if o!=0:
  print(*P[0])


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

using namespace std;

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

#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, w, h;

int main () {
    scanf("%d%d%d", &n, &w, &h);
    printf("%d", (n-w+1)*(n-h+1));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int d;
    int i;
    cin >> N;

    vector<int> v;
    for(i=0; i<N; i++){
        cin >> d;
        v.push_back ( d );
    }
    std::sort(v.begin(), v.end() );

    cout << (v[N/2] - v[N/2 - 1]) << endl;

    return 0;
}


Measured memory_bytes: 892
import sys
  
for s in sys.stdin:
    m,f,r = [ int(x) for x in s.split() ]
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    else:
        total = m+f
        if total >= 80:
            print('A')
        elif total >= 65 and total < 80:
            print('B')
        elif total >= 50 and total < 65:
            print('C')
        elif total >= 30 and total < 50:
            if r >= 50:
                print('C')
            else:
                print('D')
        elif total < 30:
            print('F')


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;


int main(){
    ll N; cin >> N;
    vi a(N+1); vi b(N+1); vi c(N+1);
    for(int i=1; i<=N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    ll dp[N+2][3];
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i=2; i<=N; i++){
        for(int j=0; j<=3; j++){
            if(j == 0){
                dp[i][j] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
            }
            else if(j == 1){
                dp[i][j] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
            }
            else{
                dp[i][j] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
            }
        }
    }
    ll h = max(dp[N][0], dp[N][1]);
    cout << max(h, dp[N][2]);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fprintf(stderr, "\n"), fflush(stderr)

typedef long long ll;

using namespace std;

const ll inf = static_cast<const ll>(1e18);
const int infi = static_cast<const int>(1e9);


void solve() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int r = 0;
    for (int i = 0; i < n; i++) {
        set<char> T{a[i], b[i], c[i]};
        r += T.size() - 1;
    }
    cout << r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef SIR
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c, x, i;
	x = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = 0; i < 5; i++){
		if( a > b){
			x = a;
			a = b;
			b = x;
		}
		if( b > c){
			x = b;
			b = c;
			c = x;
		}
		if( a > c){
			x = c;
			c = a;
			a = x;
		}
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2068
import java.util.*;

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

        long a = input.nextLong();
        long b = input.nextLong();

        if((a+b)%2 == 0 ) {
            System.out.println((a+b)/2);
        }else {
            System.out.println("IMPOSSIBLE");
        }

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=4e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll h,w;
ll d[MAXn][MAXn];
ll dsu[MAXn*MAXn],sz[MAXn*MAXn],bsz[MAXn*MAXn];
bitset<MAXn*MAXn> chk;
ll dx[] = {-1,0};
ll dy[] = {0,-1};
void init(){
  REP (i,h) REP (j,w) {
    if (d[i][j] == 1) bsz[i*w+j] = 1;
    sz[i*w+j] = 1, dsu[i*w+j] = i*w+j;
  }
}
ll fd(ll x){
  if (x == dsu[x]) return x;
  return dsu[x] = fd(dsu[x]);
}
void mrg(ll x,ll y){
  debug(x,y);
  x = fd(x), y = fd(y);
  if (x == y) return;
  if (sz[x] > sz[y]) swap(x,y);
  dsu[x] = y;
  sz[y] += sz[x];
  bsz[y] += bsz[x];
}
ll ok(ll x,ll y){
  return x<0 || x>=h || y<0 || y>=w;
}
void gogo(ll x,ll y){
  REP (i,2) {
    ll tx = x + dx[i], ty = y + dy[i];
    if (ok(tx,ty)) continue;
    debug(x,y,tx,ty);
    if (d[x][y] != d[tx][ty]) mrg(x*w+y,tx*w+ty);
  }
}
int main(){
  IOS();
  cin >> h >> w;
  REP (i,h) REP (j,w) {
    char x;
    cin >> x;
    if (x == '#') d[i][j] = 1;
    else d[i][j] = 0;
  }
  init();
  REP (i,h) REP (j,w) gogo(i,j);
  ll ans = 0;
  REP (i,h) REP (j,w) debug(dsu[i*w+j]);
  REP (i,h) REP (j,w) {
    ll tmp = fd(i*w+j);
    if (chk[tmp]) continue;
    debug(dsu[tmp],sz[tmp],bsz[tmp]);
    ans += (sz[tmp]-bsz[tmp]) * bsz[tmp];
    chk[tmp] = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5376
import Foundation

let numberOfRabits = readLine()
let arrayOfLikes = readLine()

let numberOfRabitsInt = Int(numberOfRabits!)!
let arrayOfLikesString = String(UTF8String: arrayOfLikes!)!

var mone = 0
var arrOfLikes = (arrayOfLikesString.characters.split(" ").map(String.init))

if arrOfLikes.count == 1 {
    print(1)
} else {
    var amountOfLikes = 0
    for i in 0 ... numberOfRabitsInt - 1 {
       
        let valueInCell = (Int(arrOfLikes[i]))!
        if valueInCell != i + 1 {
            if Int(arrOfLikes[valueInCell - 1])!  == i + 1 {
                amountOfLikes++
            }
        }
    }
    print(amountOfLikes / 2)

}


Measured memory_bytes: 8636
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#define LEN 100005
using namespace std;

struct Process
{
    string name;
    int time;
};

vector<Process> Q(LEN);
int head, tail, n;

void enque(Process p)
{
    Q[tail] = p;
    tail = (tail + 1) % LEN;
}

Process deque()
{
    Process p = Q[head];
    head = (head + 1) % LEN;
    return p;
}

int main()
{
    int n, q;
    cin >> n >> q;
    string name;
    int time;
    int elaps = 0;
    
    for (int i = 1; i <= n; i++)
    {
        cin >> Q[i].name;
        cin >> Q[i].time;
    }
    head = 1;
    tail = n + 1;

    while(head != tail) {
        Process p = deque();
        if(p.time - q > 0){
            p.time = p.time - q;
            elaps += q;
            enque(p);
        } else {
            elaps += p.time;
            cout << p.name << " " << elaps << endl;
        }
    }

    return 0;
}



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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  for (int i = 0; i <= 14; ++i) {
    int rest = n - i * 7;
    if (rest < 0) {
      break;
    }
    if (rest % 4 == 0) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

class Node_Class():
    def __init__(self, key, parent, left, right):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def pre_order(node):
    if node is not None:
        pl.append(node.key)
        pre_order(node.left)
        pre_order(node.right)

def in_order(node):
    if node is not None:
        in_order(node.left)
        il.append(node.key)
        in_order(node.right)

m = int(raw_input())
root = None
for i in range(m):
    line = map(str, raw_input().split())
    if line[0] == "insert":
        z = Node_Class(int(line[1]), None, None, None)
        insert(z)
    else:
        pl = []
        il = []
        pre_order(root)
        in_order(root)
        print " "+" ".join(map(str, il))
        print " "+" ".join(map(str, pl))

Measured memory_bytes: 251652
package main

import (
	"fmt"
	"math"
)

func main() {
	// // Problem A
	// // input
	// var tmp string
	// fmt.Scan(&tmp)

	// // configuration
	// count := 0
	// ans := 0

	// // check
	// for i := 0; i < len(tmp); i++ {
	// 	if string(tmp[i]) == "R" {
	// 		count++
	// 		ans = count
	// 	} else {
	// 		ans = max(ans, count)
	// 		count = 0
	// 	}
	// }

	// // output
	// fmt.Println(ans)

	// // Problem B Making Triangle
	// // input
	// var n int
	// var nums []int
	// fmt.Scan(&n)
	// nums = scanNums(n)

	// // Process
	// if n < 3 {
	// 	fmt.Println(0)
	// } else {
	// 	var L1 int
	// 	var L2 int
	// 	var L3 int
	// 	var count int
	// 	for i := 0; i < (n - 2); i++ {
	// 		for j := i + 1; j < (n - 1); j++ {
	// 			for k := j + 1; k < n; k++ {
	// 				L1 = nums[i]
	// 				L2 = nums[j]
	// 				L3 = nums[k]
	// 				if isOk(L1, L2, L3) == true {
	// 					count++
	// 				}
	// 			}
	// 		}
	// 	}
	// 	fmt.Println(count)
	// }

	// Problem C - Walking Takahashi
	var x int
	var k int
	var d int
	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)

	// process
	x = abs(x)
	count := x / d
	if k < count {
		x = abs(x - k*d)
		fmt.Println(x)
	} else {
		k = k - count
		x = abs(x - count*d)
		if k%2 == 0 {
			fmt.Println(x)
		} else {
			x = abs(x - d)
			fmt.Println(x)
		}
	}
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func isOk(n1 int, n2 int, n3 int) (ok bool) {
	return ((n1+n2 > n3 && n1+n3 > n2 && n2+n3 > n1) && (n1 != n2 && n2 != n3 && n3 != n1))
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}


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

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D, 0);
    vector<int> c(D, 0);
    for (int i = 0; i < D; i++){
        cin >> p.at(i) >> c.at(i);
    }
    int ans = 100000;
    for (int temp = 0; temp < (1<<10); temp++){
        //cout << "temp " << temp << endl;
        bitset<10> s(temp);
        int sum = 0;
        int count = 0;
        for (int i = 0; i < D; i++){
            if (s.test(i)){
                sum += p.at(i)*100*(i+1)+c.at(i);
                count += p.at(i);
            }
        }
        //cout << "sum(all) " << sum << " count(all) " << count << endl;
        if (sum >= G){
            
        }
        else{
            for (int j = D - 1; j >= 0; j--){
                if (!s.test(j)){
                    int count_2 = 0;
                    while (count_2 < p.at(j)){
                        count_2++;
                        sum += 100*(j+1);
                        if (sum >= G) {
                            count += count_2;
                            break;
                        }
                    }
                break;
                }
                
            }
        }
        
        if (ans > count){
            if (sum >= G){
                ans = count;
            }
        }
        //cout << "sum(fin) " << sum << " count(fin) " << count << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  float TT, XX;

  std::cin >> TT>>XX;

  float ans = TT/XX;

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N, K;
int h[100000];

void solve()
{
    int ans = 0;
    REP(i, N){
        if(h[i] >= K) ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N) cin >> h[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main(){
	long long a;
	scanf("%lld",&a);
	int tot=0;
	int flag=true;
	while(a>=10){
		tot+=9;
		if(a%10!=9)flag=false;
		a/=10;
	}
	if(flag==true)tot+=a;
	else
	tot+=a-1;
	printf("%d\n",tot);
}

//99989
//59992

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, M;
long long A[55];
long long B[55];
vector<long long> tree[55];
long long U[25];
long long V[25];

//えだ、状態
long long dp[55][1048580];

long long cut[55];

//
bool dfs(long long pa, long long cur, long long tar) {
	if(cur == tar) {
		return true;
	}
	for(auto next: tree[cur]) {
		if(next != pa) {
			if(dfs(cur, next, tar)) {
				return true;
			}
		}
	}
	return false;
}

int main(){
	cin >> N;
	rep(i, N-1) {
		cin >> A[i] >> B[i];
		A[i]--;B[i]--;
		tree[A[i]].push_back(B[i]);
		tree[B[i]].push_back(A[i]);
	}
	cin >> M;
	rep(i, M) {
		cin >> U[i] >> V[i];
		U[i]--;V[i]--;
	}

	rep(i, N-1) {
		rep(j, M) {
			long long u = U[j];
			long long v = V[j];

			//uがA側にある && vがB側にある
			if(dfs(B[i], A[i], u) && dfs(A[i], B[i], v)) {
				cut[i] |= (1<<j);
			}
			//uがB側にある && vがA側にある
			if(dfs(B[i], A[i], v) && dfs(A[i], B[i], u)) {
				cut[i] |= (1<<j);
			}
		}
	}

	dp[0][0] = 1;
	rep(i, N-1) {
		rep(j, (1<<M)) {
			//使う
			dp[i+1][j|cut[i]] += dp[i][j];
			//使わない
			dp[i+1][j] += dp[i][j];
		}
	}

	cout << dp[N-1][(1<<M) - 1] << endl;
}

Measured memory_bytes: 404992
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//#pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef  long long ll;

const int maxn = (int)2e6 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 998244353;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;



int main() {
	drobucs;

	ll a;
	cin >> a;
	cout << a * a + a + a * a * a;
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<string.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans=c-a+b;
    if(ans>=0)
    printf("%d",ans);
    else
    {printf("0");}
    return 0;
}

Measured memory_bytes: 128
def main():
    import sys

    input = sys.stdin.readline

    x, y, z, k = map(int, input().split())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    C = tuple(map(int, input().split()))

    AB = sorted((a + b for a in A for b in B), reverse=True)[:k]
    ret = sorted((ab + c for ab in AB for c in C), reverse=True)[:k]

    print(*ret, sep='\n')


main()


Measured memory_bytes: 139868