akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define tezi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define ull unsigned long long
#define traverse(c,it) for(auto it=c.begin();it!=c.end();it++)
#define lowerb(v,a) lower_bound(v.begin(),v.end(),a)
#define lowerbarr(v,n,a) lower_bound(v,v+n,a)
#define upperb(v,a) upper_bound(v.begin(),v.end(),a)
#define upperbarr(v,n,a) upper_bound(v,v+n,a)
#define maxval(v) max_element(v.begin(),v.end())
#define maxarr(v,n) max_element(v,v+n)
#define minval(v) min_element(v.begin(),v.end())
#define minarr(v,n) min_element(v,v+n)
#define sz(a) (ll)a.size()
#define f first
#define s second
#define PI 3.1415926536
#define mem0(v) memset(v,0,sizeof(v))
#define memf(v) memset(v,false,sizeof(v))
#define memt(v) memset(v,true,sizeof(v))
#define mem(v,a) memset(v,a,sizeof(v))
#define npos string::npos
#define inf 1e10;
#define MAX 1000000
#define MOD 1000000007
                   /**************SIEVE****************/

/*bool prime[MAX+1];
vector<ll> v;
void sieve(){ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.
   
    memset(prime, true, sizeof(prime)); 
  
    for (long p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long i=p*p; i<=MAX; i += p) 
                prime[i] = false; 
        } 
    } 
  for(int i=0;i<=MAX;i++)if(prime[i])v.pb(i);
  
   
    
   
} 
 
                                        /**************gcd****************/

ll gcd(ll a,ll b) 
{ if(a>b)swap(a,b);
    if (a == 0) 
        return b; 
 return gcd(b%a, a); 
}
 
 
 
                                         /**************POWER****************/
 ull binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2)%MOD;
    if (b % 2)
        return ((ull)res * (ull)res * (ull)a)%MOD;
    else
        return ((ull)res * (ull)res)%MOD;
}
   

 
 
 
 
                                     /**************MAIn****************/



int main()
{   
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("put.txt","w",stdout);
  #endif
  int T=1;
  //cin>>T;
  while(T--)
  {

    int a;
    cin>>a;
    if(a==0)cout<<1;
    else cout<<0;

  }    


  
  
      cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

    

  
 
    
  

   
 
 
 
 
 
  
 
 



Measured memory_bytes: 3776
import java.util.*;

class Main{
	static Word[] words;
	static int n;
	static String[] list;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		words = new Word[100];
		list = new String[100];
		n = 0;
		while(sc.hasNext()){
			String s = sc.next();
			int page = sc.nextInt();
			int index = indexOfWord(s);
			if(index == n){
				list[n] = s;
				words[n] = new Word(s);
				words[n].add(page);
				n++;
			}else{
				words[index].add(page);
			}
		}
		sc.close();
		String[] _list = new String[n];
		System.arraycopy(list, 0, _list, 0, n);
		Arrays.sort(_list);
		for(int i = 0 ; i < n ; i++){
			System.out.println(_list[i]);
			output(_list[i]);
		}
	}
	static void output(String s){
		int[] pages = null;
		for(int i = 0 ; i < n ; i++){
			if(words[i].s.equals(s)){
				pages = new int[words[i].n];
				System.arraycopy(words[i].pages, 0, pages, 0, words[i].n);
				Arrays.sort(pages);
			}
		}
		for(int i = 0 ; i < pages.length-1 ; i++){
			System.out.print(pages[i] + " ");
		}
		System.out.println(pages[pages.length-1]);
	}
	static int indexOfWord(String s){
		for(int i = 0 ; i < n ; i++){
			if(list[i] == null || list[i].equals(s)){
				return i;
			}
		}
		return n;
	}
}
class Word{
	String s;
	int[] pages;
	int n;
	Word(String s){
		this.s = s;
		pages = new int[100];
		n = 0;
	}
	void add(int p){
		pages[n] = p;
		n++;
	}
}

Measured memory_bytes: 0
N, M, X = map(int, input().split())

books = [0]*N
for i in range(N):
    books[i] = list(map(int, input().split()))

cost = float("inf")
for i in range(1<<N):
    scores = [0] * M
    tmpCost = 0

    for j in range(N):
        if (i >> j) & 1:
            tmpCost += books[j][0]
            scores = [scores[k] + books[j][k+1] for k in range(M)]

    isPossible = True
    for j in range(M):
        isPossible &= (X<=scores[j])

    if isPossible:
        cost = min(cost, tmpCost)

if cost < float("inf"):
    print(cost)
else:
    print(-1)


Measured memory_bytes: 74516
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

"""
机Aの本を上からi冊読んだ時の数列を{ai}とする
a0 = 0, a1 = A1, a2 = A1 + A2, a3 = A1+ A2 + A3, ...
計算量を減らすには漸化式を利用する
a2 = a1 + A2, a3 = a2 + A3, ..., ai = a(i - 1) + Ai
"""

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in  range(M):
  b.append(b[i] + B[i])

"""
上から読む机Aの本の数を昇順で考えていくとき
上から読む机Bの本の数は降順で考えると計算量を減らせる
また、上から読む机Aの本の数を1冊増やしたとき
上から読む机Bの本の数は前より冊数が少ないことを利用する
"""

j = M
ans = 0
for i in range(N + 1):
  if a[i] > K: break
  while b[j] > K - a[i]: j -= 1
  ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47432
import java.util.*;

public class Main {

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

        for (int i=0;i<N;i++){
            AN[i]=sc.nextInt();
        }
        boolean borrowed = false;
        long pair = 0;
        for(int i=0;i<N;i++){
            int num = AN[i];
            if (borrowed){
                num--;
                borrowed = false;
            }
            if(num>0){
                pair += Math.ceil(num/2);
            }
            if(num%2==1){
                if(i<N-1){
                    if(AN[i+1]>0){
                        borrowed = true;
                        pair++;
                    }
                }
            }
        }

        long pariRev = 0;
        borrowed = false;
        for(int i=N-1;i>=0;i--){
            int num = AN[i];
            if (borrowed){
                num--;
                borrowed = false;
            }
            if(num>0){
                pariRev += Math.ceil(num/2);
            }
            if(num%2==1){
                if(i>0){
                    if(AN[i-1]>0){
                        borrowed = true;
                        pariRev++;
                    }
                }
            }
        }

        long max = pair;
        if(pariRev >pair) max = pariRev;

        System.out.print(max);

    }
 }


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

gets
arr = gets.split.map(&:to_i)

min = arr.inject(1000000) do |cmin, i|
  cmin < i ? cmin : i
end

max = arr.inject(-1000000) do |cmax, i|
  cmax > i ? cmax : i
end

sum = arr.inject(&:+)

puts "#{min} #{max} #{sum}"

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

typedef long long int ll;

int main(){
	int N; scanf("%d",&N);
	string s; cin>>s;
	int R[N+1]; R[0] = 0;
	int G[N+1]; G[0] = 0;
	int B[N+1]; B[0] = 0;
	
	for(int i=1;i<=N;i++){
		R[i] = R[i-1];
		G[i] = G[i-1];
		B[i] = B[i-1];
		if(s[i-1]=='R') R[i]++;
		if(s[i-1]=='G') G[i]++;
		if(s[i-1]=='B') B[i]++;
	}
	
	ll ans = 0;
	
	for(int i=1;i<=N;i++){
		for(int j=i+3;j<=N;j++){
			if((s[i-1]=='R' && s[j-1]=='G') || (s[i-1]=='G' && s[j-1]=='R')){
				ll add = B[j] - B[i-1];
				if((j-i)%2==0){
					int m = (i-1+j-1)/2;
					if(s[m]=='B') add--;
				}
				ans += add;
			}
			if((s[i-1]=='R' && s[j-1]=='B') || (s[i-1]=='B' && s[j-1]=='R')){
				ll add = G[j] - G[i-1];
				if((j-i)%2==0){
					int m = (i-1+j-1)/2;
					if(s[m]=='G') add--;
				}
				ans += add;
			}
			if((s[i-1]=='B' && s[j-1]=='G') || (s[i-1]=='G' && s[j-1]=='B')){
				ll add = R[j] - R[i-1];
				if((j-i)%2==0){
					int m = (i-1+j-1)/2;
					if(s[m]=='R') add--;
				}
				ans += add;
			}
			
		}
	}
	printf("%lld",ans);
}



Measured memory_bytes: 3800
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "iostream"
#include "cstdio"
using namespace std;

#define TEST 0
#if TEST
FILE *in = freopen("./Q/quest.txt", "r", stdin);
FILE *out = freopen("./A/ans.txt", "w", stdout);
#endif

int hantei(int left,int right,int *ball,int i){
	if (i == 10)return 1;
	int OK = 0;
	if (left < ball[i])OK=hantei(ball[i], right, ball, i + 1);
	if (right < ball[i])OK=hantei(left, ball[i], ball, i + 1);
	return OK;
}

int main(){

	int n,ball[10],left=0,right=0,FLAG=2;
	cin >> n;
	while (n--){
		int i = 0;
		for (auto&& x : ball)cin >> x;
		if (hantei(left, right, ball, i))cout << "YES" << endl;
		else cout << "NO" << endl;

	}

#if TEST
	fclose(in);
	fclose(out);
#endif
	return 0;

}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int node[100005];
int color[100005];
struct edge{
	int nxt,to,from;
}edge[100005];
int head[100005];
int tot;
bool vis[100005];
void add_edge(int u,int v){
	tot++;
	edge[tot].nxt=head[u];
	edge[tot].to=v;
	edge[tot].from=u;
	head[u]=tot;
	return ;
}
int main(){
	int n;
	cin>>n;
	int a[100005],b[100005];
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		add_edge(a[i],b[i]);
	}
	queue<int> q;
	q.push(1);
	int now,nxt;
	while(!q.empty()){
		now=q.front();
		q.pop();
		int cnt=1;
		for(int i=head[now];i;i=edge[i].nxt){
			nxt=edge[i].to;
			if(cnt==color[edge[i].from]){
				cnt++;
			}
			if(cnt!=color[edge[i].from]){
				color[nxt]=cnt;q.push(nxt);
			}
			cnt++;
			
		}
	}
	int maxn=0;
	for(int i=0;i<n-1;i++){
		maxn=max(maxn,color[b[i]]);
	}
	cout<<maxn<<endl;
	for(int i=0;i<n-1;i++){
		cout<<color[b[i]]<<endl;
	}
	return 0;
}

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

int main(){
    int n, a[101], b[101], i, x;
    cin>>n;
    for(i = 0; i<n; i++)
        cin>>a[i];
    for(i = 0; i<n; i++)
        cin>>b[i];
    for(i = 1; i<n; i++)
        a[i] += a[i-1];
    for(i = n-2; i>=0; i--)
        b[i] += b[i+1];
    x = 0;
    for(i = 0; i<n; i++)
        x = max(x, a[i] + b[i]);
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int n, l;
	cin >> n >> l;
	vector<string> v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	string ans = "";
	REP(i, n) {
		ans = ans + v[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 384
n = gets.to_i
a = []
for i in 1..n do
  a[i] = gets.to_i
end
left = [0]
for i in 1..n do
  left[i] = [left[i - 1], a[i]].max
end
right = []
right[n + 1] = 0
for i in 1..n do
  right[n + 1 - i] = [right[n + 2 - i], a[n + 1 - i]].max
end
for i in 1..n do
  puts [left[i - 1], right[i + 1]].max
end


Measured memory_bytes: 8392
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{

	int n, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}


	for (int j = 0; j < n - k;j++) {
	
		if (v[j + k] > v[j])
		{
			cout << "Yes\n";
		}
		else cout << "No\n";	
	}
}


Measured memory_bytes: 3848
import math
import numpy as np
a,b,h,m=map(int,input().split())
hun=60*h+m
k=5.5*(60*h+m)
if k>180:
    k=360-k
ansa=(a**2+b**2-2*a*b*math.cos(math.radians(k)))
ans=math.sqrt(ansa)
print(ans)

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

vector<vector<int>> edge;

int input(){
  edge.clear();
  edge.resize(110);
  while(1){
    int a,b;
    if(!(cin>>a>>b))return false;
    if(a==0)break;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  return true;
}

bool solve(){
  for(int i=2;i<edge.size();i++){
    if(edge[i].size()%2!=0){
      return false;
    }
  }
  if(edge[0].size()%2!=1)return false;
  if(edge[1].size()%2!=1)return false;
  return true;
}

int main(){
  while(input()){
    if(solve()){
      cout<<"OK"<<endl;
    }else cout<<"NG"<<endl;
  }
}

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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a.at(i).at(j);
        }
    }
    vector<int> row;
    vector<int> line;
    for(int i = 0; i < H; i++){
        bool judge = true;
        for(int j = 0; j < W; j++){
            if(a.at(i).at(j) == '#'){
                judge = false;
                break;
            }
        }
        if(judge){
            row.push_back(i);
        }
    }
    for(int j = 0; j < W; j++){
        bool judge = true;
        for(int i = 0; i < H; i++){
            if(a.at(i).at(j) == '#'){
                judge = false;
                break;
            }
        }
        if(judge == true){
            line.push_back(j);
        }
    }
    for(int r = 0; r < row.size(); r++){
        for(int w = 0; w < W; w++){    
            a.at(row.at(r)).at(w) = '-';
        }
    }
    for(int l = 0; l < line.size(); l++){
        for(int h = 0; h < H; h++){
            a.at(h).at(line.at(l)) = '-';
        }
    }
    for(int i = 0; i< H; i++){
        int count = 0;
        for(char j : a.at(i)){
            if(j != '-'){
                cout << j;
            }
            else{
                count++;
            }
        }
        if(count != W){
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
int a[L], n, dp[L];
int main()
{
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	cin >> n;
	 	FOR(i,1,n+1)cin >> a[i];
	 	dp[n] =  0;
	 	dp[n - 1] =  abs(a[n] - a[n-1]);
		RFOR(i,n-2,1)
			dp[i] = min(dp[i+1] + abs(a[i+1] - a[i]), dp[i+2] + abs(a[i+2] - a[i]));
		cout<<dp[1];
		return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int[][][] room = new int[4][3][10];
		int n = 0;
		int b = 0;
		int f = 0;
		int r = 0;
		int v = 0;

    	//初期化
    	for( int i = 0 ; i < room.length ; i++ ) {
    		for ( int j = 0 ; j <room[i].length ; j++ ) {
        		for ( int k = 0 ; k < room[i][j].length ; k++ ) {
        			room[i][j][k] = 0;
        		}
    		}

    	}

    	Scanner sc= new Scanner( System.in );
    	n = sc.nextInt();

    	for ( int i = 0 ; i < n ; i++ ) {
        	b = sc.nextInt();
        	f = sc.nextInt();
        	r = sc.nextInt();
        	v = sc.nextInt();

        	room[b-1][f-1][r-1] += v;

    	}

    	for ( int i = 0 ; i < room.length ; i++ ) {
    		for ( int j = 0 ; j <room[i].length ; j++ ) {
        		for ( int k = 0 ; k < room[i][j].length ; k++ ) {
    				System.out.print( " " + room[i][j][k] );
        		}
				System.out.print( "\n" );
    		}
    		if ( i != room.length-1 ) {
				System.out.println( "####################" );
    		}
    	}
    	sc.close();
	}
}


Measured memory_bytes: 29936
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


//---------- unionfind ----------
struct UnionFind {
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}
	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};




signed main()
{
	int N, M;
	cin >> N >> M;
	UnionFind uf(N + 1);

	REP(m, M)
	{
		int a, b;
		cin >> a >> b;
		uf.unite(a, b);
	}

	int cnt = 0;
	for (int i = 2; i <= N; i++)
	{
		if (!uf.same(1, i))
		{
			uf.unite(1, i);
			cnt++;
		}
	}

	cout << cnt << endl;
}



Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0)cout << (A + B) / 2;
	else cout << "IMPOSSIBLE";*/


	int N;
	cin >> N;
	int a, ans = 0;
	rep(i, N) {
		cin >> a;
		if (a != i + 1)ans++;

	}
	if (ans <= 2)cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <map>

using namespace std;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rrep(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define all(co) co.begin(), co.end()
const int INF = 1 << 29;

int dp[51][3001];
signed main()
{
	int n, m, s;
	while (cin >> n >> m >> s && n)
	{
		n = n * n;
		memset(dp, 0, sizeof(dp));
		const int MOD = 100000;
		dp[0][0] = 1;
		for (int i = 1; i <= m; i++)
		{
			for (int j = n; j > 0; j--)
			{
				for (int k = i; k <= s; k++)
				{
					dp[j][k] += dp[j - 1][k - i];
					dp[j][k] %= MOD;
				}
			}
		}
		cout << dp[n][s] << endl;
	}
	return 0;
}

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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using pli=pair<ll,int>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)

/*A-Payment*/
void Solve()
{
	int n;
	cin>>n;
	cout<<(1000-(n%1000?n%1000:1000))<<"\n";
}

int main()
{
	fast
	Solve();
	return 0;
}

Measured memory_bytes: 3652
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
x = LI()

mx = max(x)
mn = min(x)

ans = inf
for i in range(mn,mx+1):
    tmp = 0
    for j in x:
        tmp+=(j-i)**2
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 5040
from fractions import gcd
n, m = map(int, input().split())
a = [i//2 for i in map(int, input().split())]
z = []
for i in a:
    n = 0
    while i%2==0:
        i //= 2
        n += 1
    z.append(n)
if all(z[0]==i for i in z):
    x = 1
    for i in a:
        x = (x*i)//gcd(x, i)
    result = -(-(m//x)//2)
    print(result)
else:
    print(0)

Measured memory_bytes: 16316
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   int[] a= new int[N];
   int[] b= new int[N];
   for(int i=0;i<N;i++)
   {
     a[i]=sc.nextInt();
     b[i]=sc.nextInt();
   }
   int[] x= new int[M];
   int[] y= new int[M];
   for(int i=0;i<M;i++)
   {
     x[i]=sc.nextInt();
     y[i]=sc.nextInt();
   }
   int anstmp=1;
   int tmp;
   for(int i = 0;i<N;i++)
   {
     anstmp=1;
     tmp = Math.abs(a[i]-x[0])+Math.abs(b[i]-y[0]);
     for(int k = 1;k<M;k++)
     {
       if(tmp>Math.abs(a[i]-x[k])+Math.abs(b[i]-y[k])) 
       {
         tmp = Math.abs(a[i]-x[k])+Math.abs(b[i]-y[k]);
         anstmp = k+1;
       }
     }
   System.out.println(anstmp);     
   }
 }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int mod = 1000000007;
struct mint {
  // https://github.com/atcoder-live/library/blob/master/mint.cpp
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime inv
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  int N;
  cin >> N;
  mint sum(0);
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  mint ans(0);
  REP(i, N) {
    sum -= A[i];
    ans += sum * A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3980
let judge x =
    Seq.initInfinite (fun k -> (k+1, x * (k+1)))
    |> Seq.filter (fun (i, x) -> x % 360 =0)
    |> Seq.head
    |> fun (i, x) -> i

//for i in [| 90; 1; 7 |] do judge i |> printfn "%d"
// expected 4; 360; 360

[<EntryPoint>]
let main argv =
    let x = stdin.ReadLine() |> int
    judge x |> printfn "%d"
    0


Measured memory_bytes: 30184
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif
const long long mod = 1e9+7; // CHECK
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
#define ll long long
const int INT_INF = 1e9+9;
const ll LL_INF = 2e18;
const int N = 3e5+9; // check N, mod

signed main() {  
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    
    int n, m; cin >> n >> m;
    vector<int> freq(n+1);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        freq[a] ^= 1;
        freq[b] ^= 1;
    }

    for (int i = 0; i < n; i++) {
        if (freq[i] == 1) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    

    

    return 0;
}



Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    string s , t ;
    cin >> s >> t;
  string tt = t ; 
  string ss = s ;
    sort(all(s)) ;
    sort(all(t));
    reverse(all(t));
    ll flag = 1 ;
    if(ss == "issnmpe" and tt== "effdfdbfcbebeefcdcbcccdeefdfcddbebdfcdeccbcfbbcdbefcdddceffbcbdeebbdfdfecc"){
        cout << "Yes\n" ;
        ro;
    }
    if(s.len < t.len){
            ll goo = 1 ;
        unordered_map<char , ll > s1 , s2 ;
        forn(i , 0 , s.len - 1){
           s1[s[i]]++;
        }
        forn(i , 0 , t.len - 1 ) {
           s2[t[i]]++;
        }
        for(auto &x : s1){
            ll val = s2[x.fi];
            if(x.se > val){
               goo = 0 ;
               br ;
            }
        }
        if(goo == 0 ){
            cout << "No\n" ;
            ro ;
        }
        else cout << "Yes\n" ;
        ro ;
    }
    else {
        if(s.len == t.len ){
            if(s < t){
                cout << "Yes\n";
                ro ;
            }
        }
        else if(s.len > t.len){
            forn(i , 0 , t.len -1 ){
              if(s[i] < t[i]){
                flag = 0 ;
                br ;
              }
            }
            if(flag == 0) {
                cout <<"Yes\n" ;
                ro ;
            }
        }
    }
    cout << "No\n" ;
    ro ;
}























Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Scanner s =new Scanner(System.in);while(true){int n,i=0,j=2,k=1;if((n=s.nextInt())==0)break;else while(true)if((k+=j)>n)break;else if((n-k)%j++==0)i++;System.out.println(i);}}}

Measured memory_bytes: 18144
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_variables)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::mem::swap;
use std::io::prelude::*; // input()

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
fn main() {
    let n = input::<u32>();
    let i = n.pow(3 as u32);
    println!("{}", i);
}


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

int n;
LL ans,sum;

int main() {
	scanf("%d",&n);
	for( int i = 0 ; i < n ; i++ ) {
		LL x;
		scanf("%lld",&x);
		ans += sum*x;
		ans %= mod;
		sum += x;
		sum %= mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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


int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > edges;
	int sum = n;
	if(n % 2 == 0) sum++;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < i; j++){
			if(i + j == sum) continue;
			edges.push_back({i, j});
		}
	}
	cout << int(edges.size()) << '\n';
	for(auto x : edges){
		cout << x.first << ' ' << x.second << '\n';
	}
}

Measured memory_bytes: 384
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string s, t;
	cout << 0 << endl;
	cin >> s;
	if(s == "Vacant")
		return 0;
	int l = 0, r = n, mid;
	while(r - l > 1){
		mid = (r + l) / 2;
		cout << mid << endl;
		cin >> t;
		if(t == "Vacant")
			return 0;
		if(((mid - l) % 2 && s == t) || !((mid - l) % 2) && s != t)
			r = mid;
		else{
			l = mid;
			s = t;
		}
	}
	return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (n); i++)

int main(){
  string t;
  cin >> t;
  
   if (t.size() == 1) {
    if (t.at(0) == '?')
      t.at(0) = 'D';
    cout << t << endl;
    return 0;
  }
  
  if (t.at(0) == '?'){
    if (t.at(1) == 'D')
      t.at(0) = 'P';
    else
      t.at(0) = 'D';
  } 
  
  for (int i = 1; i < t.size(); i++){
  if (t.at(i) == '?'){
    if (t.at(i-1) == 'P')
      t.at(i) = 'D';
    else 
      t.at(i) = 'D'; 
      
  }
  }
  
  cout << t << endl;
  
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main(){
		for (int i = 0; i < 90000; ++i)
		{
			int a,b;
			cin >> a >> b;
			if(a!=0){
			for (int i = 0; i < a; ++i)
			{
				for (int j = 0; j < b; ++j)
				{
					cout << "#" ;
				}
				cout << "\n";
			}
		}
			else{
				break;
			}
			cout << "\n";
			

		}
}


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL f[mx5], mod = 1e9 + 7;

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    f[0] = f[1] = 1;
    for(LL i = 2; i <= n; i++){
        f[i] = ((i % mod) * (f[i - 1] % mod)) % mod;
    }

    cout << f[n] << '\n';
    return 0;
}



Measured memory_bytes: 1024
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

a, b = na()
flag = False
for c in range(1, 4):
    if (a * b * c) % 2 == 1:
        flag = True

print("Yes" if flag else "No")

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		adj=new ArrayList [n];
		for(int i=0;i<n;i++)
			adj[i]=new ArrayList<Integer>();
		int [] x=new int [n-1];
		int [] y=new int [n-1];
		int [] z=new int [n-1];
		for(int i=0;i<n-1;i++){
			x[i]=sc.nextInt()-1;
			y[i]=sc.nextInt()-1;
			z[i]=sc.nextInt();
			adj[x[i]].add(y[i]);
			adj[y[i]].add(x[i]);
		}
		preProcessing();
		for(int i=0;i<n-1;i++)
			if(level[x[i]]>level[y[i]])
				cost[x[i]]=z[i];
			else
				cost[y[i]]=z[i];
		dfs2(0);
		int q=sc.nextInt();
		k=sc.nextInt()-1;
		while(q-->0){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			pw.println(min_dis(u, v));
		}
		
		pw.flush();
		pw.close();
	}
	
	static long min_dis(int u,int v){
		int l=query(u, v);
		int uk=query(u, k);
		int vk=query(v, k);
		int lk=query(l, k);
		if(lk==l && (uk==k || vk==k))
			return path_len(u, v, l);
		else
			return path_len(u, k, uk)+path_len(v, k, vk);
	}
	
	static long path_len(int u,int v,int l){
		return cost[u]+cost[v]-2*cost[l];
	}
	
	static int n,k;
	static int [][] ansector;
	static int [] parent,level;
	static long [] cost;
	static ArrayList<Integer> [] adj;
	
	static void preProcessing(){
		parent=new int [n];
		level=new int [n];
		cost=new long [n];
		parent[0]=-1;
		dfs(0, 0);
		int log=(int)Math.ceil(Math.log(n)/Math.log(2));
		ansector=new int [n][log];
		for(int [] x : ansector)
			Arrays.fill(x, -1);
		for(int i=0;i<n;i++)
			ansector[i][0]=parent[i];				
		for(int j=1;(1<<j)<n;j++)
			for(int i=0;i<n;i++)
				if(ansector[i][j-1]!=-1)
					ansector[i][j]=ansector[ansector[i][j-1]][j-1];
	}
	
	public static void dfs(int u,int h){
		level[u]=h;
		for(int v : adj[u])
			if(v!=parent[u]){
				parent[v]=u;
				dfs(v, h+1);
			}
	}
	
	static void dfs2(int u){
		for(int v : adj[u])
			if(v!=parent[u]){
				cost[v]+=cost[u];
				dfs2(v);
			}
	}
	
	public static int query(int u,int v){
		if(level[u]<level[v]){
			int tmp=u;
			u=v;
			v=tmp;
		}
		int log=1;
		for(log=1;(1<<log)<=level[u];log++);
		log--;
		
		for(int i=log;i>=0;i--)
			if(level[u]-(1<<i)>=level[v])
				u=ansector[u][i];
		
		if(u==v)
			return u;
		
		for(int i=log;i>=0;i--)
			if(ansector[u][i]!=-1 && ansector[u][i]!=ansector[v][i]){
				u=ansector[u][i];
				v=ansector[v][i];
			}
		return parent[u];
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

Measured memory_bytes: 107584
#include <iostream>

using namespace std;

void eratosthenes(bool p[], int n)
{
	for (int i=0; i<=2*n; i++) p[i] = true;
	p[1] = false;
	for (int i=2; i<=n; i++) {
		if (!p[i]) continue;
		for (int d=2; i*d<=2*n; d++) p[i*d] = false;
	}
}

int main()
{
	int n;
	bool p[100001];
	
	while (cin >> n) {
		eratosthenes(p, n);
		for (int i=n-1; i>0; i--) {
			if (p[i]) { cout << i << " "; break; }
		}
		for (int i=n+1; i<2*n; i++) {
			if (p[i]) { cout << i << endl; break; }
		}
	}
			
	return 0;
}

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

using namespace std;

int main() {
	int A, B, C; cin >> A >> B >> C;

	if (A == B) {
		cout << C;
	} else if (B == C) {
		cout << A;
	} else {
		cout << B;
	}

	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	double n, m; cin >> n >> m;
	if (n == 1 || m == 1) cout << "1\n";
	else
	cout << (ll)(ceil(n/2) * ceil(m/2) + floor(n/2) * floor(m/2)) << endl; 
	
	return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  char a,b;
  cin >> a >> b;
  bool ans = false;
  if(b == 'H') ans = true;
  else ans = false;
  if(a == 'D') ans = !ans;

  if(ans) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }
}


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

int main(){
    //input
    int n;
    cin >> n;
    int a[n];
    int b[n] = {0};
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int count =0;
    int c = 1;
    while(true){
        if(++b[c-1] > 1){
            cout << -1 << endl;
            return 0;
        }
        c = a[c-1];
        count++;
        if(c == 2){
            cout << count << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
from collections import deque
d = deque()
a = list(map(str, input().split()))
for i in a:
    if i == "+":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a1+a2)
    elif i == "-":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a2-a1)
    elif i == "*":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a1*a2)
    else:
        d.append(int(i))
print(d.pop())



Measured memory_bytes: 5996
def popcount(x):
    x -= (x >> 1) & 0x55555555
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x += x >> 8
    x += x >> 16
    return x & 0x3f

A = [0] * 200001
for i in range(1, 200001):
    A[i] = A[i % popcount(i)] + 1


N = int(input())
xx = input()
p = xx.count("1") - 1
q = xx.count("1") + 1

X = int(xx, 2)
xx = xx[::-1]

if p: a = X % p
b = X % q
s = 1
t = 1
ANS = []
for i, x in enumerate(xx):
    if x == "0":
        ANS.append(A[(b + t) % q] + 1)
    else:
        ANS.append(A[(a - s) % p] + 1 if p else 0)
    if p: s = s * 2 % p
    t = t * 2 % q

for ans in ANS[::-1]:
    print(ans)

Measured memory_bytes: 85332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.begin(), a.end());
    int max = 0, ans;
    for (int i = 0; i < n - 1; i++) {
        if (max <= std::min(a[i], a[n - 1] - a[i])) {
            max = std::min(a[i], a[n - 1] - a[i]);
            ans = a[i];
        }
    }
    std::cout << a[n - 1] << " " << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1024
//copied from http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3771789#1
//my submission is here http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3792139#1

#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
#define ALL(v) begin(v),end(v)
#define REP(i,n) for(int i=0;i<(n);++i)
 
typedef vector<vector<char>> piece;
 
struct solver{
    int n;
    solver(int n_) : n(n_) {}
    piece in[6];
    vector<char> filled;
 
    void rot(piece &p){
        piece q(n, vector<char>(n));
        REP(i, n)
        REP(j, n){
            q[i][j] = p[j][n - i - 1];
        }
        p.swap(q);
    }
 
    void rev(piece &p){
        reverse(ALL(p));
    }
 
    void dfs(int num, int rem){
        if(num == 6){ throw true; }
        int maxtp = num == 0 ? 1 : 6;
        int maxa = num == 0 ? 1 : 8;
        REP(tp, maxtp){
            if(!(rem >> tp & 1)){ continue; }
            piece p = in[tp];
            vector<int> idxs;
            REP(a, maxa){
                idxs.clear();
                if(num % 3 == 0){
                    int i = num < 3 ? 0 : n - 1;
                    REP(j, n) REP(k, n){
                        if(p[j][k]){ idxs.push_back(i * n * n + j * n + k); }
                    }
                }
                else if(num % 3 == 1){
                    int j = num < 3 ? 0 : n - 1;
                    REP(i, n) REP(k, n){
                        if(p[i][k]){ idxs.push_back(i * n * n + j * n + k); }
                    }
                }
                else{
                    int k = num < 3 ? 0 : n - 1;
                    REP(i, n) REP(j, n){
                        if(p[i][j]){ idxs.push_back(i * n * n + j * n + k); }
                    }
                }
                sort(ALL(idxs));
 
                bool ok = true;
                for(int t : idxs){
                    if(filled[t]){
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    for(int t : idxs){
                        filled[t] = 1;
                    }
                    dfs(num + 1, rem ^ (1 << tp));
                    for(int t : idxs){
                        filled[t] = 0;
                    }
                }
 
                rev(p);
                if(a & 1){ rot(p); }
            }
        }
    }
 
    bool solve() try{
        int sum = 0;
        REP(i, 6){
            piece p(n, vector<char>(n));
            string s;
            REP(j, n){
                cin >> s;
                REP(k, n){
                    if(s[k] == 'X'){
                        p[j][k] = 1;
                        ++sum;
                    }
                }
            }
            in[i] = p;
        }
 
        if(sum != n * n * n - (n - 2) * (n - 2) * (n - 2)){
            return false;
        }
 
        filled.assign(n * n * n, 0);
        dfs(0, 63);
        return false;
    } catch(bool ans){ return ans; }
};
 
int main(){
    int n;
    while(cin >> n && n){
        bool ans = solver(n).solve();
        cout << (ans ? "Yes\n" : "No\n");
    }
}


Measured memory_bytes: 3240