akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            long N = in.nextLong();
            out.println(N * (N - 1) / 2);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a != 1 && b != 1 && a > b) {
        cout << "Alice" << endl;
    } else if (a != 1 && b != 1 && a < b) {
        cout << "Bob" << endl;
    } else if (a == 1 && b != 1) {
        cout << "Alice" << endl;
    } else if (a != 1 && b == 1) {
        cout << "Bob" << endl;
    } else if (a == b) {
        cout << "Draw" << endl;
    }
    return 0;
}


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

int main() {
  int n, t = 0, r = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; i++) {
    t += a[i];
  }
  t = (int)round(double (t)/ double(n));
  for (int i = 0; i < n; ++i) {
    r += (int)pow(a[i] - t, 2);
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
ll INF = Mod * 100LL;
int main() {
  int N;
  cin >> N;
  ll ans = 0;
  ll sum = 0;
  ll mini = INF;
  bool all_same = true;
  for (int i = 0; i < N; i++) {
    ll A,B;
    cin >> A >> B;
    sum += A;
    if (A != B) all_same = false;
    if (A > B) {
      mini = min(mini,B);
    }
  }
  if (all_same) {
    cout << 0 << endl;
    return 0;
  }
  cout << sum - mini << endl;
  return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  
  long long q,h,s,d;
  long long n;
  long long ans = 0;
 
  cin >> q >> h >> s >> d;
  cin >> n;
  
  if(q*2 < h)h = q*2;
  if(h*2 < s)s = h*2;
  if(s*2 < d)d = s*2;
  
  ans += (n/2) * d;
  n %= 2;
  ans += n * s; 
  
  cout << ans << endl;
  
  return 0;
}

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

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

int main()
{
    int k;
    cin >> k;
    int64_t sum = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;
const int INF=~(1<<31);
const lint LINF=~(1LL<<63);

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

    deque<int> b;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(i%2) b.push_back(a);
        else b.push_front(a);
    }
    if(n%2){
        for(auto it=b.begin();it!=b.end();++it) cout << (it!=b.begin()?" ":"") << *it;
    }else{
        for(auto it=b.rbegin();it!=b.rend();++it) cout << (it!=b.rbegin()?" ":"") << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
import sys
N, Y = map(int, input().split())
for x in range(N+1):
  for y in range(N+1-x):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      print('{} {} {}'.format(x, y, z))
      sys.exit()
  else:
    continue
  break
else:
  print('-1 -1 -1')

Measured memory_bytes: 3060
import sys

def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return int(a)
    
n = int(input())
a = list(map(int, input().split()))


if n==2:
  print(max(a))
  sys.exit(0)
elif n==3:
  lis = [gcd(a[0], a[1]), gcd(a[1], a[2]), gcd(a[2], a[0])]
  print(max(lis))
  sys.exit(0)


tmp_unused = gcd(a[0], a[1])
tmp_used = max(a[0], a[1])
#print("used=", tmp_used, "unused=", tmp_unused)

for i in range(2,n):
  #print(a[i])
  tmp_used = max(tmp_unused, gcd(tmp_used, a[i]))
  tmp_unused = gcd(tmp_unused, a[i])
  
  #print("used=", tmp_used, "unused=", tmp_unused)
print(tmp_used)




Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    double th;
    cin >> th;

    int h = th /30;
    double re = th - 30 * h;
    int m =  re / 0.5;
    cout << h << " " << m << endl;
}

Measured memory_bytes: 3172
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main() {
	int n, i;
	while (cin>>n,n!=-1) {
		double x = 1.0, y = 0.0;
		for (int i = 1; i < n;i++) {
			double d = sqrt(x*x + y*y);
			double dx = -y / d, dy = x / d;
			x += dx, y += dy;
		}
		cout << x << endl << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <stdlib.h>
using namespace std;

int main()
{
	int x, a, b;

	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}

	else {
		cout << "B" << endl;
	}

	return 0;
}

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

int main(void) {
    int N;
    cin>>N;
    vector<int> X;
    for (int i = 0; i < N; i++) {
        int x;
        cin>>x;
        X.push_back(x);
    }
    sort(X.begin(), X.end());
    vector<int> result;
    int mi = X.at(0);
    int ma = X.at(N - 1);
    for (int i = mi; i <= ma; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
           sum += pow(X.at(j) - i, 2);
        }
        result.push_back(sum);
    }
    sort(result.begin(), result.end());
    cout << result.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#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>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#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 sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  double R; cin >> R;
  cout << setprecision(22) << 2*R*3.14159265359 << endl;
  return 0;
}


Measured memory_bytes: 3784
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>

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

using namespace std;

int n;
int p[200002];
bool q[200002];
bool r[200002];
int c,maxc;

int main(){
cin >> n;
rep(i,n){
  cin >> p[i];
  q[p[i]]=true;
  if(q[p[i]+1]) r[p[i]]=true;
}
r[n-1]=true;

rep(i,n){
  if(r[i]){
    maxc = max(c,maxc);
    c = 0;
  }
  c++;
}
rep(i,n-1){
  if(p[i]>p[i+1])break;
  if(i == n-2)maxc = n;
}
if(n==1)maxc = n;
maxc = n-maxc;
cout << maxc << endl;

  return 0;
}


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

int main(){
    int n,m,ans=0;
    cin>>n>>m;
    vector<int> s[m];
    vector<int> p(m);
    rep(i,m){
        int a;
        cin>>a;
        rep(j,a){
            int b;
            cin>>b;
            b--;
            s[i].push_back(b);
        }
    }
    rep(i,m) cin>>p[i];
    rep(biti,1<<n){
        int cnt=0;
        rep(i,m){
            int sum=0;
            rep(j,s[i].size()){
                if(biti>>s[i][j]&1) sum++;
            }
            if(sum%2==p[i]) cnt++;
        }
        if(cnt==m) ans++;
    }
    cout<<ans;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int s, w; cin>>s>>w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3620
import math
import calendar
import fractions
import itertools

a, b, c, d = map(int, input().split())

if c < a:
    if d < a:
        print(0)
    elif a <= d <= b:
        print(d - a)
    else:
        print(b - a)
elif a <= c <= b:
    print(min(d - c, b - c))
else:
    print(0)

Measured memory_bytes: 74476
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i,N) for(ll i=0; i<N; i++)
const ll mod=1e9+7;

int main(){
	int A,B;
	cin >> A >> B;
	int X,Y;
	X = ceil(A*12.5);
	Y = B*10;
	int ans = -1;
	if((int)(max(X,Y)*0.08) == A && (int)(max(X,Y)*0.1) == B){
		ans = max(X,Y);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 1005;

int n,m;
int x[MAXN];
int y[MAXN];
int d[40];

string ans[MAXN];

bool ok(int l,int x,int y)
{
	return (long long)abs(x) + abs(y) <= (1ll << (l + 1)) - 1;
}

int main()
{
	scanf("%d",&n);
	bool odd = 0,even = 0;
	for (int i = 1;i <= n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		odd |= (x[i] + y[i]) & 1;
		even |= ~(x[i] + y[i]) & 1;
	}
	if (odd && even)
	{
		puts("-1");
		return 0;
	}
	if (even)
	{
		d[m = 1] = 1;
		for (int i = 1;i <= n;i++)
		{
			y[i]++;
			ans[i] += "D";
		}
	}
	for (int i = 30;i >= 0;i--)
		d[++m] = 1 << i;
	for (int i = 1;i <= n;i++)
		for (int j = 30;j >= 0;j--)
		{
			if (ok(j - 1,x[i] - (1 << j),y[i]))
			{
				x[i] -= 1 << j;
				ans[i] += "R";
			}
			else if (ok(j - 1,x[i] + (1 << j),y[i]))
			{
				x[i] += 1 << j;
				ans[i] += "L";
			}
			else if (ok(j - 1,x[i],y[i] - (1 << j)))
			{
				y[i] -= 1 << j;
				ans[i] += "U";
			}
			else
			{
				y[i] += 1 << j;
				ans[i] += "D";
			}
		}
	printf("%d\n",m);
	reverse(d + 1,d + m + 1);
	for (int i = 1;i <= m;i++)
		printf("%d ",d[i]);
	printf("\n");
	for (int i = 1;i <= n;i++)
	{
		reverse(ans[i].begin(),ans[i].end());
		puts(ans[i].c_str());
	}
	return 0;
}

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

vector<int> inc(vector<int> a,int x,int y){
	vector<int> ans;
	for(int i = x ; i <= y ; i++){
		ans.push_back(a[i]);
	}
	return ans;
}
int main(){
	int n,c,p;
	while(cin >> n >> p){
		vector<int> v(n);
		for(int i = 0 ; i< n ; i++) v[i] = i;
		for(int q = 0 ; q < p ; q++){
			int c; cin >> c;
			vector<int> A = inc(v,v.size()/2,v.size()-1);
			vector<int> B = inc(v,0,v.size()/2-1);
			vector<int> C;
			int f = 0;
			while(A.size() || B.size()){
				if(!f){
					vector<int> A_ = inc(A,0,min(c-1,(int)A.size()-1));
					C.insert(C.end(),A_.begin(),A_.end());
					A = inc(A,min(c,(int)A.size()),(int)A.size()-1);
				}else{
					vector<int> B_ = inc(B,0,min(c-1,(int)B.size()-1));
					C.insert(C.end(),B_.begin(),B_.end());
					B = inc(B,min(c,(int)B.size()),(int)B.size()-1);
				}
				f ^= 1;
			}
			v = C;
		}
		cout << v.back() << endl;
	}
}

Measured memory_bytes: 0
# coding: utf-8

nmxy = input().split(" ")
n = int(nmxy[0])
m = int(nmxy[1])
xc = int(nmxy[2])
yc = int(nmxy[3])
x_list = [int(s) for s in input().split(" ")]
y_list = [int(s) for s in input().split(" ")]
x_list.append(xc) 
y_list.append(yc)
x_list.sort(reverse=True)
y_list.sort()

if x_list[0] < y_list[0]:
  print("No War")
else:
  print("War")


Measured memory_bytes: 38384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M; cin >> M;
    int sum = -1;
    int ans = -1;
    rep(i, M) {
        int d, c;
        cin >> d >> c;
        sum += d * c;
        ans += c;
    }
    ans += sum / 9;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(void)
{
	int i,j,max,second,third;
	int array[10];
	for(i = 0;i < 10;i++)
	{
		scanf("%d",&array[i]);
	}
	max = 0;
	second = 0;
	third = 0;
	for(j = 0;j < 10;j++)
	{
		if(array[j] > max)
		{
			third = second;
			second = max;
			max = array[j];
		}
		else if(array[j] > second)
		{
			third = second;
			second = array[j];
		}
		else if(array[j] > third)
		{
			third = array[j];
		}
		else
		{
		}
	}
	printf("%d\n",max);
	printf("%d\n",second);
	printf("%d\n",third);

	return 0;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
P = [list(map(int,input().split())) for i in range(M)]

ans = min(a) + min(b)
for i in range(M) :
    ans = min(ans, a[P[i][0]-1] + b[P[i][1]-1] - P[i][2])

print(ans)


Measured memory_bytes: 76304
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main(){
	char str[101]={};
	int n;
	scanf("%d", &n);
	scanf("%s", str);
	bool exist=true;
	if(n%2==1){
		exist=false;
	}else{
		for (int i = 0; i < n / 2; i++) {
			if(str[i]!=str[n/2+i]){
				exist=false;
				break;
			}
		}
	}
	if(exist)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int out=2000,n,T,c,t;
	cin>>n>>T;
	rep(i,n){
		cin>>c>>t;
		if(t<=T) out=min(out,c);
	}
	if(out>=2000) cout<<"TLE"<<endl;else cout<<out<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>
int main() {
    char input;
    char at = 'g';
    int sum = 0;
    while ( (input = getchar()) != '\n' ) {
        if ( at == 'g' && input == 'p' ) {
            sum --;
        } else if ( at == 'p' && input == 'g' ) {
            sum ++;
        }
        
        if ( at == 'g' ){
            at = 'p';
        } else if ( at == 'p' ) {
            at = 'g';
        }
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int f(int N,int d,int i){
    if (i-d >= 0) return (i-d);
    else return (N-d+i);
}

int main(){ 
    int N; SCD(N);
    ll x; SCLLD(x);
    vector<ll> a;
    REP(i,N){
        ll b; SCLLD(b);
        a.PB(b);
    }

    static ll c[2002][2002];
    //REP(i,20002){REP(j,2002){c[i][j] = 1000000000000;}}
    REP(i,N){
        c[i][0] = a[i];
    }
    
    FORq(d,1,N-1){
        REP(i,N){
            //printf("f(%d,%d,%d) = %d\n",N,d,i,f(N,d,i));
            c[i][d] = min(c[i][d-1],a[f(N,d,i)]);
        }
    }

    ll ans = 10000000000000000;

    FORq(d,0,N-1){
        ll sum = 0;
        REP(i,N){
            sum += c[i][d];
            //printf("c[%d][%d] = %lld\n",i,d,c[i][d]);
        }

        //printf("ans = %lld,d = %d\n",ans,d);
        ans = min(ans , sum + (ll)d * x);
    }

    PRINTLLD(ans);
}

Measured memory_bytes: 31616
#include <iostream>
#include <stdio.h>
#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<int, int> P;

const ll MOD = 10e9+7;
const ll INF = LLONG_MAX;
const ll MAX_N = 10e5;
const double EPS = 10e-8;

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

int main() {
	int n, a[200]{},ans=9999999;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		while (m % 2 == 0) {
			m /= 2;
			a[i]++;
		}
	}
	for (int i = 0; i < n; i++) {
		ans = min(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    cout << (N-2)*180 << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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


public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		String op = scanner.next();
		int b = scanner.nextInt();
		
		if (op.equals("+"))
		{
			System.out.print(a + b);
		}
		else
		{
			System.out.print(a - b);
		}
	}
}

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

int main(){
	string s;
	int num, h;
	while(cin >> s && s != "-"){
		cin >> num;
		for(int i = 0; i < num; i++){
			string deck1, deck2;
			cin >> h;
			for(int j = 0; j < h; j++){
				deck1 += s[j];
			}
			for(int j = h; j < s.size(); j++){
				deck2 += s[j];
			}
			s = deck2 + deck1;
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
h,w = map(int,input().split())
S = [['' for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    S[i+1][1:w+1] = input()
for i in range(h):
    for j in range(w):
        if S[i+1][j+1]=='.':
            S[i+1][j+1] = str(1*(sum(S[k+i][j:j+3].count('#') for k in range(3))))
    print(*S[i+1][1:w+1],sep='')

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

int N;
int a[20][20];

long long dp[1 << 16];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cin >> a[i][j];

    for(int S = 1; S < 1 << N; S++) {
        for(int i = 0; i < N; i++)
            for(int j = 0; j < i; j++)
                if(S >> i & S >> j & 1) dp[S] += a[i][j];

        for(int T = S; T > 0; T = T - 1 & S) {
            if(T == S) continue; // S 自身は除く
            dp[S] = max(dp[S], dp[T] + dp[S ^ T]);
        }
    }

    cout << dp[(1 << N) - 1] << endl;

    return 0;
}

Measured memory_bytes: 768
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    color = [0] * 9
    ans = 0
    for a in A:
        if a >= 3200:
            color[8] += 1
        else:
            color[a // 400] += 1

    mi = 0
    for c in color[:8]:
        if c > 0:
            mi += 1
    if mi == 0:
        print(1, color[8])
    else:
        print(mi, mi + color[8])



    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  ll n, m, k; cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  ll all_time = 0;
  int b_cnt = m;
  int ans = 0;

  rep(i,m) all_time += b[i];
  rep(i,n+1){ //Aから読む冊数
    while(b_cnt > 0 && all_time > k){
      b_cnt--;
      all_time -= b[b_cnt];
    }
    if (all_time > k) break;
    ans = max(ans, i+b_cnt);
    if (i==n) break;
    all_time += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6340
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = {}
for i in range(m):
  p, x = map(int, input().split())
  px[i] = [p, x]
time = [sum(t)] * m
for i in range(len(px)):
  time[i] = time[i] - t[px[i][0] - 1] + px[i][1]
for e in time:
  print(e)

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

int main() {
	int l, r;
	scanf("%d%d", &l, &r);
	int ans = 2019;
	int start = l%2019, end = start+min(2019, r-l+1);
	for (int i = start; i < end; ++i) {
		for (int j = i+1; j < end; ++j) {
			ans = min(i*j%2019, ans);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;





int main() {
    int n;
    cin>>n;
    int s = 1000;
    if(s < n){
        while(s < n){
            s += 1000;
        }
    }
    cout<<s-n;
    return 0;
}

Measured memory_bytes: 3436
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int x;
    cin >> x;

    if(x)cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

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

	long long ans = 0;

	for(int i = 1; i <= n; ++i) {
		if(i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

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

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(c % gcd(a, b) != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

int main() {
  int n,k;
  int x=1;
  cin >> n;
  cin >> k;
  for(int i=0;i<n;i++){
    x=min(x+k,x*2);
  }
  cout << x << "\n";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};


int main(){
    int n,k;
    cin>>n>>k;
    vector<double> p(n);
    double ans=0.0;
    rep(i,n) {
        cin>>p[i];
    }
    vector<double> exp(n);
    rep(i,n){
        p[i]=(p[i]+1)/2.0;
        if(i==0) exp[i]=p[i];
        else exp[i]=exp[i-1]+p[i];
    }
    for(int j=k;j<n;j++){
        ans=max(ans, exp[j]-exp[j-k]);
    }
    cout<<fixed<<setprecision(8)<<max(ans, exp[k-1])<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  cout<<(1000-n%1000)%1000<<endl;
}



Measured memory_bytes: 3648
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define dup(x) x.erase(unique(x.begin(), x.end()),x.end())
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
// https://atcoder.jp/contests/abc171/tasks/abc171_d
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll sum = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> m;
    for(int i = 0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }
    ll q;
    cin >> q;
    vector<ll> b(q), c(q);
    for(int i = 0;i<q;i++){
        cin >> b[i] >> c[i];
    }

    for(int i = 0;i<q;i++){
        ll diff = c[i] - b[i];
        ll cnt = m[b[i]];
        m[c[i]] += m[b[i]];
        m[b[i]] = 0;
        sum += (diff * cnt);
        cout << sum << "\n";
    }    
	return 0;
}


Measured memory_bytes: 11548
#include <iostream>

using namespace std;

int main(){

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if (
        (m1 == 1 && d1 == 31) ||
        (m1 == 2 && d1 == 28) ||
        (m1 == 3 && d1 == 31) ||
        (m1 == 4 && d1 == 30) ||
        (m1 == 5 && d1 == 31) ||
        (m1 == 6 && d1 == 30) ||
        (m1 == 7 && d1 == 31) ||
        (m1 == 8 && d1 == 31) ||
        (m1 == 9 && d1 == 30) ||
        (m1 == 10 && d1 == 31) ||
        (m1 == 11 && d1 == 30) ||
        (m1 == 12 && d1 == 31) 
        
        ){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }




    return 0; 
}

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

int main(void){

  string S; //天気の入力
  cin >> S;
  if(S == "Sunny") cout << "Cloudy";
  if(S == "Cloudy") cout << "Rainy";
  if(S == "Rainy") cout << "Sunny";

}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=[input() for _ in range(H)]
ans='Yes'
for i in range (H):
  for j in range (W):
    if S[i][j]=='#':
      if S[max(0,i-1)][j]!='#' and S[min(i+1,H-1)][j]!='#' and S[i][max(0,j-1)]!='#' and S[i][min(j+1,W-1)]!='#':
        ans='No'
        break
print(ans)

Measured memory_bytes: 3064
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

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

    if (N % 2 != 0) {
        cout << "No" << endl;
    } else {
        if (S.substr(0, N / 2) == S.substr(N / 2, N)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int getH(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<n; j++) {
			if (board[i][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getV(char** board, int n)
{
	int res = 0;
	for (int j=0; j<n; j++) {
		int count = 0;
		for (int i=0; i<n; i++) {
			if (board[i][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getLD(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[j][i-j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	for (int i=0; i<n-1; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[n-1-i+j][n-1-j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int getRD(char** board, int n)
{
	int res = 0;
	for (int i=0; i<n; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[j][n-1-i+j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	for (int i=0; i<n-1; i++) {
		int count = 0;
		for (int j=0; j<=i; j++) {
			if (board[n-1-i+j][j] == '0') count = 0;
			else {
				count++;
				if (count > res) res = count;
			}
		}
	}
	return res;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		char** board = new char*[n];
		for (int i=0; i<n; i++) board[i] = new char[n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) std::cin >> board[i][j];
		}
		int res = std::max( std::max(getH(board,n), getV(board,n)), std::max(getLD(board,n), getRD(board,n)) );
		std::cout << res << std::endl;
		for (int i=0; i<n; i++) delete[] board[i];
		delete[] board;
	}
	return 0;
}



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

bool from1[200010],ton[200010];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(a==1)from1[b]=true;
        else if(b==1)from1[a]=true;
        else if(a==n)ton[b]=true;
        else if(b==n)ton[a]=true;
    }
    for(int i=2;i<=n-1;i++){
        if(from1[i]&&ton[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(n, m);
	ll h[lim5] = {};
	repp(i, n) {
		cin >> h[i];
	}
	// int a[lim5] = {}, b[lim5] = {};
	map<int, vector<int>> map;
	repp(i, m) {
		int a, b;
		cin >> a >> b;
		map[a].push_back(b);
		map[b].push_back(a);
	}
	repp(i, n) {
		// for(auto j : map[i]) errr(i, j);
		sort(map[i].begin(), map[i].end());
		map[i].erase(unique(map[i].begin(), map[i].end()), map[i].end());
		// err("---");
		// for(auto j : map[i]) errr(i, j);
		// err("-----");
	}
		// err("-------");
	int ans = 0;
	repp(i, n) {
		bool escape = false;
		for(auto j : map[i]) {
			// errr(i, j);
			if (h[j] >= h[i]) {
				escape = true;
				break;
			}
		}
		if (escape) continue;
		++ans;
	}
	out(ans);
    return 0;
}


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

int main()
{
  cin>>N;
  vector<int> a(N);
  for(int i=0; i<N; i++)  cin>>a[i];

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

  int A = 0;
  int B = 0;
  for(int i=0; i<N; i++){
    if(i%2 == 0)  A += a[i];
    else  B += a[i];
  }
  cout<<A-B<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, K; cin >> N >> K;
	vi h(N);
	REP(i,N) cin >> h[i];
	vi dp(N + 99, numeric_limits<int>::max());
	dp[0] = 0;
	REP(i,N - 1) {
		FOR(j, 1, K + 1) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[N - 1] << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,a,b;
    cin >> n >> a >> b;
    // a-bが偶数: 間に収束
    // a-bが奇数: 一番上か一番下
    // 一番上か一番下で1つ止まってから進んでいく方法があった
    int64_t res;
    if(abs(a-b)%2 == 0){
        res = abs(a-b)/2;
    }else{
        int64_t topCount = abs(a-b)/2 + min(a,b);
        int64_t botCount = abs(a-b)/2 + n-max(a,b)+1;
        res = min(topCount, botCount);
    }
    cout << res << endl;
}

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

public class Main {

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

    int i = 0;
    int j = 0;
    int k = 0;

    char now = 'a';

    while (true) {
      if (now == 'a') {
        if (i == aString.length()) {
          System.out.println("A");
          return;
        }
        now = aString.charAt(i);
        i++;
      } else if (now == 'b') {
        if (j == bString.length()) {
          System.out.println("B");
          return;
        }
        now = bString.charAt(j);
        j++;
      } else if (now == 'c') {
        if (k == cString.length()) {
          System.out.println("C");
          return;
        }
        now = cString.charAt(k);
        k++;
      }
    }


  }

}


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

using namespace std;


int main()
{  	
	int n,m;
	int a,b,c;
	cin>>n>>m;
	stack <int> s[n];
	for(int i=1;i<=m;i++)
	{cin>>c;
		if(c==0)
		{
			cin>>a>>b;
			s[a].push(b);	
		}
		else if(c==1)
				{cin>>a;
				 if (!s[a].empty() )cout<<s[a].top()<<endl;}
		else if(c==2)
				{cin>>a;
				 if (!s[a].empty() )s[a].pop();
				 //cout<<endl;
				 }		 
	}
   
	
	
	
	return 0;
} 


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    ll x,res = 0;
    cin >> x;
    ll cur = 100;
    while (cur < x) {
        res++;
        cur = cur + cur / 100;
    }
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
  int H,W;
  int i,j;
  
  while(scanf("%d %d",&H,&W)!=EOF)
  {
  	if(H==0&&W==0)break;
  	for(i=0;i<H;i++)
  	{
  		for(j=0;j<W;j++)
  		{
  			if((i+j)%2==0)printf("#");
  			else printf(".");
  		}
  		printf("\n");
  	}
  	printf("\n");
  }

 return 0;
}

Measured memory_bytes: 572
N = int(input())
L = list(map(int, input().split()))

l = set(L)
di = {}
for c in l:
    di[c] = L.count(c)

cnt = 0
L = list(set(L))
L = sorted(L)


if N >= 3:
    for i in range(len(L)-2):
        for j in range(i+1, len(L)-1):
            for k in range(j+1, len(L)):
                if L[i]+L[j] > L[k]:
                    cnt += di[L[i]]*di[L[j]]*di[L[k]]
    print(cnt)

else:
    print(0)


Measured memory_bytes: 9184
//10-5 通勤経路
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int w,h;
int dp[101][101][2];

int solve(int x, int y, int m){//1のとき北方向、0のとき南方向
    if(dp[x][y][m]!=INT_MAX) return dp[x][y][m];
    if(x==w || y==h) return 1;
    LL re = 0;
    //曲がらない
    if(m==1 && y+1<=h) re += solve(x,y+1,1);
    if(m==0 && x+1<=w) re += solve(x+1,y,0);
    //曲がる
    if(m==1 && x+2<=w) re += solve(x+2,y,0);
    if(m==0 && y+2<=h) re += solve(x,y+2,1);
    dp[x][y][m] = re%100000;
    return re%100000;
}

int main(){
    ROOP(){
        cin >> w >> h;
        if(w==0 && h==0) break;
        for(int i=0; i<w+1; i++){
            for(int j=0; j<h+1; j++){
                dp[i][j][0] = INT_MAX;
                dp[i][j][1] = INT_MAX;
            }
        }
        cout << (solve(1,2,1)+solve(2,1,0)) % 100000 << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int n,a[5],b;
char s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=='P')a[1]++;
		if(s=='W')a[2]++;
		if(s=='G')a[3]++;
		if(s=='Y')a[4]++;
	}
	for(int i=1;i<=4;i++)
	{
		if(a[i])b++;
	}
	if(b==3)cout<<"Three";
	else cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,i;
    cin>>n>>l;
    vector<string>a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(i=0;i<n;i++)
        cout<<a[i];
    cout<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    int N,K; cin >> N >> K;
    int ans=K;
    if (K>=2) {
        for (int i=1;i<N;i++)ans *= (K-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n,m=0;
string a,b,c;
cin>>n>>a>>b>>c;
for(int i=0;i<n;i++){
  if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]) m+=2;
  else if(a[i]==b[i]&&b[i]==c[i]) ;
  else m++;
}
cout<<m;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int D;
    cin>>D;
    if (D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==25){
        cout<<"Christmas"<<endl;
    }
return 0;
}
  




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    char c;
    cin >> c;

    switch(c){
        case 'A': cout << 'T'; break;
        case 'T': cout << 'A'; break;
        case 'G': cout << 'C'; break;
        case 'C': cout << 'G'; break;
    }

    return 0;
}

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

int main(){
 int i,n,sum=100000;
 cin>>n;
 for(i=0;i<n;i++){
	 sum *=1.05;
	 //cout<<sum<<endl;
	 if((sum%1000)>0){
		sum=sum-sum%1000;
		sum+=1000;
	 }
 }
 cout<<sum<<endl;
}

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

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

	int look = D * 2 + 1;
	int ans = N % look == 0 ? N / (D * 2 + 1) : N / (D * 2 + 1) + 1;

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


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

int n, s, sum_min = 1e6, a[101], maxx;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        {cin >> a[i]; if (a[i] > maxx) maxx = a[i];}
    for (int i = 1; i <= maxx; ++i)
    {
        s = 0;
        for (int j = 1; j <= n; ++j)
        {
            s += (a[j] - i) * (a[j] - i);
        }
        if (s < sum_min) sum_min = s;
    }
    cout << sum_min;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  LL n;
  cin >> n;
  VLL a(n),b(n,0);
  REP(i,0,n){
    cin >> a.at(i);
    while(a.at(i)%2 == 0){
      a.at(i) /= 2;
      b.at(i)++;
    }
  }
  
  sort(b.begin(),b.end());
  
  cout << b.at(0) << endl;
  
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,t,o;
	cin>>a>>b>>c>>d;
	if(a%d==0) o=a/d;
	else o=a/d+1;
	if(c%b==0) t=c/b;
	else t=c/b+1;
	if(t<=o) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 3636