akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x, k, d;
void input() { cin >> x >> k >> d; }

void solve() {
  long long ans;
  x = abs(x);
  if (x / d >= k) {
    ans = abs(x - d * k);
  } else {
    ll s = x / d;  //周期に入るまでの回数
    k -= s;
    x -= s * d;
    if (k & 1) x = abs(x - d);  //奇数なら0を跨ぎ
    ans = x;                    //偶数ならそのまま
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  getchar();
}

Measured memory_bytes: 3628
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cctype>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vector<string> V(3);

signed main(){

    in(V);

    cout<<(char)toupper(V[0][0])<<(char)toupper(V[1][0])<<(char)toupper(V[2][0])<<endl;

    return 0;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(true){
        if(c<=0) {cout << "Yes" <<endl;
        break;
        }
        else if(a<=0){
            cout << "No" <<endl;
            break;
        }
        c-=b;
        a-=d;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

struct Edge{
  int to,cost;
  ll dist;
  Edge(int to,int cost,ll dist):to(to),cost(cost),dist(dist){};
};

int N,M,S;
vector<vector<Edge>> g;
vector<ll> C,D;

const ll MC=5000;
vector<vector<ll>> dp;
const ll INF=1e18;

typedef tuple<ll,int,int> T;

void dijkstra(){
  priority_queue<T,vector<T>,greater<T>> PQ;
  PQ.push(mkt(0,0,S));
  dp[0][S]=0;

  while(!PQ.empty()){
    auto f=PQ.top();
    PQ.pop();

    int now=get<1>(f);
    ll cur=get<2>(f);
    ll res=get<0>(f);
    if(dp[now][cur]<res) continue;
    if(dp[now][min(MC,cur+C[now])]>dp[now][cur]+D[now]){
      dp[now][min(MC,cur+C[now])]=dp[now][cur]+D[now];
      PQ.push(mkt(dp[now][min(MC,cur+C[now])],now,min(MC,cur+C[now])));
    }

    for(auto e:g[now]){
      int to=e.to;
      int cost=e.cost;
      ll dist=e.dist;
      
      if(cur<cost) continue;
      int nc=cur-cost;
      if(dp[to][nc]>dp[now][cur]+dist){
        dp[to][nc]=dp[now][cur]+dist;
        PQ.push(mkt(dp[to][nc],to,nc));
      }
    }
  } 
}

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

  cin>>N>>M>>S;
  g.resize(N);
  rep(i,M){
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    g[u].push_back({v,a,b});
    g[v].push_back({u,a,b});
  }
  C.resize(N);
  D.resize(N);
  rep(i,N) cin>>C[i]>>D[i];

  S=min(S,(int)MC);
  rep(i,N) C[i]=min(C[i],(ll)MC);

  dp.resize(N,vector<ll>(MC+1,INF));

  dijkstra();

  for(int i=1;i<N;i++){
    ll ans=*min_element(dp[i].begin(),dp[i].end());
    cout<<ans<<"\n";
  }


  return 0;
}


Measured memory_bytes: 9324
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if ((a * a * b / 2) <= x) {
    int t1 = a * a * a;
    int t2 = 2 * (a * a * b - x);
    double t3 = (double)t2 / double(t1);
    cout << setprecision(10);
    cout << atan(t3) * 180 / M_PI << endl;
  } else {
    int t1 = a * b * b;
    int t2 = 2 * x;
    double t3 = (double)t1 / (double)t2;
    cout << setprecision(10);
    cout << atan(t3) * 180 / M_PI << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int[] ci = new int[26];
        ContestTuple[] cTuples = new ContestTuple[26];
        int[][] sdi = new int[d][26];
        for(int i=0; i<26; i++) {
            ci[i] = in.nextInt();
            ContestTuple tuple = new ContestTuple(d);
            tuple.type = i;
            tuple.c = ci[i];
            cTuples[i] = tuple;
        }
        for(int day=0; day<d; day++) {
            for(int i=0; i<26; i++) {
                sdi[day][i] = in.nextInt();
                cTuples[i].sd[day] = sdi[day][i];
            }
        }
        
        // 初日からの経過時間とcの大きさで判断するPriorityQueue
        PriorityQueue<ContestTuple> queue = new PriorityQueue<>(26, new ContestComparator());
        for(int i=0; i<26; i++) {
            cTuples[i].queuedDate = 0;
            queue.add(cTuples[i]);
        }
        for(int day=0; day<d; day++) {
            ContestTuple tuple = queue.poll();
            System.out.println(tuple.type+1);
            tuple.queuedDate = day+1;
            queue.add(tuple);
        }
    }
}

class ContestTuple {
    int type;
    int c;
    int[] sd;
    int queuedDate;
    
    public ContestTuple(int d) {
        this.sd = new int[d];
    }
}

class ContestComparator implements Comparator<ContestTuple> {
    @Override
    public int compare(ContestTuple o1, ContestTuple o2) {
        return (o1.queuedDate - o1.c) - (o2.queuedDate - o2.c);
    }
}


Measured memory_bytes: 46760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
bool dp[81][81][26000];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    int A[81][81];
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
        }
    }
    int B[81][81];
    rep(i, H) {
        rep(j, W) {
            cin >> B[i][j];
        }
    }
    int C[81][81];
    rep(i, H) {
        rep(j, W) {
            C[i][j] = abs(A[i][j] - B[i][j]);
        }
    }
    dp[0][0][13000 + C[0][0]] = true;
    dp[0][0][13000 - C[0][0]] = true;
    rep(i, H) {
        rep(j, W) {
            REP(k, 200, 26000 - 200) {
                if (i + 1 < H) {
                    dp[i + 1][j][k + C[i + 1][j]] |= dp[i][j][k];
                    dp[i + 1][j][k - C[i + 1][j]] |= dp[i][j][k];
                }
                if (j + 1 < W) {
                    dp[i][j + 1][k + C[i][j + 1]] |= dp[i][j][k];
                    dp[i][j + 1][k - C[i][j + 1]] |= dp[i][j][k];
                }
            }
        }
    }
    int ans = INF;
    REP(i, 200, 26000-200) {
        if (dp[H - 1][W - 1][i]) ans = min(ans, abs(13000-i));
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 166144
#include<stdio.h>	
int main(){
		int s[4][2]={0,0,0,0,0,0,0,0},j;
double b[2];
while(scanf("%lf %lf",&b[0],&b[1])!=EOF){
for(j=0;j<2;j++){
if(b[j]>=1.1)
s[0][j]++;
else if(b[j]>=0.6)
s[1][j]++;
else if(b[j]>=0.2)
s[2][j]++;
else s[3][j]++;
}
}
for(j=0;j<4;j++)
printf("%d %d\n",s[j][0],s[j][1]);

return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

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

//main code

int main(int argc, char const* argv[])
{
    int a,b,c;
    cin >> a >> b >>c;
    int m = max(a,b);
    m = max(m,c);
    cout << m * 10 + a + b + c - m << endl;
    return 0;
}


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

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

    int n, count = 1;
    cin >> n;
    vector<int> h(n);
    cin >> h[0];
    int tmp = h[0];
    for (int i = 1; i < n; i++)
    {
        cin >> h[i];
        tmp = max(tmp, h[i-1]);
        if (tmp <= h[i])
            count++;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int ans = 753;
  for (int i = 0; i < S.size() - 2; i++)
    ans = min(abs(stoi(S.substr(i, 3)) - 753), ans);
  cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int W,H;
string S[12];
string T[12],R[12];
int num=0;

void hoge() {
	int x,y;
	set<string> U;
	int left=0;
	
	FOR(x,W) {
		if(U.count(R[x])) {
			U.erase(R[x]);
		}
		else {
			U.insert(T[x]);
		}
	}
	
	if(U.empty()) {
		cout<<"YES"<<endl;
		exit(0);
	}
	if(U.size()==1) {
		string s=*U.begin();
		string t=s;
		reverse(ALL(s));
		if(t==s) {
			cout<<"YES"<<endl;
			exit(0);
		}
	}
}

void add(int l) {
	int x;
	FOR(x,W) {
		T[x].push_back(S[l][x]);
		R[x][H-T[x].size()]=S[l][x];
	}
}
void del() {
	int x;
	FOR(x,W) T[x].pop_back();
}

void dfs(int mask,int last) {
	int i;
	if(__builtin_popcount(mask)>=(H+1)/2) {
		int num=0;
		FOR(i,H) {
			if((mask&(1<<i))==0) {
				num++;
				add(i);
			}
		}
		hoge();
		FOR(i,num) del();
		return;
	}
	
	FOR(i,H) if((mask&(1<<i))==0) {
		add(i);
		dfs(mask^(1<<i),i);
		del();
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(x,W) R[x].resize(H);
	FOR(y,H) cin>>S[y];
	vector<int> V;
	dfs(0,-1);
	cout<<"NO"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
N=int(input())
L_0 = 2
L_1 = 1
if N==0:
    print(L_0)
elif N==1:
    print(L_1)
else:
    for i in range (N-2):
        if i%2 ==0:
            L_0 = L_0 + L_1
        else:
            L_1 = L_0 + L_1
    print(L_0 + L_1)


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

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;


void solve()
{
  cin>>n;
  ll d;
  m=INT_MIN,k=INT_MAX,c=INT_MIN,d=INT_MAX;
  while(n--)
  {
      cin>>a>>b;
      m=max(m,a+b);
      k=min(k,a+b);
      
      c=max(c,a-b);
      d=min(d,a-b);
  }
  cout<<max(abs(m-k),abs(c-d));
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"
import "sort"
import "strings"

func main() {
	var n, l int
	fmt.Scanf("%d %d", &n, &l)

	strs := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&strs[i])
	}

	sort.Strings(strs)
	fmt.Println(strings.Join(strs, ""))
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>> A(M);
    for(int i = 0; i < M; i++){
        cin >> A[i].fi >> A[i].se;
      A[i].fi--;
      A[i].se--;
    }

    vector<int> Cnt(N, 1);
    vector<bool> Pos(N, false);
    Pos[0] = true;
    for(int i = 0; i < M; i++){
        if(Pos[A[i].fi]){
            if(Cnt[A[i].fi] == 1) Pos[A[i].fi] = false;
            Pos[A[i].se] = true;
        }
        Cnt[A[i].fi]--;
        Cnt[A[i].se]++;
    }
    int sum = 0;
    for(bool i : Pos) if(i) sum++;

    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define mp make_pair
#define all(X) X.begin(), X.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int x;
    cin >> x;
    double ans = 0;
    if(x % 2 == 0)
    {
        ans = 0.5;
    }
    else
    {
        int odd = x / 2 + 1;
        int even = x / 2;
        ans = ((float)odd / (odd + even));
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Author: Hamza Hasbi
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore(),
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline long long lcm(ll a,ll b) {return a*b/__gcd(a,b);}
//inline long long gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
void READ() {
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    #endif
}
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin >> x;
    int ans = 0;
    for(int i = 1 ; i <= sqrt(x) ; ++i){
        for(int j = 2; j <= 16 ; j++) {
            if(pow(i,j) <= x) ans = max(ans,(int)pow(i,j));
            else break;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    float n, d; cin >> n >> d;
    float range = 2 * d + 1;
    int ans = (int)ceil(n / range);
    cout << ans << endl;
}


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

int main(){
    int n;cin >> n;
    vector<double> v(n);
    for (int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double res = v[0];
    for (int i=0;i<n-1;i++){
        res = (res+v[i+1])/2.0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
mod=10**9+7
Broken = [0]*(n+2)
for i in range(m):
    a=int(input())
    Broken[a]=1
table=[0]*(n+2)
table[0]=1
for i in range(1,n+1):
    if Broken[i]==1:
        continue
    table[i] = (table[i-1]+table[i-2]) % mod
print(table[n])

Measured memory_bytes: 7668
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    x = A[0]
    for i in range(1, N):
        x = gcd(x, A[i])
    if K <= max(A) and K % x == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()


Measured memory_bytes: 62576
import sys
import math
import collections

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


def get(s):
    return str(s % 9) + '9' * (s // 9)

if __name__ == '__main__':
    # set_debug(True)

    # t = int(input())
    t = 1

    for ti in range(1, t + 1):
        n = int(input())

        res = ''

        while n >= 1:
            n -= 1
            mod = n % 26
            n = n // 26
            res += chr(ord('a') + mod)

        print(res[::-1])


Measured memory_bytes: 9168
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = Integer.parseInt(sc.next());
        BigDecimal bign = BigDecimal.valueOf(n);
        BigDecimal consumption_tax = BigDecimal.valueOf(1.08);
        //        BigDecimal x = bign.divide(consumption_tax, RoundingMode.DOWN);
        //        BigDecimal 再計算 = x.multiply(consumption_tax);
        //        //        out.println(bign);
        //        //        out.println(x);
        //        //        out.println(x.multiply(consumption_tax));
        //        //        out.println(再計算.stripTrailingZeros());
        //        if (bign.equals(再計算.stripTrailingZeros())) {
        //            out.println(x);
        //        } else {
        //            out.println(":(");
        //        }

        boolean acflg = false;
        // 税抜価格をi円と仮定
        for (int i = 1; i <= n; i++) {
            BigDecimal x = BigDecimal.valueOf(i);
            // 税抜価格 * 1.08(小数点以下切り捨て) = 仮定の税込価格
            BigDecimal value = x.multiply(consumption_tax).setScale(0, RoundingMode.DOWN);
            // 仮定の税込価格がnと一致する場合
            if (value.equals(bign)) {
                acflg = true;
                out.println(x);
                break;
            }
        }
        if (!acflg) {
            out.println(":(");
        }

        sc.close();
        out.close();
    }

}

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

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<int> d;

void dfs(int u, int w)
{
    cerr << u << " " << w << endl;
    d[u] = w;
    for (auto i: graph[u])
    {
        if (d[i.first] == -1) dfs(i.first, (w+i.second)%2);
    }
}

int main(void)
{
    int N, u, v, w;
    cin >> N;
    graph.resize(N);
    d.resize(N, -1);
    for (int i = 1; i < N; i++)
    {
        cin >> u >> v >> w;
        graph[u-1].push_back({v-1, w%2});
        graph[v-1].push_back({u-1, w%2});
    }
    dfs(0, 0);
    for(auto i: d) cout << i << endl;
    return 0;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
int w[2000], b[2000];
LL costW[4000][2000];
LL costB[4000][2000];
LL dp[4001][2001];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 2 * N; i++) {
		string c;
		int a;
		cin >> c >> a;
		if (c == "W") w[a - 1] = i;
		else b[a - 1] = i;
	}
	for (int i = 0; i < 2 * N; i++) {
		int a;
		if (i < N) a = b[i];
		else a = w[i - N];
		for (int j = 0; j < N; j++) {
			if (j > 0) {
				costW[i][j] = costW[i][j - 1];
				costB[i][j] = costB[i][j - 1];
			}
			costW[i][j] += (w[j] > a);
			costB[i][j] += (b[j] > a);
		}
	}
	fill((LL*)dp, (LL*)(dp + 2 * N + 1), 1LL << 60);
	dp[0][0] = 0;
	for (int i = 0; i < 2 * N; i++) {
		for (int j = 0; j <= min(i, N); j++) {
			if (dp[i][j] == 1LL << 60) continue;
			if (j + 1 <= N) {
				LL add = 0;
				if (j > 0) add += costB[j][j - 1];
				if (i - j > 0) add += costW[j][i - j - 1];
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + add);
			}
			if (i - j + 1 <= N) {
				LL add = 0;
				if (j > 0) add += costB[i - j + N][j - 1];
				if (i - j > 0) add += costW[i - j + N][i - j - 1];
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + add);
			}
		}
	}
	cout << dp[2 * N][N] << endl;
}

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

int main() {
    long long x;
    cin >> x;
    vector<long long> vec;
    long long i=0;
    while(i*i*i*i*i<=1e18){
        vec.push_back(i*i*i*i*i);
        i++;
    }
    long long n=vec.size();
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            if(vec.at(i)+vec.at(j)==x){
                cout << i << " " << -j << endl;
                return 0;
            }
            if(vec.at(i)-vec.at(j)==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

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

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

  int minId = 0;
  int maxId = 1 << 30;

  for (int i = 0; i < M; ++i) {
    int L, R;
    cin >> L >> R;
    minId = max(minId, L);
    maxId = min(maxId, R);
  }

  int ans = max(maxId - minId + 1, 0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  char S[128];

  do {
    scanf("%s", S);
  } while (S[0] < '0' || S[0] > '9' || S[1] < '0' || S[1] > '9' || S[2] < '0' || S[2] > '9'  || S[3] < '0' || S[3] > '9');

  int n = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == S[i + 1]) {
      n--;
    }
  }

  if (n < 0) {
    printf("Bad\n");
  } else {
    printf("Good\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 h,w;cin >> h >> w;
    vector<string> table(h+2);
    ll cnt = 0;
    repp(i,1,h+1){
        cin >> table[i];
        table[i] = "." + table[i] + ".";
        //cnt += count(all(table[i]),'#');
        rep(j,w)if(table[i][j+1] == '#')cnt++;
    }
    int dx[] = {0,1};
    int dy[] = {1,0};
    stack<P> st;
    st.push(make_pair(1,1));
    vector<vector<int>> seen(h+2,vector<int>(w+2,0));
    seen[1][1] = true;
    while(!st.empty()){
        auto a = st.top();
        ll x = a.first;
        ll y = a.second;
        st.pop();
        rep(i,2){
            if(table[x + dx[i]][y + dy[i]] == '#' && !seen[x + dx[i]][y + dy[i]]){
                st.push(make_pair(x + dx[i],y + dy[i]));
                seen[x + dx[i]][y + dy[i]] = 1;
            }
        }
    }
    //ll cnt_s = 0;
    //rep(i,h)rep(j,w)if(seen[i+1][j+1])cnt_s++;
    if(!seen[h][w] || cnt != h + w -1 ){
        cout << "Impossible\n";
    }else cout << "Possible\n";
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int n ,k, i, c, p;
int main() {
  scanf("%d%d\n", &n, &k); k *= -2;
  while(i++ < n)if((c = getchar_unlocked()) != p) k++, p = c;
  printf("%d\n", n - (k < 1 ? 1 : k));
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define per(i,a,b) for(ll i=(b)-1;i>=(a);i--)
string s;
int main() {
    ios_base::sync_with_stdio(0);
    cin>>s;
    cout<<(s=="ARC"?"ABC":"ARC")<<"\n";
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=1000,M=N*50,maxn=1e18;

bool bz[N];
int x[N],y[N];
ll v[N];
int la[N],lb[M],ne[M],le[M];
ll cost[M];
int fr[N],f1[N];

int n,m,oo,S,T;
char c[N];
int a[N],b[N],d[M];
int p[N][2],q[N][2];
ll dis[N];
ll rec;

inline ll max(ll a,ll b)
{return a>b?a:b;}

inline int min(int a,int b)
{return a<b?a:b;}

inline void llb(int a,int b,int c,ll co)
{
	ne[++oo]=la[a]; la[a]=oo; lb[oo]=b;
	le[oo]=c; cost[oo]=co; 
}

inline void gg(int a,int b,int c,ll d)
{
	llb(a,b,c,d); llb(b,a,0,-d);
}

inline bool flow()
{
	fo(i,1,T)dis[i]=maxn;
	dis[S]=0;
	int l=0,r=1; d[1]=S; bz[S]=true;
	while(l<r){
		int o=d[++l];
		for(int y=la[o];y;y=ne[y])
		if(dis[o]-cost[y]<dis[lb[y]]&&le[y]==1){
			dis[lb[y]]=dis[o]-cost[y];
			fr[lb[y]]=o; f1[lb[y]]=y;
			if(!bz[lb[y]])d[++r]=lb[y],bz[lb[y]]=true;
		}
		bz[o]=false;
	}
	if(dis[T]==maxn)return false;
	rec=0;
	for(int u=T;u!=S;u=fr[u]){
		int k=f1[u];
		le[k]=0;
		le[k^1]=1;
		rec=rec+cost[k];
	}
	return true;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n)scanf("%d%d%lld",&x[i],&y[i],&v[i]);
	scanf("%d",&m);
	fo(i,1,m){
		char ch=' ';
		for(;ch!='L'&&ch!='R'&&ch!='D'&&ch!='U';ch=getchar());
		c[i]=ch;
		scanf("%d%d",&a[i],&b[i]);
	}
	ll ans=0;
	fo(i,1,n){
		fo(l,1,i)p[l][0]=1,p[l][1]=100;
		fo(l,1,i)q[l][0]=1,q[l][1]=100;
		fo(l,1,m)
		if(c[l]=='L'&&b[l]<i){
			fo(j,b[l]+1,i)p[j][0]=max(p[j][0],a[l]+1);
		} else if(c[l]=='R'&&b[l]<i){
			fo(j,1,i-b[l])p[j][1]=min(p[j][1],a[l]-1);
		} else if(c[l]=='U'&&b[l]<i){
			fo(j,1,i-b[l])q[j][1]=min(q[j][1],a[l]-1);
		} else if(c[l]=='D'&&b[l]<i){
			fo(j,b[l]+1,i)q[j][0]=max(q[j][0],a[l]+1);
		}
		int ok=0;
		fo(l,1,i)if(p[l][0]>p[l][1]||q[l][0]>q[l][1]){ok=1; break;}
		if(ok)continue;
		oo=1;
		S=2*i+2*n+1,T=S+1;
		fo(j,1,T)la[j]=0;
		fo(l,1,i)gg(S,l,1,0);
		fo(l,1,i)gg(i+2*n+l,T,1,0);
		fo(l,1,n)gg(i+l,i+n+l,1,v[l]);
		fo(l,1,n){
			fo(j,1,i)if(p[j][0]<=x[l]&&x[l]<=p[j][1])gg(j,i+l,1,0);
			fo(j,1,i)if(q[j][0]<=y[l]&&y[l]<=q[j][1])gg(i+l+n,i+n*2+j,1,0);
		}
		ll da=0; int cs=0;
		while(flow()){
			da=da+rec;
			++cs;
		}
		if(cs==i)ans=max(ans,da);
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d)<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-


def get_fact(N):
  ret = set([N])
  for i in range(2,int(N**0.5)+2):
    if N%i == 0:
      ret.add(i)
      ret.add(N//i)
  return ret


def main():
  ## input
  N,K = map(int, input().split())
  An = list(map(int, input().split()))

  ## Solve
  fset = get_fact(sum(An))
  ans = 1
  for f in fset:
    Amod = [a%f for a in An]
    Amod = sorted(Amod)
    for i in range(len(Amod)):
      if sum(Amod[:i])==f*(N-i)-sum(Amod[i:]) and sum(Amod[:i])<=K:
        ans = max(ans,f)
  return ans


if __name__ == "__main__":
  ans = main()
  print(ans)


Measured memory_bytes: 45968
#include<bits/stdc++.h>
#define all(vc) vc.begin(),vc.end()
#define ll long long
#define MIN(a,b) ((a)<(b)) ? (a) : (b)
#define EVEN(a) (a)%2==0 ? 1 : 0
#define fi first
#define se second
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define DEBUG
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define mxel(vc) max_element(vc.begin(),vc.end())
#define mnel(vc) min_element(vc.begin(),vc.end())
using namespace std;
int MOD = 1e9+7;
long long int ji[300005];
long long int brut = 1e18;
int Search_Binary (int arr[], int left, int right, int key)
{
 int midd = 0;
 while (1)
 {
    midd = (left + right) / 2;
 if (key < arr[midd]){
    right = midd - 1;
 }else if (key > arr[midd]){
    left = midd + 1;
 }else{
    return midd;
 }
 if (left > right){
    return -1;
    }
  }
}
int fDig(int i)
{
   int k;
   do
   {
      k=i;
      i/=10;
   }while(i);
   return k;
}
int gcd (int a, int b) {
           while (b) {
                a %= b;
           swap (a, b);
        }
    return a;
    }
int lcm (int a, int b) {
     return a / gcd (a, b) * b;
    }
int to_int(string s){
    int x;
    stringstream geek(s);
    geek >> x;
    return x;
}
int prim_const( int x){
    vector<bool> prime(x, true);
    prime[0] = prime[1] = false;
    for (int i=2; i * i<=x; ++i){
        if (prime[i]){
            if (i * 1ll * i <= x){
                for (int j=i*i; j<=x; j+=i){
                    prime[j] = false;
                }
            }
        }
    }
    if (prime[x] == true){
        return 1;
    }else{
        return 0;
    }
}
void solve(int n){
    if(n % 2 == 0){
        cout << (n/2)-1;
    }else{
        cout << (n/2);
    }
}
long long int j;
long long int drujba=0;
int main()
{
  cin.tie(0);cout.tie(0);
  int n;
  cin >>n;
  solve(n);
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
mem = 0
m = int(input())
for i in range(m):
    p, x = map(int, input().split())
    mem = t[p-1]
    t[p-1] = x
    print(sum(t))
    t[p-1] = mem

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

#include <unordered_map> 
#include <cstdio>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n

using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

// UTILITY FUNCTIONS

// String
char toUpper(const char &c) { return isupper(c) ? c : c - 'a' + 'A'; }
char toLower(const char &c) { return islower(c) ? c : c + 'a' - 'A'; }
bool isvowel(char c){  c = toLower(c);return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u' || c == 'y');}
void toLowerCase(string &s){rep(s.size()){  if (!islower(s[i]))  {    s[i] = tolower(s[i]);  }}}
void toUpperCase(string &s){rep(s.size()) { s[i] = toupper(s[i]); }}
bool ispal(string s){  ll lo, hi;  lo = 0;  hi = s.length() - 1;  while (lo <= hi)  {    if (s[lo] != s[hi])    {      return 0;    }    lo++;    --hi;  }  return 1;}
template <class T>string toString(T n){  string v = "";  while (n)  {    v.pb(n % 10 + '0');    n /= 10;  }  reverse(all(v));  return v;}

// Maths
template <typename t>t gcd(t a, t b){  a = abs(a), b = abs(b);  return ((b == 0) ? a : gcd(b, a % b));}
template <typename t>t lcm(t a, t b) { return (a * (b / gcd(a, b))); }
template <typename T>T modpow(T base, T exp, T modulus){  base %= modulus;  T result = 1;  while (exp > 0)  {    if (exp & 1)      result = (result * base) % modulus;    base = (base * base) % modulus;    exp >>= 1;  }  return result;}
template <typename T>void cumulative(T *a, T *b, T n){  rep(n) { i ? b[i] = b[i - 1] + a[i] : b[i] = a[i]; }}

// Some constants
const int inf = 1e9 + 7;
const double eps = 1e-6;
const double pi = 1.00 * acos(-1.00);

//------------------------------------------------------------------------

void solve(ll testcase){
  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  s[m-1] = toLower(s[m-1]);
  cout << s << endl;
}

int main()
{
  std::ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef ONLINE_JUDGE
#else
  //freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  ll t = 1;
  // cin >> t;
  ll cas = 0;
  while (t--)
  {
    solve(++cas);
  }
}


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

int main(){
 int H,W;
 while(true){
  cin >> H >> W;
  if(H == 0 && W == 0) break;
  
  for(int i=0;i<H;i++){
   for(int j=0;j<W;j++){
   cout<< '#';
   }
   cout << "\n";
  }
  cout << "\n";
 }
}


Measured memory_bytes: 3044
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let c: usize = sc.cin();
    let k: u64 = sc.cin();
    let mut xs: Vec<u64> = sc.vec(n);
    xs.sort();

    let mut ans = 1;
    let mut num = 0;
    let mut s = 0;
    for &x in xs.iter() {
        if num == 0 {
            s = x;
            num = 1;
        } else if x <= s + k && num + 1 <= c {
            num += 1;
        } else {
            s = x;
            num = 1;
            ans += 1;
        }
    }

    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> score(n);
	int x = s.length();
	int cur = 0;
	int res = 0;
	for (int i = 0; i < x; i++) {
		if (s.at(i) == 'I')cur++;
		else cur--;
		res = max(cur, res);
	}
	cout << res << endl;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

u32 rec(vector<u32> &vec, u32 &ans, u32 n, function<u32(vector<u32> &)> eval) {
  u32 v = ans;
  if (n == 0) {
    v = eval(vec);
    ans = max(ans, v);
    return ans;
  }
  REP(i, vec[n]) {
    vec[n - 1] = i + 1;
    v = max(v, rec(vec, ans, n - 1, eval));
  }
  return v;
}

int main() {
  u32 N = 0, M, Q;

  cin >> N >> M >> Q;

  vector<u32> a(Q), b(Q), c(Q), d(Q);
  u32 ain, bin, _cin, din;

  REP(q, Q) {
    cin >> ain >> bin >> _cin >> din;
    a[q] = ain;
    b[q] = bin;
    c[q] = _cin;
    d[q] = din;
  }

  vector<u32> A(N + 1, M);
  u32 ans = 0;
  rec(A, ans, N, [&](vector<u32> &vec) {
    u32 sum = 0;
    REP(q, Q) {
      if (vec[b[q]] - vec[a[q]] == c[q]) {
        sum += d[q];
      }
    }
    return sum;
  });

  cout << ans;

  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> a(101),b(101);
int n,w;

vector<vector<int>> dp(101,vector<int>(100001,-1));

int go(int i, int w){
    if(dp[i][w]!=-1)
        return dp[i][w];
    if(i==n)
        return 0;
    if(w==0)
        return 0;
    int sum=0;
    int mmax = 0;
    if(a[i]<=w)
        mmax = max(mmax, b[i] + go(i+1,w-a[i]));
    mmax = max(mmax, 0 + go(i+1,w));
    return dp[i][w]=mmax;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,m,i,j,sum=0;
    cin>>n>>w;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    cout<<go(0,w)<<'\n';


    return 0;
}


Measured memory_bytes: 80256
package main

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

func main() {
	n := nextInt()
	a := nextInt()
	b := nextInt()

	k := max(a, b)
	perms := make([]mint, b+1)
	facts := make([]mint, b+1)

	perms[1] = mint(n)
	facts[1] = mint(1)
	for i := 2; i <= k; i++ {
		perms[i] = perms[i-1].mul(mint(n - i + 1))
		facts[i] = facts[i-1].mul(mint(i))
	}

	// 全組み合わせ - aが入るパターン - bが入るパターン
	ans := mint(2).pow(mint(n)).sub(1)
	ans = ans.sub(perms[a].div(facts[a])).sub(perms[b].div(facts[b]))

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type mint int64

var mod = mint(1e9 + 7)

// add は a + bを返します
func (a mint) add(b mint) mint {
	return (a + b) % mod
}

// sub は a - bを返します
func (a mint) sub(b mint) mint {
	return (a - b + mod) % mod
}

// mul は a * bを返します
func (a mint) mul(b mint) mint {
	return (a * (b % mod)) % mod
}

// div は a/bを返します
func (a mint) div(b mint) mint {
	return a.mul(b.inv())
}

// inv は aの逆元を返します
func (a mint) inv() mint {
	// 拡張ユークリッドの互除法
	b := mod
	u := mint(1)
	v := mint(0)
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	return (u + mod) % mod
}

// pow は a ^ bを返します
func (a mint) pow(b mint) mint {
	ans := mint(1)

	for b != 0 {
		if b&1 == 1 {
			ans = ans.mul(a)
		}
		a = a.mul(a)
		b = b >> 1
	}
	return ans
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<30)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
vector<int> g[100100];
int a[100100][3];

signed main(){
	int n,m;
	cin>>n>>m;
	lp(i,100100){
		lp(j,3)a[i][j]=INF;
	}
	lp(i,m){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
	}
	int s,t;
	cin>>s>>t;
	queue<pair<int,int>> q;
	q.push({s,2});
	a[s][2]=0;
	int ans=-1;
	while(!q.empty()){
		int now=q.front().first;
		int cnt=q.front().second;
		q.pop();
		if(now==t&&cnt==2){
			ans=a[now][cnt];
			break;
		}
		int gx=a[now][cnt];
		gx++;
		cnt++;
		cnt%=3;
		lp(i,g[now].size()){
			int next=g[now][i];
			if(a[next][cnt]>gx){
				a[next][cnt]=gx;
				q.push({next,cnt});
			}
		}
	}
	if(ans==-1) cout<<-1<<endl;
	else cout<<ans/3<<endl;

	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

int main(){
    int n;
    cin >> n;
    double arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    double cntr = 0;
    for(int i=0; i<n; i++){
        cntr+= 1/arr[i];
    }
    cout << 1/cntr;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  int ix = 0, i = N - 1;
  vector<int> B(N);
  while (i >= 0) {
    B[ix++] = A[i];
    i -= 2;
  }
  i = (N % 2 == 0) ? 0 : 1;
  while (i < N) {
    B[ix++] = A[i];
    i += 2;
  }
  printf("%d", B[0]);
  for (int i = 1; i < N; ++i) {
    printf(" %d", B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
#define PI 3.14159265359

int main() {
	double a, b, c, s, C, S;
	cin >> a >> b >> C;
	c = sqrt(a*a + b*b - 2*a*b * cos(C*PI/180.0));
	s = (a + b + c) / 2.0;
	S = sqrt(s*(s-a)*(s-b)*(s-c));
	cout << fixed << setprecision(6) << S << ' ' << a + b + c << ' ' << S*2.0 / a << endl;
	return 0;
}

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

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<tuple<int,int,int>> T;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    for (int j = 0; j < A[i]; j++){
      int a,b;
      cin >> a >> b;
      T.push_back(make_tuple(i,a-1,b));
    }
  }
  int M = 0;
  bool flg = false;
  for (int i = 0; i < (1<<N); i++){
    vector<int> P;
    int m = 0;
    int j = i;
    for (int k = 0; k < N; k++){
      m += j % 2;
      P.push_back(j % 2);
      j/=2;
    }
    for (int k = 0; k < T.size(); k++){
      int f = get<0>(T[k]);
      int t = get<1>(T[k]);
      int p = get<2>(T[k]);
      if (P[f]==1 && P[t]!=p){
        flg = true;
        break;
      }
    }
    if (!flg) M=max(M,m);
    flg = false;
  }
  cout << M;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	vector<int> b(k+111,0);
	FOR(i,0,n){
		cin>>a[i];
	}

	FORQ(i,0,k){
		int f=0;
		FOR(j,0,n){
			int frm=i-a[j];
			if(frm<0)break;
			if(b[frm]==0)f=1;
		}
		b[i]=f;
	}
	if(b[k]==1){
		cout<<"First";
	}else{
		cout<<"Second";
	}
    return 0;
}


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

int dp[12][12],arr[12][12],res,temp,a,b;

int main(){
    scanf("%d %d", &a, &b);
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &arr[i][j]);
            dp[i][j] = arr[i][j];
        }
    }
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                dp[i][j] = min(dp[i][j],(dp[i][k]+dp[k][j]));
            }
        }
    }
    for(int i = 0; i < a; i++){
        for(int j = 0; j < b; j++){
            scanf("%d", &temp);
            if(temp!=-1){
                res += dp[temp][1];
                //cout<<res<<endl;
            }
        }
    }
    printf("%d\n", res);
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define ll int64_t
const ll MOD = 1e9 + 7;


int main()
{

  ll n, m;
  cin >>  n;

  vector<long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

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

  // set<long> twoNumSet;

  // for (int i = 1; i < n; ++i) {
  //   if (a[i] == a[i - 1])twoNumSet.insert(a[i]);
  // }

  vector<long> edge;
  long ans = 0;

  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1]){
      edge.push_back(a[i]);
      i++;
    }
  }

  if (edge.size() >= 2) {


    for (int i = 0; i < edge.size() - 1; ++i) {
      for (int j = i + 1; j < edge.size(); ++j) {
        if (ans < edge[i] * edge[j])ans = edge[i] * edge[j];
      }
    }
  }




  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1660
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, k = nm()

if n % k == 0:
    print(0)
else:
    print(1)

Measured memory_bytes: 3696