akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
# define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
    ll a;
    ll ans = 0;
    ll min_a = 1e9;
    ll m_n = 0;
    rep(i,N){
        cin>>a;
        if(a>=0){
            ans += a;
            min_a = min(min_a,a);
        }else{
            ++m_n;
            ans -= a;
            min_a = min(min_a,-a);
        }
    }
    if(m_n%2!=0){
        ans -= min_a*2;
    }
    // cout<<min_a<<"\n";
    cout<<ans<<"\n";
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, k;
  cin >> n >> k;
  if (n < 2 * k - 1) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> xs(n);
  vector<int> ys(n);
  vector<int> zs(n);

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      xs[i] = k + i / 2;
      ys[i] = k + n + (n / 2) + i / 2;
    } else {
      xs[i] = k + ((n + 1) / 2) + i / 2;
      ys[i] = k + n + i / 2;
    }
    zs[i] = k + 2 * n + i;
  }

  for (int i = 0; i < n; i++) {
    cout << xs[i] << " " << ys[i] << " " << zs[i] << "\n";
  }
}

Measured memory_bytes: 3456
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10) cout << - 1 << endl;
    else                    cout << a * b << endl;
    return 0;
}

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

int main(int argc, char *argv[]){
    int N,K;
    std::cin >> N >> K;
    double P=0;
    for(int i=0; i<N; ++i){
        P += std::pow(0.5,std::max(0.0, std::ceil(std::log2(static_cast<double>(K)/(i+1))) ));
    }
    P /= N;
    std::cout << std::fixed << std::setprecision(11) << P << std::endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
// #include<map>
#include<cmath>
#include<list>
#define ll long long
#define N 150005
#define pb push_back
#define Sca(a) scanf("%d",&a)
#define Scs(a) scanf("%s",&a)
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define Scal(a) scanf("%ld",&a)
#define Scall(a) scanf("%lld",&a)
#define Pri(a) printf("%d",a)
#define Prs(a) printf("%s",a)
#define Pril(a) printf("%ld",a)
#define Prill(a) printf("%lld",a)
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double pi = 3.141592653;
using namespace std;
template <class T>void tomax(T&a, T b) {
	a = max(a, b);
}
template <class T>void tomin(T&a, T b) {
	a = min(a, b);
}
int main(){
	int n,a[30],b[30],c[30],sum=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i],sum+=b[i];
	for(int i=1;i<=n-1;i++) cin>>c[i];
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]+1) sum+=c[a[i-1]];
	}	

	cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;

public class OneCardPoker
{
    static void Main()
    {
        string[] inputs = Console.ReadLine().Split( ' ' );
        if ( inputs.Length < 2 ) return;

        int a = Number( inputs[ 0 ] );
        int b = Number( inputs[ 1 ] );
        if ( a == 0 || b == 0 ) return;

        Console.WriteLine( a > b ? "Alice" : a < b ? "Bob" : "Draw" );
    }

    static int Number( string input )
    {
        int number = 0;
        if ( !int.TryParse( input, out number ) ) { return 0; }
        return Check( number );
    }

    static int Check( int number )
    {
        if ( number == 1 ) number = 14;
        return number;
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    if(k>n)
        printf("1");
    else if(k==n)
        printf("2");
    else
    {
        int c=0;
        while(n)
        {
            n=n/k;
            c++;
        }
        printf("%d", c);
    }
    return 0;
}

Measured memory_bytes: 760
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int n;
	cin >> n;
	vector<P> A(n);
	Rep(i, n) {
		cin >> A[i].first >> A[i].second;
	}
	Sort(A);
	Rep(i, n) {
		cout << A[i].first << " " << A[i].second << endl;
	}
	return 0;
}


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

template <class T> void chmin(T &x, T y)
{
    if(x>y) x=y;
}

main()
{
    int n,m; cin>>n>>m;
    bool yet[1<<17];
    int re[1<<17]={};
    fill(yet,yet+n+1,true);
    int ac=0;
    int pe=0;
    while(m--)
    {
        string s; int p; cin>>p>>s;
        if(!yet[p])
        {
            continue;
        }
        if(s=="AC")
        {
            yet[p]=0;
            pe+=re[p];
            ac++;
        }
        else
        {
            re[p]++;
        }
    }
    cout << ac << " " << pe << "\n";
}

Measured memory_bytes: 896
const main = arg => {
    arg = arg.trim().split("\n");
    const k = arg[0]
    const s = arg[1]
    if(s.length <= k) console.log(s)
    else console.log(s.slice(0, k) + '...')
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29488
from collections import defaultdict

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

# 1 -> 1+D ->
# 2 -> 2+D ->
# 3 -> 3+D -> みたいなものを事前に計算

# 辞書で管理する
# d[A[i][j]] = [i,j] みたいな感じ
d = defaultdict(list)
for i in range(H):
    for j in range(W):
        d[A[i][j]].append([i, j])


p = []
for s in range(1, D + 1):
    c = 0
    q = [0]
    for i in range(s + D, H * W + 1, D):
        i0, j0 = d[i - D][0]
        i1, j1 = d[i][0]
        c += abs(i0 - i1) + abs(j0 - j1)
        q.append(c)

    p.append(q)


for l, r in LR:
    i = l % D - 1
    s = (l - 1) // D
    e = (r - 1) // D
    print(p[i][e] - p[i][s])


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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ret = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i-1] == s[i]) {

		}
		else {
			++ret;
		}
	}

	cout << ret << endl;

	return 0;
}

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

int main()
{
	long long n, x, a[100010], cnt=0, sum;
	cin >> n >> x;
	for(int i = 0; i < n; i++)cin >>a[i];
	for(int i = 1; i < n; i++)
    {
        sum = a[i-1]+a[i];
        if(sum>x)
        {
            sum-=x;
            if(sum>a[i])a[i]=0, a[i-1]-=sum-a[i];
            else        a[i]-=sum;
            cnt+=sum;
        }
    }
    cout << cnt << endl;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    
    vector<vector<int>> vvi(N + 1);

    vector<int> P(M), Y(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        vvi[P[i]].push_back(Y[i]);
    }

    vector<map<int, int>> vm(N + 1);
    for (int i = 0; i < N + 1; i++) {
        sort(vvi[i].begin(), vvi[i].end());
        for (int j = 0; j < vvi[i].size(); j++) {
            vm[i][vvi[i][j]] = j + 1;
        }
    }

    for (int i = 0; i < M; i++) {
        printf("%06d%06d\n", P[i], vm[P[i]][Y[i]]);
    }

    return 0;
}


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

int fl(int a, int b) {
	if (!(a%b))return a / b;
	return a / b + 1;
}
int main() {
	int l, a, b, c, d; cin >> l >> a >> b >> c >> d;
	cout << l - max(fl(a, c), fl(b, d)) << endl;
	return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N;
ll MAX = 3500;

int main()
{
	scanf("%lld",&N);

	for(ll i = 1;i <= MAX;i++){
		for(ll j = 1;j <= MAX;j++){
			if(N * i * j == 0 || 4 * i * j - N * i - N * j == 0){
				continue;
			}
			else if((N * i * j) % (4 * i * j - N * i - N * j) == 0 && N * i * j / (4 * i * j - N * i - N * j) > 0){
				printf("%lld %lld %lld\n",i,j,(N * i * j) / (4 * i * j - N * i - N * j));
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
a,b,c,k=[int(x) for x in input().split()]
count=0
if a>=k:
  count+=k
  print(count)
else:
  count+=a
  k-=a
  if b>=k:
    print(count)
  else:
    k-=b
    count-=k
    print(count)
  

Measured memory_bytes: 9176
#include<iostream>
#include<queue>

using namespace std;

struct process{
  string name;
  int time;
};

int main(){
  int n, q, overall_time = 0;
  cin >> n >> q;
  queue<process> S;
  process temp;
  for(int i = 0; i < n; i++){
    cin >> temp.name >> temp.time;
    S.push(temp);
  }
  while(!S.empty()){
    temp = S.front();
    S.pop();
      if(temp.time <= q){
        overall_time += temp.time;
        cout << temp.name << " " << overall_time << endl;
      }else{
        overall_time += q;
        temp.time -= q;
        S.push(temp);
      }
  }
  return 0;
}

Measured memory_bytes: 4404
a,b,c=(int(x) for x in input().split())
k=int(input())
flag=True
for i in range(k+1):
    if a<2**(k-i)*b and 2**(k-i)*b<2**i*c:
        print("Yes")
        exit()
        flag=False
        break
if flag:
    print("No")

Measured memory_bytes: 8948
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>

using namespace std;
struct point{
  int x;
  int y;
};

int main(void){
  int H,W,D;
  cin>>H>>W>>D;
  int L,R,Q;
  int data;
  point pt[H*W+1];
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin>>data;
      pt[data]={i,j};
    }
  }
  int d[H*W+1]={0};
  for (int i=D+1;i<H*W+1;i++){
    d[i]=d[i-D]+abs(pt[i].x-pt[i-D].x)+abs(pt[i].y-pt[i-D].y);
  }
  cin>>Q;
  for (int i=0;i<Q;i++){
    int MP=0;
    cin>>L>>R;
    MP=d[R]-d[L];
    cout<<MP<<endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 100005;
int a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a+n); reverse(a, a+n);
  for (int i = 0; i < n; i++) b[min(a[i], n)-1]++;
  for (int i = n-1; i >= 0; i--) b[i] += b[i+1];
  int m = 0;
  while (a[m] > m) ++m;
  // case 1: even & even
  if ((a[m-1]-m)%2 == 0 && (b[m-1]-m)%2 == 0) {
    puts("Second");
    return 0;
  }
  // case 2: else
  puts("First");
  return 0;
}



Measured memory_bytes: 896
#include <stdio.h>

int main(){
	int n;
	int p[30];
	int count=0;

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(int i=1;i<n-1;i++){
		if(p[i-1]<p[i]&&p[i+1]>p[i]){
			count++;
		}else if(p[i-1]>p[i]&&p[i+1]<p[i]){
			count++;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define     LL              long long int
#define     FOR(I,A,B)      for( int I = A; I < B; ++I )
#define     SFI(X)          scanf("%d",&X)
#define     SFL(X)          scanf("%lld",&X)


int main() {

//    SAT, SUN, MON, TUE, WED, THU, FRI
//    1     2    3    4    5    6    7

    string S;

    cin >> S;

    if(S == "MON") {
            printf("6\n");
    } else if(S == "TUE") {
                printf("5\n");
    } else if(S == "WED") {
                printf("4\n");
    } else if(S == "THU") {
                printf("3\n");
    } else if(S == "FRI") {
                printf("2\n");
    } else if(S == "SAT") {
        printf("1\n");
    }else {
        printf("7\n");
    }
    
    return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	double A,B,C;
    	A = Double.parseDouble(in.next());
    	B = Double.parseDouble(in.next());
    	C = Double.parseDouble(in.next());
    	
    	double ans = B/A;
    	
    	if (C > ans) {
    		System.out.println((int)ans);
    	} else {
    		System.out.println((int)C);
    	}
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define pii pair<long double, long double>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const ll oo = 1 << 31;

int main(void){
    int n;
    double fat = 0.0, ans = 0.0;
    cin >> n;

    vector<pair<double, double>> v(n);
    
    for (int i=0; i<n; i++){
        cin >>  v[i].ff >> v[i].ss;
    }
    sort(all(v));

    do{
        fat = fat+1.0;

        for (int i=1;i<n; i++){
            ans+=hypot(v[i].ff - v[i-1].ff, v[i].ss - v[i-1].ss);
        }
    }while(next_permutation(all(v)));
    
    cout << fixed << setprecision(10) << ans/fat << endl;
return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

signed main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<int> b(n + 1);

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

  vector<int> ans;

  for (int i = n; i > 0; i--) {
    int t = 0;
    for (int j = i; j <= n; j += i) {
      t += b[j];
    }

    if (a[i] != (t % 2)) {
      b[i] = 1;
      ans.push_back(i);
    }
  }

  cout << ans.size() << endl;
  for (auto& x : ans) {
    cout << x << " ";
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 4980
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
 int a,b,c,ans =0;
  int n,group=0;
  scanf("%d", &n);
  for(b=1;b<=n;b++){
    //group=(n-n%b)/b;
    group=(n-1)/b;
    ans += group;
    //ans += (b-1)*group;
    //if(n%b==1) ans+=n%b;
  }
  printf("%d", ans);
  return 0;

      

}
  

Measured memory_bytes: 1736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long a[N];
	f(i, N)a[i] = 0;
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld %lld", &n, &k);
	if (n == 1) {
		printf("1\n");
		return 0;
	}
	ans = n;
	f(i, 60) {
		x = i + 2;
		s = i + 2;
		while (true) {
			z = 1;
			f(ii, x) {
				y = (s + ii) / x;
				z *= y;
			}
			if (z >= n)break;
			s++;
		}
		s += ((i + 1)*k);
		ans = min(ans, s);
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 128
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) {
	return ist >> right.first >> right.second;
}
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) {
	return ost << right.first << ' ' << right.second;
}

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N, M, R;
int W[8];
int A[21000], B[21000], C[21000];
int Q[200][200];
int main() {
	cin >> N >> M >> R;
	REP(i, 0, R) {
		cin >> W[i];
		--W[i];
	}
	REP(i, 0, N) {
		REP(j, 0, N) {
			Q[i][j] = INF;
		}
	}


	REP(i, 0, M) {
		cin >> A[i] >> B[i] >> C[i];
		--A[i]; --B[i];
		Q[A[i]][B[i]] = C[i];
		Q[B[i]][A[i]] = C[i];
	}

	REP(k, 0, N) {
		REP(i, 0, N) {
			REP(j, 0, N) {
				Q[i][j] = min(Q[i][j], Q[i][k] + Q[k][j]);
			}
		}
	}
	sort(W, W + R);

	int mn = INF;
	do {
		int sum = 0;
		REP(i, 0, R - 1) {
			sum += Q[W[i]][W[i + 1]];
		}
		mn = min(mn, sum);
	} while (next_permutation(W, W + R));
	
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 640
import 'dart:io';

void main() {
  int n = int.parse(stdin.readLineSync());
  List aList =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int oddNum = 0;
  for (int i = 0; i < n; i++) {
    if (aList[i] % 2 == 1) oddNum++;
  }

  if (oddNum % 2 == 0) {
    print("YES");
  } else {
    print("NO");
  }
}

Measured memory_bytes: 30676
import os, sys, re, math

N = int(input())
A = [int(n) for n in input().split()]

ta = [(A[i], i + 1) for i in range(N)]
sa = sorted(ta, key=lambda k: k[0])

result = ''
for s in sa:
    result += '%s ' % s[1]
print(result.strip())


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::cout << 1.0 * ((N + 1) / 2) / N << '\n';
}


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

int main(){
    int x;
    cin>>x;
    if(x<600) cout<<"8"<<endl;
    else if(x<800) cout<<"7"<<endl;
    else if(x<1000) cout<<"6"<<endl;
    else if(x<1200) cout<<"5"<<endl;
    else if(x<1400) cout<<"4"<<endl;
    else if(x<1600) cout<<"3"<<endl;
    else if(x<1800) cout<<"2"<<endl;
    else if(x<2000) cout<<"1"<<endl;
    
}


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

using namespace std;
#define int long long

const int MAXN = 98;

char ans[MAXN][MAXN];

signed main() {
    ios_base::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;

    swap(a, b);

    int have1 = 1;
    int have2 = 1;
    int mid = MAXN / 2;
    for (int i = 0; i < mid; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            if (i % 2 && j % 2) {
                ans[i][j] = '#';
                ++have1;
            }
            else ans[i][j] = '.';        
        }
    }
    for (int i = mid; i < MAXN; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            if (i % 2 == 0 && j % 2) {
                ans[i][j] = '.';
                ++have2;
            }
            else ans[i][j] = '#';
        }
    }

    int r1 = have1 - a;
    for (int i = 0; i < mid; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            if (i % 2 && j % 2 && r1) {
                ans[i][j] = '.';
                --r1; 
            }   
        }
    }
    int r2 = have2 - b;
    for (int i = mid; i < MAXN; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            if (i % 2 == 0 && j % 2 && r2) {
                ans[i][j] = '#';
                --r2;
            }
        }
    }
    cout << MAXN << ' ' << MAXN << '\n';

    for (int i = 0; i < MAXN; ++i) {
        for (int j = 0; j < MAXN; ++j) {
            cout << ans[i][j];
        }
        cout << '\n';
    }

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

int A, B;

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

    std::cin >> A >> B;

    if(13 <= A) {
        std::cout << B << std::endl;
    }
    else if(6 <= A && A < 13) {
        std::cout << B / 2 << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] t = new int[n];

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

    int m = sc.nextInt();
    int[] p = new int[m];
    int[] x = new int[m];

    for (int i = 0; i < m; i++) {
      p[i] = sc.nextInt();
      x[i] = sc.nextInt();
    }

    for (int i = 0; i < m; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        if (p[i]-1 == j) {
          sum += x[i];
          // System.out.println("drink   "+sum);
          continue;
        }
        sum += t[j];
      }
      System.out.println(sum);
    }

  }

}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N) cin >> A[i + 1];
    ll sum = 0;
    repi2(i, 1, N) {
        ll temp = max(0LL, A[i - 1] - A[i]);
        sum += temp;
        A[i] += temp;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll n;
	cin>>n;
	ll arr[n];
	for (ll i=0;i<n;i++) {
		cin>>arr[i];
	}
	for (ll i=0;i<n-1;i++) {
		cout<<arr[n-i-1]<<' ';
	}
	cout<<arr[0]<<endl;
}




Measured memory_bytes: 3092
function gcd( x, y )
{
  if( 0 == y ) {
    return x;
  } else {
    return gcd( y, x%y );
  }
}

var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  var nums =  chunk.split( ' ' ).map( Number );
  console.log( gcd( Math.max( nums[0], nums[1] ), Math.min( nums[0], nums[1] ) ) );
});

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	vector<ll> B(N, 0);
	priority_queue<ll, vector<ll>, greater<ll>> A;
	priority_queue<ll> C;
	ll SSA=0;
	ll SSC=0;
	Rep0(i, N) {
		ll a;
		cin >>a;
		SSA +=a;
		A.push(a);
	}
	Rep0(i, N)
		cin >>B.at(i);
	Rep0(i, N) {
		ll a;
		cin >>a;
		SSC +=a;
		C.push(a);
	}
	vector<ll> SA(N+1, 0);
	vector<ll> SC(N+1, 0);
	SA.at(0)=SSA;
	Rep0(i, N) {
		SSA+=B.at(i);
		A.push(B.at(i));
		SSA-=A.top();
		A.pop();
		SA.at(i+1)=SSA;
	}
	SC.at(N)=SSC;
	for (int i=N-1; i>=0; i--) {
		SSC+=B.at(i);
		C.push(B.at(i));
		SSC-=C.top();
		C.pop();
		SC.at(i)=SSC;
	}
	ll S=-100000;
	S*=1000000001;
	Rep0(i, N+1)
		S=max(S, SA.at(i)-SC.at(i));
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define SIZE 200005

int a[SIZE],
loop[SIZE],//An array that contains the loop from town 1 to the loop
dp[SIZE] ;//An array of judgments as to whether each town has appeared. It does not come with 0 (false).

int main() {
	long long k;
	int n,
		town = 1,//The first is in town 1
		start = 0,//Index of the loop contents at the start of the loop
		length = 0,//Length of array loop
		loop_length = 0;//Actual loop length
	//input
	cin>>n>>k;
	for (int i = 0; i < n; i++) cin>>a[i];

	//Create an array loop by processing from here
	//If you come to a town you've been to at least once
	//Array dp should be 1 (true)
	//(! dp [town-1]) becomes false
	int i = 0;
	while(!dp[town -1]) {
		dp[town-1] = 1;
		//Set the current town of array dp to 1 (true)
		loop[i] = town;
		//cout<<town<<endl;
		//Teleport
		town = a[town-1];
		//Recorded because the length used by the array loop changes
		length++;
		i++;
	}

	//Find out where in the array loop the loop starts and find out the actual loop size
	for (int i = 0; i < length; i++) {
		//If town (which can guarantee the beginning of the loop) and array loop are the same
		if (town == loop[i]) {
			//Record the actual loop size
			loop_length = length - i;
			//Record the index of the place before entering the loop
			//cout<<loop_length<<endl;
			start = i;
			//Stop the loop
			//cout<<start<<endl;
			break;
		}
	}
	//If k is smaller than the size of the array loop,
	//Unconditionally output loop [k]
	if (k < length) {
		cout<<loop[k]<<endl;
	}
	else {

		//Otherwise subtract from k before entering the actual loop
		//Then, tell how many times you want to loop and then move
		//The "how much you move after that" is
		//Since it is a subscript of the array loop after removing the part before entering the loop,
		//I will add before I enter the loop properly
		cout<<loop[(k -start) % loop_length +start]<<endl;
	}
}



Measured memory_bytes: 5860
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define MAXN 10010
#define MAXM 40010

int n,m;
struct node
{
    int v,d,c,next;
}e[MAXM];
int ecnt,pre[MAXN],dis[MAXN],co[MAXN];
bool vis[MAXN];
void add(int u,int v,int d,int c)
{
    e[ecnt].v=v;
    e[ecnt].d=d;
    e[ecnt].c=c;
    e[ecnt].next=pre[u];
    pre[u]=ecnt++;
}
void spfa()
{
    queue<int> q;
    q.push(1);
    memset(vis,0,sizeof(vis));
    memset(dis,0x3f,sizeof(dis));
    memset(co,0x3f,sizeof(co));
    dis[1]=co[1]=0;
    while (!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for (int i=pre[u];i!=-1;i=e[i].next)
        {
            int v=e[i].v;
            if ((dis[v]>dis[u]+e[i].d)||(dis[v]==dis[u]+e[i].d&&co[v]>e[i].c))
            {
                dis[v]=dis[u]+e[i].d;
                co[v]=e[i].c;
                if (!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    //freopen("/home/moor/Code/input","r",stdin);
    while (scanf("%d%d",&n,&m)&&n+m)
    {
        ecnt=0;
        memset(pre,-1,sizeof(pre));
        int u,v,d,c;
        for (int i=0;i<m;i++)
        {
            scanf("%d%d%d%d",&u,&v,&d,&c);
            add(u,v,d,c);
            add(v,u,d,c);
        }
        spfa();
        int ans=0;
        for (int i=2;i<=n;i++)
            ans+=co[i];
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1832
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.h"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	string str;
	cin >> n >> str;
	auto a = str.substr(0, n / 2);
	auto b = str.substr(n / 2, n / 2);
	if (n & 1) {
		cout << "No" << endl;
		return 0;
	}
	dump(a,b);
	cout << ((a == b) ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
h,w=map(int,input().split())
if h%3==0 or w%3==0:print(0)
else:
    l=(h+1)//3
    b=(w+1)//3
    ans=min(w*abs(l-(h-2*l)),h*abs(b-(w-2*b)))
    for x in range(1,w):
        half=h//2
        rest=h-h//2
        sub=max(x*half,x*rest,(w-x)*h)-min(x*half,x*rest,(w-x)*h)
        ans=min(ans,sub)

    for y in range(1,h):
        half=w//2
        rest=w-w//2
        sub=max(y*half,y*rest,(h-y)*w)-min(y*half,y*rest,(h-y)*w)
        ans=min(ans,sub)
    print(ans)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    long long H, W, t;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
    }
    else {
        t = H * W;
        cout << (t % 2 == 1 ? t / 2 + 1 : t / 2) << endl;
    }
}

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

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

  int x[3], max;
  x[0] = a + b;
  x[1] = a - b;
  x[2] = a * b;
  max = x[0];
  for(int i = 0; i < 2; i++){
    if(max < x[i+1]){
      max = x[i+1];
    }
  }

  cout << max ;

}


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

int main() {
    int d, l;
    cin >> d >> l;
    int t = d - (d / l) * l;
    int ans = t + (d / l);
    cout << ans << endl;
}


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

vector<int> tree[100010];
vector<int> gtree[100010];

int ans[100010] = {};
int deep[100010] = {};

int dfs(int idx){
  if(tree[idx].size() == 0){
    deep[idx] = 1;
    return 1;
  }

  int dmax = 0;
  for(int i = 0;i < tree[idx].size();i++){
    if(deep[tree[idx][i]] == 0) dfs(tree[idx][i]);
    dmax = max(dmax, deep[tree[idx][i]]);
  }

  deep[idx] = dmax+1;

  for(int i = 0;i < tree[idx].size();i++){
    if(ans[tree[idx][i]] == 0){
      ans[tree[idx][i]] = idx+1;
    }
  }

  return dmax+1;
}



int main(){
  int n, m;
  cin >> n >> m;

  int a, b;
  for(int i = 0;i < n-1+m;i++){
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    gtree[b].push_back(a);
  }

  int root = 0;
  while(!gtree[root].empty()) root = gtree[root][0];

  ans[root] = 0;

  dfs(root);

  for(int i = 0;i < n;i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 18816
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N

S = input()
count = 0
flag = 0
for i in range(len(S)):
    count = 0
    for j in range(len(S)):
        if S[i] == S[j]:
            count += 1

    if count > 1:
        flag = 1
        break

if flag == 1:
    print('no')
else:
    print('yes')


Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

typedef pair<pair<double,double>,double> data;

template<class T> inline T dbl(T a){ return a * a; }

inline double dist(const data &a, const data &b){
  return sqrt(dbl(a.f.f - b.f.f) + dbl(a.f.s - b.f.s)) - (a.s + b.s);
}


int main(){
  int n;
  while(scanf("%d",&n), n){
    vector<data> v(n);

    REP(i,n)
      scanf("%lf%lf%lf", &v[i].s, &v[i].f.f, &v[i].f.s);

    double a1 = 0.0; REP(i,n) a1 += v[i].f.f; a1 /= n;
    double a2 = 0.0; REP(i,n) a2 += v[i].f.s; a2 /= n;

    double b1 = 0.0; REP(i,n) b1 += dbl(v[i].f.f - a1); b1 /= n;
    double b2 = 0.0; REP(i,n) b2 += dbl(v[i].f.s - a2); b2 /= n;

    if(b1 < b2) REP(i,n) swap(v[i].f.f, v[i].f.s);

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

    double ans = 1e20;

    double r  = 0.0; REP(i,n) r = max(r, v[i].s); r *= 2;


    for(int i = 0; i < n; i++){
      double x1 = v[i].f.f;
      for(int j = i + 1; j < n; j++){
	double x2 = v[j].f.f;

	if((x2 - x1 - r) > ans) break;

	ans = min(ans, dist(v[i], v[j]));
      }
    }
    
    printf("%.6f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    REP(i, N) { cin >> T[i]; }
    int M;
    cin >> M;
    vector<int> P(M);
    vector<int> X(M);
    REP(i, M) { cin >> P[i] >> X[i]; }
    ll s = accumulate(T.begin(), T.end(), 0LL);
    REP(i, M) { cout << s - T[P[i] - 1] + X[i] << endl; }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
  }
  int mn = 2e9;
  ll sum = 0;
  for(int i = 1; i <= n; ++i) {
    sum += b[i];
    if(a[i] > b[i]) mn = min(mn, b[i]);
  }
  if(mn == 2e9) printf("0\n");
  else printf("%lld\n", sum - mn);
  return 0;
}

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

int main(){	
	int n, x;
	cin >> n >> x;

	while (n != 0 || x != 0) {
		int i, j, k;
		int o = 0;

		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if(i + j + k == x) o++;
				}
			}
		}
		cout << o << endl;

		cin >> n >> x;
	}
	return 0;
}


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

using namespace std;
long long qq[100005];
int main(){
	int A,B,Q;
	cin >> A >> B >> Q;	
	vector<pair<long long, int> > chua,den;
	for (int i=0;i<A;i++){
		long long x;
		cin >> x;
		chua.push_back({x,0});
	}
	for (int i=0;i<B;i++){
		long long x;
		cin >> x;
		den.push_back({x,0});
	}
	map <long long,long long> m,md,m1,md1;
	for (int i=0;i<Q;i++){
		long long x;
		cin >> x;
		qq[i]=x;
		if (m[x]==0){
			chua.push_back({x,1});
			den.push_back({x,1});	
		}
		m[x] = 100000000000LL;
		md[x] = 100000000000LL;
		m1[x] = 100000000000LL;
		md1[x] = 100000000000LL;
	}
	
	sort(chua.begin(), chua.end()); 
	sort(den.begin(), den.end()); 
	long long f = -100000000000LL;
	for (int i=0;i<chua.size(); i++){
		if (chua[i].second==1){
			long long ds = abs(chua[i].first-f);
			if (m[chua[i].first]>ds) m[chua[i].first]=ds;
			if  (m[den[i].first]==0) m1[den[i].first]=0;
		} else
			f = chua[i].first;
	}
	
	f = 100000000000LL;
	for (int i=chua.size()-1;i>=0; i--){
		if (chua[i].second==1){
			long long ds = abs(chua[i].first-f);
			if (m1[chua[i].first]>ds) m1[chua[i].first]=ds;
			if  (m1[den[i].first]==0) m[den[i].first]=0;
		} else
			f = chua[i].first;
	}
	
	f = -100000000000LL;
	for (int i=0;i<den.size(); i++){
		if (den[i].second==1){
			long long ds = abs(den[i].first-f);
			if (md[den[i].first]>ds) md[den[i].first]=ds;
			if  (md[den[i].first]==0) md1[den[i].first]=0;
		} else
			f = den[i].first;
	}
	
	f = 100000000000LL;
	for (int i=den.size()-1;i>=0; i--){
		if (den[i].second==1){
			long long ds = abs(den[i].first-f);
			if (md1[den[i].first]>ds) md1[den[i].first]=ds;
			if  (md1[den[i].first]==0) md[den[i].first]=0;
		} else
			f = den[i].first;
	}
	for (int i=0;i<Q;i++){
		long long mm1 = min(max(m[qq[i]],md[qq[i]]),max(m1[qq[i]],md1[qq[i]]));
		mm1 = min(mm1,2*min(m[qq[i]],m1[qq[i]])+min(md[qq[i]],md1[qq[i]]));
		mm1 = min(mm1,min(m[qq[i]],m1[qq[i]])+2*min(md[qq[i]],md1[qq[i]]));
		cout<<mm1 << endl;
	}	
}

Measured memory_bytes: 40040
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

int a, b, c;

int main() {
	cin >> a >> b >> c;
	swap(a, b), swap(a, c);
	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=inf,sum=0,num=0;
	cin >> n;
	int w[n+1];

	rep(i,n){
		cin >> w[i];
		sum += w[i];
	}

	int i = 0;
	while(abs(sum-num)<ans){
		ans=abs(sum-num);
		sum -= w[i];
		num += w[i];
		i++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
    };

    let mut res = 0;

    res += a * (n / (a + b));

    let x = n % (a + b);
    if x < a {
        res += x;
    } else {
        res += a;
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    cin >> s;
    for(int i = 0 ; i < 3; i++){
        if(s[i] == '1'){
            cout << '9';
        }
        else if(s[i] == '9'){
            cout << '1';
        }
        else
        {
            cout << s[i];
        }
        
    }
    cout << endl;
}


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

using namespace std;

int main(){
    int n, a, b;
    cin >> n;
    int ra = 1 << 29;
    int rb = -100;
    for(int i = 0;i < n;i++){
	cin >> a >> b;
	if(rb < b || rb == b && ra > a){
	    ra = a;
	    rb = b;
	}
    }
    cout << ra << " " << rb << endl;
    return 0;
}

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

#define ar array
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define vt vector 
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
  
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
template<class T> bool umin(T& a, const T& b) {
	return b<a?a=b, 1:0;
}
template<class T> bool umax(T& a, const T& b) { 
	return a<b?a=b, 1:0;
} 
 
 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b?"true":"false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vt<bool> v) {
	string res;
	FOR(sz(v))
		res+=char('0'+v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	FOR(S)
		res+=char('0'+b[i]);
	return res;
}
template<class T> string to_string(T v) {
    bool f=1;
    string res;
    EACH(x, v) {
		if(!f)
			res+=' ';
		f=0;
		res+=to_string(x);
	}
    return res;
}
 
template<class A> void write(A x) {
	cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) { 
	write(h);
	write(t...);
}
void print() {
	write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) { 
	write(h);
	if(sizeof...(t))
		write(' ');
	print(t...);
}
 
void DBG() {
	cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const ll LLINF = 1e18 + 10;

void solve()
{
    int n = 4;
    vt <ll> vec(n);
    read(vec);
    ll ans =-LLINF;
    FOR(i,0,2){
        FOR(j,2,n){
            ll curr = (vec[i] * vec[j]);
            DBG(vec[i], vec[j], curr);
            umax(ans,curr);
        }
    }
    print(ans);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int t=1;
	//read(t);
	FOR(t) {
		//write("Case #", i+1, ": ");
		solve();
	}
}




Measured memory_bytes: 3644