akhauriyash/Code-Regression huggingface dataset:
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

int main() {
	long long N, K;
	cin >> N >> K;

	long long p = N % K;
	long long ans = 0;
	do {
		ans = p;
		p = abs(ans - K);
	} while (ans > p);

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

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=2002020;
int n,m,k,ans,suma[N],sumb[N];
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
#undef int
int main()
{
	#define int long long
	n=read(); m=read(); k=read();
	for(int i=1;i<=n;i++)suma[i]=suma[i-1]+read();
	for(int i=1;i<=m;i++)sumb[i]=sumb[i-1]+read();
	for(int i=0;i<=n;i++){
		if(suma[i]>k)break;
		int tmp=k-suma[i];
		int l=1,r=m,th=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(tmp>=sumb[mid])l=mid+1,th=mid;
			else r=mid-1;
		} ans=max(ans,i+th);
	} cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define ll long long int
ll n,k;
using namespace std;
int main() {			
cin>>n>>k;
int arr[n];
int memo[n];
for(int i=0;i<n;i++)
cin>>arr[i];
for(int i=0;i<n;i++)
memo[i]=INT_MAX;
memo[0]=0;
//memo[1]=abs(arr[0]-arr[1]);//Queda rebundante. Sigue siendo 10000
for(int i=0;i<n;i++)
for(int j=1;j<=k&&j+i<n;j++)
memo[j+i]=min(memo[j+i],memo[i]+abs(arr[i]-arr[j+i]));
cout << memo[n-1] << endl;
return 0;
}

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

int main(){
  int A,B,C;
  cin >>A>>B>>C;
  
  string ans;
  
  if(A==5&&B==5&&C==7)ans="YES";
  else if(A==5&&C==5&&B==7)ans="YES";
  else if(B==5&&C==5&&A==7)ans="YES";
  else ans = "NO";
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + y1 - y2 << " " << y2 - x1 + x2 << " ";
    cout << x1 + y1 - y2 << " " << y1 + x2 - x1 << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  
  set<int> number;
  int count = 0;
  
  for(int i = 0; i < N; i++){
    auto it = number.find(A.at(i));
    if(it != number.end()) {
      number.erase(A.at(i));
      count --;
    }
    else{
      number.insert(A.at(i));
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 5376
def d_handstand(N, K, S):
    index_switched = [0] + [i for i in range(1, N) if S[i] != S[i - 1]]

    ans_candidate = []
    for k in range(len(index_switched)):
        if S[index_switched[k]] == '0':
            t = index_switched[k + 2 * K] if k + 2 * K < len(index_switched) else N
            ans_candidate.append(t - index_switched[k])
        elif S[index_switched[k]] == '1':
            t = index_switched[k + 2 * K + 1] if k + 2 * K + 1 < len(index_switched) else N
            ans_candidate.append(t - index_switched[k])
    return max(ans_candidate)

N, K = [int(i) for i in input().split()]
S = input()
print(d_handstand(N, K, S))

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

int main(){
    string s;
    cin >> s;
    int ans = 700;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'o') ans += 100;
    }

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

Measured memory_bytes: 256
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


X = INT()

def f(a, b):
    return a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4

for alpha in range(1, int(X**0.5)+1):
    if X % alpha == 0:
        beta = X // alpha

        a = alpha // 2
        b = a - alpha

        while f(a, b) <= beta:
            if f(a, b) == beta:
                break
            a += 1
            b += 1
        
        else:
            continue
        break

print(a, b)

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

map<string,int> table;

int main() {

	string word, frequent, longest;
	size_t N=0;

	while ( cin >> word ) {

		table[word] += 1;

		if ( table[word] > N ) {

			N = table[word];
			frequent = word;

		}

		if ( word.size() > longest.size() ) {

			longest = word;

		}

	}

	cout << frequent << " " << longest << endl;

}

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

int main() {

    int n, y; cin >> n >> y;
    
    int c1 = -1;
    int c2 = -1;
    int c3 = -1;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i - j;
            if (k < 0) continue;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                c1 = i;
                c2 = j;
                c3 = k;
                break;
            }
        }
    }

    cout << c1 << " " << c2 << " " << c3 << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
K = int(input())
Q = collections.deque([(1, 1)])
searched = set()
while True:
    n, d = Q.popleft()
    r = n % K
    if not r in searched:
        if r == 0:
            break
        else:
            searched.add(r)
            Q.append((n + 1, d + 1))
            Q.appendleft((n * 10 % K, d))
print(d)
# https://img.atcoder.jp/arc084/editorial.pdf


Measured memory_bytes: 21220
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  vector<P> robots;

  rep(i, N){
    ll x, l;
    cin >> x >> l;
    robots.push_back({x-l, x+l});
  }

  sort(ALL(robots), [](P a, P b){return a.second<b.second;});

  /*
  rep(i, N){
    cout << endl << robots[i].first << " " << robots[i].second;
    }*/
  
  ll ans = 1;
  ll val = robots[0].second;
  rep(i, N){
    if(val<=robots[i].first){
      val = robots[i].second;
      ans++ ;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define N 200003
int n, num_w=0, num_b=0, sum_w[N], sum_b[N], ret = N+10;
string str;
int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int i;
	cin>>n>>str;	
	num_w=sum_w[0] = str[0]=='.';
	num_b=sum_b[0] = str[0]=='#';
	for(i=1; i<n; i++){	
		if(str[i]=='.'){
			num_w++;
			sum_w[i]=sum_w[i-1]+1;
			sum_b[i]=sum_b[i-1];
		} else{
			num_b++;
			sum_w[i]=sum_w[i-1];
			sum_b[i]=sum_b[i-1]+1;
		}
	}
	ret = num_w;  // 全变为黑色 
	for(i=0; i<n; i++){
		ret = min(ret, sum_b[i]+num_w-sum_w[i]);
	}
	
	cout<<ret<<endl;
	
	return 0;
}


Measured memory_bytes: 2196
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int main(){
  int i, j, k;
  cin >> n >> m;
  if(n > m)swap(n, m);
  int a = (n + m) / 2;
  if(a - n != m - a)cout << "IMPOSSIBLE" << endl;
  else cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        long p = nl(), q = nl(), r = nl();
        pn(p+q+r-Math.max(Math.max(p,q),r));
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1000000007, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>

int p[20];

int main(int argc, char **argv)
{
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) std::cin >> p[i];
    int c = 0;
    for (int i = 1; i < n - 1; i++) {
        int c1 = std::max(std::max(p[i - 1], p[i]), p[i + 1]);
        int c2 = std::min(std::min(p[i - 1], p[i]), p[i + 1]);

        if (p[i] != c1 && p[i] != c2) ++c;
    }

    std::cout << c << std::endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
  public class Program
  {
    static void Main(string[] args)
	  {
      int target = 0;
      string[] input = Console.ReadLine().Split(' ');
      int[] nums = new int[5];
      for (int i = 0; i < 5; i++)
      {
        nums[i] = int.Parse(input[i]);
      }
      for (int i = 0; i < 5; i++)
      {
        if (nums[i] == 0)
        {
          target = i + 1;
        }
      }
      Console.WriteLine(target);
	  }
  }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	string S;cin>>S;
	vint acc(N+1);
	rep(i,N){
		acc[i+1]=acc[i]+(S[i]=='#');
	}

	int ans=N;
	rep(i,N+1){
		int p=acc[i];
		int s=N-i-(acc[N]-acc[i]);
		chmin(ans,p+s);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2180
s = input()

len_s = len(s)
ans = 0

for i in range(2**(len_s-1)):
    num = s[0]
    rnum = 0
    for j in range(len_s-1):
        flag = i >> j & 1
        if flag == 1:
            rnum += int(num)
            num = s[j+1]
        else:
            num += s[j+1]
    ans += rnum + int(num)

print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	int a[3] = {};
	int d;
	cin >> a[0] >> a[1] >> a[2] >> d;
	//sort(a, a + 3);
	if (abs(a[1] - a[0]) <=d&& abs(a[2] - a[1]) <= d)cout << "Yes" << endl;
	else if (abs(a[2] - a[0]) <= d)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from math import sqrt

def cross(p0, p1, p2):
  x0, y0 = p0
  x1, y1 = p1
  x2, y2 = p2
  x1 -=x0
  x2 -=x0
  y1 -=y0
  y2 -=y0
  return x1*y2 - x2*y1

def dot(p0, p1, p2):
  x0, y0 = p0
  x1, y1 = p1
  x2, y2 = p2
  x1 -=x0
  x2 -=x0
  y1 -=y0
  y2 -=y0
  return x1*x2 + y1*y2

def dist2(p0, p1):
  x0, y0 = p0
  x1, y1 = p1
  return (x1-x0)**2 + (y1 - y0)**2

def collision_ll(s0, s1,t0,t1):
  return cross(s0, s1,t0)*cross(s0,s1,t1)<0 and cross(t0, t1,s0) * cross(t0,t1,s1) < 0

def dist_lp(S,E,P):
  dd = dist2(S,E)
  if 0 <= dot(S,E,P) <= dd:
    return abs(cross(S,E,P))/sqrt(dd)
  return sqrt(min(dist2(S,P), dist2(E,P)))

def dist_ll(s0, s1, t0, t1):
  if collision_ll(s0,s1,t0,t1):
    return 0
  return min(
    dist_lp(s0, s1, t0),
    dist_lp(s0, s1, t1),
    dist_lp(t0, t1, s0),
    dist_lp(t0, t1, s1)
    )

n = int(input())
for i in range(n):
  x0,y0,x1,y1,X0,Y0,X1,Y1 = map(int,input().split())
  print("%.010f"%dist_ll((x0,y0), (x1,y1), (X0,Y0),(X1,Y1)))



Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  string s;
  vector<int> l;
  cin>>s;
  int A,B,C;
  A=stringcount(s,char('a'));
  B=stringcount(s,char('b'));
  C=stringcount(s,char('c'));
  l.pb(A);
  l.pb(B);
  l.pb(C);
  sort(all(l));
  if(l[2]-l[0]>1){
    cout<<"NO";
  }
  else{
    cout<<"YES";
  }
}

Measured memory_bytes: 512
c = input().rstrip().split(' ')
number = input().rstrip().split(' ')
num1 = int(number[0])
num2 = int(number[1])
ans = input()

if c[0]==ans:
    num1 -= 1
elif c[1]==ans:
    num2 -= 1

print(str(num1) +' '+ str(num2))

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  vii a(n, vi(n));
  rep (i, n) {
    rep (j, n) {
      cin >> a[i][j];
    }
  }
  int m = 1 << n;
  vll dp(n + 1, vl(m));
  dp[0][0] = 1;
  rep (i, n) {
    rep (j, m) {
      if (dp[i][j] == 0) continue;
      int mask = 1;
      rep (k, n) {
        if (a[i][k] == 0 || (j & mask)) {
          mask <<= 1;
          continue;
        }
        (dp[i + 1][j + mask] += dp[i][j]) %= MOD;
        mask <<= 1;
      }
    }
  }
  cout << dp[n][m - 1] << endl;
}
      


Measured memory_bytes: 377216
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        counter = collections.Counter(S)
        if len(counter) != 2:
            print("No")
            exit()

        for v in counter.values():
            if v != 2:
                print("No")
                exit()
        print("Yes")


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    while(cin >> N >> M){
        int Q; cin >> Q;
        vector<int> order;
        vector<int> used(M, 0);
        vector<int> q(Q);
        for(auto& t : q){ cin >> t; --t; }
        reverse(q.begin(), q.end());
        for(auto& t : q){
            if(used[t]) continue;
            used[t] = 1;
            order.push_back(t);
        }
        for(int i=0;i<M;i++) if(!used[i]) order.push_back(i);
        reverse(order.begin(), order.end());
        vector<int> idx(M);
        for(int i=0;i<M;i++) idx[order[i]] = i;
        vector<int> stock(M, 0);
        for(int i=0;i<M;i++){
            if(i+1 == M || order[i] < order[i+1]){
                stock[i] = N;
                break;
            }
        }
        reverse(q.begin(), q.end());
        for(auto& t : q){
            int p = idx[t];
            if(p == 0) continue;
            if(stock[p-1] > 0){
                --stock[p-1];
                ++stock[p];
            }
        }
        cout << (stock.back() >= N ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 2296
/*  ex9_1
    Acro   */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10000

/* stackの定義 */
typedef struct{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char x);
char pop(stack *stk);

stack stk;

int main(void){
    int i;
    char string[SIZE];
    /* 入力 */
    scanf("%s",string);
    /* stackの初期化 */
    initialize_stack(&stk);
    /* 文字数の分ループ */
    for ( i = 0; i < strlen(string); i++)
    {
        if (string[i] == 'B')
        {
            /* stackが空でない場合、pop */
            if (stk.count > 0)
            {
                pop(&stk);
            }
            
        }
        else
        {
            /* B以外の場合、挿入 */
            push(&stk,string[i]);
        }
        
    }
    /* 出力 */
    for ( i = 0; i < stk.count; i++)
    {
        printf("%c",stk.data[SIZE-1-i]);
    }
    printf("\n");
    return 0;
}


/* stackの初期化 */
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
/* 要素の挿入 */
void push(stack *stk, char x){
    if (stk->count >= stk->size)
    {
        printf("Error : stack overflow\n");
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = x;
        stk->count++;
    }
}
/* 要素の取り出し */
char pop(stack *stk){
    char x;
    if(stk->count <= 0)
    {
        printf("Error : stack underflow\n");
        exit(1);
    }
    else
    {
        x = *(stk->top);
        stk->top++;
        stk->count--;
        return x;
    }
    
}

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

int main(){
    vector<int> K(32);
    K.at(0)=1;
    K.at(1)=1;
    K.at(2)=1;
    K.at(3)=2;
    K.at(4)=1;
    K.at(5)=2;
    K.at(6)=1;
    K.at(7)=5;
    K.at(8)=2;
    K.at(9)=2;
    K.at(10)=1;
    K.at(11)=5;
    K.at(12)=1;
    K.at(13)=2;
    K.at(14)=1;
    K.at(15)=14;
    K.at(16)=1;
    K.at(17)=5;
    K.at(18)=1;
    K.at(19)=5;
    K.at(20)=2;
    K.at(21)=2;
    K.at(22)=1;
    K.at(23)=15;
    K.at(24)=2;
    K.at(25)=2;
    K.at(26)=5;
    K.at(27)=4;
    K.at(28)=1;
    K.at(29)=4;
    K.at(30)=1;
    K.at(31)=51;
    int A;
    cin >> A;
    cout << K.at(A-1);
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
ll powModulo(ll a,ll b)
{
    ll ans=1;
    while(b>0)
    {
        if (b&1)
        {
            ans=ans*a;
        }
        b /=2;
        a=a*a;
    }
    return ans;
}
int main()
{
	IOS;
    cout.precision(30);
    ll n;cin >> n;
    cout << powModulo(n,3);
    return 0;
}


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

int main()
{
    long long int n, k;
    cin >> n >> k;
    long long int j1 = abs(n - k), j2 = abs(k - j1), j3 = abs(k - j2);
    if (n >= k)
    {
        long long int j5 = n - (n / k) * k;
        j5 = min(j5, min(abs(k - j5), abs(k - abs(k - j5))));
        j3 = min(j3, j5);
    }
    cout << min(j1, min(j3, j2));
}

Measured memory_bytes: 256
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

int buf[10];
int A[10];
int B[10];
int main(){
    int N;
    cin>>N;
    bool af=false;
    bool bf=false;
    int aval=1;
    int bval=1;
    for(int i=0;i<N;i++){
        buf[i]=i+1;
    }
    for (int i=0; i<N;i++) {
        cin>>A[i];
    }
    for (int i=0; i<N;i++) {
        cin>>B[i];
    }
    do{
        if (!af) {
            if (memcmp(A, buf, sizeof(int)*N)==0) {
                af=true;
            }else{
                aval++;
            };
        }
        if (!bf) {
            if (memcmp(B, buf, sizeof(int)*N)==0) {
                bf=true;
            }else{
                bval++;
            };
        }
        if (af&&bf) {
            break;
        }
    }while(next_permutation(buf, buf+N));
    cout<<abs(aval-bval)<<endl;
    

}




Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <set>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 1010;
int a[maxn][maxn];
int ap[maxn];
int last[maxn];
std::set<int> wait[maxn];

int n;
void update(int x) {
	if(ap[x] == n)
		return;

	int y = a[x][ap[x]];

	if(wait[x].count(y)) {
		wait[x].erase(y);

		int now = std::max(last[x], last[y]) + 1;
		last[x] = last[y] = now;

		ap[x] ++;
		ap[y] ++;

		update(x);
		update(y);
	}

	else {
		wait[y].insert(x);
	}
}

int main() {
	n = input();

	for(int i = 1; i <= n; i ++)
		for(int j = 1; j < n; j ++)
			a[i][j] = input();

	for(int i = 1; i <= n; i ++)
		ap[i] = 1;

	for(int i = 1; i <= n; i ++)
		update(i);

	bool empty = true;
	for(int i = 1; i <= n; i ++)
		if(not wait[i].empty())
			empty = false;

	if(empty) {
		int ans = 0;
		for(int i = 1; i <= n; i ++)
			ans = std::max(ans, last[i]);
		printf("%d\n", ans);
	}

	else
		puts("-1");
}


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

int main(){
  int N;
  scanf("%d", &N);
  using pr = tuple<int, string, int>;
  vector<pr> ppr(N);
  
  for(int i = 0; i < N; i++){
    string f;
    int s;
    cin >> f >> s;
    int id = i + 1;
    ppr.at(i) = make_tuple(id, f, s);
  }
  
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      int s[2] = {0, 0};
      string f[2] = { " ", " " };
      tie(ignore, f[0], s[0]) = ppr.at(i);
      tie(ignore, f[1], s[1]) = ppr.at(j);
      
      if(f[0] > f[1]){
        swap(ppr.at(i), ppr.at(j));
      }
      else if(f[0] == f[1]){
        if(s[0] < s[1]){
          swap(ppr.at(i), ppr.at(j));
        }
      }
    }
  }
  
  for(auto &b : ppr){
    int id;
    tie(id, ignore, ignore) = b;
    cout << id << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
s=input()

m=int(s)
n=len(s)

for i in range(1,n):
    for j in range(0,n-i+1):
        if j==0 or j==n-i:
            m+=int(s[j:j+i])*2**(n-1-i)
        else:
            m+=int(s[j:j+i])*2**(n-2-i)
print(m)


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<long long> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    for(int i=0;i<k;i++){
        h.pop_back();
    }
    long long sum=0;
    for(int i=0;i<n-k;i++){
        sum+=h[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN],sieve[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    sieve[0]=sieve[1]=1;
    for(int i=2;i<=1e5+5;i++){
        if(sieve[i]) continue;
        for(int j=2*i;j<=1e5+5;j+=i)
            sieve[j]=i;
    }
    for(int i=2;i<1e5+5;i++){
		if(sieve[i]==0 && sieve[(i+1)/2]==0)
			tab[i]=1;
		tab[i]+=tab[i-1];
	}
	int l,r,q;
    cin >> q;
    while(q--){
		cin >> l >> r;
		cout << tab[r]-tab[l-1] << '\n';
	}
}


Measured memory_bytes: 5120
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 3e3+23;
const int maxn = 2e5+35;
int a[maxm],b[maxm],c[maxm],d[maxm],e[maxm],f[maxm];
vector<int> x,y;
int D[maxm][maxm],U[maxm][maxm],L[maxm][maxm],R[maxm][maxm];
inline int getx(int val){
    return lower_bound(all(x),val) - x.begin() + 1;
}
inline int gety(int val){
    return lower_bound(all(y),val) - y.begin() + 1;
}
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
bool check(int fx,int fy){
    return fx>0&&fx<=sz(x)&&fy>0&&fy<=sz(y);
}
int vis[maxm][maxm];
LL solve(int sx,int sy){
    queue<pii> q; q.push(pii(sx,sy)); vis[sx][sy] = 1; 
    LL ans = 0;
    while(!q.empty()){
        pii now = q.front(); q.pop();
        ans += 1ll*(x[now.x]-x[now.x-1])*(y[now.y]-y[now.y-1]);
        for(int i = 0;i < 4; ++i){
            if(i==0&&U[now.x][now.y]) continue;
            if(i==1&&D[now.x][now.y]) continue;
            if(i==2&&R[now.x][now.y]) continue;
            if(i==3&&L[now.x][now.y]) continue;
            int fx = now.x+dx[i],fy = now.y+dy[i];
            if(check(fx,fy)){
                if(!vis[fx][fy]){
                    vis[fx][fy] = 1;
                    q.push(pii(fx,fy));
                }
            }
            else return -1;
        }
    }
    return ans;
}
int main(){
    int n,m; scanf("%d %d",&n,&m);
    for(int i = 1;i <= n; ++i){
        scanf("%d %d %d",a+i,b+i,c+i);
        x.push_back(a[i]);
        x.push_back(b[i]);
        y.push_back(c[i]);
    }
    for(int i = 1;i <= m; ++i){
        scanf("%d %d %d",d+i,e+i,f+i);
        x.push_back(d[i]);
        y.push_back(e[i]);
        y.push_back(f[i]);
    }
    x.push_back(0); y.push_back(0);
    sort(all(x)); sort(all(y));
    x.erase(unique(all(x)),x.end());
    y.erase(unique(all(y)),y.end());
    for(int i = 1;i <= n; ++i){
        a[i] = getx(a[i]);b[i] = getx(b[i]);c[i] = gety(c[i]);
        for(int j = a[i];j < b[i]; ++j){
            U[j][c[i]-1] = 1;
            D[j][c[i]] = 1;
        }
    }
    for(int i = 1;i <= m; ++i){
        d[i] = getx(d[i]);e[i] = gety(e[i]);f[i] = gety(f[i]);
        for(int j = e[i];j < f[i]; ++j){
            L[d[i]][j] = 1;
            R[d[i]-1][j] = 1;
        }
    }
    LL res = solve(getx(0),gety(0));
    if(res == -1) puts("INF");
    else cout << res << '\n';
    return 0;
}

Measured memory_bytes: 114496
N=int(input())
S='abcdefghijklmnopqrstuvwxyz'
A=['a']
for _ in range(N-1):
    now=[]
    for a in A:
        b=sorted(list(a))[-1]
        bi=S.index(b)
        for i in range(bi+2):
            now.append(a+S[i])
    A=now.copy()
A.sort()
for a in A:
    print(a)

Measured memory_bytes: 19540
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
//#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)1e5 * 5 + 22;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int n, a[N], x;
int main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> x;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] >= x) cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> cnt(n, 0);
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            int dis = min({j-i, abs(i-x)+1+abs(y-j)});
            ++cnt[dis];
        }
    }
    for(int i = 1; i < n; ++i){
        cout << cnt[i] << '\n';
    }
    
    
    return 0;
}


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

int main(){
  long long l, r; cin >> l >> r;
  int max_iter = min(r + 1, l + 2020);
  int ans = 2018;
  
  long long mul;
  
  for(long long i = l; i < max_iter; i++){
    for(long long j = i + 1; j < max_iter; j++){
      mul = i * j;
      if(mul % 2019 < ans){
        ans = mul % 2019;

      }
    }
  }
  
  cout << ans << endl;

}


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

int main(){
        int e,x,y,z,m,min;

        while(1) {
                min=1000000;
                cin >> e;
                if(e==0) {
                        break;
                }
                else{
                        for(y=0; y<=1000; y++) {
                                for(z=0; z<=100; z++) {
                                        x=e-z*z*z-y*y;
                                        if((min>x+y+z)&&(x>=0)) {
                                                min=x+y+z;
                                        }
                                }
                        }
                }
                cout<<min<<endl;
        }

}



Measured memory_bytes: 2996
N = int(input())
P = []

for i in range(N):
    A, B = map(int, input().split())
    P.append((A + B, -A, B))

P.sort()
P.reverse()

ans = 0
turn = 1
for i in range(N):
    ans -= P[i][turn]
    turn = 3 - turn

print(ans)

Measured memory_bytes: 61272
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
//	freopen("SNOOKER.inp","r",stdin);
//	freopen("SNOOKER.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
/*----------------------------------------------------------------------
2
3 4
2 4 2
3 3
3 3 3
-----------------------------------------------------------------------*/
using ll =  long long;
#define endl "\n"
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define what_is(x)  cerr << #x << " is :" << (x) << endl
#define what_are(x,y) cerr << #x <<" is : " << (x) <<" ; " << #y <<" is: " <<y << endl
#define pii pair<int,int>
#define fs first
#define sc second
const int MOD =  1e9+7;
const int inf = INT_MAX;
const int MAX_N = 1e5 + 7;


int n, w, s = 0;
ll wei[107], v[107];
ll dp[107][100007];
void solve()
{
	
	
	
	cin >> n >> w;
	for(int i = 1; i<= n; i++)
	{
		cin >> wei[i] >> v[i];
		
	}
	fill(dp[0] , dp[0] + MAX_N, 0);
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			
			dp[i][j] = dp[i-1][j];
			if(j >= wei[i])
			{
				dp[i][j] = max(dp[i][j], dp[i-1][j - wei[i]] + v[i]);
			}
			
		}
	}
	
	cout << dp[n][w];
		
	
	
	
}


Measured memory_bytes: 80128
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	bool strong = true;
	cin >> s;
	int x = s.size();
	for (int i = 0; i < x / 2; ++i) {
		if (s[i] != s[x - i - 1]) {
			strong = false;
		}
	}
	for (int i = 0; i < ((x - 1) / 2) / 2; ++i) {
		if (s[i] != s[(x - 1) / 2 - i - 1]) {
			strong = false;
		}
	}
	for (int i = 0; i < (x-(x+3)/2)/2; ++i) {
		if (s[i] != s[x - i - 1]) {
			strong = false;
		}
	}
	if (strong) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}


Measured memory_bytes: 256
from math import factorial

def comb(n, k):
    f = factorial
    return f(n) / f(k) / f(n-k)

N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())

v.sort(reverse = True)

t = v[A-1]

ans = 0
X, Y = v.count(t), v[:A].count(t)

if (v[0] != v[A-1]):
    ans = comb(X, Y)

else:
    for i in range(A, B+1):
        if(i <= X):
            ans += comb(X, i)

print float(sum(v[0:A]))/A
print ans

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

bool kaibun(string s) {
  if (s.size() != 2) {
    for (int i = 0; i < (s.size() - 1) / 2; i++) {
      if (s.at(i) != s.at(s.size() - i - 1)) {
        return false;
      }
    }
  } else {
    if (s.at(0) != s.at(1)) {
      return false;
    }
  }
  return true;
}

int main() {
    string s;
    cin >> s;
    if (kaibun(s) && kaibun(s.substr(0, (s.size() - 1) / 2)) && kaibun(s.substr((s.size() + 3) / 2 - 1))) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

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

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

    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());

    bool sta = false;
    for(int i=0; i<n-1; i++){
        if(a.at(i)==a.at(i+1)){
            cout << "NO" << endl;
            sta = true;
            break;
        }
    }

    if(!sta){
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();
		long AA = 0;
		long BB = 0;
		long CC = 0;

		AA = B + C;
		BB = A + C;
		CC = A + B;
		A = AA;
		B = BB;
		C = CC;
/*
		for(int i = 0; i < K; i++) {

			if((A == B) && (B == C) && (C == A)) {
				break;
			}
			AA = B + C;
			BB = A + C;
			CC = A + B;
			A = AA;
			B = BB;
			C = CC;

			if (Math.abs(A - B) > Math.pow(10, 18)) {
				break;
			}

		}

		if (Math.abs(A - B) > Math.pow(10, 18)) {
			System.out.println("Unfair");
		}else {
			System.out.println(A - B);
		}
		*/
		//答えの絶対値が10の18乗を超える
		if (Math.abs(A-B) > Math.pow(10, 18)) {
			System.out.println("Unfair");
		}
		else if (K % 2 == 1) {
			System.out.println(A - B);
		}
		else if(K % 2 == 0) {
			System.out.println(-(A - B));
		}

	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define PI 3.1415926535897932384626
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	ll n;
	cin>>n;
	string ans;
	while(n) {
		n--;
		ans+=('a'+n%26);
		n/=26;
	}
	reverse(all(ans));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    REP(i,n){
        cin >> x[i];
    }
    int res = 0;
    REP(i,n){
        res += min(abs(x[i]),abs(k-x[i]));
    }
    put(res*2);
}


Measured memory_bytes: 256
#include "stdio.h"

int ac[5000];
int bc[5000];

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	for(int i = 0; i < a; i++)
	{
		scanf("%d",&(ac[i]));
	}
	for(int i = 0; i < b; i++)
	{
		scanf("%d",&(bc[i]));
	}
	int n;
	int big = 0;
	for(int i = 0; i < b; i++)
	{
		n = 0;
		for(int ii = 0; ii < a; ii++)
		{
			if(bc[i + n] == ac[ii])
			{
				n++;
			}
		}
		if(n > big)
		{
			big = n;
		}
	}
	printf("%d\n",big);
}

Measured memory_bytes: 1060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

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

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

int main(){
	init();
	ll N;cin>>N;
	vector<ll>v(100006,0);
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		a++;
		v[a-1]++;
		v[a]++;
		v[a+1]++;
	}
	ll ans=0;
	for(int i=0;i<100006;i++){
		ans=max(v[i],ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int maxv = -1000000000;
    a[0] = sc.nextInt();
    int minv = a[0];
    for(int i = 1; i<n; i++){
      a[i] = sc.nextInt();
      maxv = Math.max(maxv, a[i]-minv);
      minv = Math.min(minv,a[i]);
    }
    System.out.println(maxv);
  }
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long d = sc.nextLong();
        out.println(Math.max(Math.max(a * d, a * c), Math.max(b * c, b * d)));
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public 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: 32824
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    long long int a, mini = 753;

    cin >> a;

    while (a > 99) {
        mini = min(mini, abs(753 - (a%1000)));
        a /= 10;
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
for tsuru in range(200):
    for kame in range(200):
        num = tsuru + kame
        ashi = tsuru * 2 + kame * 4 
        if x == num and ashi == y:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define int long long int




main() {
	int n;
	cin>>n;
	int arr[2*n];
	for(int i=0; i<2*n; i++){
		cin>>arr[i];
	}
	sort(arr, arr+2*n);
	int sum=0;
	for(int i=0; i<2*n; i=i+2){
		sum+=arr[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;


int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        LL n,w;
        cin >> n >> w;
        LL a[n+2][2];
        for(int i = 1 ; i <= n ; i++)
        {
                cin >> a[i][0] >> a[i][1];
        }
        LL dp[n+2][w+2];
        for(int i = 0 ; i <= w ; i++)
        {
                dp[0][i] = 0;
        }
        for(int i = 0 ; i <= n ; i++)
        {
                dp[i][0] = 0;
        }
        for(int i = 1 ; i <= n ; i++)
        {
                for(int j = 1 ; j <= w ; j++)
                {
                        dp[i][j] = dp[i-1][j];
                        if(j - a[i][0] >= 0)
                        {
                                dp[i][j] = max(dp[i][j] , dp[i-1][j - a[i][0]] + a[i][1]);
                        }
                }
        }
        cout << dp[n][w] << endl;
        return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, a, b, c, e;
	cin >> n >> a >> b >> c;
	cout << b - c + a << ' ' << c + (b - n) << ' ' << a + n - c << ' ' << c + (b - n) - (c - a) << endl;;
	cin >> e;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int a,b,c;
  cin>>a>>b>>c;
  int cnt=0;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==c){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256