akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 200010;
VI e[N];
int dist[N];

void dfs(int now, int past){
    for (int next : e[now]){
        if (next == past) continue;
        if (dist[now] == 1) dist[next] = 2;
        else dist[next] = 1;
        dfs(next, now);
    }
}

int main(void){
    int n;
    cin >> n;
    VI cnt(3);
    FOR(x,1,n) cnt[x % 3]++;
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dist[0] = 1;
    dfs(0, -1);
    VI c(3), a(n);
    REP(i,n){
        a[i] = dist[i];
        c[dist[i]]++;
    }
    if (c[1] >= cnt[1] && c[2] >= cnt[2]){
        REP(i,n){
            if (c[a[i]] > cnt[a[i]]){
                c[a[i]]--;
                a[i] = 0;
            }
        }
    } else if (c[1] < cnt[1]){
        REP(i,n){
            if (a[i] == 1){
                a[i] = 0;
            }
        }
        c[0] = c[1];
        c[1] = 0;
        REP(i,n){
            if (a[i] != 2) continue;
            if (c[0] < cnt[0]){
                a[i] = 0;
                c[0]++;
            }else if (c[1] < cnt[1]){
                a[i] = 1;
                c[1]++;
            }
        }
    } else if (c[2] < cnt[2]){
        REP(i,n){
            if (a[i] == 2){
                a[i] = 0;
            }
        }
        c[0] = c[2];
        c[2] = 0;
        REP(i,n){
            if (a[i] != 1) continue;
            if (c[0] < cnt[0]){
                a[i] = 0;
                c[0]++;
            }else if (c[2] < cnt[2]){
                a[i] = 2;
                c[2]++;
            }
        }
    }
    VI idx({3, 1, 2}), ans(n);
    REP(i,n){
        ans[i] = idx[a[i]];
        idx[a[i]] += 3;
    }
    REP(i,n) printf("%d ", ans[i]);
    cout << endl;

    return 0;
}


Measured memory_bytes: 19584
import java.awt.Point;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static int n;
	static int wayn;
	static int railn;
	static int[] ar;
	static int[] br;
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		ar = new int[n+1];
		br = new int[n+1];
		wayn = sc.nextInt();
		railn = sc.nextInt();
		for(int i = 0; i <= n; i++) {
			ar[i] = i;
			br[i] = i;
		}
		for(int i = 0; i < wayn; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			unite(a, b);
		}
		for(int i = 0; i < railn; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			bunite(a, b);
		}
		HashMap<Point, Integer> map = new HashMap<>();
		for(int i = 1; i <= n; i++) {
			Point p = new Point(root(i),broot(i));
			if(map.containsKey(p)) {
				map.put(p, map.get(p)+1);
			} else {
				map.put(p, 1);
			}
		}
		for(int i = 1; i <= n; i++) {
			System.out.println(map.get(new Point(root(i),broot(i))));
		}
	}
	static int root(int x) {
		if(ar[x]==x) {
			return x;
		} else {
			return ar[x] = root(ar[x]);
		}
	}
	static boolean same(int x, int y) {
		return root(x)==root(y);
	}
	static void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if(x == y) return;
		ar[x] = y;
	}

	static int broot(int x) {
		if(br[x]==x) {
			return x;
		} else {
			return br[x] = broot(br[x]);
		}
	}
	static boolean bsame(int x, int y) {
		return broot(x)==broot(y);
	}
	static void bunite(int x, int y) {
		x = broot(x);
		y = broot(y);
		if(x == y) return;
		br[x] = y;
	}
}

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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    int x = 0;
    while (ans<n && x!=1) {
        x = a[x];
        ans++;
    }
    if (ans==n) ans = -1;
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (s - i - j >= 0 && s - i - j <= k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <climits>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF = LLONG_MAX;
const ll MAX_N = 100000;

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


int main() {
	ll n, a[100002]{},all=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++) {
		all += abs(a[i + 1] - a[i]);
	}
	for (int i = 1; i <= n; i++) {
		ll ans;
		ans = all - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int A, B;

int main()
{
    cin >> A >> B;
    rep(i, 1, 101000)
    {
        int a = i * 0.08;
        int b = i * 0.1;
        if (a == A && b == B)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

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

signed main() {
    int n;
    cin >> n;

    int ans = 1;
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        ans = lcm(ans, t);
    }

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


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		char[] c = s.toCharArray();

		Arrays.sort(c);

		char min = 97;
		for (int i = 0; i < s.length(); i++) {
			if ((int)c[i] == min) min++;
		}

		if (min == '{') {
			System.out.println("None");
		} else {
			System.out.println(min);
		}

		sc.close();
	}

}


Measured memory_bytes: 24788
function solve()
    N = parse(Int64, readline())
    S = [chomp(readline()) for s in 1:N]
  
	numMARCH = [0, 0, 0, 0, 0]
    MARCH = ["M", "A", "R", "C", "H"]
  
  	for name in S
        for (i, m) in enumerate(MARCH)
            if name[1] == m[1]
                numMARCH[i] += 1
            end
        end
    end

    nonzero = numMARCH[numMARCH .!= 0]
    if length(nonzero) < 3
        println(0)
        return
    end

  	combinations::Int64 = 0
    for i in 1:length(nonzero)
    	for j in i+1:length(nonzero)
            for k in j+1:length(nonzero)
                combinations += nonzero[i]*nonzero[j]*nonzero[k]
            end
        end
    end
    println(combinations)
    
end

solve()

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string s;
    while (n != 0) {
        int rem = n % (-2);
        n = n / (-2);
        if (rem < 0) {
            rem = rem + 2;
            n = n + 1;
        }
        s.push_back('0' + rem);
    }
    reverse(s.begin(), s.end());
  	if(s.empty())
      s.push_back('0');
    cout << s << endl;
}


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

int H, W;
string maze[1005];
int dp[1005][1005];
const int inf = 1 << 30;

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

int main(void){
    cin >> H >> W;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;
    for (int i=0; i<H; i++) cin >> maze[i];
    
    for (int i=0; i<H; i++) for(int j=0; j<W; j++) dp[i][j] = inf;
    
    queue<pair<int, int>> q;
    queue<pair<int, int>> q2;
    q.push({sx, sy});
    dp[sx][sy] = 0;
    int cnt = 0;
    
    while(!q.empty()){
        while(!q.empty()){
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            if(x == gx && y == gy){
                cout << cnt << endl;
                return 0;
            }
            if(maze[x][y] == '#')continue;
            
            maze[x][y] = '#';
            // ４近傍
            for (int k=0; k<4; k++){
                int nx = x + dx[k];
                int ny = y + dy[k];
                
                if(0<=nx && nx < H && 0<=ny && ny<W){
                    if(maze[nx][ny] == '.'){
                        q.push({nx, ny});
                    }
                }
                
            }
            
            for (int i=-2; i<3; i++){
                for (int j=-2; j<3; j++){
                    int nx = x + i;
                    int ny = y + j;
                    if(0<=nx && nx < H && 0<=ny && ny<W){
                        if(maze[nx][ny] == '.'){
                            q2.push({nx, ny});
                        }
                    }
                }
            }
        }
        swap(q, q2);
        cnt++;
    }
    // for(int i=0; i<H; i++){
    //     for (int j=0; j<W; j++){
    //       cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if(dp[gx][gy] != inf)cout << dp[gx][gy] << endl;
    else cout << -1 << endl;
}   


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

typedef pair<string, int> PAIR;

void fnInput(int &a_riMaxProc, int &a_riQuantum, queue<PAIR> &a_rqPProcess)
{
  cin >> a_riMaxProc >> a_riQuantum;
  
  for (int i = 0; i < a_riMaxProc; i++)
  {
    string sProcName;
    int iProcTime;
    cin >> sProcName >> iProcTime;
    a_rqPProcess.push(PAIR(sProcName, iProcTime));
  }
}

void fnSchedule(int a_iQuantum, queue<PAIR> &a_rqPProcess)
{
  int iTotalTime = 0;
  while (a_rqPProcess.size())
  {
    PAIR PProcess = a_rqPProcess.front(); a_rqPProcess.pop(); 
    if (PProcess.second > a_iQuantum)
    {
      PProcess.second -= a_iQuantum;
      a_rqPProcess.push(PProcess);
      iTotalTime += a_iQuantum;
    }
    else
    {
      iTotalTime += PProcess.second;
      cout << PProcess.first << " " << iTotalTime << endl;
    }
  }
}

int main()
{
  int iMaxProc, iQuantum;
  queue<PAIR> qPProcess;
  
  fnInput(iMaxProc, iQuantum, qPProcess);
  fnSchedule(iQuantum, qPProcess);

  return 0;
}

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

#define ll long long
#define ar array
const int mxn=1e5+1;
ll n,m;
vector<ll>g[mxn];
vector<bool>used(mxn,false);
int ans=0;
void dfs(int u)
{
	used[u]=true;
	for(ll i:g[u])
		if(!used[i])
			dfs(i);
}
void solve(){
	cin>>n>>m;
	while(m--)
	{
		ll a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(ll i=1;i<=n;i++)
		if(!used[i])
	      dfs(i),++ans;
	cout<<ans-1;

}
int main(){
	solve();
}


Measured memory_bytes: 10272
import sys
from itertools import islice
from collections import deque
read = map(int, sys.stdin.read().split())

N = next(read)
A = [deque()] + [deque(islice(read, N - 1)) for _ in range(N)]
days = 1
available_players = deque(range(1, N + 1))
next_opponent = [0] * (N + 1)
played = set()

while available_players:
    player = available_players.popleft()
    if not A[player]:
        continue

    opponent = A[player].popleft()
    if next_opponent[opponent] == player:
        available_players.append(player)
        available_players.append(opponent)
        next_opponent[player] = 0
        next_opponent[opponent] = 0
        if player in played:
            days += 1
            played.clear()
        played.add(player)
        played.add(opponent)
    else:
        next_opponent[player] = opponent

if max(next_opponent) > 0:
    print(-1)
else:
    print(days)

Measured memory_bytes: 98672
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	char s[3][101]; rep(i, 3)cin >> s[i];
	int c[3] = { 0 };
	int ans = 0;
	for (;;) {
		switch(s[ans][c[ans]]) {
		case 'a':
			c[ans]++;
			ans = 0;
			break;
		case 'b':
			c[ans]++;
			ans = 1;
			break;
		case 'c':
			c[ans]++;
			ans = 2;
			break;
		case  '\0':
			if (ans == 0)cout << "A" << endl;
			else if (ans == 1)cout << "B" << endl;
			else cout << "C" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 9;
const int maxn = (int)1e5 + 5;
using namespace std;

map<ll, int> m;

int main()
{
	ll a, n, sum = 0, ans = 0;
	cin >> n;
	m[0] = 1;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
		ans += m[sum];
		m[sum]++;
	}
	cout << ans << endl;
}

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


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        if (!isKaibun(s)) {
            System.out.println("No");
            return;
        }

        String head = s.substring(0, (s.length() - 1) / 2);
        String tail = s.substring(((s.length() + 3) / 2) - 1, s.length());

        if (isKaibun(head) && isKaibun(tail)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

    private static boolean isKaibun(String s) {
        for (int i = 0; i < (s.length() / 2); i++) {
            char[] chars = s.toCharArray();
            if (chars[i] == chars[s.length() - 1 - i]) {
                continue;
            }
            return false;
        }
        return true;
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
const int N = 105;
long long n,x;
int main(){
	x = 100;
	cin >> n;
	int step = 0;
	while (x < n) {
		x *= 1.01;
		step++;
	}
	cout << step;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, sum[128][128], f[128][128];
	
	cin >> n;
	rep(i, n) rep(j, n)
	{
		cin >> f[i][j];
		sum[i+1][j] = sum[i][j] + f[i][j];
	}
	
	int ans = f[0][0];
	for (int si=0; si<n; si++)
	{
		for (int ti=si+1; ti<=n; ti++)
		{
			int l = 0, r = 0, s = 0;
			while (1 < n)
			{
				if (s < 0)
				{
					l = r;
					s = 0;
				} else if (r < n) {
					s += sum[ti][r] - sum[si][r];
					r++;
					ans = max(ans, s);
				} else {
					break;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1272
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  int n, r, minv=2000000000, maxv=-1000000000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>r;
    if(maxv<=r-minv) maxv=r-minv;
    if(minv>=r) minv=r;
  }
  cout<<maxv<<endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> D1(n), D2(n);
  for (ll i = 0; i < n; i++) {
    cin >> D1[i] >> D2[i];
  }
  ll cnt = 0;
  bool flag = false;
  for (ll i = 0; i < n; i++) {
    if (D1[i] == D2[i]) {
      cnt++;
      if (cnt >= 3) {
        flag = true;
      }
    } else {
      cnt = 0;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <numeric>
using namespace std;

int memo[1000010] = {0};
double pi = 3.14159265359;

int main(void){
    
    int n;
    cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];
    int m,all = accumulate(t.begin(),t.end(),0);
    cin >> m;
    for(int i = 0; i < m; i++){
        int p,x;
        cin >> p >> x;
        cout << all - (t[p-1] - x)  << endl;
    }

}


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

ll solve(vector<ll>& a, int n, bool posi){
	ll ans = 0, s = 0;
	for(int i=0;i<n;i++){
		s += a[i];
		if(posi){
			if(s <= 0){
				ans += -s + 1;
				s = 1;
			}
		}else{
			if(0 <= s){
				ans += s + 1;
				s = -1;
			}
		}
		posi = !posi;
	}
	return ans;
}

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

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

	ll ans = solve(a, n, true);
	ans = min(ans, solve(a, n, false));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

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

    vector<ll> score(1 << n, 0LL);
    for(int bit = 0; bit < (1 << n); ++bit){
        for(int i = 0; i < n; ++i){
            if(!((bit >> i) & 1))   continue;
            for(int j = i + 1; j < n; ++j){
                if(i == j)  continue;
                if((bit >> j) & 1)  score[bit] += a[i][j];
            }
        }
    }

    vector<ll> dp(1 << n);
    for(int bit = 0; bit < (1 << n); ++bit){
        dp[bit] = score[bit];
        int subset = (bit - 1) & bit;
        while(subset){
            chmax(dp[bit], dp[subset] + dp[bit ^ subset]);
            subset = (subset - 1) & bit;
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int now=0;
	int calc=0;
	char enzansi[4]="+";
	while(enzansi[0]!='=') {
		scanf("%d",&calc);
		switch(enzansi[0]) {
			case '+': now+=calc;break;
			case '-': now-=calc;break;
			case '*': now*=calc;break;
			case '/': if(calc==0)return 1;now/=calc;break;
			default: return 1;
		}
		scanf("%s",enzansi);
	}
	printf("%d\n",now);
	return 0;
}

Measured memory_bytes: 596
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int            long long int
#define ull            unsigned int
#define ld             long double
#define pb             push_back
#define pa             pair<int,int>
#define ppa            pair<pair<int,int>,int>
#define pap            pair<int,pair<int,int>>
#define v1d            vector<int>
#define v2d            vector<vector<int> >
#define vpa            vector<pair<int,int>>
#define M              1000000007
#define MN             LLONG_MIN
#define MX             LLONG_MAX
#define ff             first
#define ss             second
#define endl           "\n"
#define v1s            vector<string>
#define all(v)         v.begin(),v.end()
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
#define isEven(n)  (!n & 1);
const int MOD = 1e9 + 7;
// bool isEven(int n){
//     return (!(n & 1));
// }
// int popcount(int num){
//     num = num - ((num >> 1) & 0x55555555);
//     num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
//     return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
// }
// int powerOfTwo(int n){
//     return 1 << n;
// }

// int arr[1000001];
// bool temet = false;


void codeforce2(){
    int a[3]; cin>>a[0]>>a[1]>>a[2];
    swap(a[0], a[1]);
    swap(a[0], a[2]);
    cout << a[0] << " " << a[1] << " " << a[2] << endl; 

    return;
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    //codeChef();

    // T{
    //     codeforce2();
    // }
    codeforce2();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int e[128];
  int dp[2048][2048];
  int n,m,l;
  string s;
  while(1){
    cin >> m >> n;
    if(m==0) return 0;
    for(int i=0;i<n;i++){
      cin >> s;
      e[i]=0;
      l=s.length();
      for(int j=0;j<l;j++){
        if(s[l-j-1]=='1') e[i]+=(1<<j);
      }
    }
    for(int i=0;i<(1<<m);i++){
      for(int j=0;j<(1<<m);j++){
        dp[i][j]=0;
      }
    }
    for(int i=0;i<(1<<m);i++){
      map<int,int> mp;
      for(int j=0;j<n;j++){
        if(mp.find(i&e[j])==mp.end()) mp[i&e[j]]=1;
        else mp[i&e[j]]++;
      }
      for(auto it:mp){
        if(it.second>1){
          dp[i][it.first]=100;
        }
      }
    }
    for(int i=(1<<m)-1;i>=0;i--){
      for(int j=0;j<(1<<m);j++){
        if((i&j)==j){
          // cout << i SP j << endl;
          if(dp[i][j]==0) continue;
          for(int k=0;k<m;k++){
            if(!(i&(1<<k))){
              dp[i][j]=min(dp[i][j],max(dp[i|(1<<k)][j],dp[i|(1<<k)][j|(1<<k)])+1);
            }
          }
        }
        // cout << dp[i][j] << " ";
      }
      // cout << endl;
    }
    cout << dp[0][0] << endl;
  }
  return 0;
}



Measured memory_bytes: 19592
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int comp(int x, int y, int i, int j){
	if(x==i) return (y<j)-(y>j); else return (x<i)-(x>i);
}

int n;
int a[300000][2];
bool bs(int x, int y){
	int l=0, r=n-1;
	while(l<=r){
		int m=(l+r)/2;
		if(comp(x, y, a[m][0], a[m][1])>=0) r=m-1; else l=m+1;
	}
	return comp(x, y, a[l][0], a[l][1])==0;
}
int bx[300000][2], by[300000][2];
int cx[300000], cy[300000];
int main(void){
	int h=nextint();
	int w=nextint();
	n=nextint();
	for(int i=0; i<n; i++){
		int x=nextint()-1;
		int y=nextint()-1;
		a[i][0]=x; bx[x][1]++; cx[x]++;
		a[i][1]=y; by[y][1]++; cy[y]++;
	}
	for(int x=0; x<h; x++) bx[x][0]=x;
	for(int y=0; y<w; y++) by[y][0]=y;
	rsorta_d32(a, n, 2, 1);
	rsorta_d32(a, n, 2, 0);
	rsorta_d32(bx, h, 2, 1);
	rsorta_d32(by, w, 2, 1);
	int ans=0;
	for(int i=h-1; i>=0; i--){
		if(bx[i][1]!=bx[h-1][1]) break;
		for(int j=w-1; j>=0; j--){
			if(by[j][1]!=by[w-1][1]) break;
			int x=bx[i][0], y=by[j][0];
			int now=cx[x]+cy[y];
			if(bs(x, y)){
				now--;
				if(now>ans) ans=now;
			}else{
				if(now>ans) ans=now;
				break;
			}
		}
	}
	printf("%d\n", ans);
}


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

int main() {
  int n;
  cin >> n;
  if (n==3) {
    printf("2 5 63\n");
    return 0;
  }
  vector<int> res;
  int last = 0;
  for (int i = 0; i < n / 8; i++) {
    for (int loop = 0; loop < 2; loop++) {
      res.push_back(last += 2);
      res.push_back(++last);
      res.push_back(++last);
      res.push_back(last += 2);
    }
  }
  int rest = n - res.size();
  if (rest >= 2) res.push_back(last + 3), res.push_back(last + 9);
  if (rest >= 4) res.push_back(last + 2), res.push_back(last + 4);
  if (rest >= 6) res.push_back(last + 8), res.push_back(last + 10);
  if (rest & 1) res.push_back(last + 6);
  for (auto &x : res) printf("%d ", x);
  puts("");
  return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> A(N);
    ll sum = 0;
    ll tmp = 0;
    rep(i, N) {
        int a;
        cin >> A[i];
        A[i] -= (i + 1);
    }

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

    int b = (N % 2 == 0) ? A[N / 2 - 1] : A[(N + 1) / 2 - 1];

    ll ans = 0;
    rep(i, N) {
        ans += abs(A[i] - b);
    }

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

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n, p;
  cin >> n >> p;
  vector<ll> ans(2);
  ans[0] = 1;

  for (int i = 0; i < n; ++i) {
    vector<ll> next = ans;
    int a;
    cin >> a;
    a %= 2;
    for (int j = 0; j < 2; ++j) next[j ^ a] += ans[j];
    ans = next;
  }

  cout << ans[p] << endl;

  return 0;
}


Measured memory_bytes: 256
x,i,t;
a(x){
    if(x==2)return 1;
    if(x<2||x%2==0)return 0;
    for(i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}
main(){
    for(scanf("%d",&x);~scanf("%d",&x);t+=a(x));
    printf("%d\n",t);
}

Measured memory_bytes: 1824
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    X = Scanner.map_int()
    ans = INF
    for l in range(N - K + 1):
        r = l + K - 1
        if X[l] <= 0 and X[r] <= 0:
            ans = min(ans, abs(X[l]))
        elif X[l] >= 0 and X[r] >= 0:
            ans = min(ans, abs(X[r]))
        else:
            ans = min(ans, abs(X[l]) * 2 + abs(X[r]))
            ans = min(ans, abs(X[r]) * 2 + abs(X[l]))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84460
#! /usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, K, *A = map(int, read().split())

if K == N:
    ans = 1
    for a in A:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos = [a for a in A if a >= 0]
A_neg = [a for a in A if a < 0]

if len(A_pos) == 0:
    if K % 2 == 1:
        A_neg.sort(reverse=True)
    else:
        A_neg.sort()
    ans = 1
    for a in A_neg[:K]:
        ans = ans * a % MOD
    print(ans)
    sys.exit()

A_pos.sort()
A_neg.sort(reverse=True)
ans = 1
r = K
if r % 2 == 1:
    ans = ans * A_pos.pop() % MOD
    r -= 1

while r > 0:
    if len(A_pos) <= 1:
        ans = ans * A_neg.pop() * A_neg.pop() % MOD
    elif len(A_neg) <= 1:
        ans = ans * A_pos.pop() * A_pos.pop() % MOD

    else:
        acc_pos = A_pos[-1] * A_pos[-2]
        acc_neg = A_neg[-1] * A_neg[-2]

        if acc_pos > acc_neg:
            ans = ans * A_pos.pop() * A_pos.pop() % MOD
        else:
            ans = ans * A_neg.pop() * A_neg.pop() % MOD
    r -= 2
print(ans % MOD)


Measured memory_bytes: 27864
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const int MAX = 500005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n+1);
    vector<int> cnt(n+1, 0);
    rep(i, n+1) cin >> a[i], ++cnt[a[i]];

    int twice;
    int left=-1, right=-1;
    repr(i, 1, n+1) if(cnt[i]==2) twice = i;
    rep(i, n+1) if(a[i] == twice){
        if(left == -1) left = i;
        else right = i;
    }

    COMinit();
    repr(k, 1, n+2){
        ll ans = COM(n+1, k) - COM(n+left-right, k-1);
        chmod(ans);
        cout << ans << endl;
    }

}

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

int main()
{ int a,b,c;
  cin>>a>>b>>c;
  a^=b;
  b^=a;
  a^=b;
  a^=c;
  c^=a;
  a^=c;
  cout<<a<<" "<<b<<" "<<c;
  return 0;
}  

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int gcd(int a, int b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(){
	string o, e;
	cin >> o >> e;
	rep(i, o.size()){
		if(i == o.size() - 1 && e.size() < o.size()){
			cout << o[i];
		}else{
			cout << o[i] << e[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char s[100003];
	scanf("%s", s);
	
	int l, r;
	for (l = 0; s[l] != 0; l++) {
		if (s[l+1] == s[l]) {
			r = l + 1;
			break;
		} else if (s[l+2] == s[l]) {
			r = l + 2;
			break;
		}
	}
	
	if (s[l] != 0) printf("%d %d\n", l + 1, r + 1);
	else printf("-1 -1\n");
	fflush(stdout);
	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>;
const int MOD=1000000007;

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

  cout << n*n*n << endl;
}


Measured memory_bytes: 256
num_500 = int(input())
num_100 = int(input())
num_50 = int(input())
target = int(input())
count = 0
for i in range(0,num_500+1,1):
    if(500*i > target):
        break
    for j in range(0,num_100+1,1):
        if(500*i+100*j>target):
            break
        for k in range(0,num_50+1,1):
            if(500*i+100*j+50*k > target):
                break
            if(500*i+100*j+50*k == target):
                count += 1
                break
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var ans = ReadLong();
            for (int i = 1; i < N; i++)
            {
                var tmp = ReadLong();
                ans = Lcm(ans, tmp);
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static long Gcd(long a, long b) { if (b == 0) return a; return Gcd(b, a % b); }
        static long Lcm(long a, long b)
        {
            var gcd = Gcd(a, b);
            var tmpA = a / gcd;
            var tmpB = b / gcd;

            return tmpA * tmpB * gcd;
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a[3],ans=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[1]-a[0])%2==0){
        ans+=(a[1]-a[0])/2+a[2]-a[1];
    }
    else if((a[1]-a[0])%2!=0){
        ans+=(a[1]-a[0]-1)/2+a[2]-a[1]+2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
X ,Y = map(int,input().split())
if X > 50:
    print('No')
    exit(0)
for i in range(1, X+1):
    f = 2 * i + 4 * (X - i)
    if f == Y:
        print('Yes')
        break
else:
    ans = X * 4
    count = ans/4
    if count == X and ans==Y and Y%4 == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 61788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  LL n;
  cin >> n;

  LL ans = pow(n, 3);
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<pair<double,double>> p(N);
  rep(i,N){
    cin >> p[i].first >> p[i].second;
  }
  int N_=1;
  rep(i,N){
    N_ *= (i+1);
  }
  double sum=0;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      double l = sqrt((p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));
      sum += l;
    }
  }
  //cout << sum/N*2;
  cout << setprecision(20) << sum/N*2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
ll a,b,c,k;
int main() {
	read(a);read(b);read(c);read(k);
	ll ans=a-b; if (k&1) ans=-ans;cout<<ans;
	return 0;
}


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

using namespace std;
template <typename T> void print(T vec) {for(auto d: vec) cout<<d<<' ';cout<<'\n';}
template<typename T> void print2D(T mat) {for(auto vec:mat) print(vec);}


int n;
double probab(vector<double> & prob) {
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            if(j == 0) dp[i][j] = dp[i - 1][j] * ((double)1 - prob[i]);
            else dp[i][j] = dp[i - 1][j - 1] * prob[i] + dp[i - 1][j] *((double)1 - prob[i]);
        }
    }

    // print2D(dp);
    double ans = 0.0;
    for(int i = (n + 1)/ 2; i <= n; i++) {
        ans += dp[n][i];
    }
    return ans;

}


int main() {
    // int n;
    cin>>n;
    vector<double> A(n + 1);
    for(int i = 1; i <= n;i++) cin>>A[i];
    // cout<<setprecision (numeric_limits<double>::digits10 + 1)<<probab(A)<<'\n';
        cout<<setprecision (16)<<probab(A)<<'\n';

    return 0;
}

Measured memory_bytes: 70656
import java.util.*;
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;
class Main{
    static final int N = 101;
    static final long mod = 100000007;
    static long comb[][]=new long[N][N];
    static void precalc(){
	comb[0][0]=1;
	for(int i=1;i<N;i++){
	    comb[i][0]=comb[i][i]=1;
	    for(int j=1;j<i;j++){
		comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%mod;
	    }
	}
    }

    public static void main(String[] args){
	precalc();
	int n;
	Scanner scanner = new Scanner(System.in);
	while(true){
	    n = scanner.nextInt();
	    if (n == 0)break;
	    int next[] = new int[n];
	    BigDecimal p1[]=new BigDecimal[n],p2[]=new BigDecimal[n];
	    boolean vis[]=new boolean[n];
	    BigDecimal one=new BigDecimal(1);
	    BigDecimal eps=new BigDecimal(1e-19);
	    for(int i=0;i<n;i++){
		int tmp;
		p1[i]=scanner.nextBigDecimal();
		p1[i]=one.divide(p1[i],30,RoundingMode.HALF_EVEN);
		tmp=scanner.nextInt();
		p2[i]=scanner.nextBigDecimal();
		p2[i]=one.divide(p2[i],30,RoundingMode.HALF_EVEN);
		next[tmp]=i;
		vis[i]=false;
	    }

	    int all = n;
	    long ans = 1;
	    double exp=0;
	    BigDecimal bExp=new BigDecimal(0);
	    for(int k=0;k<n;k++){
		if (vis[k] == true)continue;
		int now = k;
		int in[]=new int[n];
		int ind=0;
		while(vis[now] == false){
		    vis[now]=true;
		    in[ind++]=now;
		    now=next[now];
		}
		BigDecimal mini = new BigDecimal(1e20);
		int cnt=0;
		for(int i=0;i<ind;i++){
		    BigDecimal tmp=p1[in[i]];
		    for(int j=0;j<ind;j++){
			if (i != j)tmp=tmp.add(p2[in[j]]);
		    }
		    if (eps.compareTo((mini.subtract(tmp)).abs()) == 1){
			cnt++;
		    }else if (mini.compareTo(tmp) == 1) {
			cnt=1;
			mini=tmp;
		    }
		}
		ans=ans*cnt;
		ans%=mod;
		ans=ans*comb[all][ind];
		bExp=bExp.add(mini);
		//System.out.println(mini.toPlainString());
		all-=ind;
	    }
	    if (all != 0)System.out.println("WA");
	    System.out.println(bExp + " " + ans);
	}
    }
}

Measured memory_bytes: 13000
while gets
    arr=Array.new
    arr=$_.chomp.split(//).map(&:to_i)
    while true
        i=0
        while true
            break if(arr[i+1]==nil)
            arr[i]=arr[i]+arr[i+1]
            i+=1
        end
        arr.pop
        break if(arr.size==1)
    end
    puts arr.join.split(//).last
end

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	while(1){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}

		a -= d;

		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3620