akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    int k,a,b,f=0;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
    	if(i%k==0){
    		f=1;
    		break;
		}
	}
	if(f==1){
		cout<<"OK";
	}
	else
	cout<<"NG";
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			Set<Integer> a = new TreeSet<>();
			for(int i = 0; i < n; i++) {
				a.add(sc.nextInt());
			}
			int m = sc.nextInt();
			Set<Integer> b = new TreeSet<>();
			for(int i = 0; i < m; i++) {
				b.add(sc.nextInt());
			}

			a.removeIf((num) -> !b.contains(num));
			a.forEach(num -> System.out.println(num));
		}
	}
}


Measured memory_bytes: 165672
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define fixed fixed<<setprecision(12)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol a[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n,m,k,r,x,y;
  double b;
  cin >>b;
  cout <<2*b*M_PI<<'\n';
  
  return (0);
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9;
const int N = 1e5+10;
/*=======================================================================*/

int n, h[N], sum;
int f[N];

int main() {
   scanf("%d", &n);
   for1(i, n) {
      scanf("%d", &h[i]);
   }
   ms(f, inf);
   f[n] = 0;
   for(int i = n; i > 1; i--) {
      if(i == 2) {
         f[i-1] = min(f[i-1], f[i] + abs(h[i] - h[i-1]));
      } else {
         f[i-1] = min(f[i-1], f[i] + abs(h[i] - h[i-1]));
         f[i-2] = min(f[i-2], f[i] + abs(h[i] - h[i-2]));
      }
      // if(i == 2) {
      //    sum += abs(h[i] - h[1]);
      //    i--;
      // } else {
      //    if(abs(h[i] - h[i-1]) < abs(h[i] - h[i-2])) {
      //       sum += abs(h[i] - h[i-1]);
      //       i -= 1;
      //    } else {
      //       sum += abs(h[i] - h[i-2]);
      //       i -= 2;
      //    }
      // }
   }
   cout << f[1] << endl;
   return 0;
}

Measured memory_bytes: 1024
main = do
  [l,r] <- map read . words <$> getLine
  let modList = takeWhile (/=0) $ map (\(x,y) -> mod (x*y) 2019) [(i,j)| i <- [l..r],j <- [(i+1)..r]]
  print $ let diff = r - l in if length modList == (div (diff * (diff + 1)) 2) then minimum modList else 0

Measured memory_bytes: 7804
import java.util.*;

public class Main{
    public static void main(String[] args){
        int[] s = new int[100];
        int max,min;
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0){break;}

            int sum=0;
            for(int i=0;i<n;i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }

            max = s[0];
            min = s[0];
            for(int i=1;i<n;i++){
                if(max < s[i]){max = s[i];}
                if(min > s[i]){min = s[i];}
            }

            System.out.println((sum-max-min)/(n-2)); 
        }
    }
}


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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  ll diff = a-b; if(diff<0)diff*=-1;
  for(int pc=0; pc<=n-1; pc++){
    int mc = n-1-pc;
    ll m1 = pc*c-mc*d;
    ll m2 = pc*d-mc*c;
    if(m1<=diff && diff<=m2 || m2<=diff && diff<=m1){ cout<<"YES"<<endl; return 0; }
  }

  cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int k;
    cin >> k;
    ll a[k];
    rep(i,k)cin >> a[i];
    ll mnn=2;
    ll mxn=2;
    rep(i,k){
        if(((mnn-1)/a[k-i-1]+1)*a[k-i-1]>mxn){
            cout << -1;
            return 0;
        }
        mnn=((mnn-1)/a[k-i-1]+1)*a[k-i-1];
        mxn=(mxn/a[k-i-1]+1)*a[k-i-1]-1;
      	//cerr << mnn << mxn << endl;
    }
    cout << mnn << ' ' << mxn;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

ll dp[3010][3010][4];
ll d[3010][3010];

int main(){
    int r,c,k; cin >> r >> c >> k;
    map<P,ll> m;
    rep(i,k){
        int a,b,v; cin >> a >> b >> v;
        a--; b--;
        d[a][b]=v;
    }

    dp[0][0][0]=0;

    rep(i,r)rep(j,c){
        for(int k=2; k>=0; k--){
            dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+d[i][j]);
        }
        rep(k,4){
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
            dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    ll ans=0;
    rep(i,4) ans=max(ans,dp[r-1][c-1][i]);
    cout << ans << endl;
return 0;
}

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

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	char ans;
	if (abs(a - x) <= abs(b - x)) {
		ans = 'A';
	} else {
		ans = 'B';
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
length =int(input())

s, t = map(str, input().split())

result = ""

list_s = list(s)
list_t = list(t)

for i in range(length):
  result = result + list_s[i]
  result = result + list_t[i]
  #result = result + s + list_t[i]
 
print(result) 

Measured memory_bytes: 3060
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let d = get!();
    let n = get!();
    
    let mut x = 1;
    for _ in 0..d {
    	x *= 100;
    }
    let mut ans = 0;
    let mut p = 0;
    
    loop {
    	ans += x;
        let mut k = ans;
        let mut e = 0;
        while k % 100 == 0 {
        	k /= 100;
            e += 1;
        }
        if e == d {
        	p += 1;
            if p == n {
            	break;
            }
        }
    }
    println!("{}", ans);
    
    
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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 ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m; cin >> n >> m;
  vll ball(n, 1);
  V<bool> red(n, false); red[0] = true;
  ll ans = 1;
  REP(i, m) {
    ll x, y; cin >> x >> y;
    ball[x-1]--; ball[y-1]++;
    if (red[x-1]) {
      if (!red[y-1]) {ans++; red[y-1]=true;}
      if (ball[x-1]==0) {ans--; red[x-1]=false;}
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        map<int,int> Tag;
        int N;
        cin>>N;
        int Arr[N+5];
        for(int i=1;i<=N;++i){
            cin>>Arr[i];
            Tag[Arr[i]]++;
        }
        int ans=0;
        for(int i=1;i<=N;++i){
            bool ok=1;
            if(Tag[Arr[i]]>=2){
                continue;
            }
            if(Arr[i]!=1&&Tag[1]){
                continue;
            }
            for(int j=2;j*j<=Arr[i]&&ok;++j){
                if(Arr[i]%j==0){
                    if(Tag[j]||Tag[Arr[i]/j]){
                        // cout<<Arr[i]<<" "<<j<<endl;
                        ok=0;
                    }
                }
            }
            ans+=ok;
        }
        cout<<ans<<endl;
	}
	return 0;
}




Measured memory_bytes: 33236
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
#define INF 1 << 30
using namespace std;
typedef pair<int, int> PII;
typedef priority_queue<PII, vector<PII>, greater<PII> > PQ;

int root[101][101], n, k; //not use 0;
int ans = 0;
void newboat()
{
	int c, d, e;
	cin >> c >> d >> e;
	if (root[c][d] > e)	root[c][d] = root[d][c] = e;
	return;
}

int solve()
{
	int a, b;
	cin >> a >> b;
	bool though[101][101]; //not use 0;
	PQ cand;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++) though[i][j] = false;
	}

	cand.push(make_pair(0, a));
	while (!cand.empty()){
		PII now = cand.top();
		cand.pop();
		if (now.second == b) return now.first;

		for (int i = 1; i <= n; i++){
			if (root[now.second][i] != INF && !though[now.second][i]){
				though[now.second][i] = though[i][now.second] = true;
				cand.push(make_pair(now.first + root[now.second][i], i));
			}
		}
	}
	return -1;
}

int main()
{
	while (true){
		cin >> n >> k;
		if (!n && !k) break;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				root[i][j] = INF;
			}
		}
		for (int i = 0; i < k; i++){
			bool in;
			cin >> in;
			if (in) newboat();
			else cout << solve() << endl;
		}
	}
	return 0;
}

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

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

  // R = r - 100 * (100 - K)
  if(N >= 10){
    cout << R << endl;
  }else{
    cout << R + 100 * (10 - N) << endl;
  }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 5e5+10;
char s[SIZE];
bool an[SIZE];
int dp[SIZE][27];
int nxt[SIZE][20];
int main(){
    MS1(dp);
    RS(s);
    int n=LEN(s);
    nxt[n][0]=n;
    for(int i=n-1;i>=0;i--){
        int me=s[i]-'a';
        dp[i][me]=i+1;
        REPP(j,me+1,27){
            if(dp[i][j-1]==-1||dp[dp[i][j-1]][j-1]==-1)break;
            dp[i][j]=dp[dp[i][j-1]][j-1];

        }
        if(dp[i][26]!=-1){
            REP(j,me){
                dp[i][j]=dp[dp[i][26]][j];
            }
            nxt[i][0]=dp[i][26];
        }
        else nxt[i][0]=i;
    }
    REPP(i,1,20){
        REP(j,n+1)nxt[j][i]=nxt[nxt[j][i-1]][i-1];
    }
    DRI(Q);
    REP(i,Q){
        DRII(x,y);x--;
        for(int j=19;j>=0;j--){
            if(nxt[x][j]<=y)x=nxt[x][j];
        }
        puts(x==y?"Yes":"No");
    }
    return 0;
}


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

int main() {
	string s;
	string abc[6] = { "abc", "acb", "bac", "bca", "cab", "cba" };
	bool check = false;
	cin >> s;
	for (int i = 0; i < 6; i++) {
		if (s == abc[i]) check = true;
	}
	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
D.append(0)

s = 24
D.sort()
D2 = [_ for _ in D]
for i in range(N):
  if D2[i] == D2[i + 1]:
    D2[i] = 24 - D2[i]

D2.sort()
for i in range(N):
  s = min(D2[i + 1] - D2[i], s)
s = min(24 - D2[N] + D2[0], s)

if s != 0 and N <= 12:
  for b in range(1 << N):
    D2 = [_ for _ in D]
    for i in range(N):
      if b & (1 << i):
        D2[i + 1] = 24 - D2[i + 1]
    D2.sort()
    s2 = 24
    for i in range(N):
      s2 = min(D2[i + 1] - D2[i], s2)
    s2 = min(24 - D2[N] + D[0], s2)
    s = max(s2, s)

print(s)

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

int main(int argc, char const *argv[]) {
    int n, t, a;
    cin >> n >> t >> a;

    vector<int> h;

    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    double min = DBL_MAX;
    int idx;

    for (int j = 0; j < h.size(); ++j) {
        double tmp = t - 0.006*h.at(j);
        if (abs(a - tmp) < min) {
            min = abs(a - tmp);
            idx = j;
        }
    }

    cout << idx+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int N, M, K;
long long int MOD = 998244353;

long long int POW(long long int a, long long int k) {
	if (k == 0) { return 1; }
	if (k == 1) { return a; }

	if (k % 2 == 1) { return (a*POW(a, k - 1)) % MOD; }

	long long int tmp = POW(a, k / 2);
	return (tmp*tmp) % MOD;
}

long long int INV(long long int a) {
	return POW(a, MOD - 2);
}

long long int P[200005], IP[200005];

long long int C(int n, int k) {
	long long int ret = P[n];

	ret *= IP[k]; ret %= MOD;
	ret *= IP[n - k]; ret %= MOD;

	return ret;
}

int main(void) {

	cin >> N >> M >> K;
	
	P[0] = 1;
	for (long long int i = 1; i <= N; i++) {
		P[(int) i] = (P[(int)i - 1] * i) % MOD;
	}

	for (long long int i = 0; i <= N; i++) {
		IP[i] = INV(P[i]);
	}

	long long int ans = 0;

	for (int k = 0; k <= K; k++) {
		long long int tmp = (C((int)N-1, k)*POW(M - 1,N-1- k)) % MOD;
		tmp *= M; tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}

	

	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 6632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[210000];
set<pair<int,int> > S;
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	for(int i=0;i<a;i++)S.insert(make_pair(p[i],i));
	int ret=0;
	for(int i=a;i>=0;i--){
		if(S.count(make_pair(p[i],i))==0)continue;
		int at=-1;
		for(int j=1;j<=30;j++){
			int req=(1<<j)-p[i];
			if(req<0)continue;
			set<pair<int,int> >::iterator it=S.lower_bound(make_pair(req,0));
			if(it!=S.end()&&it->second==i)it++;
			if(it!=S.end()&&it->first==req){
				at=it->second;break;
			}
		}
		if(at!=-1){
			ret++;
			S.erase(make_pair(p[i],i));
			S.erase(make_pair(p[at],at));
		}
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define rint register int
using namespace std;
int n,ans;
char c[60];
int main(){
	scanf("%d",&n);
	scanf("%s",c+1);
	for(rint i=1;i<=n-2;++i){
		if(c[i]=='A'){
			if(c[i+1]=='B'&&c[i+2]=='C') ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef complex<int> ci;
typedef complex<double> cd;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define ins insert
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define FORI(a, b) for (auto(a) = (b).begin(); (a) != (b).end(); ++(a))
#define ROFI(a, b) for (auto(a) = (b).rbegin(); (a) != (b).rend(); ++(a))
#define CEIL(a, b) ((a) + (b)-1) / (b)
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

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

    ll n, k;
    cin >> n >> k;
    vector<ll> sols;
    sols.pb(n);
    if (n >= k) {
        n -= (n - k) / k * k;
        sols.pb(n);
        n -= k;
    }
    assert(n < k);
    sols.pb(n);
    sols.pb(k - n);

    cout << *min_element(ALL(sols)) << endl;

    return 0;
}


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    ll a,b;
    cin>>a>>b;
    char c;
    cin>>c;
    ll x;
    cin>>x;
    b*=100;
    b+=x;
    ll ans=a*b;
    ans/=100;
    cout<<ans;
return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#define rep(i, n) for(i=0; i<n; i++)
#define pb push_back
#define ll long long
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i;
    cin >> n;
    ll sum = 0, S=0;
    vector<ll> notch;
    for(i=0; i<n; i++){
        ll x;
        cin >> x;
        notch.pb(x);
        S += x;
    }
    ll mi = S+1;
    for(i=0; i<n; i++){
        sum += notch[i];
        mi = min(mi, abs(sum - (S-sum)));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 5296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
/* constant */
 
#define MAX_M           (10)
#define MAX_N           (10)
#define MAX_HOME        (23)
 
/* typedef */
 
typedef int nbr_t[MAX_HOME + 1];
 
/* global variables */
 
static int m, n;
static int nhome;
 
static int toch[MAX_HOME], visited[MAX_HOME];
static nbr_t nbrs[MAX_HOME][4];
 
static int drcs[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
 
/* subroutines */
 
void find_nbr(int y0, int x0, int sects[], nbr_t *nbr) {
  int dx, dy, hid, i, j, x, y;
 
  for (i = 0; i < 4; i++) {
    dy = drcs[i][0];
    dx = drcs[i][1];
    y = y0 + dy;
    x = x0 + dx;
    j = 0;
 
    while (y >= 0 && y < n && x >= 0 && x < m) {
      hid = sects[y * m + x];
      if (hid != -1) nbr[i][j++] = hid;
      y += dy;
      x += dx;
    }
 
    nbr[i][j] = -1;
  }
}
 
int count_rt(int k, int hid) {
  int count, i;
  int *nb0;
 
  if (k == 0)
    return (toch[hid] ? 1 : 0);
 
  count = 0;
 
  for (i = 0; i < 4; i++) {
    for (nb0 = nbrs[hid][i]; *nb0 != -1; nb0++) {
      if (! visited[*nb0]) {
        visited[*nb0] = 1;
        count += count_rt(k - 1, *nb0);
        visited[*nb0] = 0;
        break;
      }
    }
  }
 
  return count;
}
 
/* main */
 
int main(int argc, char **argv) {
  int chx, chy, count, d, hid, i, *nb0, x, y;
  static int homes[MAX_HOME][2];
  static int sects[MAX_N * MAX_M];
  static nbr_t fromch[4];
 
  for (;;) {
    scanf("%d %d", &m, &n);
    if ((m | n) == 0) break;
 
    nhome = 0;
 
    for (y = 0; y < n; y++) {
      for (x = 0; x < m; x++) {
        scanf("%d", &d);
 
        switch (d) {
        case 1:
          homes[nhome][0] = y;
          homes[nhome][1] = x;
          sects[y * m + x] = nhome++;
          break;
        case 2:
          chy = y;
          chx = x;
        default:
          sects[y * m + x] = -1;
        }
      }
    }
 
    find_nbr(chy, chx, sects, fromch);
 
    memset(toch, 0, sizeof(int) * nhome);
 
    for (i = 0; i < 4; i++)
      for (nb0 = fromch[i]; *nb0 != -1; nb0++)
        toch[*nb0] = 1;
 
    for (i = 0; i < nhome; i++)
      find_nbr(homes[i][0], homes[i][1], sects, nbrs[i]);
 
    memset(visited, 0, sizeof(int) * nhome);
 
    count = 0;
 
    for (i = 0; i < 4; i++) {
      hid = *(fromch[i]);
      if (hid != -1) {
        visited[hid] = 1;
        count += count_rt(nhome - 1, hid);
        visited[hid] = 0;
      }
    }
 
    printf("%d\n", count);
  }
 
  return 0;
}


Measured memory_bytes: 1916
// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)s.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn = 1e7+1;
ll spf [maxn] , n; 
ll divi[maxn] ;
void seive () {
	for (ll i=2; i<=n; ++i) {
		if (!spf[i]) {
		spf[i]=i;
		for (ll j=i*i; j<=n;j+=i) {
			if (!spf[j]) spf[j]=i;
		}
	}
	}
}

void divisor () {
	divi[1]=1;
	F (j,2,n+1,1) {
	ll num = j ;
	ll res=1;
	while (num!=1) {
	ll cnt=0 , a=spf[num];
	while (num%a==0) {
		num=num/a;
		++cnt;
	}
	res*=(cnt+1);
}
divi [j] = res;
}
}
int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
cin>>n;
ll ans=0;
seive ();
divisor ();
F (i,1,n+1,1) {
	ans+= (i*divi[i]);
}
cout<<ans;
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/

Measured memory_bytes: 159784
#include <iostream>

class funca{
public:
	funca()
	{

	}
	void func(const int& i){
		std::cout << " " << i;
	}
};

int main(){
	funca a;
	int n;
	std::cin >> n;

	for (auto i = 1; i <= n; i++)
	{
		if (i % 3 == 0){
			a.func(i);
		}
		else{
			for (auto x = i; x != 0; x /= 10)
				if (x % 10 == 3){
					a.func(i);
					break;
				}
		}
	}
	std::cout << std::endl;
}


Measured memory_bytes: 3116
/*
      HET PAGHADAR
      DA-IICT
      @HET262
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long double ld;
typedef long long ll;
 
typedef vector<ll> vec; 
#define INF LLONG_MAX
 
#define P pair<ll,ll>
 
#define PP pair<int,int>
#define pb push_back
 
#define ff first
#define ss second
 
#define int long long int
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define N 200005
#define MOD 1000000007


signed main()
{
      FAST;
      
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      
      d=(d==1);
      
      cout<<d;
      
      
      
}

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

using namespace std;

int main(void) {

  int n;
  cin >> n;
  
  int max_x = 0;
  
  vector<int> X;
  for (int i = 0; i < n; i++) {
  	int x;
    cin >> x;
    if (max_x < x) {
    	max_x = x;
    }
    X.push_back(x);
  }
  
  vector<long> HP;
    
  for (int i = 1; i <= max_x; i++) {
  	long hp = 0;
    for (int j = 0; j < n; j++) {
    	hp += (X[j] - i) * (X[j] - i);
      	//cout << "hp " << hp << endl;
    }
    HP.push_back(hp);
   
  }
     cout << *std::min_element(HP.begin(), HP.end()) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll gcd(ll x,ll y) {
    if (x == 0) return y;
    return gcd(y%x,x);
}

ll lcm(ll x,ll y) {
    return x/gcd(x,y)*y;
}
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    ll ans = 1LL;
    rep(i,N) ans = lcm(ans,a[i]);

    cout << ans << endl;
}


Measured memory_bytes: 3184
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M, X; cin >> N >> M >> X;
    vi A(M); REP(i, M) cin >> A[i];

    vi x(N + MGN, 0);
    REP(i, M) x[A[i]] = 1;

    int i = X, j = X;
    int left = 0, right = 0;
    while(i<N  || j>0) {
        if (i<N && 0<x[i]) right++;
        if (j>0 && 0<x[j]) left++;
        i++;
        j--;
    }

    int ans = min(left, right);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && a!=c && b!=c){
        printf("%d",c);
    }
    if(b==c && a!=b && a!=c){
        printf("%d",a);
    }
    if(c==a && a!=b && c!=b){
        printf("%d",b);
    }
    
    
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int n, w, h;
  while(cin >> n >> w && (n + w) > 0){
    int MAXW = 0;
    int MAXH = 0;
    
    vector<int> count(20, 0);
    REP(i, n){
      cin >> h;
      count[h / w]++;      
      MAXW = max(MAXW, h / w);
      MAXH = max(MAXH, count[h/w]);
    }
    double ans = 0.01;
    for(int i = 0; i < MAXW + 1; i++){
      
      ans += (double)(MAXW - i) * count[i] / (MAXW * MAXH);
    }
    cout << fixed << setprecision(20) << ans << endl;
  }
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    ll N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    vector<ll> S(N+1); S[0] = 0; REP(i,N) S[i+1] = A[i] + S[i];

    vector<ll> pq(N-3); pq[0] = 1;
    ll l = 1, B = A[0], C = A[1];
    FOR(i,3,N-1){
        C += A[i-1];
        while(l < i-1 && abs(S[l+1]-(S[i]-S[l+1])) < abs(B-C)){
            l++;
            B = S[l];
            C = S[i]-S[l];
        }
        pq[i-2] = l;
    }

    vector<ll> rs(N-3); rs[N-4] = N-1;
    ll r = N-1, D = A[N-2], E = A[N-1];
    RFOR(i,N-2,2){
        D += A[i];
        while(i < r-1 && abs((S[r-1]-S[i])-(S[N]-S[r-1])) < abs(D-E)){
            r--;
            D = S[r]-S[i];
            E = S[N]-S[r];
        }
        rs[i-2] = r;
    }

    ll ans = LL_INF;
    REP(i,N-3){
        B = S[pq[i]];
        C = S[i+2]-S[pq[i]];
        D = S[rs[i]]-S[i+2];
        E = S[N]-S[rs[i]];
        chmin(ans, abs(max(max(B,C),max(D,E)) - min(min(B,C),min(D,E))));
    }

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

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

int main(void){
        char s[1000];
        scanf("%s", s);

        int n;
        scanf("%d", &n);
        for(int i=0; i<n; i++){
                char op[8];
                int l, r;
                scanf("%s %d %d", op, &l, &r);

                if(!strcmp(op, "print")){
                        for(int j=l; j<=r; j++) putchar(s[j]);
                        puts("");
                }
                if(!strcmp(op, "reverse")){
                        char tmp[r-l+1];
                        for(int j=l; j<=r; j++) tmp[j-l] = s[j];
                        for(int j=l; j<=r; j++) s[r+l-j] = tmp[j-l];
                }
                if(!strcmp(op, "replace")){
                        getchar();
                        for(int j=l; j<=r; j++){
                                s[j] = getchar();
                        }
                        getchar();
                }
        }
        return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int &i: a) cin >> i;
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(void){
    int N,sum=0,p,ini;
    cin>>N;
    ini=N;
    REP(i,9){
        p=pow(10,8-i);
        sum+=N/p;
        N%=p;
    }
    if(ini%sum==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int a,b;
    cin>>a>>b;
    int la=ceil(a/0.08),ra=ceil((a+1)/0.08)-1,lb=ceil(b/0.1),rb=ceil((b+1)/0.1)-1;
    if(la>rb||lb>ra) cout<<-1;
    else cout<<int(max(la,lb));
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
Node T[MAX];
int n;

/* Preoder */
void preParse(int u){
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

/* Inoder */
void inParse(int u){
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

/* Postorder */
void postParse(int u){
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main(){
    int i, v, l, r, root;
    scanf("%d", &n);
    for (i=0; i<n; i++){
        T[i].p = NIL;
    }

    for (i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i=0; i<n; i++){
        if (T[i].p == NIL) root = i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;

}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int N;
std::vector<int> W;

int main(int argc, char const* argv[])
{
    std::cin >> N;
    int tmp;
    while(std::cin >> tmp) {
        W.push_back(tmp);
    }

    int group1 = W[0];
    int group2 = std::accumulate(W.begin()+1, W.end(), 0);

    int min = 100*100+1;
    for (int i = 1; i < N-1; i++) {
        group1 += W[i];
        group2 -= W[i];
        int cur = std::abs(group2-group1);
        min = std::min(cur, min);
    }
    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n, m, c;
  cin >> n >> m >> c;
  vector<ll> b(m);
  for(ll i = 0; i < m; i++) cin >> b[i];

  ll ans = 0;
  for(ll i = 0; i < n; i++){
    ll sum = 0;
    for(ll j = 0; j < m; j++){
      ll a = 0;
      cin >> a;
      sum += a * b[j];
    }
    if(sum + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int result = 1;
        for (result=1; result<=5; result++) {
            int xi = sc.nextInt();
            if (xi == 0) {
                break;
            }
        }
        System.out.println(result);
    }
}

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


using namespace std;

/* macros */
#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

/*typedefs*/
typedef long long ll;
/*functions*/
bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str) {
    int num;
    istringstream iss(str); //put string in input stream
    iss>>num; return num; //read from stream as integer
}

template <class T> string toStr(T par) {
    ostringstream oss;  //output stream string
    oss<<par;    //write par to the stream
    return oss.str(); //return string of output
}



int main() {
    IOS();
    int n , m , t_l, t_r;
    int l = 0;
    int r = 100009 ;
    cin>>n>>m;
    REP(i,m)
    {
        cin>>t_l>>t_r;
        l = max(l, t_l);
        r = min(r,t_r);
    }

    cout<<max(0,r-l+1)<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val dp = Array(N+1){Array(4){Array(4){LongArray(4){0L}}}}
    //ACGT 0123 xAGC 021
    dp[0][3][3][3] = 1

    for (n in 0 until N) {
        for (i in 0 until 4) {
            for (j in 0 until 4) {
                for (k in 0 until 4) {
                    for (x in 0 until 4) {
                        if (dp[n][i][j][k] == 0L) continue
                        if (j == 0 && k == 2 && x == 1) continue
                        if (j == 0 && k == 1 && x == 2) continue
                        if (j == 2 && k == 0 && x == 1) continue
                        if (i == 0 && j == 2 && x == 1) continue
                        if (i == 0 && k == 2 && x == 1) continue
                        dp[n + 1][j][k][x] += dp[n][i][j][k] % 1000000007L
                    }
                }
            }
        }
    }
    var ans = 0L
    for (i in 0 until 4) {
        for (j in 0 until 4) {
            for (k in 0 until 4) {
                ans += dp[N][i][j][k]
                ans %= 1000000007L
            }
        }
    }
    println(ans)
}


Measured memory_bytes: 31388
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 100000001
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][1050];

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    int i;
    int n;
    int a,b,d,c;
    int e,weight;
    ll h,w;
    cin>>h>>w;
    vector<string> stra(h);
    rep(i,h){
        cin>>stra[i];
    }
    rep(i,h){
        rep(j,2){
            cout<<stra[i]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    try {
      while (input.ready()) {
        String[] dataset = input.readLine().split(" ");
        int sum = Integer.valueOf(dataset[0]) + Integer.valueOf(dataset[1]);
        System.out.println(countDigitNumber(sum));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  public static int countDigitNumber(int number) {
    int digitNumber = 1;
    while (number >= 10) {
      digitNumber++;
      number = number / 10;
    }
    return digitNumber;
  }
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    vector<int> t(n);
    int sum = 0;
    rep(i, n)
    {
        t[i] = l + i;
        sum += t[i];
    }
    int mn = 1e9;
    int ans = 0;
    rep(i, n)
    {
        int r = sum - t[i];
        if (mn > abs(sum - r))
        {
            mn = abs(sum - r);
            ans = r;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define eps 1e-6
using namespace std;

int main()
{
  string a;
  cin>>a;
  if(a[2]==a[3]&&a[4]==a[5])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use Data::Dumper;
my ($w,$h,$x,$y) = map { $_ - 0 } split(/\s+/,<STDIN>);
if( $w > $h ){
  my $dm = $x;
  $x = $y;
  $y = $dm;
  $dm = $w;
  $w = $h;
  $h = $dm;
}
if( $x > $w / 2 ){
  $x = $w - $x;
}
if( $y > $h / 2 ){
  $y = $h - $y;
}

my $mul = 0; 
$mul = 1 if( $x == $w / 2 and $y == $h / 2 );
my $men = ( $w * $h ) / 2;

print "$men $mul\n";



Measured memory_bytes: 1920
import sys


for line in sys.stdin:
    n = int(line)
    ret = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                tmp = n - a - b - c
                if tmp < 0:
                    break
                if tmp <= 9:
                    ret += 1
    print ret

Measured memory_bytes: 4220
n,m = map(int,input().split())
raw = []
for _ in range(m):
  s,c = map(int,input().split())
  s -= 1
  raw.append([s,c])
for d in range(1000):
  e = str(d)
  e = '0' * (n-len(e)) + e
  #print(e)
  for x in raw:
    s,c = x
    if e[s] != str(c):
      break
  else:
    if e[0] == '0' and n != 1:
      continue
    else:
      print(e)
      break
  continue
else:
  print(-1)

Measured memory_bytes: 3064