akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

int main(){
    i64 n;
    cin >> n;
    vector<i64> a(n + 1), ans(n + 1);
    for(int i = 1; i < n + 1; ++i) cin >> a[i];
    i64 cnt = 0;
    for(int i = n; i >= 1; --i){
        i64 s = 0;
        for(int j = i; j <= n; j += i) s += ans[j];
        if(s % 2 != a[i] % 2){
            ans[i] = 1;
            ++cnt;
        }
    }
    cout << cnt << endl;
    for(int i = 1; i < n + 1; ++i) if(ans[i]) cout << i << endl;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 100;
int n;
struct Node {
	string name;
	int id, score;
	
	inline friend bool operator<(Node x, Node y) {
		if (x.name == y.name) return x.score > y.score;
		return x.name < y.name;
	}
} a[MAXN + 5];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].name;
		read(a[i].score);
		a[i].id = i;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		write(a[i].id);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll a; 
    std::string b;
    cin >> a >> b;

    int b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    cout << a * b100 / 100 << endl;   
}

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

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

int main()
{
  int n, m, Q;
  cin >> n >> m >> Q;
  int graph[501][501] = {};
  int sum[510][510] = {};
  vector<int> ans;
  for (int i = 0; i < m; ++i)
  {
    int l, r;
    cin >> l >> r;
    graph[l][r] += 1;
  }
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
      sum[i + 1][j + 1] = graph[i + 1][j + 1];
  }

  for (int i = 0; i < n + 1; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      sum[i][j + 1] += sum[i][j];
    }
  }
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n + 1; ++j)
    {
      sum[i + 1][j] += sum[i][j];
    }
  }

  for (int i = 0; i < Q; ++i)
  {
    int p, q;
    cin >> p >> q;
    ans.push_back(sum[q][q] - sum[p - 1][q] - sum[p][p - 1] + sum[p - 1][p - 1]);
  }
  for (auto &e : ans)
    cout << e << endl;

  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> a(N);
    REP(i, N)
        cin >> a.at(i);

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

    ll a_max = a.at(N / 2);
    ll a_min = a.at(N / 2 - 1);

    cout << a_max - a_min << endl;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
/* mt19937 mrand(random_device{}()); 
int rnd(int x) { return mrand() % x;}*/
ll powmod(ll a,ll b) {ll res=1;a%=mod;  for(;b>0;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
const int N=105;
int _;
double n,m;

int dp[N][N],a[N][N];
int main() {
		scanf("%lf",&m);
		double n=3.141592;
		printf("%.2f",m*2*n);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  long long a;
  cin>>a;
  long long ans=0,wa=0;
  int n;
  n=sqrt(a);
  for(long long i=1;i<=n;i++)
    for(long long j=i;j<=a-1;j++){
      if(i*j<a)
        ans++;
      if(i==j&&i*j<a)
        wa++;
      }
  cout<<ans*2-wa;
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,W;
	cin>>n>>W;
	long long int w[n],v[n],value[n+1][W+1],max1=0;
	for(long long int i=1; i<=n; i++)
		cin>>w[i]>>v[i];
	for(long long int i=0; i<=W; i++)value[0][i]=0;
	for(long long int i=0; i<=n; i++)value[i][0]=0;
	for(long long int i=1; i<=W; i++)
	{
		for(long long int j=1; j<=n; j++)
		{
			if(i - w[j] >= 0)
			{
				value[j][i] =  max((value[j-1][i-w[j]] + v[j]) , value[j-1][i]);
			}
			else
			{
				value[j][i] = value[j-1][i];
			}
		}
	}
	max1=0;
	for(long long int i=0; i<=n; i++)
	{
		if(value[i][W] > max1)
			max1 = value[i][W];
	}
	cout<<max1<<endl;
}

Measured memory_bytes: 79104
A,B,M=map(int, input().split())
AList=list(map(int, input().split()))
BList=list(map(int, input().split()))
XYCList = [list(map(int, input().split())) for i in range(M)]
ANS=[min(AList)+min(BList)]
i=0
while i<M:
    ANS.append(AList[XYCList[i][0]-1]+BList[XYCList[i][1]-1]-XYCList[i][2])
    i+=1
print(min(ANS))

Measured memory_bytes: 42528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int a = 0;
	string s;
	cin >> s;
	FOR(i, 4) {
		if (s[i] == '+')a++;
		else a--;
	}
	cout << a << endl;

	return 0;
}


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

int main() {
  int n,i,j,ans=0,c;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(26),b(26);
  for(i=0;i<n;i++){
    a={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    b={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    for(j=0;j<i;j++){
      c=s[j]-'a';
      a[c]++;
    }
    for(j=i;j<n;j++){
      c=s[j]-'a';
      b[c]++;
    }
    c=0;
    for(j=0;j<26;j++){
      if(b[j]>0 && a[j]>0){
        c++;
      }
    }
    ans=max(ans,c);
  }
  cout << ans;
}



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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	int n;cin>>n;
	cout<<n*n*n<<endl;
}

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

int used[10000];

void dfs(int v, const Graph& G, vector<int>& res) {
	used[v] = 1;
	for (auto to : G[v]) if (used[to] == 0) {
		dfs(to, G, res);
	}
	res.push_back(v);
}

int main()
{
	int V, E;
	cin >> V >> E;
	Graph G(V);
	vector<int> ide(V);
	for (int i = 0, s, t; i < E; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		ide[t]++;
	}
	vector<int> res;
	for (int i = V - 1; i >= 0; i--) {
		if (ide[i] == 0) {
			dfs(i, G, res);
		}
	}
	reverse(res.begin(), res.end());
	for (int i = 0; i < V; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3848
import sys
from io import StringIO
import unittest


def resolve():
    n = int(input())
    b = list(map(int, input().split()))

    a = [0 for _ in range(n)]

    for i in range(n - 1, -1, -1):
        if i == n - 1:
            a[i] = b[i - 1]
        elif i == 0:
            a[i] = b[0]
        else:
            a[i] = min(b[i], b[i - 1])
    print(sum(a))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
2 5"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
3"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
0 153 10 10 23"""
        output = """53"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 6264
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,m,sum=0,b;
	cin>>n>>m;
	vector<int>ppl(n);
	rep(i,n)cin>>ppl[i];
	rep(i,n)sum+=ppl[i];
	sort(ppl.begin(),ppl.end(),greater<int>());
	b=ppl[m-1];
	if(b*4*m<sum)cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

int main(){
    int n ,d;
    cin >> n >>d;
  if((n%((d*2)+1))==0){
  cout << n/((d*2)+1) <<endl;
  }else{
   cout <<(n/((d*2)+1)+1)<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static String[] mySplit(String str){return str.split("");}
        public static void main(String[] args){
          int N = getInt();
          int M = getInt();
          if(N >= M){
            myout(0);
            return;
          }
          long output = 0;
          ArrayList<Integer> list = new ArrayList<Integer>(M);
          for(int i = 0; i < M; i++){
            list.add(getInt());
          }
          Collections.sort(list);
          //myout(list);
          PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
          for(int i = 1; i < M; i++){
            pq.add(Math.abs(list.get(i)-list.get(i-1)));
          }
          for(int i = 0; i < N-1; i++){
            pq.poll();
          }
          while(pq.size() != 0){
            output += pq.poll();
          }
          myout(output);
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 47996
#include <bits/stdc++.h>
//#define ll long long
//#define INF LONG_MAX
using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string jug = "No";
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int black = i * (m - j) + (n - i) * j;
      if (k == black) jug = "Yes";
    }
  }
  cout << jug << endl;
  return 0;
}


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

int main(){

    int a[3];
    rep(i,3)  cin >> a[i];

    int i=0;
    int j,minj,t;

    rep(i,2){
        minj = i;
        for(j=i;j<3;j++){
            if( a[j] < a[minj] ) minj = j;
           }
            t = a[i];a[i]=a[minj];a[minj]=t;
        }
    
    cout << a[0]<< " " << a[1] << " " << a[2] << endl;


}



Measured memory_bytes: 3104
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
  cin.sync_with_stdio(0);
  ll x;
  cin >> x;
  if(x >= 30) {
	  cout << "Yes" << endl;
  } else {
	  cout << "No" << endl;
  }
}


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

#define fill(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pb push_back
#define smp(x,y,z) mp(x,mp(y,z))
#define reads(x) scanf("%s",&x)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)

typedef long long ll;
typedef string s;
typedef pair<ll,ll> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vector<int> > matrix;

const ll oo = 1e16;
const int maxSize = 100100;
const int mod = 1e9+7;

const double EPS = (1e-9);

int dcmp(double x, double y){return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;}

int arr[4*100000]={0};
ll fron[4*100000],bac[4*100000] ;

int main(){
    int n ; cin >> n ;
    for(int i=0 ;i<n*3 ;i++){
        cin>> arr[i] ;
    }
    int i=0 ;
    ll sum=0 ;
    priority_queue<int> seq;
    for(;i<n;i++){
        sum+=arr[i];
        seq.push(-1*arr[i]);
    }
    fron[n-1] = sum ;
    for(;i<2*n;i++){
        int out = seq.top() ;
        if(arr[i]>-1*out){
            seq.pop();
            seq.push(-1*arr[i]);
            sum -= -1*out-arr[i] ;
        }
        fron[i] = sum ;
    }
    i=3*n-1;
    sum=0;
    priority_queue<int> seq2;
    for(;i>=2*n;i--){
        sum+=arr[i];
        seq2.push(arr[i]);
    }
    bac[i+1] = sum ;
    for(;i>=n;i--){
        int out = seq2.top() ;
        if(arr[i]<out){
            seq2.pop();
            seq2.push(arr[i]);
            sum -= out-arr[i] ;
        }
        bac[i] = sum ;
    }
    ll maxi = -oo;
    for(;i<2*n;i++){
        maxi=max(maxi,fron[i]-bac[i+1]);
    }
    cout << maxi ;
}
/*
2
3 1 4 1 5 9*/


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    vector<int> alpha1(26, 0), alpha2(26, 0), cp(26, 0);
    REP(i, 1, s.size()){
        alpha1 = cp; alpha2 = cp;
        REP(l, 0, i){
            alpha1[s[l]-'a']++;
        }
        REP(l, i, s.size()){
            alpha2[s[l]-'a']++;
        }
        int count = 0;
        REP(l, 0, 26){
            if(alpha1[l] != 0 && alpha2[l] != 0){
                count++;
            }
        }
        ans = max(count, ans);
    }
    cout << ans << endl;
}

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

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

    int N;
    cin >> N;
    list<int> b;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        b.push_front(a);
    }

    stack<int> ans;
    while (!b.empty()) {
        bool isok = false;
        int i = 0;
        for (auto itr = b.begin(); itr != b.end(); ++itr) {
            if (*itr == b.size() - i) {
                ans.push(*itr);
                b.erase(itr);
                isok = true;
                break;
            }
            i++;
        }
        if (!isok) {
            cout << -1 << endl;
            return 0;
        }
    }

    while (!ans.empty()) {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 256
// Problem : C - Poll
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin >> n;
	string arr[n];
	for(int i=0;i<n;++i)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	string b[n];
	int ar[n];
	int j=0,mx=0;
	for(int i=0;i<n;++i)
	{
		int cnt=1;
		while(i<n-1 && arr[i].compare(arr[i+1])==0)
		{
			cnt++;
			i++;
		}
		b[j]=arr[i];
		ar[j]=cnt;
		mx=max(mx,cnt);
		++j;
	}
	for(int i=0;i<j;i++)
	{
		if(ar[i]==mx)
		cout << b[i] << endl;
	}
	return 0;
}

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

int main(){
	int b, f, r, v;
	int data[4][3][10];

	//初期化
	for (int fofofo = 0; fofofo < 4;fofofo++){
		for (int jojojo = 0; jojojo < 3; jojojo++){
			for (int kokoko = 0; kokoko < 10; kokoko++){
				data[fofofo][jojojo][kokoko] = 0;
			}
		}
	}

	int count;
	cin >> count;

	//入力
	for (int rororo = 0; rororo < count; rororo++){
		cin >> b >> f >> r >> v;
		data[b - 1][f - 1][r - 1] += v;
	}

	//出力
	for (int re = 0; re < 4; re++){
		for (int i = 0; i < 3; i++){
			for (int oo = 0; oo < 10; oo++){
				cout << " " << data[re][i][oo];
			}
			cout << endl;
		}
		if (re < 3){
			cout << "####################" << endl;
		}
	}
	
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  int a[n],sum=0;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<k;i++){
  	sum+=a[i];
  }
  cout<<sum;
}

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

using namespace std;

int main() {
    string x;
    cin>>x;
    char a[20];
    int j=0;
    for(int i=0;i<x.size();i++){
        if(x[i]=='0'){
            a[j]='0';
            j++;
        }
        else if(x[i]=='1'){
            a[j]='1';
            j++;
        }
        else{
            j--;
            if(j<0)
            j=0;
            a[j]=' ';
        }


    }
    for(int i=0;i<j;i++)
        cout<<a[i];

    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
//package com.atcoder.contest171.d;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long[] arr = fs.readArray(n);
        long sum = 0;
        Map<Long,Long> mp = new HashMap<>();
        for(long x : arr) {
            sum += x;
            mp.put(x, mp.getOrDefault(x, 0L)+1);
        }
        int q = fs.nextInt();
        StringBuilder sb = new StringBuilder();
        while(q-- != 0){
            long b = fs.nextLong();
            long c = fs.nextInt();
            boolean present = mp.containsKey(b);
            long cnt = mp.getOrDefault(b,0L);
            sum -= b * cnt;
            sum += c * cnt;
            if(present){
                mp.remove(b);
            }
            mp.putIfAbsent(c, 0L);
            mp.put(c, mp.getOrDefault(c,0L) + cnt);
            sb.append(sum).append("\n");
        }
        System.out.print(sb.toString());

    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long[] readArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 62344
#include<stdio.h>

int main(){
  int i,e,m,j,te,tm,k;
  do{
    scanf("%d",&e);
    if(!e) break;
    for(m=0,i=2;i*i*i<=e;i++);
    for(j=0,m=-1;j<i;j++){
      te=e-j*j*j;
      tm=j;
      for(k=2;k*k<=te;k++);
      if(k!=2){
	te-=(k-1)*(k-1);
	tm+=k-1;
      }
      tm+=te;
      if(m==-1){
	m=tm;
      }else if(tm<m){
	m=tm;
      }
    }
    printf("%d\n",m);
  }while(1);
  return 0;
}
    

Measured memory_bytes: 408
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

const int MX = 100 * 1000 + 5;
int a [MX][3], dp [MX][3];

int
main () {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++)
            scanf ("%d", &a [i][j]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp [i][j] = max (dp [i][j], a [i][j] + (i > 0 ? dp [i - 1][k] : 0));
                dp [i][j] = max (dp [i][j], a [i][j] + (i > 0 ? dp [i - 1][k] : 0));
                dp [i][j] = max (dp [i][j], a [i][j] + (i > 0 ? dp [i - 1][k] : 0));
            }

    int ret = max ({ dp [N - 1][0], dp [N - 1][1], dp [N - 1][2] });
    printf ("%d\n", ret);

#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



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

using ll = long long;
using Pi = pair < int, int >;

constexpr int mod = 1000000007;
constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
	int power2[100005];
	int cnt[26] = {};
	int N;
	string S;

	cin >> N >> S;
	
	power2[0] = 1;
	for ( int i = 1; i < 100005; i++ ) {
		power2[i] = (power2[i - 1] * 2) % mod;
	}
	
	for ( int i = 0; i < S.size(); i++ ) {
		cnt[S[i] - 'a']++;
	}
	
	int sum[26] = {};	

	memcpy(sum, cnt, sizeof(cnt));	
	for ( int i = 1; i < 26; i++ ) {
		(sum[i] += (sum[i - 1] + ((ll)sum[i - 1] * cnt[i]) % mod) % mod) %= mod;
	}
	cout << sum[25] << endl;

	return ( 0 );
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int k;
  cin >> k;
  vector<ll> a{1,2,3,4,5,6,7,8,9};
  while(true){
    if(k <= a.size()){
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> temp;
    for(ll num: a){
      for(int i = -1; i <= 1; i++){
        int t = num % 10 + i;
        if(t < 0 || t > 9) continue;
        ll nt = num * 10 + t;
        temp.push_back(nt);
      }
    }
    swap(a, temp);
  }
  return 0;
}

Measured memory_bytes: 1712
N = int(input())
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

T = [int(input()) for _ in range(N)]
ans = T[0]
for e in T:
    ans = lcm(e,ans)
print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n ,i,j,mini=INT_MAX;
    cin>>n;
    vector<int>vi;
    for(i = 0 ;i<n ;i++)
    {
        cin>>j;
        vi.push_back(j);
    }
    for(i = 0 ;i<n ;i++)
    {
        int c= 0;
        while(vi[i]%2==0)
        {
            vi[i]/=2;
            c++;
        }
        mini = min(mini,c);
    }
    cout<<mini<<endl;
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0)
        cout<<"0";
    else 
    {
        --n;
        --m;
        cout<<n*m;
    }
    puts("");
    return 0;
}

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

struct Query
{
  int t;
  int f;
  char c;
};

using Queries = std::vector<Query>;

std::string solve(std::string& s, const Queries& queries)
{
  bool reversed = false;
  std::ostringstream head;
  std::ostringstream tail;
  for (const auto& q : queries) {
    if (q.t == 1) {
      reversed = !reversed;
    } else {
      if (q.f == 1) {
        if (reversed) {
          tail << q.c;
        } else {
          head << q.c;
        }
      } else {
        if (reversed) {
          head << q.c;
        } else {
          tail << q.c;
        }
      }
    }
  }
  if (reversed) {
    std::string h = tail.str();
    std::reverse(h.begin(), h.end());
    std::reverse(s.begin(), s.end());
    return h + s + head.str();
  } else {
    std::string h = head.str();
    std::reverse(h.begin(), h.end());
    return h + s + tail.str();
  }
}

int main()
{
  std::string s;
  long q;
  std::cin >> s >> q;

  Queries queries(q);
  for (auto& q : queries) {
    std::cin >> q.t;
    if (q.t == 2) {
      std::cin >> q.f >> q.c;
    }
  }

  std::cout << std::setprecision(20);
  std::cout << solve(s, queries) << std::endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    if(s[0]=='9' || s[1]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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>;
using Graph = vector<vector<int>>;
int n,m,ans=0;
Graph g;
vector<bool>seen;
void dfs(int x){
    seen[x]=true;
    bool flag=true;
    rep(i,n){
        if(!seen[i]){
            flag=false;
        }
    }
    if(flag){
        ans++;
        return;
    }


    for(int next_x:g[x]){
        if(seen[next_x])continue;
        seen[next_x]=true;
        dfs(next_x);
        seen[next_x]=false;
    }
    return;
}
int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>n>>m;
    int a,b;
    g.resize(n);
    seen.resize(n);
    rep(i,m){
        cin>>a>>b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    seen[0]=true;
    dfs(0);
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long r){
  cout<<3*r*r<<endl;
}

int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

#define MAXN 100000
struct node{
    int l,c;
    bool operator < (node b) const{
        return c<b.c;
    }
}A[MAXN+5];

bool cmp(node i,node j){
    return i.l<j.l;
}

int ID[MAXN+5];

int main(){
    int N=read(),M=read();
    for(int i=1;i<=N;i++)
        A[i].l=M-read(),A[i].c=read(),ID[i]=i;
    sort(A+1,A+N+1,cmp);
    int E=N;
    while(A[E].l>M)
        E--;
    int Ans=0;
    priority_queue<node> Q;
    while(M>=0){
        while(E>=1&&A[E].l==M)
            Q.push(A[E--]);
        M--;
        if(!Q.empty()){
            Ans+=Q.top().c;
            Q.pop();
        }
    }
    printf("%d",Ans);
}


Measured memory_bytes: 2552
List = list(map(int,input().split()))
A = List[0]
B = List[1]

wa = A + B
sa = A - B
seki = A * B

if wa < sa:
    if sa <= seki:
        print(seki)
    else:
        print(sa)

if wa >= sa:
    if wa >= seki:
        print(wa)
    else:
        print(seki)



Measured memory_bytes: 3060
n,k = map(int,input().split())
mod = 10**9+7
"""
dp[i] := gcd(a1,...,an) = i となるものがいくつあるか
"""
dp = [0 for _ in range(k+1)]
subdp = [0 for _ in range(k+1)]
for i in range(1, k+1)[::-1]:
	target = pow(k//i, n, mod)
	for j in range(2*i, k+1, i):
		target -= dp[j]
	dp[i] = target
ans = 0
for i in range(k+1):
	ans = (ans + dp[i]*i) % mod
print(ans)

Measured memory_bytes: 12016
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x=parseInt(readline())
    println(x÷500*1000+x%500÷5*5)
end
main()

Measured memory_bytes: 110088
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
    int n;
    cin>>n;
    int tab[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
    	cin>>tab[i];
    	dp[i]=0;
	}
		dp[1]=abs(tab[0]-tab[1]);
		dp[2]=abs(tab[0]-tab[2]);
		for(int i=3;i<n;i++)
		{
			dp[i]=min(dp[i-2]+abs(tab[i-2]-tab[i]),dp[i-1]+abs(tab[i-1]-tab[i]));
		}
	    cout<<dp[n-1];
}



Measured memory_bytes: 1024
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
#define max(x,y) x>y?x:y
#define min(x,y) x<y?x:y
using namespace std;
const int maxn=1e5+10;
const int maxm=6*1e5+10;
const int gg=0x7FFFFFFF;
int a,b,c;
int main()
{
    int p[4];
    scanf("%d%d%d",&p[0],&p[1],&p[2]);
    

        //sort(p,p+3);
        if(p[1]<p[0])
        {
            int temp=p[1];
            p[1]=p[0];
            p[0]=temp;
        }
        if(p[2]<p[1])
        {
            int temp=p[2];
            p[2]=p[1];
            p[1]=temp;
        }
       if(p[1]<p[0])
        {
            int temp=p[1];
            p[1]=p[0];
            p[0]=temp;
        }
        a=p[0]; b=p[1]; c=p[2];
        //cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
        int ans=0;
        ans=c-b;
        int t=0;
        if((b-a)%2==1)
        {
            ans+=(b-a+1)/2+1;
        }
        else
        {
            ans+=(b-a)/2;
        }
        printf("%d\n",ans );
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  vll A(N);
  ll keta = 0;
  ll k = K;
  while (k > 0) {
    keta++;
    k /= 2;
  }
  if (K == 0) keta = 1;

  vll count(keta);
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
    ll index = 0;
    while (a > 0) {
      if (a & 1) {
        count[index]++;
      }
      index++;
      a /= 2;
    }
  }

  ll x = 0;
  repr(i, keta - 1) {
    ll a = 1ll << i;
    if (count[i] <= N / 2 && x + a <= K) {
      x += a;
    }
  }

  if (K == 0) x = 0;
  ll ans = 0;
  rep(i, N) {
    ans += A[i] ^ x;
  }
  ANS;
  return 0;
}


Measured memory_bytes: 3916
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int arareCount = int.Parse(Reader.ReadLine());
        char[] inpt = Reader.ReadLine().Split(' ').Select(a => a[0]).Distinct().ToArray();

        string ans = "Four";
        if(inpt.Count() == 3)  {
            ans = "Three";
        }
        Console.WriteLine(ans);
    }




    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


8
P Y W G Y W Y Y

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

long long N;
pair<long long, long long> parr[200005];
long long mini, maxi;

int main(){
	cin >> N;
	mini = 1000000000;
	maxi = 1;
	for(long long i = 0; i < N; i++){
		cin >> parr[i].first >> parr[i].second;
		if(parr[i].first > parr[i].second){
			swap(parr[i].first, parr[i].second);
		}
		mini = min(mini, parr[i].first);
		maxi = max(maxi, parr[i].second);
	}

	if(N == 1){
		return 1;
	}

	long long Xmax = maxi, Ymax = 1;
	long long Xmin = mini, Ymin = 1000000000;
	long long ans = 1e18;

	//Xmin == mini && Xmax == maxi
	long long mapos1 = -1, mapos2 = -1;
	long long mipos1 = -1, mipos2 = -1;

	for(long long i = 0; i < N; i++){
		if(parr[i].second == maxi){
			if(mapos1 < 0){
				mapos1 = i;
			}else{
				mapos2 = i;
			}
		}


		if(parr[i].first == mini){
			if(mipos1 < 0){
				mipos1 = i;
			}else{
				mipos2 = i;
			}
		}
	}

	//Which Y should choose?
	if((mapos2 > 0 )|| (mipos2 > 0) || (mapos1 != mipos1)){
		//            val    ,   pos
		vector<pair<long long, long long> > pairvec;
		long long pastmin = 1000000000;

		for(long long i = 0; i < N; i++){
			pairvec.push_back(make_pair(parr[i].first, i));
		}
		sort(pairvec.begin(), pairvec.end());


		Ymin = pairvec[0].first;
		Ymax = pairvec[pairvec.size() - 1].first;
		ans = min(ans, Ymax - Ymin) * (Xmax - Xmin);

		for(int i = 0; i < pairvec.size(); i++){
			//swap does not update minimum val
			if(pairvec[i].first >= pastmin){
				break;
			}
			pastmin = min(pastmin, parr[pairvec[i].second].second);

			if(i == pairvec.size() - 1){
				Ymin = pastmin;
			}else{
				Ymin = min(pastmin, pairvec[i+1].first);
			}

			Ymax = max(Ymax, parr[pairvec[i].second].second);

			ans = min(ans, (Ymax - Ymin) * (Xmax - Xmin));
		}
	}


	//Xmin == mini && Ymax == maxi
	Xmax = 1;
	Ymax = 1;
	Xmin = 1000000000;
	Ymin = 1000000000;
	
	for(long long i = 0; i < N; i++){
		Ymin = min(Ymin, parr[i].second);
		Xmax = max(Xmax, parr[i].first);
	}

	ans = min(ans, (maxi - Ymin) * (Xmax - mini));

	cout << ans << endl;

}


Measured memory_bytes: 9584
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}

void solve()
{
int n,k;
cin>>n>>k;
if(n>k)
{
    int x=n/k;
    n-=(x*k);
}
cout<<min(n,k-n);
}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





Measured memory_bytes: 256
/*CODED BY

|||||||THE LNM INSTITUTE OF INFORMATION TECHNOLOGY||||||||||||


  *****                   <<<<<<<<<<*>>>>>>>>>
  *******                 ********************
  ***   ***                        ***
  ***    ***                       ***
  ***     ***    **************    ***
  ***      ***   *DARSHAN JAIN*    ***
  ***      ***   **************    ***
  ***      ***                     *** 
  ***     ***                      ***  
  ***    ***              ***      ***
  ***   ***      ****      ***     ***       ****
  *******        |19|       ***   ***        |19|
  *****          ****          ***           ****


|||||||THE LNM INSTITUTE OF INFORMATION TECHNOLOGY||||||||||||  

*/



#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define M 1000000007
#define mint INT_MAX;
#define checkloop cout<<"i="<<i<<"     "<<"j="<<j<<endl;
#define checkvalue(qq,ww) cout<<"value1="<<qq<<"     "<<"value2="<<ww<<endl;
#define output(out) cout<<out<<endl;
#define linechange cout<<endl;
#define space cout<<"\t";
#define testoutput(first,out) cout<<first<<"===="<<out<<endl;
ll t,inp,inp1,inp2,n;
ll count=0;
#define ull unsigned long long int
ll dp1[1000000+6];
ll max=0;
int main() 
{
  ll n;
  cin>>n;
  ll a[n]={0};
  for (int i=0;i<n;++i)
  {
    cin>>a[i];
  }
  ll sum=0;
  for (int i=0;i<n;++i)
  {
    for (int j=i+1;j<n;++j)
    {
      sum+=a[i]*a[j];
      //testoutput(a[i],a[j]);
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,a,b,i,j;
    cin>>n>>a>>b;
    vector<ll> p(n);
    for(i=0;i<n;i++) cin>>p[i];
    ll ans = 0;
    for(i=1;i<n;i++)
    {
        ans+=(min((p[i]-p[i-1])*a, b));
    }
    cout<<ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    lld d,t,s;
    cin>>d>>t>>s;
    lld k=d/s;
    if(t>=k)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
}

Measured memory_bytes: 3756
fun main(args: Array<String>) {
    val a = readLine()!!.split(" ").map { it.toInt() }
    var y = 0
    var n = 0

    for(i in 1 until a.size){
        if(a[0] == a[i]){
            y++
        }
    }
    if(y == 1){
        println("Yes")
    }else if(a[1] == a[2] && y == 0){
        println("Yes")
    }else{
        println("No")
    }
}


Measured memory_bytes: 35920
#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
long long N,K;
cin>>N>>K;
if(K%2==1){
cout<<(N/K)*(N/K)*(N/K)<<endl;}
else if(N%K>=K/2)
cout<<((N/K)+1)*((N/K)+1)*((N/K)+1)+(N/K)*(N/K)*(N/K)<<endl;
else if(N%K<K/2)
cout<<2*(N/K)*(N/K)*(N/K)<<endl;}

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

string s;
int n;

int check(int x){
  set<string> S;
  int mx=-1e9,mn=1e9;
  for(int i=0;i<n;i+=x){
    string t;
    int res=0;
    for(int j=0;j<x;j++){
      if(x-j<3)res=res*10+s[i+j]-'0';
      else t+=s[i+j];
    }
    mx=max(mx,res);
    mn=min(mn,res);
    S.insert(t);
  }
  if(S.size()>1)return 1e9;
  return mx-mn;
}

int main(){
  cin>>s;
  n=s.size();
  int ans=9;
  for(int i=1;i<n;i++)
    if(n%i==0)ans=min(ans,check(i));
  int mx=-1e9,mn=1e9;
  for(int i=0;i<n;i++){
    int res=s[i]-'0';
    if(s[i]=='1'&&i!=n-1)res=10+s[++i]-'0';
    mx=max(mx,res);
    mn=min(mn,res);
  }
  if(n>2)ans=min(ans,mx-mn);
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int a[3], b[3];
  int count[4] = {};
  for(int i = 0; i < 3; i++){
    cin >> a[i] >> b[i];
    count[a[i]-1]++;
    count[b[i]-1]++;
  }
  sort(count, count + 4);
  if(count[0] == 1 && count[1] == 1 && count[2] == 2 && count[3] == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
    


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

// ALDS1_3_B
public class Main {
	public static void calc(Queue<Info> qu, int q) {
		Info info;
		int time = 0;
		while (!qu.isEmpty()) {
			info = qu.remove();
			if (info.time - q > 0) {
				info.time = info.time - q;
				qu.add(info);
				time += q;
			} else {
				time += info.time;
				System.out.println(info.name + " " + time);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Queue<Info> qu = new LinkedList<Info>();
		int n = sc.nextInt();
		int q = sc.nextInt();
		for (int i = 0; i < n; i++) {
			qu.add(new Info(sc.next(), sc.nextInt()));
		}
		calc(qu, q);
		sc.close();
	}
}

class Info {
	String name;
	int time;
	Info(String name, int time) {
		this.name = name;
		this.time = time;
	}
	Info() {}
}


Measured memory_bytes: 75104