akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 300010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int a[N];
int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int T,i,j,k,ca=0,m,K,n;
    scanf("%d",&n);m=3*n;
    rep(i,0,m)scanf("%d",&a[i]);
    sort(a,a+m);
    ll ans=0;
    rep(i,n,m){
        ans+=a[i++];
    }
    printf("%lld\n",ans);
    //cerr<<clock()*1./CLOCKS_PER_SEC<<"ms\n";
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int n;
    cin >> n;
    vector<pair<double, string> > a(n);
    rep(i, n)cin >> a[i].first >> a[i].second;
    double btc = 380000;
    double ans = 0;
    rep(i, n){
        if(a[i].second[0] == 'B'){
            a[i].first *= btc;
        }
        ans += a[i].first;
    }
    cout << fixed << setprecision(8) << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
for h in range(1, 3500):
    for n in range(1, 3500):
        if (4*h*n - N*h - N*n) == 0:
            continue
        w = N*h*n / (4*h*n - N*h - N*n)
        if w.is_integer() and 1 <= w <= 3500:
            print(h, n, int(w))
            exit()


Measured memory_bytes: 41180
#include <stdio.h>

int main(){
    int n, weigh[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    int i, j, sum, v[10];
    
    while(scanf("%d", &n) != EOF){
        sum = 0;
        for (i = 0; i <= 9; i++) v[i] = 0;
        for (i = 9; i >= 0; i--){
            if (weigh[i] + sum <= n) {sum += weigh[i]; v[i]++;}
            if (sum == n) break;
        }
        for (i = 0; i <= 9; i++){
            if (v[i] == 1) {
                printf("%d", weigh[i]);
                for (j = i + 1; j <= 9; j++)if (v[j] == 1) break; 
                printf("%s", (j == 10) ? "\n" : " ");
                if (j == 10) break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

//

string t;
vector<string> ansbox;

void creator(string s, int i){
    for(int j=0; j<t.size(); j++){        
        s[i+j]=t[j];
    }
    for(int i=0; i<s.size(); i++){
        if(s[i]=='?') s[i]='a';
    }
    ansbox.push_back(s);
}

int main(){
    string s; cin>>s>>t;
    bool exist=false;
    for(int i=0; i+t.size()<=s.size(); i++){
        bool ok=true;
        for(int j=0; j<t.size(); j++){
            if(s[i+j]!='?' and s[i+j]!=t[j]) ok=false;
        }
        if(ok==true){
            exist=true;
            creator(s,i);
        }
    }
    if(exist==false){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    sort(ansbox.begin(), ansbox.end());
    cout<<ansbox[0]<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n) x[i]--, y[i]--;
    vector<vi> X(101010), Y(101010);
    rep(i,n){
        X[x[i]].pb(i);
        Y[y[i]].pb(i);
    }
    vector<vi> adj(n);
    rep(i,101010){
        for(auto e:X[i]){
            if (e==X[i][0]) continue;
            adj[e].pb(X[i][0]);
            adj[X[i][0]].pb(e);
        }
        for(auto e:Y[i]){
            if (e==Y[i][0]) continue;
            adj[e].pb(Y[i][0]);
            adj[Y[i][0]].pb(e);
        }
    }
    vector<bool> used(n,false);
    ll ans=0;
    rep(i,n){
        if (used[i]) continue;
        queue<int> que;
        que.push(i);
        set<int> xs, ys;
        while(!que.empty()){
            int v = que.front(); que.pop();
            used[v] = true;
            xs.ins(x[v]);
            ys.ins(y[v]);
            for(auto u:adj[v]){
                if (used[u]) continue;
                que.push(u);
            }
        }
        int xk = xs.size();
        int yk = ys.size();
        ans += (ll)xk*yk;
    }
    ans-=n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19200
#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 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	REP(i, n) cin >> d[i];

	sort(ALL(d));
	int ans = 1;
	REP(i, n - 1){
		if (d[i] != d[i + 1]) ans++;
	}

	cout << ans << endl;
}


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

int main()
{
  std::string s;
  std::string t;
  
  std::cin >> s >> t;
  
  unsigned int n=0;
  for(auto i=0 ; i<s.size() ; i++ )
  {
    if(s[i] != t[i])
    {
      n++;
    }
  }
  std::cout << n;
  return 0;
}


Measured memory_bytes: 3904
#include <iostream>
#include <atcoder/dsu>

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  atcoder::dsu d(N);

  rep(i, Q) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      d.merge(u, v);
    } else {
      cout << (d.same(u, v) ? 1 : 0) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 120;

int main(){
    IOS;
    in n,m,ans=0;
    cin >> n >> m;
    cout <<  (n)*(n-1)/2 + (m)*(m-1)/2 << "\n";
}

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

using namespace std;

int main() {
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);

  int n, n1;
  scanf("%d", &n);
  n1 = n;
  int s = 0;
  while (n1) {
    s += n1 % 10;
    n1 /= 10;
  }
  if (n % s == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int num[6];
  int top=0,front=1,right=2,left=3,back=4,bottom=5;
  int i,rep;
  int begin=0;
  char c;
  for(i=0;i<6;i++) scanf("%d",&num[i]);
  while(1)
    {
      begin++;
      scanf("%c",&c);
      if((c=='\n')&&(begin!=1)) break;
      else if(c=='E')
	{
	  rep=top;
	  top=left;
	  left=bottom;
	  bottom=right;
	  right=rep;
	}
      else if(c=='N')
	{
	  rep=top;
	  top=front;
	  front=bottom;
	  bottom=back;
	  back=rep;
	}
      else if(c=='S')
	{
	  rep=top;
	  top=back;
	  back=bottom;
	  bottom=front;
	  front=rep;
	}
      else if(c=='W')
	{
	  rep=top;
	  top=right;
	  right=bottom;
	  bottom=left;
	  left=rep;
	}
    }
  printf("%d\n",num[top]);
  return 0;
}

Measured memory_bytes: 596
from collections import Counter
n=int(input())
v=list(map(int, input().split()))
v1=Counter(v[::2])
v2=Counter(v[1::2])
c1=v1.most_common()+[(0, 0)]
c2=v2.most_common()+[(0, 0)]
if c1[0][0]==c2[0][0]:
    ans=max(c1[1][1]+c2[0][1], c1[0][1]+c2[1][1])
    print(n-ans)
else:
    print(n-c1[0][1]-c2[0][1])

Measured memory_bytes: 21184
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+5;
int n;
ll ans,a[N],b[N];
int main(){
    cin>>n;
    for(int i=0;i<n+1;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=n-1;i>=0;i--){
        if(a[i+1]>=b[i]){
            ans+=b[i];
            b[i]=0;
        }
        else{
            ans+=a[i+1];
            b[i]-=a[i+1];
        }
        if(a[i]>=b[i]){
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
        else{
            ans+=a[i];
            a[i]=0;
        }
    }
    cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int dp[1001][1001];
int latte(int i,int j,int k){
    return dp[i+k][j+k]-dp[i+k][j-1]-dp[i-1][j+k]+dp[i-1][j-1];
}
int main(){
    int n;
    while(cin>>n,n){
        fill(dp[0],dp[0]+1001*1001,0);
        for(int i=0;i<n;i++){
            string str;
            cin>>str;
            for(int j=0;j<n;j++){
                dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j];
                if(str[j]=='*')dp[i+1][j+1]++;
            }
        }
        int Max=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(latte(i,j,0))continue;
                int lb=0,ub=min(n-i,n-j)+1;
                while(ub-lb>1){
                    int k=(ub+lb)/2;
                    //if(i+k>n||j+k>n)ub=k;
                    if(latte(i,j,k))ub=k;
                    else lb=k;
                }
                Max=max(Max,lb+1);
            }
        }
        cout<<Max<<endl;
    }
}

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

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

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> t(N);
    for (int &i : t) cin >> i;

    ll ans = 0;
    rep(i, N) {
        if (i+1 < N) {
            ans += min(t[i] + T, t[i+1]) - t[i]; 
        } else {
            ans += T;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> a[M+1];
    
    for(int i=0;i<N;i++){
        long long x,y;
        scanf("%lld %lld",&x,&y);
        if(x <= M)
            a[x].push_back(y);
    }
    
    priority_queue<long long> Q;
    long long ans = 0;
    
    for(int i=1;i<=M;i++){
        for(int j=0;j<a[i].size();j++){
            Q.push(a[i][j]);
        }
        
        if(!Q.empty()){
            ans += Q.top();
            Q.pop();
        }
    }
    
    cout << ans;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int W, H, X, Y;
  cin >> W >> H >> X >> Y;
  bool bl = (X * 2 == W && Y * 2 == H);
  double ans = (double) W * H / 2;
  printf("%.10f ", ans);
  puts(bl ? "1" : "0");
  return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

D,N = inputIL()

if N != 100:
  print(str(N)+"00"*D)
else:
  print(str(101)+"00"*D)

Measured memory_bytes: 38384
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

if t1==1:
    print(6000*n1)
elif t1==2:
    print(4000*n1)
elif t1==3:
    print(3000*n1)
else:
    print(2000*n1)
    
if t2==1:
    print(6000*n2)
elif t2==2:
    print(4000*n2)
elif t2==3:
    print(3000*n2)
else:
    print(2000*n2)
    
if t3==1:
    print(6000*n3)
elif t3==2:
    print(4000*n3)
elif t3==3:
    print(3000*n3)
else:
    print(2000*n3)
    
if t4==1:
    print(6000*n4)
elif t4==2:
    print(4000*n4)
elif t4==3:
    print(3000*n4)
else:
    print(2000*n4)


Measured memory_bytes: 5604
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e2+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }



int h,n;


void solve() {
    cin>>h>>n;
     int ct=0;
     while(h>0) {
		    h-=n;
		    ct++;
		 }       
		 
		 cout<<ct<<endl;
       
               
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


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

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

using namespace std;


int main() {

    int a,b,c; cin >> a >> b >> c;
    int d = a%b;
    int s = d;

    while(1){
        if(d == c) break;
        else{
            d += s;
            d %= b;
            if(d == s) break;
        };
    }

    cout << ((d == c)?"YES":"NO");

    return 0;
}











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

#define ll long long

string s,t;
int dp[3001][3001];
char b[3001][3001];

void print(int n,int m)
{
    if(n==0 or m==0)
        return;
    if(b[n][m]=='D')
    {
        print(n-1,m-1);
        cout<<s[n-1];
    }
    else
    {
        if(b[n][m]=='L')
            print(n,m-1);
        else
            print(n-1,m);
    }
}

int main()
{
//    freopen("a.in","r",stdin);
    cin>>s>>t;
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
                b[i][j]='D';
            }
            else
            {
                if(dp[i-1][j]>dp[i][j-1])
                {
                    dp[i][j]=dp[i-1][j];
                    b[i][j]='U';
                }
                else
                {
                    dp[i][j]=dp[i][j-1];
                    b[i][j]='L';
                }
            }
        }
    }
    print(s.size(),t.size());
}




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

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans = 0;
  if(b == 1){
    cout << 0 << endl;
    return 0;
  }
  if(b - 1 <= x){
    ans = floor(a * (b - 1) / b);
  }else {
    ans = floor(a * x / b) - a * floor(x / b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int x, a, b;
    cin >> x >> a >> b;
    int ans = x-a;
    ans %= b;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
/*************************************************************************
    > File Name: e.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月02日 星期四 23时03分52秒
 ************************************************************************/

#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn = 100005;

long long a[maxn];
long long s[maxn];

int main(){
    int n;
    long long m;
    scanf("%d%lld", &n, &m);
    for(int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    sort(&a[1], &a[n+1]);
    for(int i = 1; i <= n; i++)
        s[i] = s[i-1]+a[i];

    register long long cl = 2*a[1], cr = 2*a[n];
    register long long ans, cnt;
    while(cl <= cr){
        ans = cnt = 0;
        register long long cm = (cl+cr)>>1;
        for(int i = 1; i <= n; i++){
            register int ci = lower_bound(&a[1], &a[n+1], cm-a[i])-&a[1];
            cnt += n-ci;
            ans += (n-ci)*a[i]+s[n]-s[ci];
        }
        if(cnt > m)
            cl = cm+1;
        else if(cnt < m)
            cr = cm-1;
        else
            break;
    }
    if(cnt != m)
        ans += cr*(m-cnt);
    printf("%lld\n", ans);
}



Measured memory_bytes: 1664
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

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

class Point {
public:
  double x, y;
  Point() {};
  Point(double x, double y): x(x), y(y) {}

  Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
  Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
  Point operator * (double d) { return Point(d * x, d * y); }
  Point operator / (double d) { return Point(d / x, d / y); }

  bool operator < (const Point &p) const {
    return (x == p.x ? y < p.y : x < p.x);
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  friend ostream& operator << (ostream &os, Point &p) {
    return os << "Point(" << p.x << ", " << p.y << ")";
  }
};

typedef Point Vector;

struct Segment {
  Point p1, p2;  
};

double cross (Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

double dot(Vector v1, Vector v2) {
  return v1.x * v2.x + v1.y * v2.y;
}

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

bool isOrthogonal(Segment s1, Segment s2) {
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Segment s1, Segment s2) {
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p) {
  Vector v = s.p2 - s.p1;
  double r = dot(p - s.p1, v) / norm(v);
  return s.p1 + v * r;
}

Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  Segment s;
  s.p1 = Point(x1, y1);
  s.p2 = Point(x2, y2);

  int n; cin >> n;

  while (n--) {
    int x, y; cin >> x >> y;
    Point p = reflect(s, Point(x, y));

    cout << fixed << setprecision(10) << p.x << ' ' << p.y << endl;
  }
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

P Info[101000];
int main(){
    int N;
    cin >> N;
    vector<P> x;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        x.emplace_back(P(l, r));
    }
    sort(x.begin(), x.end());   // サタンでソート

    Info[N] = P(1, 1e9);
    for(int i = N-1; i >= 0; i--){
        ll l = x[i].fs, r = x[i].sc;
        Info[i].fs = max(Info[i+1].fs, l);
        Info[i].sc = min(Info[i+1].sc, r);
    }

    ll rMin = 1e9 + 7;
    ll res = 0;
    for(int i = 0; i < N-1; i++){
        ll l1 = x[i].fs, r1 = x[i].sc;
        ll l2 = Info[i+1].fs, r2 = Info[i+1].sc;

        // 1の方に含める
        ll resTmp1 = 0;
        resTmp1 += max(min(r1, rMin) - l1 + 1, 0LL);
        resTmp1 += max(r2 - l2 + 1, 0LL);

        // 2の方に含める
        ll resTmp2 = 0;
        resTmp2 += max(min(r2, rMin)- l2 + 1, 0LL);
        resTmp2 += max(r1 - l1 + 1, 0LL);

        res = max(res, max(resTmp1, resTmp2));

        rMin = min(rMin, r1);
    }

    cout << res << endl;


    return 0;
}




Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N=S.size();
    vector<ll> num(N,0);
    for(ll i=0;i<N;++i){
        num[i]=S[i]-'0';
    }
    ll ans=INF;
    for(ll i=0;i<N-2;++i){
        chmin(ans,llabs(-753+100*num[i]+10*num[i+1]+num[i+2]));
    }
    prt(ans)


    return 0;
}


Measured memory_bytes: 764
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	"""Compute the lowest common multiple of a and b"""
	return a * b // gcd(a, b)

def resolve():
	n = int(input())
	print(lcm(n, 2))
resolve()

Measured memory_bytes: 38256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: i64 = read();
    let left = n % 11;
    let mut ans = (n / 11) * 2;
    if left <= 0 {
        //
    } else if left <= 6 {
        ans += 1;
    } else {
        ans += 2;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for a_ in range(a+1):
    for b_ in range(b+1):
        for c_ in range(c+1):
            can = 500*a_ + 100*b_ + 50*c_
            if x == can:
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;    


int32_t main(){

    fast
    int n,m;
    cin>>n>>m;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int u,v;
    set<int>s;
    while(m--){
        cin>>u>>v;
        u--;v--;
        if(arr[u]<arr[v]){
            s.insert(u);
        }
        else if(arr[u]>arr[v]){
            s.insert(v);
        }
        else{
            s.insert(u);
            s.insert(v);
        }

    }
    cout<<(n-s.size());


    return 0;
}



Measured memory_bytes: 6632
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    string s = "";
    int length = 0;
    int count = 0;
    cin >> length >> s;
    for (int i = 0; i < length - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		if(str.size()<2)cout << "NA" << endl;
		else if(str[0]=='>' && str[1]=='\''){
			int j=2;
			int l[2]={0,0};
			int ck=0;
			bool ch[2]={false,true};
			while(j<str.size()){
				if(str[j]=='=')l[ck]++;
				else if(str[j]=='#' && l[0]>0)ch[0]=true,ck=1;
				else if(str[j]=='~')break;
				else ch[1]=false;
				j++;
			}
			if(ch[0]==true && ch[1]==true && l[0]==l[1])cout << "A" << endl;
			else cout << "NA" << endl;
		}else if(str[0]=='>' && str[1]=='^'){
			if(str.size()%2==1 || str.size()<6)cout << "NA" << endl;
			else{
				bool ch=true;
				for(int j=2;j<str.size()-2;j+=2){
					if(str[j]!='Q' || str[j+1]!='=')ch=false;
				}
				if(str[str.size()-2]!='~' || str[str.size()-1]!='~')ch=false;
				if(ch==true)cout << "B" << endl;
				else cout << "NA" << endl;
			}
		}else cout << "NA" << endl;
	}
    return 0;
}

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

// ------ graph ------ //
using Weight = long long;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator[](int v) { return adj[v]; }
    const Edges operator[](int v) const { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;
using UnweightedGraph = vector<vector<int>>;

// ------ Diameter of a tree ------ //
namespace Double_Sweep {
    using Result = pair<Weight, int>;
    Result visit(const Graph &g, int u, int p = -1) {
        Result r(0, u);
        for (Edge e: g[u]) if (e.dst != p) {
            Result t = visit(g, e.dst, u);
            t.first += e.weight;
            if (r.first < t.first) r = t;
        }
        return r;
    }
    Weight diameter(const Graph &g) {
        Result u = visit(g, 0);
        Result v = visit(g, u.second);
        return v.first;
    }
};

int main() {
    int n;
    while (cin >> n, n) {
        Graph G(n);
        vector<int> p(n + 1), d(n + 1);
        vector<vector<int>> ord(n + 1);
        int all = 0;
        for (int i = 2; i <= n; i++) cin >> p[i];
        for (int i = 2; i <= n; i++) cin >> d[i], all += d[i];
        for (int i = 2; i <= n; i++) {
            ord[i].emplace_back(p[i]);
            ord[p[i]].emplace_back(i);
        }
        vector<int> inner_idx;
        int inner = all;
        for (int i = 1; i <= n; i++) if (ord[i].size() == 1) {
            int idx = max(i, ord[i].back());
            inner_idx.emplace_back(idx);
            inner -= d[idx];
            d[idx] = 0;
        }
        for (int i = 2; i <= n; i++) {
            G.add_edge(i - 1, p[i] - 1, d[i]);
        }
        cout << all + inner * 2 - Double_Sweep::diameter(G) << endl;
    }
    return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;


int main(){

    string s;
    int q;
    cin >> s;
    cin >> q;

    vector<char> front;
    vector<char> back;

    bool r = false;

    rep(i, q){

        int q1;
        cin >> q1;

        if(q1 == 1){

            r = !r;

        }else{
            int q2;
            char c;
            cin >> q2 >> c;

            if(r){
                //反転してる

                if(q2 == 1){
                    //反転してるので1でもbackにいれる
                    back.pback(c);
                }else{
                    front.pback(c);
                }

            }else{

                if(q2 == 1){
                    //frontにいれる
                    front.pback(c);
                }else{
                    back.pback(c);
                }

            }

        }

    }

    if(r){

        //反転しているのでbackとsを反転して表示
        //front[0]とback[0]が内側にくるイメージ

        reverse(ALL(back));

        rep(i, back.size()){
            cout << back[i];
        }

        rep(i, s.size()){
            cout << s[s.size() - 1 - i];
        }

        rep(i, front.size()){
            cout << front[i];
        }
        cout << endl;

    }else{

        //frontを反転する。front[0]が内側に来るイメージ

        reverse(ALL(front));

        rep(i, front.size()){
            cout << front[i];
        }

        cout << s;

        rep(i, back.size()){
            cout << back[i];
        }
        cout << endl;

    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
  char S[11];
  cin >> S;
  if (strncmp(S,"2017",4)==0) {
    S[3]='8';
  }
  printf("%s\n",S);
  return 0;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ll dbl(string s){
   int n = s.size();
   if(n == 1)return 0;
   ll res = 0;
   rep(i,n-1){
      if(s[i] == s[i+1]){
         s[i+1] = '?';
         res++;
      }
   }
   return res;
}

int main(void){
   ioboost;
   string s;cin >> s;
   ll n = s.size();
   ll k;cin >> k;
   bool all_same = true;
   char p = (char)s[0];
   rep(i,n){
       if(p != (char)s[i]){
           all_same = false;
       }
   }
   if(all_same){
       cout << k*n/2 << endl;
       return 0;
   }
   
   string z = s;
  // rep(i,k-1)z += s;
   //cout << dbl(z) << endl;
   if(n == 1){
      cout << k - 1 << endl;
      return 0;
   }
   string t3 = s + s + s;
   ll a3 = dbl(t3);
   string t2 = s + s;
   ll a2 = dbl(t2);
   ll d = a3 - a2;
   
   if(k == 1){
      cout << dbl(s) << endl;
   }else if( k == 2){
      cout << a2 << endl;
   }else{
      cout << a2 + (k - 2)*d << endl;
   }
   return 0;
}


Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ab = readInts()
    let a = ab[0]
    let b = ab[1]
    
    print([a + b, a - b, a * b].sorted(by: >)[0])
}

main()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
int a, b;

int main() {
  cin >> a >> b;
  int ans = 0;
  
  while (1){
    if(1+(a-1)*ans>=b) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static double dist=0;
	static int kaisu=0;
	static int[] x;
	static int[] y;
	static int[] ns;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		x=new int[N];
		y=new int[N];
		ns = new int[N];
		for(int i=0; i<N; i++) {
			ns[i]=i;
		}
		for(int i=0; i<N; i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}

		permute(ns, ns.length);
		p(dist/(double)kaisu);
	}
	public static void p(Object o) {
		System.out.println(o);
	}
	static long root(long a) {

		int ketasu=0;
		long tmp=a;
		while(tmp>0) {
			ketasu++;
			tmp/=10L;
		}
		int constant=(ketasu+1)/2;	//よく使うので定数化
		if(ketasu>=1) {
			long[] suuji=new long[constant];
			tmp=a;
			for(int i=0; i<constant; i++) {
				suuji[constant-1-i]=a%100L;
				a/=100L;
			}
			long ans=0;
			long kai=0;
			long mae=0;
			if(constant<=1) {
				for(long i=10L; i>=0L; i--) {
					if(suuji[0]>=i*i) {
						return i;
					}
				}
			}
			else {
				for(long i=0L; i<constant; i++) {
					mae+=kai*2L;
					for(long j=9L; j>=0L; j--) {
						if((mae*10+j)*j<=suuji[(int)i]) {
							ans=ans*10+j;
							mae*=10;
							kai=j;
							if(i+1<constant) {
								suuji[(int)i+1]+=(suuji[(int)i]-(mae+j)*j)*100;
							}
							break;
						}
					}
				}
			}
			return ans;
		}
		else {
			return 0L;
		}
	}
	private static void swap(int[] v, int i, int j) {
		int t = v[i]; v[i] = v[j]; v[j] = t;
	}
	public static void permute(int[] v, int n) {
		if (n == 1) {
			kaisu++;
			double tmp=0;
			for(int i=1; i<x.length; i++) {
				tmp+=Math.sqrt((x[ns[i]]-x[ns[i-1]])*(x[ns[i]]-x[ns[i-1]])+(y[ns[i]]-y[ns[i-1]])*(y[ns[i]]-y[ns[i-1]]));
			}
			dist+=tmp;
		}
		else {
			for (int i = 0; i < n; i++) {
				permute(v, n-1);
				if (Math.abs(n) % 2 == 1) {
					swap(v, 0, n-1);
				} else {
					swap(v, i, n-1);
				}
			}
		}
	}
}

Measured memory_bytes: 24460
#include<stdio.h>
int main(void){
    int k,n;
    scanf("%d%d",&k,&n);
    int a[n];
    for(int i=0;n>i;++i){
        scanf("%d",&a[i]);
    }
  /*入力*/
    int b[n-1];
    for(int i=0;n-1>i;++i){
        b[i]=a[i+1]-a[i];
    }
    int max=b[0];
    for(int i=1;n-1>i;++i){
        max=max>b[i]?max:b[i];
    }
    int p=k-a[n-1]+a[0];
    max=max>p?max:p;
    printf("%d",k-max);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  ll N;
  cin >> N;

  for (int h = 1; h <= 3500; h++) {
    for (int n = h; n <= 3500; n++) {
      if (4.0 * h * n - N * n - N * h <= 0) continue;
      if ((N * h * n) % (4 * h * n - N * n - N * h) == 0) {
        printf("%d %d %lld\n", h, n, (N * h * n) / (4 * h * n - N * n - N * h));
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

m= [0]*n
d = 0
for i in range(n):
  m[i] = abs(l[i])
  if l[i] < 0:
    d += 1

if d%2 == 0:
  print(sum(m))
else:
  m.sort()
  print(sum(m)-2*m[0])
  

Measured memory_bytes: 64880
#include <iostream>

int n,c[505],s[505],f[505];
int main(){
  std::cin>>n;
  for(int i=0,end=n-1;i<end;++i)
    std::cin>>c[i]>>s[i]>>f[i];
  
  for(int i=0,end=n-1;i<end;++i){
    long long ans=0;
    for(int j=i;j<end;++j){
      if(ans<s[j])
        ans=s[j];
      else if((ans-s[j])%f[j]!=0)
        ans=ans+f[j]-ans%f[j];
      ans+=c[j];
    }
    std::cout<<ans<<std::endl;
  }
  std::cout<<"0"<<std::endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
num=0
for i in range(N):
    if i==0:
        num=(T-H[0]*0.006)
        spot=0
    else:
        if abs(A-(T-H[i]*0.006))<=abs(A-num):
            num=(T-H[i]*0.006)
            spot=i

print(spot+1)


Measured memory_bytes: 9164
fn solve(abcs: Vec<(usize, usize, usize)>) -> usize {
    use std::cmp::max;

    let n = abcs.len();
    let mut dp = vec![vec![0; n + 1]; 3];

    for i in 1..(n + 1) {
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + abcs[i - 1].0;
        dp[1][i] = max(dp[2][i - 1], dp[0][i - 1]) + abcs[i - 1].1;
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + abcs[i - 1].2;
    }

    max(dp[0][n], max(dp[1][n], dp[2][n]))
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![(10, 40, 70), (20, 50, 80), (30, 60, 90)]), 210);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let abcs = (0..n)
        .map(|_| parse_line!(usize, usize, usize))
        .collect::<Vec<_>>();
    println!("{}", solve(abcs));
}


Measured memory_bytes: 10492
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <stdlib.h>
const int MAXN = 1000005;
using namespace std;

int main()
{
    int n;
    while(cin >> n) {
        if(n == 1)
            cout << "Hello World" << endl;
        else if(n == 2) {
            int a, b;
            cin >> a >> b;
            cout << a + b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int inf=1e9;
const int mod=998244353;
int x,m;
ll n;
int pre[maxn];
ll sum1[maxn];

int main(){
    scanf("%lld%d%d",&n,&x,&m);

    pre[x]=1;sum1[1]=x;

    int cnt=0,pos=inf;
    ll sum=0;
    for(int i=2;i<=n;i++){
        x=1ll*x*x%m;
     //   printf("x=%d\n",x);
        sum1[i]=sum1[i-1]+x;
        if(pre[x]){
            cnt=i-pre[x];
            pos=i;
            sum=sum1[i]-sum1[pre[x]];
            break;
        }
        pre[x]=i;
    }

    ll sumr=0;
    int cntr=0;
    for(int i=0;i<maxn;i++)
        if(pre[i]&&pre[i]+cnt<pos)cntr++,sumr+=i;

    if(!cnt){
        sum+=sumr;
        printf("%lld\n",sum);
        return 0;
    }

    sum*=(n-cntr)/cnt;
    sum+=sumr;

    int r=(n-cntr)%cnt;

    for(int i=1;i<=r;i++){
        sum+=x;
        x=1ll*x*x%m;
    }

    printf("%lld\n",sum);


    return 0;
}


Measured memory_bytes: 4400
import math
N = int(input())
for i in range(N):
  A,B,C,D = map(int,input().split())
  if A<B: #初期の在庫が足りないならダメ
    print("No")
    continue
  if B>D: #消費のほうが大きいならダメ。
    print("No")
    continue
  if A%B > C: #一回目の補給が間に合うか。
    print("No")
    continue
  cycle = D-B
  GCD = math.gcd(B,cycle)
  #print(GCD)
  if GCD == 1 and B-1 > C:
    print("No")
    continue
  if B-GCD > C:
    print("No")
    continue
  print("Yes")
    
    

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#ifndef ONLINE_JUDGE
#define OJ \
    freopen("input.txt", "r", stdin); \
    //freopen("output.txt", "w", stdout);
#else
#define OJ ;
#endif
#define fo(int, i, l, r) for ( int i = l ; i < r ; ++ i)
#define srtV(a) sort(a.begin(),a.end())
void solve()
{
    string s;
    int n;
    cin>>s;
    n=s.size();
    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans=(ans + (s[i]-'0'))%9;
    }
    if(ans==0)
    {
        cout<<"Yes\n";

    }
    else
    {
        cout<<"No\n";
    }
    
}
signed main()
{
    OJ
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,W;
  cin>>n>>W;
  int w[n],v[n];
  rep(i,0,n) cin>>w[i]>>v[i];
  ll dp[n+1][W+1];
  rep(i,0,W+1) dp[0][i]=0;
  rep(i,0,n){
    rep(j,0,W+1){
      if(w[i]>j){
        dp[i+1][j]=dp[i][j];
      }
      else{
        dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      }
    }
  }
  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104