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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
int n,m;
int a,b;
string solve(){
	int edge[n-1];
	FOR(i,n-1)edge[i]=0;
	FOR(i,m){
		cin >> a >> b;
		edge[a-1]++;edge[b-1]++;
	}
	
	
	FOR(i,n-1) if(edge[i]%2){
		return "NO";
	}
	return "YES";
}


int main(){
	cin >> n >> m;
	
	cout <<solve();


	return 0;
}

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


void solve(std::vector<long long> x){
  int ret = 0;
  for (int i=0; i<5; i++) if (x[i] == 0) ret = i+1;
  cout << ret << endl;
}

int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
vector<int> xxx;
int main()
{
	string s;
	cin>>s;
	int ans=MOD;
	for(int i=0;i<26;i++)
	{
		char c='a'+i;
		xxx.pb(0);
		for(int j=0;j<s.length();j++)
		{
			if(s[j]==c)
			{
				xxx.pb(j+1);
				//cout<<j+1<<endl;
			}
		}
		int l=s.length();
		xxx.pb(l+1);
		int now=0;
		for(int j=1;j<xxx.size();j++)
		{
			//if(c=='r')
			//	cout<<xxx[j]<<endl;
			now=max(now,xxx[j]-xxx[j-1]-1);
		}
		//cout<<endl;
		xxx.clear();
		ans=min(ans,now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int mod = 1e9 + 7;

int a, b, c, A, B, C;

lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

lint D2(int a, int A, int b, int B){
	lint ret = a * ipow(b, A / a) + b * ipow(a, B/ b) - a * b + mod;
	return ret % mod;
}

int n, m;
lint bino[105][105];
lint dp[105][105];

lint f(int p, int q){
	if(p == n&& q == m) return 1;
	if(~dp[p][q]) return dp[p][q];
	lint ret = (1ll * bino[n][p] * bino[m][q] % mod) * ipow(c, (n-p) * (m-q)) % mod;
	for(int i=p; i<=n; i++){
		for(int j=q; j<=m; j++){
			if(i + j != p + q){
				ret += mod - (1ll * bino[i][p] * bino[j][q] % mod) * f(i, j) % mod;
			}
		}
	}
	return dp[p][q] = ret % mod;
}

int main(){
	cin >> a >> b >> c >> A >> B >> C;
	if(A % a || B % b || C % c){
		puts("0");
		return 0;
	}
	for(int i=0; i<105; i++){
		bino[i][0] = 1;
		for(int j=1; j<=i; j++){
			bino[i][j] = (bino[i-1][j]+bino[i-1][j-1]) % mod;
		}
	}
	lint ans = 0;
	ans += ipow(D2(a, A, b, B), C / c) * c;
	ans += ipow(D2(b, B, c, C), A / a) * a;
	ans += ipow(D2(c, C, a, A), B / b) * b;
	ans += mod - ipow(a, C * B / (c * b)) * b * c % mod;	
	ans += mod - ipow(b, A * C / (a * c)) * a * c % mod;
	ans += mod - ipow(c, A * B / (a * b)) * a * b % mod;
	ans += a * b * c;
	memset(dp, -1, sizeof(dp));
	for(int i=1; i<A/a; i++){
		for(int j=1; j<B/b; j++){
			// nontrivial patterns have i / j dominated pattern
			n = A / a;
			m = B / b;
			lint cnts = f(i, j); 
			lint each_floor = ipow(b, i) + ipow(a, j) - 1;
			lint each_floor_badx = ipow(b, i);
			lint each_floor_bady = ipow(a, j);
			int f = C / c;
			cnts *= ipow(each_floor, f) - ipow(each_floor_badx, f) - ipow(each_floor_bady, f) + 1 + 2 * mod;
			cnts %= mod;
			ans += cnts * a * b * c % mod;
		}
	}
	cout << ans % mod << endl;
}


Measured memory_bytes: 384
/*
T M Hridoy KUET CSE 15
*/
#include<bits/stdc++.h>

using namespace std;

#define print printf("==================\n");
typedef    long long ll;
typedef pair<ll,ll   > payar;
typedef   unsigned long long ull;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define readf                freopen("in.txt", "r", stdin);
#define writef               freopen("out.txt", "w", stdout);

priority_queue<int, vector<int>,  greater<int> > pq; ///accending
vector< pair<int,payar  > > vpp;
vector< pair<int,  pair<int,payar  > > > own;
vector < payar >  vp;
#define pi acos(-1.0);
#define EPS 1e-9
#define  mod   1000000007
#define  mod2  998244353
#define all(x) x.begin(),x.end()
#define endl "\n"
const int N=2e5+5;


int a[N];
const int M = 998244353;
double maxvolume(double s)
{
    double l = s / 3.0;

    s -= l;

    double b = s / 2.0;

    double h = s - b;

    return l * b * h;
}

int main()
{
    IOS;
    ll t ;
    cin>>t;
    cout<<fixed<<setprecision(10);

   cout<<maxvolume(t)<<endl;


    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int ans = 0;
    string s; cin >> s;
    REP(i, s.length())
    {
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;

int main(){
	int N, D, X; cin >> N >> D >> X;
	int A[N], ans = X;
	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < N; ++i){
		for(int j = 0;; ++j){
			if(j * A[i] + 1 <= D) ans++;
			else break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
p = N // 2
A = [int(s) for s in input().split()]
assert len(A) == N
total = sum(A)

ans = [0] * N
core_even = sum(A[i] for i in range(0, N + 1, 2))
core_odd = sum(A[i % N] for i in range(1, N + 1, 2))

for i in range(N):
    new_idx = (2 * p + i) % N
    if i >= 2 and i % 2 == 0:
        core_even += A[new_idx] - A[i - 2]
    if i >= 3 and i % 2 == 1:
        core_odd += A[new_idx] - A[i - 2]

    if i % 2 == 0:
        ans[i] = 2 * core_even - total
    else:
        ans[i] = 2 * core_odd - total

print(*ans)

Measured memory_bytes: 14616
#include <bits/stdc++.h>
#define se second
#define fi first
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
using namespace std;
const int N = 1e6+ 7;
const int INF = 1e9 + 7;
ll a,b,c,t,x,mx=-999999,temp = 0,mx2,mx1,m,n;
int main()
{
    cin >> n;
    cout << (n * (n-1)) / 2;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

bool check(ll x, const vector<bool>& ng){
    while(x > 0){
        if(ng.at(x % 10)){
            return false;
        }
        x /= 10;
    }
    return true;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<bool> ng(10, false);
    REP(i, k){
        ll di;
        cin >> di;
        ng.at(di) = true;
    }

    for(ll ans = n; ans <= 100000; ++ans){
        if(check(ans, ng)){
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}


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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int A = sc.nextInt();
    int[] H = new int[N];
    double[] temp = new double[N];

    for (int i = 0; i<N; i++){
      H[i] = sc.nextInt();
      temp[i] = 0;
    }

    double tp = 0;
    for (int i=0;i<N;i++){
      tp = T - H[i] * 0.006;
      temp[i] = Math.abs( tp - A);
    }

    int min_index = 0;
    double tmp = temp[0];
    for (int i = 0; i<N; i++){
      if (tmp > temp[i]) {
        tmp = temp[i];
        min_index = i;
      }
    }

    System.out.println(min_index+1);

  }
}


Measured memory_bytes: 23636
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main() {
    stack<int> S;
    int a,b,x;
    string s;
    while(cin>>s){
        if(s[0]=='+'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a+b);
        }else if(s[0]=='-'){
            b=S.top();S.pop();
            a=S.top();S.pop();
            S.push(a-b);
        }else if(s[0]=='*'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }
    cout<<S.top()<<endl;
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int a[100007],b[100007],c[100007];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        c[i]=a[i]-b[i];
    }
    sort(c+1,c+1+n);
    long long sum=0;
    int ans=0;
    int flag=0;
    for(int i=1;i<=n;i++){
        if(c[i]>=0){
            break;
        }
        else{
            if(sum+c[i]>=0){
                sum+=c[i];
                c[i]=0;
                ans++;
            }
            else{
                while(1){
                    flag=0;
                    for(int j=n;j>i;j--){
                        if(c[j]>0){
                            sum+=c[j];
                            c[j]=0;
                            ans++;
                            n--;
                            break;
                        }
                        if(j==i+1)
                            flag=1;
                    }
                    if(i==n)
                        flag=1;
                    if(sum+c[i]>=0){
                        sum+=c[i];
                        c[i]=0;
                        ans++;
                        break;
                    }
                    if(flag==1)
                        break;
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(c[i]<0){
            flag=1;
            break;
        }
    }
    if(flag)
        printf("-1");
    else
        printf("%d",ans);
    return 0;
}


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

int main() {
  int64_t X;
  cin >> X;
  
  if (X == 2) {
    cout << 2 << endl;
    return 0;
  }
  
  while(1) {
    if (!(X % 2)) {
      X++;
      continue;
    } else {
      int n = sqrt(X);
      //cout << n << endl;
      int frag = 0;
      for ( ; n > 1; ) {
        //if (n <= 5) cout << n << ',' << X;
        if (!(X % n)) {
          X++;
          frag = 1;
          continue;
        } else {
          n--;
        }
      }
      if (frag) continue;
      break;
    }
  }
  
  cout << X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b, c;
    cin >> a >> b >> c ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //Sunny, Cloudy, Rainy
    /*
    if( a < 10 && b < 10 ){
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    //*/
    
    cout << c << " " << a << " " << b << endl;
    
    //printf("%lf\n", ((a / 2 + a % 2) / a));

    return 0; 
}


Measured memory_bytes: 3548
//
// Created by 李青坪 on 2018/12/1.
//

#include <cmath>
#include <cstdio>
#include <algorithm>

#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK -2
#define ONLINE_FRONT 2
#define ON_SEGMENT 0
using namespace std;

// 点
class Point {
public:
    double x;
    double y;

    Point() {}

    Point(double x, double y) : x(x), y(y) {}

    Point operator+(Point a) {
        return Point(x + a.x, y + a.y);
    }

    Point operator-(Point a) {
        return Point(x - a.x, y - a.y);
    }

    Point operator*(double a) {
        return Point(x * a, y * a);
    }

    Point operator/(double a) {
        return Point(x / a, y / a);
    }

    double norm() {
        return x * x + y * y;
    }

    double absVector() {
        return sqrt(norm());
    }

    bool operator==(Point a) const {
        return equals(x, a.x) && equals(y, a.y);
    }
};

typedef Point Vector;

// 线段
class Segment {
public:
    Point a, b;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

int ccw(Segment s, Point p) {
    Vector v1 = s.b - s.a;
    Vector v2 = p - s.a;
    if (cross(v1, v2) > 0) return COUNTER_CLOCKWISE;
    if (cross(v1, v2) < 0) return CLOCKWISE;
    if (dot(v1, v2) < 0) return ONLINE_BACK;
    if (v1.norm() < v2.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}


int n;


int main() {
    Segment s;
    Point p[2];
    scanf("%lf %lf %lf %lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y);
    s.a = p[0];
    s.b = p[1];
    scanf("%d", &n);
    Point point;
    for (int i = 0; i < n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        point = Point(x, y);
        int re = ccw(s, point);
        switch (re){
            case COUNTER_CLOCKWISE:
                printf("%s\n", "COUNTER_CLOCKWISE");
                break;
            case CLOCKWISE:
                printf("%s\n", "CLOCKWISE");
                break;
            case ONLINE_BACK:
                printf("%s\n", "ONLINE_BACK");
                break;
            case ONLINE_FRONT:
                printf("%s\n", "ONLINE_FRONT");
                break;
            default:
                printf("%s\n", "ON_SEGMENT");
        }
    }
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int A;
  cin >> A;
  
  char op;
  cin >> op;
  
  int B;
  cin >> B;
  
  if(op == '+'){
    cout << A+B << endl;}
  else if(op == '-'){
    cout << A-B <<endl;}
}

Measured memory_bytes: 256
m, n = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
ans = 0
MAX = 0
now = 0
for i in range(n):
    if i == n-1:
        now = m + arr[0] - arr[n-1]
    else:
        now = arr[i+1]-arr[i]
    if now > MAX:
        MAX = now
    ans += now
print(ans-MAX)

Measured memory_bytes: 25836
h,w = map(int,input().split())
grid = list('.' + input() + '.' for _ in range(h))
grid = ['.'*(w+2)] + grid + ['.'*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j] == '#':
            if '#' in grid[i-1][j]+grid[i][j-1]+grid[i][j+1]+grid[i+1][j]:
                continue
            else:
                print("No")
                quit()
print("Yes")

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

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    map<int,int> printed;
    --k;
    for(int i=a ; i<=a+k && i<=b ; ++i)
    {
        cout<<i<<endl;
        printed[i]=1;
    }
    if(printed[b])
    return 0;
    for(int i=b-k ; i<=b ; ++i)
    {
        if(printed[i])
        continue;
        cout<<i<<endl;
    }
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    ll t[n+1],x[n+1],y[n+1];
    t[0]=x[0]=y[0]=0;
    rep(i,n) cin>>t[i+1]>>x[i+1]>>y[i+1];
    bool can=true;
    rep(i,n){
        ll dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        ll dt=abs(t[i+1]-t[i]);
        if(dt<dist){
            can=false;
        }
        if(dist%2!=dt%2) can=false;
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 5868
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  
  ll now=a[0];
  ll ans=n;
  rep(i,n-1){
    if(now*2>=a[i+1]){
      now+=a[i+1];
    }
    else{
      ans=n-i-1;
      now+=a[i+1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
num_list = [int(item) for item in input().split()]

def countingSort(A, k):
    B = [0 for _ in range(N+1)]
    C = [0 for _ in range(k+1)]

    for j in range(N):
        C[A[j]] += 1
    
    for i in range(1, k+1):
        C[i] = C[i] + C[i - 1]

    for j in reversed(range(N)):
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1
    return B[1:]


print(*countingSort(num_list, max(num_list)))


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

struct Problem {

	static ULL gcd(ULL a, ULL b) { return b ? gcd(b, a % b) : a; }

	void Solve() {
		ULL N, M; cin >> N >> M;
		ULL G = gcd(N, M);
		ULL ans = N * M / G;
		string S, T; cin >> S >> T;
		{
			UL n = N / G, m = M / G;
			rep(i, G) {
				if (S[n * i] != T[m * i]) { cout << -1 << endl; return; }
			}
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 512
s = int(input())
a = [0 for i in range(1000001)]
a[s] = 1
ai = s
i = 2
while True:
  if ai % 2 == 0:
    ai //= 2
  else:
    ai = 3 * ai + 1
  if a[ai] > 0:
    print(i)
    break
  else:
    a[ai] = 1
    i += 1


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

int main(){
    int n;
    std::cin >> n;
    
    bool ans = false;
    while(true){
        if(n%4 == 0 || n%7 == 0){
            ans = true;
            break;
        }else if(n >= 11){
            n -= 11;
        }else{
            ans = false;
            break;
        }
    }
    
    std::cout << (ans ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split(" "))
s = input()
l = []
if s[0] == "0":
    l.append((0, 0))
i = 0
while i < n:
    if s[i] == "1":
        b = i
        while i < n and s[i] == "1":
            i += 1
        l.append((b, i))
    i += 1
if s[n-1] == "0":
    l.append((n, n))
if len(l)-1 <= k:
    print(n)
else:
    maximum = 0
    for i in range(len(l)-k):
        maximum = max(maximum, l[i+k][1]-l[i][0])
    print(maximum)

Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r,a,c;
    cin >>r;
    a=2*r*3.14159265358979323846264338;
    c=r*r*3.14159265358979323846264338;
    printf("%lf ",c);
    printf("%lf",a);
}


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

using i64 = long long;

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

i64 n;

int main() {
    std::scanf("%lld", &n);
    i64 result = 0;
    for(i64 l = 1, r, x; l <= n; l = r + 1) {
        x = n / l, r = n / x;
        if(x >= r || n % x) continue;
        i64 y = n / x - 1;
        if(y >= l && y <= r) result += y;
    }
    std::printf("%lld\n", result);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,C;
  string S;
  cin >> S;
  N=S.size();
  for(int i=0;i<N;i++){
    if(S[i]=='x')C++;
  }
  if(C<8)cout << "YES" <<endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	writeln((N + 1) / 2 >= K ? "YES" : "NO");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;

ll check(ll n){
	ll num=n;
	ll sum=0;
    while (num != 0){
        sum = sum + num % 10;
        num = num / 10;
    }
    return sum;
}
ll ans,mx,mn=1e8,sum,cnt;

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

    if(n%10==0){
    	ans = check(n/2);
    	cout<<ans*2;
    } else cout<<check(n)<<endl;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <istream>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cmath>


using namespace std;


int main() {
    int n, d; cin >> n >> d;
    vector<vector<int>> x(n);
    for (int i=0; i<n; ++i) x[i].resize(d);
    for (int i=0; i<n; ++i) {
        for (int j=0; j<d; ++j) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) {
            if (i == j) continue;
            int dist = 0;
            for (int k=0; k<d; ++k) {
                dist += pow(x[i][k] - x[j][k], 2);
            }

			if (sqrt(dist) - int(sqrt(dist)) == 0) ans++;
        }
    }

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



Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

int main() {
    string s;
    cin >> s;
    REP(i, s.size()-1) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
        
    }
    
    cout << "Good" << endl;
}


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


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

    sort(a.begin(),a.end());
    cout << a[0]+a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x;
    cin >> x;
    ll cv = x;
    ll ans = 1;
    while(cv % 360 != 0) {
        cv += x;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
s = input()
s += "0000000000"
i = 0
while i < len(s):
    # print("s:[{}:] : {}".format(i, s[i:]))
    if s[i:i + 5] == "dream":
        if s[i + 5:i + 7] == "er":
            if s[i + 7] == "a":  # dream+eraだと確定
                i += 5
                continue
            else:  # dreamerと確定
                i += 7
                continue
        else:  # dreamと確定
            i += 5
            continue
    elif s[i:i+5] == "erase":  # eraseで始まる場合
        if s[i + 5] != "r":  # eraseで確定
            i += 5
            continue
        else:  # eraserで確定
            i += 6
            continue
    elif s[i:] == "0000000000":
        print("YES")
        exit()
    else:
        print("NO")
        exit()

Measured memory_bytes: 3188
loop do
    m, f, r = gets.chomp.split.map(&:to_i)
    if m == -1 && f == -1
        break
    end
    total = m + f
    if m == -1 || f == -1
        puts "F"
    elsif total >= 80
        puts "A"
    elsif total >= 65
        puts "B"
    elsif total >= 50
        puts "C"
    elsif total < 30
        puts "F"
    elsif r >= 50 && total >= 30
        puts "C"
    elsif  r < 50 && total >=30
        puts "D"
    end
end

Measured memory_bytes: 8664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
			var iN =  cin.ReadInt;
          	var iM =  cin.ReadInt;
          	var lA = new List<Answer>();
          	var dA = new Dictionary<int,int>();
          	var sA = new HashSet<int>();
          	var ansOk = 0;
          	var ansNg = 0;
          	for(var i=0;i<iM;i++)
            {
              	var input = cin.ReadLine.Split(' ');
              	lA.Add(new Answer()
                {
                	iP = Int32.Parse(input[0]),
                  	sS = input[1]
                });
            }
            // Process
			foreach(var item in lA)
            {
                if(sA.Contains(item.iP))continue;
              	if(item.sS=="AC")
                {
					ansOk++;
                  	if(dA.ContainsKey(item.iP))ansNg+=dA[item.iP];
                  	sA.Add(item.iP);
                }
              	else
                {
                    if(dA.ContainsKey(item.iP))dA[item.iP]++;
                    else dA.Add(item.iP,1);
                }
            }
            // Output
			WriteLine($"{ansOk} {ansNg}");
        }
    }
  
    public class Answer
    {
        public int iP ;
        public string sS ;
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b;
	if ((a+b)%2 == 0){
		cout << (a+b)/2;
	}
	else cout << "IMPOSSIBLE";
	return 0;
}


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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>

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

    ll d,t,s;
    cin >> d >> t >> s;
    if (s*t >= d) cout << "Yes\n";
    else cout << "No\n";


    return 0;
}



Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0;i <= n;i++)
    {
        for(int j = 0;j <= n;j++)
        {
            int x = n - r * i - g * j;
            if(x % b == 0 && x >= 0)
            {
                ans++;
            }
        }
    }
    cout << ans << "\n";
    
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B; cin >> A >> B;
    if(A%3==0 || B%3==0 || (A+B)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3644
N, M = map(int, input().split())
A = list(map(int, input().split()))

check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1

ans = N - x

if ans >= M :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.*;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        boolean[] visited = new boolean[V];
        HashMap<Integer, List<int[]>> graph = new HashMap<>(V);
        for(int i = 0; i < V; ++i){
            graph.put(i, new LinkedList<int[]>());
        }

        for(int i = 0; i < E; ++i){
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            int weight = scanner.nextInt();

            graph.get(x).add(new int[] {y, weight});
            graph.get(y).add(new int[] {x, weight});
        }

        PriorityQueue<int[]> queue = new PriorityQueue<>(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });

        queue.offer(new int[]{0, 0});
        long minCost = 0;

        while(!queue.isEmpty()){
            int[] edge = queue.poll();
            if(visited[edge[0]]){
                continue;
            }

            visited[edge[0]] = true;
            minCost += edge[1];

            for(int[] adj : graph.get(edge[0])){
                if(!visited[adj[0]]){
                    queue.offer(adj);
                }
            }
        }

        System.out.println(minCost);
    }
}

Measured memory_bytes: 117780
def f():
    return int(raw_input())
def f2():
    return map(int, raw_input().split())

def merge(left, mid, right):
    L = S[left:mid]
    R = S[mid:right]
    lp, rp, xp = 0, 0, 0
    a, b = L[0], R[0]
    c = right - left
    x = [0] * c
    while xp < c:
        while xp < c and a <= b:
            x[xp] = a
            lp += 1
            xp += 1
            try:
                a = L[lp]
            except:
                for e in R[rp:]:
                    x[xp] = e
                    xp += 1
                break
        while xp < c and a >= b:
            x[xp] = b
            rp += 1
            xp += 1
            try:
                b = R[rp]
            except:
                for e in L[lp:]:
                    x[xp] = e
                    xp += 1
                break
    S[left:right] = x
    return c

def mergesort(left, right):
    c = 0
    if left + 1 < right:
        mid = (left + right)/2
        c += mergesort(left, mid)
        c += mergesort(mid, right)
        c += merge(left, mid, right)
    return c

global S
n = f()
S = f2()

c = mergesort(0, n)
print " ".join(map(str,S))
print c

Measured memory_bytes: 52884
from collections import Counter
n = int(input())
a = [int(v) for v in input().split()]
 
M = max(a)
d = [1 for i in range(M+1)]
for v in sorted(a):
    for j in range(2*v, M+1, v):
        d[j] = 0
ans = 0
c = Counter(a)
for i in a:
    if c[i]==1:
      ans += d[i]
print(ans)

Measured memory_bytes: 44612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  long n,k=0,now=1000; cin>>n;
  long a[n];
  rep(i,n)cin>>a[i];
  
  for(int i=1;i<n;i++){
    if(a[i-1]<=a[i]){
      k+=now/a[i-1];
      now=now%a[i-1];
    
    }
    else if(a[i-1]>a[i]){
      now+=k*a[i-1];
      k=0;
    }
    
    //cout<<now<<"  "<<k<<endl;
    
    
  }
  
  if(a[n-2]<=a[n-1])now+=k*a[n-1];
  //else if(a[n-2]>a[n-1])
  
  
  
  cout<<now<<endl;
  
  //cout<<k;

  //string s; cin>>s;
  //cout<< <<endl;
}


Measured memory_bytes: 3620
import sys
input=sys.stdin.readline

a,b,k = map(int, input().split())
x = []
for i in range(a,a+k):
    if a <= i and i <= b:
        x.append(i)
for i in range(b-k+1,b+1):
    if a <= i and i <= b:
        x.append(i)

x = list(set(x))
x.sort()

for i in x:
    print(i)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void){
int n, i, j, k, S, t;
char s[9];
    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        S=0;
        for (j=1; j<=2; j++) {
            scanf("%s", s);
            t=1;
            for (k=0; k<strlen(s); k++) {
                if (s[k] == '2') t=2;
                if (s[k] == '3') t=3;
                if (s[k] == '4') t=4;
                if (s[k] == '5') t=5;
                if (s[k] == '6') t=6;
                if (s[k] == '7') t=7;
                if (s[k] == '8') t=8;
                if (s[k] == '9') t=9;
                if (s[k] == 'm') {
                S+=1000*t;
                t=1;
                }
                if (s[k] == 'c') {
                    S+=100*t;
                    t=1;
                }
                 if (s[k] == 'x') {
                    S+=10*t;
                    t=1;
                }
                if (s[k] == 'i') {
                    S+=t;
                    t=1;
                }
            }
        }
        if (S/1000 != 0) {
            if (S/1000 != 1) printf("%d", S/1000);
            printf("m");
        }
        if (S/100%10 != 0) {
            if (S/100%10 != 1) printf("%d", S/100%10);
            printf("c");
        }
        if (S/10%10 != 0) {
            if (S/10%10 != 1) printf("%d", S/10%10);
            printf("x");
        }
        if (S%10 != 0) {
            if (S%10 != 1) printf("%d", S%10);
            printf("i");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 1980
#include<iostream>
using namespace std;
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int d, e;
	d = x, x = y, y = d;
	e = x, x = z, z = e;
	cout << x << " " << y << " " << z << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i = 0; i < M; i++) cin >> B[i];
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    int count = 0;
    for(int i = 0; i < N; i++){
        int sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum > 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//nの約数を返す関数.sortされてない.
vector<long long int> divisors(long long int n){
	vector<long long int> res;
	for (long long int i = 1; i * i <= n;i++){
		if (n % i == 0){
			res.push_back(i);
			if(i * i != n){
				res.push_back(n / i);
			}
		}
	}
	return res;
}

int main()
{
	ll n;
	cin >> n;
	vector<ll> d = divisors(n);
	int ans = inf;
	for (auto x : d)
	{
		ans = min(max(int(to_string(x).size()), int(to_string(n/x).size())),ans);
	}
	cout << ans << endl;

	return 0;
}




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

using namespace std;

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

int gcd(int m,int n){
  if (m==0||n==0){
    return 0;
  } else {
    while(m!=n){
      if(m>n){
        m=m-n;
      } else {
        n=n-m;
      }
    }
    return m;
  }
}

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};


int main(){
  while(1){
    int m,n;
    cin >> m >> n;
    if(m==0)break;
    vector<int> b(m),r(n);
    rep(i,m)cin>>b[i];
    rep(i,n)cin>>r[i];
    bipartite_matching bm(m+n);
    rep(i,m)rep(j,n){
      if (gcd(b[i],r[j])>1){
        bm.add_edge(i,j+m);
      }
    }
    cout << bm.maximum_matching()<<endl;
  }
  return 0;
}



Measured memory_bytes: 4420
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int k = 1;

	rep(i, N) {
		int a;
		cin >> a;
		if (a == k) k++;
	}

	if (k != 1) co(N - k + 1);
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    total = 0
    mn = float('inf')
    cnt = 0
    for a in A:
        if a < 0:
            cnt += 1
        mn = min(mn, abs(a))
        total += abs(a)
    if cnt % 2 != 0:
        total -= mn * 2
    print(total)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(void){
	int a, b, k=0, x, y;

	scanf("%d %d", &a, &b);

	if(a == b){
		k = 0;
		printf("%d\n",k);
	}else if ((a + b) % 2 == 0){
		k = (a + b) / 2;
		printf("%d\n",k);
	}else{
		printf("IMPOSSIBLE\n");
	}

	return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + A[i];

    vector<ll> B;
    rep(i, N + 1) {
        rep(j, i) {
            B.push_back(sum[i] - sum[j]);
        }
    }

    sort(B.begin(), B.end(), greater<int>());

    ll ans = 0;
    int M = B.size();
    vector<bool> available(M, true);
    for (int i = 60; i >= 0; --i) {
        int cnt = 0;
        rep(j, M) if (available[j] && B[j] >> i & 1) cnt++;
        if (K <= cnt) {
            ans += 1L << i;
            rep(j, M) {
                if (!(B[j] >> i & 1)) available[j] = false;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

std::string str;

int main() {
	std::cin >> str;
	bool a = (str[0] == 'x'), b = (str[str.size() - 1] == 'x');
	if (a && b)std::cout << 'x' << std::endl;
	else std::cout << 'o' << std::endl;

	return 0;
}

Measured memory_bytes: 1172
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n,k;cin>>n>>k;
    ll r,S,p;cin>>r>>S>>p;
    string s;cin>>s;

    s.insert(s.begin(), '^');

    vl dp(n+1, 0);

    vl used(n+1);
    rep(i, 1, n+1){
        ll a = 0;
        if (s[i]=='r') a += p;
        if (s[i]=='s') a += r;
        if (s[i]=='p') a += S;
        dump(a);

        if (i-k >= 1 && s[i-k] == s[i] && used[i-k]){
            dp[i] = dp[i-1];
        }
        else{
            dp[i] = dp[i-1] + a;
            used[i] = 1;
        }
        dump(dp[i]);
    }
    cout << dp[n] << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 2000