akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, tmp, p, q;
    unordered_map<int64_t, pair<int64_t, int64_t>> list;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        p = i + tmp, q = i - tmp;
        list[p].first++;
        list[q].second++;
    }
    int64_t ans = 0;
    for (auto x : list)
        ans += x.second.first * x.second.second;
    cout << ans;
}

Measured memory_bytes: 24484
#include<stdio.h>

int main(){
	int N,i,j,j_start;
	scanf("%d",&N);
	int A[N];
	int count=0;
	int count_ball=0;
	int count_ball_part=0;
	int boxes[N];

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

	for(i=N-1;i>=0;i--){
		count=N/(i+1);
		if(count==1){
			if(A[i]==1){
				boxes[i]=1;
				count_ball+=1;
			}else{
				boxes[i]=0;
			}
		}else{
			count_ball_part=0;
			j_start=2*i+1;
			for(j=j_start;j<N;j+=(i+1)){
					if(boxes[j]==1){
						count_ball_part+=1;
					}
			}
		
			if(A[i]==1){
				if(count_ball_part%2==0){
					boxes[i]=1;
					count_ball+=1;
				}else{
					boxes[i]=0;
				}
			}else{
				if(count_ball_part%2==0){
					boxes[i]=0;
				}else{
					boxes[i]=1;
					count_ball+=1;
				}
			}
		}
	}

	count=0;
	if(count_ball==0){
		printf("%d\n",count_ball);
	}else{
		printf("%d\n",count_ball);
		for(i==0;i<N;i++){
			if(boxes[i]==1){
				if(count==0){
					printf("%d",i+1);
					count+=1;
				}else{
					printf(" %d",i+1);
				}
			}
		}
		printf("\n");
	}
				
	return 0;
}


Measured memory_bytes: 2432
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int popcnt(int x) {
    int r = 0;
    foreach (i; 0 .. 22) if (x & (1 << i)) r++;
    return r;
}

void main() {
    int N, Hx, Hy, Dx, Dy;
    int[] Y, X;
    bool input() {
        scanf("%d %d %d %d %d\n", &N, &Hx, &Hy, &Dx, &Dy);
        if (N == 0) return false;
        Y = new int[N + 2];
        X = new int[N + 2];
        Y[0] = Hy;
        X[0] = Hx;
        foreach (i; 1 .. N + 1) {
            scanf("%d %d\n", &X[i], &Y[i]);
        }
        Y[N + 1] = Dy;
        X[N + 1] = Dx;
        return true;
    }
    double Distance(int a, int b) {
        double dy = Y[a] - Y[b],
               dx = X[a] - X[b];
        return sqrt(dy * dy + dx * dx);
    }
    void solve() {
        //static double[int] cache[22];
        //cache.clear;
        bool dfs(int v, int used, double t) {
            //writefln("%d %0" ~ (N + 2).to!string ~ "b %f", v, used, t);
            if (used == (1 << (N + 1)) - 1) return true;
            //if (cache[v].get(used, 1e4) <= t) return false;
            //if (v <= N - 8) {
            //    cache[v][used] = t;
            //}
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (Distance(v, i) + t >= Distance(N + 1, i)) return false;
            }
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (dfs(i, used | 1 << i, t + Distance(v, i))) return true;
            }
            return false;
        }
        writeln(dfs(0, 1, 0) ? "YES" : "NO");
    }
    while (input) solve;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvll vector<vetor<ll>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

using namespace std;

int x;
bool dp[110000];

main()
{
        cin>>x;
        dp[100]=true;
        dp[101]=true;
        dp[102]=true;
        dp[103]=true;
        dp[104]=true;
        dp[105]=true;
        rep(i,x)
        {
            if(!dp[i])continue;
            rep(j,6)dp[i+100+j]=true;
        }

        cout<<dp[x]<<endl;

}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int a1, a2, a3, total;
	scanf("%d %d %d", &a1, &a2, &a3);
	total = a1+a2+a3;
	if (total>=22){
		printf("bust\n");
	} else {
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 2056
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    ll K;
    cin >> S >> K;

    char d = '1';
    for (int i = 0; i < K; i++) {
        if (S[i] != '1') {
            d = S[i];
            break;
        }
    }

    cout << d << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

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

Measured memory_bytes: 3636
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int dp[N][3];

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

	long long n;
	cin >> n;
	set <long long> goods;
	auto check = [&] (long long k) {
		return (n % k) == ((n / k));
	};

	for (long long i = 1; 1LL * i * i <= n; i++) {
		if (check(i))
			goods.insert(i);
		if (n % i == 0 && i * i != n && check(n / i - 1))
			goods.insert(n / i - 1);
	}
	long long res = 0;
	for (long long i: goods)
		res += i;
	cout << res << endl;
}

int gcd (int a, int b) {
	return !b? a : gcd (b, a % b);
}

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

Measured memory_bytes: 384
n, m = map(int, input().split())
abList = sorted([list(map(int, input().split())) for _ in range(n)])
abSum = 0
abNum = m
for ab in abList:
    a, b = ab[0], ab[1]
    if b >= abNum:
        abSum += abNum * a
        break
    else:
        abSum += b * a
        abNum -= b
print(abSum)


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

using namespace std;

using ll = long long;

int Check(const int a, const int b, const int c, const int d) {
    int da = d - a, db = d - b, dc = d - c;

    int cnt = 0;
    if (da % 2 == 1) ++cnt;
    if (db % 2 == 1) ++cnt;
    if (dc % 2 == 1) ++cnt;

    if (cnt == 3 || cnt == 1) return -1;

    if (cnt == 0) return da / 2 + db / 2 + dc / 2;
    else return (int)(da / 2) + (int)(db / 2) + (int)(dc / 2) + 1;
}

int Solve() {
    int a, b, c;

    cin >> a >> b >> c;
    int ans = a + b + c;
    const int max_abc = max({a, b, c});
    for (int x = max_abc; x <= 2 * max_abc; ++x) {
        int res = Check(a, b, c, x);
        if (res != -1) ans = min(ans, res);
    }

    return ans;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int d,n;
    cin>>d>>n;
    int x=1;
    for(int i=0;i<d;i++){
        x*=100;
    }
    if(n==100){
        cout<<(n+1)*x<<endl;
    }else{
        cout<<n*x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    __slots__ = ['_tree', '_node_list']
    def __init__(self):
        self._tree = None
        self._node_list = set()
    def insert(self, value):
        self._node_list.add(value)
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        print("yes" if value in self._node_list else "no")
    def preoder_walk(self):
        def preoder(node):
            result = []
            if node is not None:
                result.extend([node.value])
            if node.left is not None:
                result.extend(preoder(node.left))
            if node.right is not None:
                result.extend(preoder(node.right))
            return result
        return preoder(self._tree)
    def inorder_walk(self):
        def inorder(node):
            result = []
            if node is not None:
                result.extend(inorder(node.left))
                result.append(node.value)
                result.extend(inorder(node.right))
            return result
        return inorder(self._tree)
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        tree.find(int(com[1]))
    else:
        print(" " + " ".join(map(str, tree.inorder_walk())))
        print(" " + " ".join(map(str, tree.preoder_walk())))



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

int A[10000],n;

int linearSearch(int key){
  int i=0;
  while( A[i]!=key){
    i++;
    if(i==n)return 0;
  }
  return 1;
}

int main(){
  int i,j,m,num=0,key;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&m);
  for(j=0;j<m;j++){
    scanf("%d",&key);
    num+=linearSearch(key);
  }
  printf("%d\n",num);

  return 0;
}
   



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

using namespace std;
typedef long long int ll;

const int MAXN = 100 * 1000 + 10;
const ll md = 1e9 + 7;
ll k, n, dp[MAXN], ans = 0;

ll pw(ll a, ll b)
{
	if(b == (ll)0)
		return (ll)1;
	if(b % 2 == 0)
		return ((pw(a, b / 2)) * (pw(a, b / 2))) % md;
	return ((((pw(a, b / 2)) * (pw(a, b / 2))) % md) * a) % md;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(ll x = k; x >= 1; x--)
	{
	//	cout << "x " << x << endl;
		dp[x] = pw((k / x), n);
		for(ll y = 2 * x; y <= k; y += x)
		{
			dp[x] -= dp[y];
			dp[x] %= md;
		}
	}
	for(ll x = 1; x <= k; x++)
	{
		ll y = x * dp[x];
		y %= md;
		ans += y;
		ans %= md;
	}
	cout << ans << endl;
	return 0; 
}


Measured memory_bytes: 4428
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;
int a[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<tuple<int, int, int, int>> vp;
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			scanf("%d", &a[i][j]);
			a[i][j] &= 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (i & 1)
		{
			for (int j = 1; j <= m; j++)
			{
				if (a[i][j] & 1)
				{
					if (j < m) vp.emplace_back(i, j, i, j + 1), a[i][j + 1] ^= 1;
					else if (i < n) vp.emplace_back(i, j, i + 1, j), a[i + 1][j] ^= 1;
				}
			}
		}
		else
		{
			for (int j = m; j > 0; j--)
			{
				if (a[i][j] & 1)
				{
					if (j > 1) vp.emplace_back(i, j, i, j - 1), a[i][j - 1] ^= 1;
					else if (i < n) vp.emplace_back(i, j, i + 1, j), a[i + 1][j] ^= 1;
				}
			}
		}
	}
	printf("%d\n", vp.size());
	for (auto& p : vp)
	{
		int x1, y1, x2, y2;
		tie(x1, y1, x2, y2) = p;
		printf("%d %d %d %d\n", x1, y1, x2, y2);
	}
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int a = 1;
  for(int i = 0 ; i < n ; i++){
    if(a <= k){
      a *= 2;
    }else{
      a += k;
    }
  }
  cout << a << endl;
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  int res = 0;
  for (int l = 0; l < K + 1; l++) {
    for (int r = 0; r < K + 1; r++) {
      if (l + r > min(K, N)) continue;
      int m = K - (l + r);

      priority_queue<int, vector<int>, greater<int>> que;
      for (int i = 0; i < l; i++) {
        que.push(V[i]);
      }
      for (int i = 0; i < r; i++) {
        que.push(V[N - i - 1]);
      }
      for (int i = 0; i < m; i++) {
        if (!que.empty() && que.top() < 0) que.pop();
      }
      int sum = 0;
      while (!que.empty()) {
        sum += que.top();
        que.pop();
      }
      res = max(res, sum);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>s;
if(s.size()%2==1)
{
  cout<<"No";
  return 0;
}
for(i=0;i<s.size()-1;i++)
{
  if(s[i]=='h'&&s[i+1]=='i')
  {
    i++;
  }
  else
  {
    flag=1;
    break;
  }
}
if(flag)
{
  cout<<"No";
}
else
{
  cout<<"Yes";
}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

ll gcd(ll a, ll b)
{
      if(!b) return a;
      return gcd(b,a%b);
}

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll N;
      cin>>N;
      ll vagses=N%1000;
      if(vagses==0) cout<<0<<endl;
      else cout<<1000-vagses<<endl;


      bye;
}


Measured memory_bytes: 3648
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

pqr=get_i
puts pqr.inject(:+)-pqr.max

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
signed  main()
{
  int a,p;
  cin>>a>>p;
  if(a<=5){
    cout<<"0\n";
  }else{
    if(a>=6 && a<=12){
      cout<<p/2<<"\n";
    }else{
      cout<<p<<"\n";
    }
  }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define  f first
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define  s second

using namespace std;

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(max(a*c,b*d),max(a*d,b*c));
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
 
  if(a+b<b+c && a+b<a+c)
    cout << a+b << endl;
  else if(b+c<a+b && b+c<a+c)
    cout << b+c << endl;
  else
    cout << a+c << endl;
}


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

int main(){
  int a, b, c;
  char op;
 

  while(1){

 cin >> a >> op >> b;


  if(op == '+'){
    c = a + b;
    cout << c << "\n";
  }

  else if(op == '-'){
      c = a - b;      
      cout << c << "\n";
  }

  else if(op == '*'){
    c = a * b;
    cout << c << "\n";
  }

  else if(op == '/'){
    c = a / b; 
    cout << c << "\n";

  }
  else break;
  }
}

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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int count=0;
	for(int i=0;i<=N;i++){
      int now;
      now=(i/10000+(i%10000)/1000+((i%10000)%1000)/100+(((i%10000)%1000)%100)/10+(((i%10000)%1000)%100)%10);
      if(now>=A&&now<=B){
        count+=i; 
      }
	}
  cout<<count<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout<< max(0, a-2*b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"


int h, w;
int n;
vi a;

bool read() {
	if  (scanf("%d%d", &h, &w) < 2) {
		return 0;
	}
	scanf("%d", &n);
	a.resize(n);
	forn(i, n) {
		scanf("%d", &a[i]);
	}
	return 1;
}

vii get_order() {
	vii res;
	forn(i, h) {
		if  (i & 1) {
			ford(j, w) {
				res.pb(mp(i, j));
			} 
		} else {
			forn(j, w) {
				res.pb(mp(i, j));
			}
		}
	}
	return res;
}

void solve() {
	vii order = get_order();

	vvi c(h, vi(w, -1));
	while (!a.empty()) {
		int i, j;
		tie(i, j) = order.back();
		order.pop_back();
		c[i][j] = sz(a) - 1;
		// eprintf("i=%d, j=%d\n", i, j);
		--a.back();
		if  (!a.back()) {
			a.pop_back();
		}
	}

	forn(i, h) {
		forn(j, w) {
			printf("%d ", c[i][j] + 1);
		}
		puts("");
	}
	puts("");
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		solve();
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

int main() {
	UL F; cin >> F;
	cout << (F - 30) / 2 << endl;

	return 0;
}



Measured memory_bytes: 3104
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    s = [input() for i in range(n)]
    cs = Counter(s)
    print(len(cs))

    return


# Solve
if __name__ == "__main__":
    solve()


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

int main() {
	int n;
	cin>>n;
	long long h,w;
	long cnt=0;
	cin>>h>>w;
	for(int i=0;i<n;i++)
	{
		long long a,b;
		cin>>a>>b;
		if(a>=h&&b>=w)cnt++;
	}
	cout<<cnt;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n), b(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	REP(i, n - 1)a[i+1] += a[i];
	RREP(i, n-1)b[i] += b[i + 1];
	int ans = 0;
	REP(i, n)ans = max(ans, a[i] + b[i]);
	cout << ans << endl;

}


Measured memory_bytes: 256
// AOJ ALDS1_2_D Shell Sort
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cnt;

void insertion_sort(int n, int *a, int g)
{
	int i, j, key;

	for (i = g; i < n; i++) {
		key = a[i];
		j = i-g;
		while (a[j] > key) {
			a[j+g] = a[j];
			j -= g;
cnt++;
			if (j < 0) break;
		}
		a[j+g] = key;
	}
}

int m;
int g[102];

void shell_sort(int n, int *a)
{
	int i, lim;

	lim = n / 9;		// 要素数/9
	if (lim < 40) lim = 40;
	g[0] = 1;
	for (m = 1; ; m++) {
		g[m] = 3*g[m-1]+1;
		if (g[m] >= n || g[m] > lim) break;
	}

	cnt = 0;
	for (i = m-1; i >= 0; i--) insertion_sort(n, a, g[i]);
}

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n, int ln)
{
	int i = 0;
	if (n == 0) buf[i++] = '0';
	else while (n) buf[i++] = n%10 + '0', n/=10;
	while (i) pc(buf[--i]);
	if (ln) pc('\n');
}

int a[1000002];

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	shell_sort(N, a);
	mypr(m, 1);
	mypr(g[m-1], 0);
	for (i = m-2; i >= 0; i--) pc(' '), mypr(g[i], 0);
	pc('\n');
	mypr(cnt, 1);
	for (i = 0; i < N; i++) mypr(a[i], 1);
	return 0;
}


Measured memory_bytes: 5420
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			Queue<Integer> q = new LinkedList<Integer>();
			while (true) {
				String x = sc.nextLine();


				if (x.length() == 1) {
					if (Integer.parseInt(x) == 0) break;					
				}

				int total = 0;

				for (int i=0; i<x.length(); i++) {
					String s = x.substring(i,i+1);
					int a = Integer.parseInt(s);
					total += a;
				}
				q.add(total);
			}
			int a = q.size();
			for (int i=0; i<a; i++) {
				System.out.println(q.remove());
			}
		}
	}
}



Measured memory_bytes: 26892
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
int main() {
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> board(H);
	rep(i,0,H) cin >> board[i];
	int si = -1, sj = -1;
	rep(i,0,H) rep(j,0,W) if (board[i][j] == 'S') si = i, sj = j;
	queue<pii> q;
	q.push(pii(si, sj));
	vector<vi> dists(H, vi(W, -1));
	dists[si][sj] = 0;
 
	vector<pii> onestep;
 
	while (!q.empty()) {
		pii pa = q.front();
		q.pop();
		int di = dists[pa.first][pa.second];
		if (di <= K) onestep.push_back(pa);
		rep(d,0,4) {
			pii pa2 = pa;
			if (d == 0) pa2.first++;
			if (d == 1) pa2.second++;
			if (d == 2) pa2.first--;
			if (d == 3) pa2.second--;
			if (pa2.first < 0 || pa2.second < 0 || pa2.first >= H || pa2.second >= W) continue;
			if (board[pa2.first][pa2.second] == '#') continue;
			if (dists[pa2.first][pa2.second] != -1) continue;
			dists[pa2.first][pa2.second] = di+1;
			q.push(pa2);
		}
	}
 
	dists.assign(H, vi(W, -1));
	trav(pa, onestep) {
		q.push(pa);
		dists[pa.first][pa.second] = 0;
	}
 
	while (!q.empty()) {
		pii pa = q.front();
		q.pop();
		int di = dists[pa.first][pa.second];
		if (di <= K) onestep.push_back(pa);
		rep(d,0,4) {
			pii pa2 = pa;
			if (d == 0) pa2.first++;
			if (d == 1) pa2.second++;
			if (d == 2) pa2.first--;
			if (d == 3) pa2.second--;
			if (pa2.first < 0 || pa2.second < 0 || pa2.first >= H || pa2.second >= W) continue;
			// if (board[pa2.first][pa2.second] == '#') continue;
			if (dists[pa2.first][pa2.second] != -1) continue;
			dists[pa2.first][pa2.second] = di+1;
			q.push(pa2);
		}
	}
 
	int res = INT_MAX;
	rep(i,0,H) rep(j,0,W) {
		if (i == 0 || j == 0 || i == H-1 || j == W-1) {
			res = min(res, dists[i][j]);
		}
	}
 
	cout << (res + K-1) / K + 1 << endl;
 
	exit(0);
}


Measured memory_bytes: 26096
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;

int main() {
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    
}


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

using namespace std;

bool ok(string s) {
  for (const auto& c : s) {
    if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
      return false;
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int len = (int)s.size();
  int ans = 0;
  for (int i = 0; i < len; i++) {
    for (int j = 1; j <= len - i; j++) {
      string ss = s.substr(i, j);
      if (ok(ss)) ans = max(ans, (int)ss.size());
    }
  }
  cout << ans << '\n';
  return 0;
}

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





int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    long A,B,C,K;
    long i;
    long ans;
    cin>>A>>B>>C>>K;
    long a,b,c;
    int tencount=0;
    long x,y,z;

    int l=0;
    if(A==B){
        cout<<l<<endl; 
        l=1;
    }else{
        if(K%2==1){
        	ans = B-A;
        }else{
        	ans=A-B;
        }
    }




   

    int keta=tencount;
    //出力
    //高橋-中橋
    if(l==0){
        if(keta>18){
            cout<< "Unfair"<<endl;
        }else{
            for(i=0;i<tencount;++i){
                ans*=10;
            }
            cout << ans<<endl;
        }
    }
    

    return 0;
}


//3 人は同時に、他の 2 人の持っている整数の和を求める。
//その後、自分の持っている整数を求めた整数で置き換える。

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 100000
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}


int main(){

  ll N, K;
  cin >> N;
  cin >> K;

  vector<ll> A;
  ll temp;
  REP(i, 0, N){
    cin >> temp;
    A.push_back(temp);
  }

  sort(A.begin(), A.end());

  ll ans = 0;
  make();
  REP(max_, K-1, N) { // 2 <= max_ < 6
    ans += A[max_] * comb(max_, K-1);
    ans = ans % 1000000007;
  }
  REP(min_, 0, N-K+1) { // 0 <= min_ < 4
    ans -= A[min_] * comb(N-min_-1, K-1);
    ans = ans % 1000000007;
  }

  if ( ans < 0 ) {
    ans = ans + 1000000007;
  }
  cout << ans << endl;

  return 0;
}


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

int main(void)
{
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	cout.setf(ios::fixed, ios::floatfield);
	cout<<sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const int N = 110;
const int M = 100010;
const ll INF = 2e9;
ll f[N][M], n, max_w, w[N], v[N];

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

  cin >> n >> max_w;
  for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

  for (int i = 0; i < M; i++) f[n - 1][i] = INF;
  f[n - 1][v[n - 1]] = w[n - 1];
  f[n - 1][0] = 0;

  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < M; j++) {
      f[i][j] = f[i + 1][j];
      if (j >= v[i]) f[i][j] = min(f[i][j], w[i] + f[i + 1][j - v[i]]);
    }
  }

  ll ans = 0;
  for (int i = 1; i < M; i++) {
    if (f[0][i] <= max_w) ans = max(ans, (ll)i);
  }
  
  cout << ans << "\n";
}


Measured memory_bytes: 81776
n, s = map(int, input().split())
a = list(map(int, input().split()))

mod = 998244353
dp = [[0] * n for _ in range(3000 + 1)]
dp[a[0]][0] = 1

for i in range(1, s + 1):
    for j in range(1, n):
        if i == a[j]:
            dp[i][j] = dp[i][j-1] + j + 1
        elif i - a[j] > 0:
            dp[i][j] = dp[i][j-1] + dp[i - a[j]][j - 1]
        else:
            dp[i][j] = dp[i][j-1]

        dp[i][j] %= mod

print(sum([dp[s][j] for j in range(n)]) % mod)


Measured memory_bytes: 113244
S = input()
flag = 0
for i in range(0,len(S)//2):
    if S[i] == S[-1-i]:
        continue
    else:
        flag = 1
        print("No")
        break
if flag == 0:
    S = S[:((len(S)-1)//2)]
    for i in range(0,len(S)//2):
        if S[i] == S[-1-i]:
            continue
        else:
            flag = 1
            print("No")
            break
if flag == 0:
    print("Yes")

Measured memory_bytes: 61916
import java.util.*;  
import java.lang.*;  
import java.math.*;  
import java.io.*;  
  
import static java.lang.Math.*;  
import static java.util.Arrays.*;  
  
public class Main{  
  
 Scanner sc=new Scanner(System.in);  
  
 int INF=1<<28;  
 double EPS=1e-9;  
  
 HashMap<Integer, Integer> map;  
 int[] a;  
 int w=4, h=2;  
  
 void run(){  
  a=new int[w*h];  
  init();  
  for(; sc.hasNext();){  
   for(int i=0; i<w*h; i++){  
    a[i]=sc.nextInt();  
   }  
   println(""+map.get(id(a)));  
  }  
 }  
  
 void init(){  
  
  LinkedList<S> que=new LinkedList<S>();  
  map=new HashMap<Integer, Integer>();  
  
  que.offer(new S(0, 0, new int[]{0, 1, 2, 3, 4, 5, 6, 7}));  
  map.put(id(que.peek().a), 0);  
  int[] dx={0, 0, -1, 1};  
  int[] dy={-1, 1, 0, 0};  
  
  for(; !que.isEmpty();){  
   S s=que.poll();  
   int p=s.y*w+s.x;  
   for(int i=0; i<4; i++){  
    int x2=s.x+dx[i];  
    int y2=s.y+dy[i];  
    int p2=y2*w+x2;  
    if(x2>=0&&x2<w&&y2>=0&&y2<h){  
     int[] a2=s.a.clone();  
     int t=a2[p];  
     a2[p]=a2[p2];  
     a2[p2]=t;  
     S s2=new S(x2, y2, a2);  
     if(!map.containsKey(id(s2.a))){  
      que.offer(s2);  
      map.put(id(s2.a), map.get(id(s.a))+1);  
     }  
    }  
   }  
  }  
 }  
  
 int id(int[] a){  
  int res=0;  
  for(int e : a){  
   res=res*10+e;  
  }  
  return res;  
 }  
  
 class S{  
  int x, y;  
  int[] a;  
  
  S(int x, int y, int[] a){  
   this.x=x;  
   this.y=y;  
   this.a=a;  
  }  
 }  
  
 void debug(Object... os){  
  System.err.println(Arrays.deepToString(os));  
 }  
  
 void print(String s){  
  System.out.print(s);  
 }  
  
 void println(String s){  
  System.out.println(s);  
 }  
  
 public static void main(String[] args){  
  // System.setOut(new PrintStream(new BufferedOutputStream(System.out)));  
  new Main().run();  
 }  
}  

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

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

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

 int cnt=0,ans=0,a,b,c,cmp,data,n,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
        
    
        cin >> n >> m;
        
        bool fromisland[200001]={};
        bool toisland[200001]={};
        bool ans=false;
        
        rep(i,m){
            cin >> a >> b;
            if(a==1){
                fromisland[b]=true;
            }
            else if(b==n){
                toisland[a]=true;
            }
        }
        rep(i,n){
            if(fromisland[i] && toisland[i]){
                ans=true;
            }
        }
        Cout((ans ? "POSSIBLE" : "IMPOSSIBLE"));
return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) + "..." << endl;
    }
    return 0;
}


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

int r, g, b;

int main() {

    scanf("%d%d%d", &r, &g, &b);

    if ((100*r + 10*g + b) % 4) {
        // 余りがあるとき => true
        printf("NO\n");
    } else {
        // 余りがないとき0 => False
        printf("YES\n");
    }

    return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
QUERY = []
for i in range(Q):
    # q = list(map(int, input().split()))
    q = input().split()
    if q[0] == '1':
        QUERY.append([int(q[0])])
    else:
        QUERY.append([int(q[0]), int(q[1]), q[2]])

st = []
en = []
rev = False
rev_c = 0
for q in QUERY:
    if q[0] == 1:
        if rev:
            rev = False
        else:
            rev = True
        rev_c += 1
    else:
        if q[1] == 1:
            if not rev:
                st.append(q[2])
            else:
                en.append(q[2])
        else:
            if not rev:
                en.append(q[2])
            else:
                st.append(q[2])

# print(st)
# print(en)

st_s = "".join(st)
st_s = st_s[::-1]
en_s = "".join(en)

ans = st_s + S + en_s
if rev_c % 2 == 0:
    pass
else:
    ans = ans[::-1]

print(ans)

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

int n,x,ans;
int a[110];

int main()
{
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<n;i++) if (x>=a[i]) {
		ans++; x-=a[i];
	} else break;
	if (x==a[n]) ans++;
	printf("%d\n",ans);
}

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

int main(){
    int n,m;cin>>n>>m;
    vector<int> P(m),Y(m);
    for(int i=0;i<m;i++)cin>>P[i]>>Y[i],P[i]--;
    vector<vector<int> > vals(n);
    for(int i=0;i<m;i++)vals[P[i]].push_back(Y[i]);
    for (int v=0;v<n;v++){
        sort(vals[v].begin(),vals[v].end());
        vals[v].erase(unique(vals[v].begin(),vals[v].end()),vals[v].end());

    }

    for (int i=0;i<m;i++){
        int v=P[i];
        printf("%06d",v+1);

        int id=lower_bound(vals[v].begin(),vals[v].end(),Y[i])-vals[v].begin();
        printf("%06d\n",id+1);
    }
}

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

using namespace std;

int main()
{
    char s[4];
    scanf("%s",s);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int d[2]={1,-1};
char p[2]={'+','-'};

int main(){
  string s;
  int a[5];
  cin>>s;
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
	if(a[0]+a[1]*d[i]+a[2]*d[j]+a[3]*d[k]==7){
	  cout<<s[0]<<p[i]<<s[1]<<p[j]<<s[2]<<p[k]<<s[3]<<"=7"<<endl;
	  return(0);
	}
      }
    }
  }
  return(0);
}

Measured memory_bytes: 256
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
flag = list(map(lambda x: False if x%10 == 0 else True, s))

if sum(s)%10==0:
    for i in range(n):
        if flag[i]:
            s.pop(i)
            print(sum(s))
            break
    else:
        print(0)
else:
    print(sum(s))

Measured memory_bytes: 62420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

void solve(void){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    bool can = false;;
    rep(N-1, i) {
        ll lb = C*(N-1-i) - D*i;
        ll ub = D*(N-1-i) - C*i;
        if (lb <= (B-A) and (B-A) <= ub) can = true;
    }
    cout << (can?"YES":"NO") << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int f(int n) {
  if(n % 2 == 0) { return n / 2; }
  else { return 3 * n + 1; }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s, i = 0;
  cin >> s;
  vector<int> a(0);
  while(true) {
    i++;
    a.push_back(s);
    s = f(s);
    REP(j,a.size()) if(s == a[j]) { cout << i + 1 << endl; return 0; }
  }
  return 0;
}
//templete by private_yusuke

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

int main(){
  int R, G, B, N, ans=0;
  cin >> R >> G >> B >> N;
  for(int i=0;i*R<=N;i++){
    for(int j=0;j*G+i*R<=N;j++){
      if(N==j*G+i*R||(N-j*G-i*R)%B==0)ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256