akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    double n, k;
    cin >> n >> k;
    double ans = 0;
    REP(i, n){
        double now = 1/n;
        double sum = i;
        while(sum < k){
            now *= 0.5;
            sum *= 2.0;
        }
        ans += now;
    }
    cout << setprecision(15) << ans << endl;
}


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

int main() {
  int A,B;
  cin >>A >>B;
  if(A >=13){
	cout <<B <<endl;
  }
  else if (5 <A && A <13){
   cout <<B / 2 <<endl; 
  }
  else {
cout << 0 <<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <sstream>

using namespace std;

vector<int> nums;

void dfs(int remketa, string created)
{
    if(created.size() >= 3){
        set<char> ss;
        ss.clear();
        for(int i = 0; i < created.size(); i++){
            ss.insert(created[i]);
        }
        if(ss.size() == 3){
            //printf("TESS %s\n",created.c_str());
            //printf("TEST %d\n", stoi(created));
            //nums.push_back(atoi(created.c_str()));
            //nums.push_back(stoi(created));
            istringstream ss(created);
            int nn;
            ss >>nn;
            nums.push_back(nn);
        }
    }
    if(remketa == 0){
        return;
    }

    dfs(remketa - 1, created + "7");
    dfs(remketa - 1, created + "5");
    dfs(remketa - 1, created + "3");
}

int main(void)
{
    dfs(10, "");
    int n;
    cin >>n;

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

    int ct = 0;
    for(int i = 0; i < nums.size() && nums[i] <= n; i++){
        ct++;
    }
    printf("%d\n", ct);
    return 0;
}

Measured memory_bytes: 892
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int k = scan.nextInt();
      	int x = scan.nextInt();
      	int min = x - k + 1;
      	int max = x + k - 1;
      	for(int i = min; i <= max; i ++){
        	System.out.print(i + " ");
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7; 
long long ans=0,n,a[210000],sum[210000]={0};
int main()
{
	 cin>>n;
	 for(long long i=1;i<=n;i++)
	 {
	 	cin>>a[i];
	 	sum[i]=(sum[i-1]+a[i])%mod;
	 }
	for(long long i=1;i<n;i++)
	{
	 	ans=(ans+((a[i]%mod)*(sum[n]-sum[i]+mod)%mod)%mod)%mod;
	}
	cout<<ans;
 } 

Measured memory_bytes: 6708
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b,t; cin>>a>>b>>t;
	int ans=0;
	for(int i=a; i<=t; i+=a){
		ans+=b;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (A, B, C, D) = readInts()

    val lateStarted = Math.max(A, C)
    val earlyEnded = Math.min(B, D)
    val time = earlyEnded - lateStarted

    println(if (0 < time) time else 0)
}

Measured memory_bytes: 36004
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b; cin >> a >> b;
    vi h(999); h[0]=1;
    repf(i, 998) h[i]=h[i-1]+(i+1);
    cout << h[b-a-1] - b << endl;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        if (a > b) {
            System.out.println(a - 1);
        } else {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,x;
  cin>>a>>b>>x;
  float f=45;
  if(x==(a*a*b/2))
    cout<<fixed<<setprecision(10)<<f<<endl;
  else if(x>(a*a*b/2))
  {
  	//cout<<"A"<<endl;
    double d=a*a*a/(2*(a*a*b-x));
    cout<<fixed<<setprecision(10)<<90-(atan(d)*180/3.1415926536)<<endl;
  }
  else
  {
    double d=2*x/(b*b*a);
    cout<<fixed<<setprecision(10)<<90-(atan(d)*180/3.1415926536)<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

const int mod=1000000007;
struct mint{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const{return mint(-x);}
  mint& operator+=(const mint a){
    if((x+=a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x+=mod-a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=mod;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a=pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  // for prime mod
  mint inv() const{
    return pow(mod-2);
  }
  mint& operator/=(const mint a){
    return (*this)*=a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

map<ll,ll> pfmp; //各素因数の冪指数の総和を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
  ll n=N;
  if(n<=0) return;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    while(n%2==0){
      n/=2;
      pfmp[2]++;
    }
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      while(n%i==0){
        n/=i;
        pfmp[i]++;
      }
    }
  }
  if(n!=1){
    if(pfmp[n]==0) pfv.push_back(n);
    pfmp[n]++;
  } 
  sort(all(pfv));
}

int main(){
  int N; cin >> N;
  for(int i=2;i<=N;i++){
    PF(i);
  }
  mint ans=1;
  for(auto c:pfmp){
    ans*=c.second+1;
  }
  cout << ans.x << endl;
}

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

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

    ll ans = 0;
    rep(i, n) {
        if (a[i] <= b[i]) {
            ans += a[i];
            b[i] -= a[i];
            if (a[i+1] <= b[i]) {
                ans += a[i+1];
                a[i+1] = 0;
            } else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        } else {
            ans += b[i];
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int sum[2];
int n[10];

int main(){
	REP(i, 2){
		REP(j, 10){
			cin >> n[j];
		}
		sort(n, n + 10, greater<int>());
		sum[i] = n[0] + n[1] + n[2];
	}
	cout << sum[0] << " " << sum[1] << endl;
}

Measured memory_bytes: 1180
S = input()

def solve():
    alpha = [c for c in 'abcdefghijklmnopqrstuvwxyz']
    if len(S) < 26:
        for S_i in S:
            alpha.remove(S_i)
        print(S + alpha[0])
        return
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return
    last_alpha = ""
    post_fix = ""
    latest = -1
    post_fix_index = 25
    for S_i in S[::-1]:
        if last_alpha == "" or S_i > last_alpha:
            last_alpha = S_i
            post_fix = S_i + post_fix
            post_fix_index -= 1
            if latest == -1:
                latest = S_i
        else:
            alpha_post_fix = sorted([c for c in post_fix])
            for c in alpha_post_fix:
                if S[post_fix_index] < c:
                    print(S[:post_fix_index] + c)
                    return


solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

vector<int> dx = {0, 1, -1, 0};
vector<int> dy = {1, 0, 0, -1};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> cs(h);
    rep(i, h) cin >> cs[i];
    int cnt = 0;
    rep(i, h) rep(j, w) {
        if (cs[i][j] == '#') {
            bool flag = false;
            rep(k, 4) if (i+dx[k] < h && i+dx[k] >=0 && j+dy[k] < w && j+dy[k] >= 0 && (cs[i+dx[k]][j+dy[k]] == '#')) flag = true;
            if (!flag) cnt++;
        }
    }
    if (cnt == 0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
// 69

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    ll a, b_100, ans;
    long double b;
    cin >> a >> b;
    b_100 = b*100 + 0.5;
    ans = a*b_100/100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define N 500
typedef long long LL;
using namespace std;
int a[N][N], h[N][N], n;

int main() {
    cin >> n;
    LL ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            scanf("%d", &a[i][j]);
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++) {
            if (i == k) continue;
            for(int j = i + 1; j <= n; j++) {
                if (j == k) continue;
                LL tmp = (LL)a[i][k] + a[k][j];
                if (a[i][j] > tmp) {cout << -1 << endl;return 0;}
                if (a[i][j] == tmp) h[i][j] = 1;
            }
        }
    for(int i = 1; i <= n; i++)
        for(int j = i + 1; j <= n; j++)
            ans += a[i][j] * (1 - h[i][j]);
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
using namespace std;

int main(){
  int h,w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if((i+j)%2==0){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2612
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x,y,a,b,c=MI()
    pp=LI()
    qq=LI()
    rr=LI()
    hp=[]
    for p in pp:heappush(hp,(-p,0))
    for q in qq:heappush(hp,(-q,1))
    for r in rr:heappush(hp,(-r,2))
    cnt=[0]*3
    lim=[x,y,10**9]
    ans=0
    while hp and sum(cnt)<x+y:
        d,i=heappop(hp)
        if cnt[i]==lim[i]:continue
        ans-=d
        cnt[i]+=1
    print(ans)



main()

Measured memory_bytes: 123944
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,a0) memset(a,a0,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
int k,a,b;
signed main(){
	cin>>k>>a>>b;
	cout<<(a%k==0 || b%k==0 || a/k!=b/k ? "OK" : "NG")<<endl;
	return 0;
}

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

int main()
{
    int n , x, t;
    cin >> n >> x >> t;
    cout << (n+x - 1)/x * t << endl;
    return 0;
}


Measured memory_bytes: 3648
li = [int(input()) for _ in range(5)]
li_mod = [[i % 10, i] for i in li if i % 10 != 0]
li_mod_r = [i for i in li if i % 10 == 0]
li_mod = sorted(li_mod, reverse = True)
time = 0
if li_mod != []:
  for lis in li_mod[:-1]:
    time += lis[1] + (10-lis[0])
  time += li_mod[-1][1]
if li_mod_r != []:
  time += sum(li_mod_r)
#time += li_mod[-1][1]
print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;
    int N = S.length();
    vector<vector<int>> dp(N + 1, vector<int>(3));
    ll k = 1;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'A' || S[i] == '?') {
            (dp[i + 1][0] += dp[i][0] + k) %= MOD;
            (dp[i + 1][1] += dp[i][1]) %= MOD;
            (dp[i + 1][2] += dp[i][2]) %= MOD;
        }
        if (S[i] == 'B' || S[i] == '?') {
            (dp[i + 1][0] += dp[i][0]) %= MOD;
            int tmp = (dp[i][0] + dp[i][1]) % MOD;
            (dp[i + 1][1] += tmp) %= MOD;
            (dp[i + 1][2] += dp[i][2]) %= MOD;
        }
        if (S[i] == 'C' || S[i] == '?') {
            (dp[i + 1][0] += dp[i][0]) %= MOD;
            (dp[i + 1][1] += dp[i][1]) %= MOD;
            int tmp = (dp[i][1] + dp[i][2]) % MOD;
            (dp[i + 1][2] += tmp) %= MOD;
        }
        if(S[i] == '?')
            (k *= 3) %= MOD;
    }

    cout << dp[N][2] << endl;
    return 0;
}


Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[51],b[51];
	gets(a);
	gets(b);
	int xa=strlen(a),xb=strlen(b);
	for(int i=0;i<xa;i++)
	{
		cout<<a[i];
		if(i<xb)
		{
			cout<<b[i];
		}
	}
	if(xb>xa)
	{
		cout<<b[xb-1];
	}
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
// Hint: Don't look, No need

#pragma optimize("O2")
#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
  #define var(...)
  #define stl(...)
#endif

signed main() {
  fast;
  long double a, b;
  cin >> a >> b;
  int x = a * b;
  cout << x << '\n';
  // cout << floor() << '\n';


  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <cmath>

const double PI = 3.14159265359;

using namespace std;

int main() {
	double x = 0.0, y = 0.0;
	int d, a;
	int ca = 90; //????????????????????????
	scanf("%d,%d", &d, &a);	

	do {
		x += d * cos(ca / 180.0 * PI);
		y += d * sin(ca / 180.0 * PI);
		ca -= a;
		scanf("%d,%d", &d, &a);	
		
	} while(d != 0 || a!= 0);

	cout << static_cast<int>(x) << endl << static_cast<int>(y) << endl;

	return 0;
}

Measured memory_bytes: 3320
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    s=SI()
    B=0
    W=0
    for i in range(n):
        if s[i]=="#":
            B+=1
        else:
            W+=1
    b=0
    w=0
    ans=min(B,W)
    for i in range(n):
        if s[i]==".":
            w+=1
            ans=min(ans,b+W-w)
        else:
            b+=1
    print(ans)
        
        







if __name__=="__main__":
    main()


Measured memory_bytes: 9692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
cin >> s;
if(s == "Sunny"){
	cout << "Cloudy";
}
  else if(s == "Cloudy"){
  	cout << "Rainy";
  }
  else cout << "Sunny";

	
}

Measured memory_bytes: 256
main :: IO ()
main = do
  s <- getLine
  let isPa = s == reverse s
  let s2 = take ((length s - 1) `div` 2)  s
  let isPb = s2 == reverse s2
  let s3 = drop (((length s + 3) `div` 2) - 1) s
  let isPc = s3 == reverse s3
  putStrLn $ if isPa && isPb && isPc then "Yes" else "No"


Measured memory_bytes: 508
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  int N[4];
  for(int i=0; i<4; i++){
    cin>>N[i];
  }
  sort(N,N+4);
  if(N[0]==1&&N[1]==4&&N[2]==7&&N[3]==9){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll fd(ll n){
  rep(i,51){
    if((1LL<<i)&n){
      return i;
    }
  }
}
ll ed(ll n){
  for(ll i=50;i>=0;i--){
    if((1LL<<i)&n){
      return i;
    }
  }
}
ll pa(ll n){
  ll res=1LL<<fd(n);
  for(ll i=fd(n)+1;i<=50;i++){
    if(i>=ed(n))break;
    if(!((1LL<<i)&n)){
      res+=1LL<<i;
    }
  }
  return res;
}
int main(){
  ll n;
  cin>>n;
  map<ll,ll> p;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    p[a[i]]++;
  }
  sort(rall(a));
  ll ans=0;
  rep(i,n){
    if(p[a[i]]==0)continue;
    if(p[pa(a[i])]){
      if((pa(a[i])==a[i])&&(p[a[i]]<2)) continue;
    ans++;
    p[pa(a[i])]--;
    p[a[i]]--;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 26752
import java.util.Scanner;
import java.util.Stack;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] mat = new int[h][w];
    long max = Math.max(h, w);

    for (int i=0; i<h; i++) {
      char[] tmp = sc.next().toCharArray();
      for (int j=0; j<w; j++) {
        if (tmp[j]=='#')
          mat[i][j] = 1;
        else
          mat[i][j] = 0;
      }
    }
    sc.close();

    boolean[][] n_mat = new boolean[h-1][w-1];
    for (int i=0; i<h-1; i++) {
      for (int j=0; j<w-1; j++) {
        if ((mat[i][j]+mat[i+1][j]+mat[i][j+1]+mat[i+1][j+1])%2==0)
          n_mat[i][j]=true;
        else
          n_mat[i][j]=false;
      }
    }

    int[][] hist = new int[h-1][w-1];
    for (int i=0; i<h-1; i++) {
      for (int j=0; j<w-1; j++) {
        if (n_mat[i][j]) {
          if (i==0) {
            hist[i][j]=1;
          } else {
            hist[i][j]=hist[i-1][j]+1;
          }
        } else {
          hist[i][j]=0;
        }
      }
    }

    Stack<int[]> stack = new Stack<>();
    for (int i=0; i<h-1; i++) {
      if (!stack.isEmpty()) {
        for (int[] tmp: stack) {
          max = Math.max(max, (long)(tmp[0]+1)*(w-tmp[1]));
        }
        stack.clear();
      }

      for (int j=0; j<w-1; j++) {
        int th = hist[i][j];
        if (th==0) {
          for (int[] tmp: stack) {
            max = Math.max(max, (long)(tmp[0]+1)*(j-tmp[1]+1));
          }
          stack.clear();
          continue;
        }

        if (stack.isEmpty()) {
          stack.push(new int[]{th,j});
          continue;
        }

        if (th==stack.peek()[0])
          continue;

        if (th>stack.peek()[0]) {
          stack.push(new int[]{th,j});
          continue;
        }

        Stack<int[]> mini = new Stack<>();
        while (!stack.isEmpty()) {
          int[] tmp = stack.pop();
          if (th>tmp[0]) {
            stack.push(tmp);
            break;
          }
          mini.push(tmp);
        }
        if (!mini.isEmpty()) {
          if (th==mini.peek()[0]) {
            stack.push(mini.pop());
          } else {
            int tw = mini.peek()[1];
            stack.push(new int[]{th,tw});
          }
          for (int[] tmp: mini) {
            max = Math.max(max, (long)(tmp[0]+1)*(j-tmp[1]+1));
          }
          mini.clear();
        }
      }
    }
    if (!stack.isEmpty()) {
      for (int[] tmp: stack) {
        max = Math.max(max, (long)(tmp[0]+1)*(w-tmp[1]));
      }
      stack.clear();
    }

    System.out.println(max);
  }
}

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

using namespace std;

const int INF = 100000000;

int n, size;
set<string> city;
vector<string> node;
int cost[14][14];

bool isContained(string a, string b){
  if(b.find(a) != string::npos) return true;
  return false;
}

int solve(){
  int dp[1<<14][14];
  fill(dp[0], dp[1<<14], INF);
  for(int i=0;i<size;++i) dp[1<<i][i] = node[i].size();
  for(int i=0;i<(1<<size);++i){
    for(int j=0;j<size;++j){
      for(int k=0;k<size;++k){
        dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] + cost[j][k]);
      }
    }
  }
  int ans = INF;
  for(int i=0;i<size;++i){
    ans = min(ans, dp[(1<<size)-1][i]);
  }
  return ans;
}

main(){
  while(cin >> n && n){
    city.clear();
    for(int i=0;i<n;++i){
      string name;
      cin >> name;
      city.insert(name);
    }
    node.clear();
    for(set<string>::iterator i=city.begin();i!=city.end();++i){
      bool f = true;
      for(set<string>::iterator j=city.begin();j!=city.end();++j){
        if(i == j) continue;
        if(isContained(*i, *j)){
          f = false;
          break;
        }
      }
      if(f) node.push_back(*i);
    }
    size = node.size();
    for(int i=0;i<size;++i){
      for(int j=0;j<size;++j){
        if(i == j){
          cost[i][j] = 0;
          continue;
        }
        int msize = min(node[i].size(), node[j].size());
        bool f = false;
        for(int k=msize;k>0;--k){
          if(node[i].substr((int)node[i].size()-k, k) == node[j].substr(0, k)){
            cost[i][j] = (int)node[j].size() - k;
            f = true;
            break;
          }
        }
        if(!f) cost[i][j] = (int)node[j].size();
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

main(){
    ll n=in<ll>();
    if (n%2==0) out(n);
    else out(n*2);
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var b = new Dictionary<int, int>();
        for (var i = 0; i < A.Length; i++)
        {
            if (b.ContainsKey(A[i]))
            {
                b[A[i]]++;
            }
            else
            {
                b.Add(A[i], 1);
            }
        }

        for (var i = 1; i < N + 1; i++)
        {
            if (b.ContainsKey(i))
            {
                Console.WriteLine(b[i]);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 52744
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string a;
string b;
int ans[1000+1][1000+1];
int lcs()
{
    int al=a.size();
    int bl=b.size();
    int maxn=-1;
    a=" "+a;
    b=" "+b;
    for (int i=1;i<=al;i++)
    {
        for (int j=1;j<=bl;j++)
        {
            if(a[i]==b[j])
            {
                ans[i][j]=ans[i-1][j-1]+1;
            }
            else {
                ans[i][j]=max(ans[i-1][j],ans[i][j-1]);
            }
            if(ans[i][j]>maxn)
                maxn=ans[i][j];
        }
    }
   return maxn;
}
int main()
{
    int q;
    scanf("%d",&q);
    for(int i=1;i<=q;i++)
    {
        cin>>a;
        cin>>b;
        int sum=lcs();
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 7128
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, D = list(map(int, sys.stdin.readline().split()))

X, Y = np.meshgrid(np.arange(H), np.arange(W))
X, Y = X + Y, X - Y
X = X.ravel()
Y = Y.ravel()
colors = np.zeros(H * W, dtype=str)

if D % 2 == 1:
    colors[X % 2 == 1] = 'R'
    colors[X % 2 == 0] = 'Y'
else:
    colors[(X % (D * 2) < D) & (Y % (D * 2) < D)] = 'R'
    colors[(X % (D * 2) < D) & (Y % (D * 2) >= D)] = 'Y'
    colors[(X % (D * 2) >= D) & (Y % (D * 2) < D)] = 'G'
    colors[(X % (D * 2) >= D) & (Y % (D * 2) >= D)] = 'B'

x, y = (X + Y) // 2, (X - Y) // 2
ans = np.zeros((H, W), dtype=str)
ans[x, y] = colors
print('\n'.join(map(lambda r: ''.join(r), ans)))


Measured memory_bytes: 23416
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n,m;cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n){
        cout << -1 << endl;
    }
    else{
        cout << n - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){

  ll N, M;
  cin >> N >> M;

  cout << (N*(N-1))/2 + (M*(M-1))/2 << endl;

  return 0;
  
}


Measured memory_bytes: 256
class Node:
    def __init__(self):
        self.id = -1
        self.parent = None
        self.childs = [None, None]
        self.sibling = -1
        self.depth = -1
        self.height = -1

    def parentId(self):
        return -1 if self.parent == None else self.parent.id


n = int(input())
nodes = [Node() for _ in range(n)]

for i in range(n):
    id, l, r = map(int, input().split())
    p = nodes[id]
    p.id = id
    if l >= 0:
        nodes[l].parent = p
        p.childs[0] = nodes[l]
    if r >= 0:
        nodes[r].parent = p
        p.childs[1] = nodes[r]

root = None
for node in nodes:
    if node.parent == None:
        root = node
        break


def preorder(p):
    s = ""
    if p == None:
        return ""
    s += f"{p.id} "
    s += preorder(p.childs[0])
    s += preorder(p.childs[1])
    return s


def inorder(p):
    s = ""
    if p == None:
        return ""
    s += inorder(p.childs[0])
    s += f"{p.id} "
    s += inorder(p.childs[1])
    return s


def postorder(p):
    s = ""
    if p == None:
        return ""
    s += postorder(p.childs[0])
    s += postorder(p.childs[1])
    s += f"{p.id} "
    return s


print("Preorder")
print(" "+preorder(root).strip())
print("Inorder")
print(" "+inorder(root).strip())
print("Postorder")
print(" "+postorder(root).strip())



Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long N;
  cin>>N;
  long long a,b,b_sum;
  vector<long long> a_and_b;
  b_sum=0;
  int judge=0;
  for(long long i=0;i<N;++i){
    cin>>a>>b;
    b_sum+=b;
    a_and_b.push_back(a+b);
  }
  sort(a_and_b.begin(),a_and_b.end());
  judge=(N-1)%2;
  long long ans=0;
  for(long long i=N-1;i>=0;--i){
    if(i%2==judge){
      ans+=a_and_b[i];
    }
  }
  ans-=b_sum;
  cout<<ans;
return 0;
}


Measured memory_bytes: 1400
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int cnt(bool s, string S)
{
  int r = 0;
  for (auto &c : S)
  {
    char t = s ? '0' : '1';
    if (t != c)
      r++;
    s = !s;
  }
  return r;
}

int main()
{
  string S;
  cin >> S;

  cout << min(cnt(true, S), cnt(false, S)) << '\n';

  return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n;
    cin>>n;
    lvec a(n);
    cinf(n,a);
    sort(all(a));
    ll ans;
    int s=0,t=0;
    set<ll> st2,st4;
    while(t<n){
        while(a[s]==a[t])t++;
        if(t-s>=4){
            st2.insert(a[s]);
            st4.insert(a[s]);
        }else if(t-s>=2) st2.insert(a[s]);
        s=t;
    }
    if(st2.size()<2) ans=0;
    else{
        ll u=*rbegin(st2);
        st2.erase(u);
        ll v=*rbegin(st2);
        ans=u*v;
        if(!st4.empty()){
            ll p=*rbegin(st4);
            if(u<=p)p*=p;
            else p*=u;
            if(p>ans)ans=p;
        }
    }cout<<ans<<endl;
}

Measured memory_bytes: 2944
//嘘っぽいのに通ってたやつでいこう

#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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

char cn[2000100], *ci = cn, c;

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


	fread(cn, 1, 2000100, stdin);
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	int sL[1001] = {}, sR[1001] = {};
	pair<int, int> RR[500], LL[500];
	int rr = 0, ll = 0;
	int tot = 0;
	rep(i, N) {
		int l = 0, r = 0;
		while ((c = *ci++) >= '(') {
			if (c == '(') r++;
			else {
				if (r > 0) r--;
				else l++;
			}
		}
		tot += r - l;
		if (l < r) {
			if (l <= 1000) sR[l] += r;
			else RR[rr++] = { l,r };
		}
		else {
			if (r <= 1000) sL[r] += l;
			else LL[ll++] = { r,l };
		}
	}

	if (tot != 0) {
		printf("No");
		return 0;
	}

	sort(RR, RR + rr);
	sort(LL, LL + ll);

	int OK = 1;
	int k = 0;
	rep(i, 1001) {
		if (sR[i]) {
			if (k < i) OK = 0;
			k += sR[i];
		}
	}
	rep(i, rr) {
		if (k < RR[i].first) OK = 0;
		k += RR[i].second - RR[i].first;
	}
	k = 0;
	rep(i, 1001) {
		if (sL[i]) {
			if (k < i) OK = 0;
			k += sL[i];
		}
	}
	rep(i, ll) {
		if (k < LL[i].first) {
			OK = 0;
		}
		k += LL[i].second - LL[i].first;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999

int main()
{
	int n;
	cin >> n;
	vector<int> nums(n);
	loop(i, n)cin >> nums[i];
	int ans = INF;
	loops(i, -100, 101)
	{
		int count = 0;
		loop(j, nums.size())
		{
			count += pow(abs(nums[j] - i), 2);
		}
		ans = min(ans, count);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
X,K,D = list(map(int, input().split()))
#XからD歩移動をK回繰り返す
X = max(X, -X)

if X-(K*D)>0:
  print(X-(K*D))
else:
  #原点に最も接近するステップ数
  step, place, nokori = int(X/D), X-(int(X/D)*D), K-int(X/D)
  #print(step, place, nokori)
  if nokori%2 ==0:
    print(place)
  else:
    print(-(place-D))

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 300;

int X, Y;
struct Flow{
    struct edge{
        int to, cap, rev;
    };
    vector<edge> G[MAX_V];//??£??\?????????
    bool used[MAX_V];

    void add_edge(int from, int to, int cap){
        G[from].push_back((edge){to, cap, G[to].size()});//from -> to
        G[to].push_back((edge){from, 0, G[from].size() - 1});//to -> from
    }

    //?¢???????????????¢???
    int dfs(int v, int t, int f){
        if(v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); ++i){
            edge &e = G[v][i];
            if(!used[e.to] && e.cap > 0){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    //s??????t???????????§???
    int max_flow(int s, int t){
        int flow = 0;
        while(1){
            memset(used, 0, sizeof(used));
            int f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(void){
	int e; cin >> X >> Y >> e;
	int s = X + Y;
	int t = X + Y + 1;
	Flow mf;
	//s -> x
	rep(i, X){
		mf.add_edge(s, i, 1);
	}
	// y -> t
	rep(i, Y){
		mf.add_edge(X + i, t, 1);
	}
	// x -> y
	rep(i, e){
		int tx, ty; cin >> tx >> ty;
		mf.add_edge(tx, X + ty, 1);
	}

	printf("%d\n", mf.max_flow(s, t));
}

Measured memory_bytes: 1516
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key


int poww(int a, int b){
    // a%=MOD;
    int res=1;
    while(b>0){
        if(b&1)res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

signed main() {
   tezz
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int final=INT_MAX;
    int ans=0;
    for(int i=1; i<=100;i ++){
        ans=0;
        for(int j=0; j<n; j++){
            ans+=(poww(i-a[j],2));
        }
        final=min(ans,final);
    }
    cout << final;
    
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 1e5+10;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int r, g, b, k; cin>>r>>g>>b>>k;
	while(b<=r) {b*=2, k--; if(k<0) {cout << "No\n"; return 0;}}
	while(g<=r) {g*=2, k--; if(k<0) {cout << "No\n"; return 0;}}
	while(b<=g) {b*=2, k--; if(k<0) {cout << "No\n"; return 0;}}
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
Q = int(input())
AB = [list(map(int,input().split())) for i in range(Q)]

small_case = {(1,1):0, (1,2):0}
for A,B in AB:
    M = A*B
    A,B = sorted([A,B])
    if (A,B) in small_case:
        print(small_case[(A,B)])
        continue
    ans = 0
    i = 1
    b = int(pow(M,0.5))
    if b == B:
        b -= 1
    ans += (M-1)//b - A
    ans += b-1
    ans += A-1
    print(ans)


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

using namespace std;
using ll = long long;

ll MOD;
vector<int> path[100010];
ll dp[100010], ans[100010];

ll dfs(int v, int r) {
    dp[v] = 1;
    for (int sv : path[v]) {
        if (sv == r) continue;
        dp[v] *= dfs(sv, v) + 1;
        dp[v] %= MOD;
    }
    return dp[v];
}

void edfs(int v, int r, ll par) {
    ans[v] = dp[v] * (par + 1) % MOD;

    vector<int> chv = {-1};
    for (int sv : path[v]) {
        if (sv == r) continue;
        chv.push_back(sv);
    }
    int L = chv.size() - 1;

    ll fore[L + 2], back[L + 2];
    fore[0] = back[L + 1] = 1;
    for (int i = 1; i <= L; ++i) fore[i] = fore[i - 1] * (dp[chv[i]] + 1) % MOD;
    for (int i = L; i >= 1; --i) back[i] = back[i + 1] * (dp[chv[i]] + 1) % MOD;

    for (int i = 1; i <= L; ++i) {
        edfs(chv[i], v, fore[i - 1] * back[i + 1] % MOD * (par + 1) % MOD);
    }
}

int main() {
    int N;
    cin >> N >> MOD;
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        path[u].push_back(v);
        path[v].push_back(u);
    }

    dfs(0, -1);
    edfs(0, -1, 0);
    for (int v = 0; v < N; ++v) cout << ans[v] << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

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

	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	for (ll i = 2, maxval = sqrt(N); i < maxval; ++i) {
		ll cnt = 0;
		while (N % i == 0) {
			N /= i;
			++cnt;
		}

		ll a = 1;
		while (cnt >= a) {
			cnt -= a;
			++a;
			++ans;
		}
	}

	if (N != 1) ++ans;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<string>


using namespace std;

int main(void)
{
	int a, b, h;
	cin >> a >> b >> h;
	int ans;
	ans = (a + b)*h / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int gcd(int n, int m) {
  if (n == 0) {
    return m;
  }
  if (m == 0) {
    return n;
  }
  return gcd(m, n % m);
}

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;

  int n;
  cin >> n;
  int g;
  cin >> g;
  for (int i = 1; i < n; ++i) {
    int a;
    cin >> a;
    g = gcd(g, a);
  }
  cout << g;

  return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  var k int = NextInt()
  var a []int64 = NextInt64Array()
  if a[k-1] != 2 {
    fmt.Println(-1)
    return
  }
  var min,max int64 = 2,3
  for i:=k-2;i>-1;i-- {
    min = ((min+a[i]-1)/a[i])*a[i]
    if max < a[i] || max < min {
      fmt.Println(-1)
      return
    }
    max = (max/a[i])*a[i]+a[i]-1
  }
  fmt.Println(min,max)
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextInt64Array() []int64 {
  var s []string = strings.Split(NextLine()," ")
  var a []int64 = make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}

Measured memory_bytes: 6016