akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    string S;
    cin >> S;
    int N = S.size();
    long long A[2019];
    fill_n(A, 2019, 0);
    A[0] = 1;
    long long cur = 0;
    long long ans = 0;
    long long fac = 1;
    for(int i=N-1; i>=0; i--){
        cur += fac * (S[i] - '0');
        cur %= 2019;
        fac *= 10;
        fac %= 2019;
        ans += A[cur];
        A[cur]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3740
A,B,C,D,E,F = map(int, input().split())

x = sorted(set([w for i in range(0,F+1,A*100) for j in range(0,F+1,B*100) if (w := i + j) < F]))[1::]
y = sorted(set([s for i in range(0,F+1,C) for j in range(0,F+1,D) if (s := i + j) < F]))

n = 0
WS = S = 0
for w in x:
    for s in y:
        if w + s > F:
            break
        if w * E//100 >= s:
            m = s / (w + s)
            if m >= n:
                n = m
                WS, S = w + s , s

print(WS,S)

Measured memory_bytes: 18004
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n;
           cin>>n;
           int cnt=0;
           for(int i=2;i*i<=n;i++)
           {
                 if(n%i==0)
                 {
                       int tot=0;
                       while(n%i==0)
                       {
                           tot++;  
                           n/=i;
                       }
                       rep(j,1,100)
                       {
                            int num=(j*(j+1))/2;
                            if(num>tot)
                            {
                                  cnt+=(j-1);
                                  break;
                            } 
                       }
                 }
           }
           if(n!=1)cnt++;
           cout<<cnt<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll s,w;cin>>s>>w;
  string ans= s<=w ? "unsafe":"safe";
  cout<<ans<<endl;
  return 0;
}


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

int N;
int num[20];
bool is_exst[3000];

bool dfs(int, int, int);

int main() {
  while (cin >> N, N) {
    fill(&num[0], &num[20], -1), num[0] = 1;
    fill(&is_exst[0], &is_exst[3000], false), is_exst[1] = true;
    for (int i = 1; i <= 20; ++i)
      if (dfs(1, i, 1)) {
        cout << i - 1 << "\n";
        break;
      }
  }

  return 0;
}

bool dfs(int dpt, int dpt_lim, int max_elem) {
  if (is_exst[N])         return true;
  if (dpt >= dpt_lim)     return false;
  if (max_elem >= 2 * N)  return false;

  int min_stp = 1;
  for (int i = max_elem; i * 2 < N; i *= 2)
    ++min_stp;

  if (dpt + min_stp > dpt_lim)  return false;

  for (int i = 0; i < dpt; ++i)
    if (!is_exst[max_elem + num[i]]) {
      num[dpt] = max_elem + num[i], is_exst[max_elem + num[i]] = true;
      if (dfs(dpt + 1, dpt_lim, max_elem + num[i]))
        return true;
      is_exst[max_elem + num[i]] = false;
    }

  for (int i = 0; i < dpt; ++i)
    if (max_elem - num[i] > 0 && !is_exst[max_elem - num[i]]) {
      num[dpt] = max_elem - num[i], is_exst[max_elem - num[i]] = true;
      if (dfs(dpt + 1, dpt_lim, max_elem))
        return true;
      is_exst[max_elem - num[i]] = false;
    }

  return false;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <boost/math/tools/minima.hpp>
using namespace std;
using boost::math::tools::brent_find_minima;

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int inf = 1e9+7;

int main(){
	string s;
    cin >> s;
	
    int n = s.size();
	int id = 0;
	ll ans = 0;
	int tmp = 0;
	for(int i = n - 1; i >= 0; i--) {
		if (s[i] == 'A') {
			if (id == 1) {
				id = 0;
                tmp = 0;
				if (s[i] == 'C') id = 1;
			}
			ans += tmp;
		}
		else if (id == 0) {
			if (s[i] == 'C') {
				id = 1;
			} else {
				tmp = 0;
			}
		} else {
			if (s[i] == 'B') {
				id = 0;
                tmp++;
			} else if(s[i]=='A'){
				id = tmp = 0;
			} else {
				id = 1;
                tmp = 0;
			}
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve() {
    string s, t;
    cin >> s >> t;
    bool F = false;
    for(int i = s.size()-1; i >= 0; i--){
        bool flag = true;
        for(int j = t.size()-1; j >= 0; j--){
            if(!(s[i+j] == t[j] || s[i+j] == '?')){
                flag = false;
            }
        }
        if(flag){
            s.replace(i, t.size(), t);
            F = true;
            break;
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?'){
            s.replace(i, 1, "a");
        }
    }

    if(F){
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;

}

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

int main(){
  int A, B, C, D, left, right;
  
  cin >> A >> B >> C >> D;
  
  left  = A + B;
  right = C + D;
  
  if(left > right){
    cout << "Left" << endl;
  }
  else if(left == right){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <math.h>

int main(){
	double x1,x2,y1,y2;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",sqrt(pow((x1-x2),2)+pow((y1-y2),2)));
	return 0;
}

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


int main() {
  
  int N;
  cin >> N;
  double D = N;
  
  
  if (N % 2 == 0) cout << 0.5 << endl;
  else cout << (D + 1) / (2 * D) << endl;
  
}

Measured memory_bytes: 256
N = int(input())
x = 0
y = 0
t = 0
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    dist = abs(x-xi) + abs(y-yi)
    flag = False
    if dist % 2 == 0 and not t % 2 == ti % 2:
        flag = True
    elif not dist % 2 == 0 and t % 2 == ti % 2:
        flag = True
    if dist > ti - t or flag:
        print('No')
        exit()
    x = xi
    y = yi
    t = ti

print('Yes')


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {+1,+0,-1};
static const int ty[] = {+0,+1,+0};

class State {
public:
  int x,y;
  int volume;
  int cost;
  int visited[11];
  State(int _x,int _y,int _v,int _c,int _vis[11]) :
    x(_x),y(_y),volume(_v),cost(_c) {
    memcpy(visited,_vis,sizeof(int)*11);
    visited[_y] |= (1 << _x);
  }
  State(int _x,int _y,int _v,int _c) :
    x(_x),y(_y),volume(_v),cost(_c) {}

  State& init(){
    memset(visited,0,sizeof(visited));
    return *this;
  }

  State& add(int _x,int _y){
    visited[_y] |= (1 << _x);
    return *this;
  }

  bool operator<(const State& s) const {
    return cost < s.cost;
  }
  bool operator>(const State& s) const {
    return cost > s.cost;
  }
};

int dp[1<<11][11][11];

int main(){
  int W,H;
  while(~scanf("%d %d",&W,&H)){
    if(W == 0 && H == 0) break;

    int upper_cost;
    int capacity;
    int initial_volume;
    scanf("%d %d %d",&upper_cost,&capacity,&initial_volume);

    int stage[11][11];
    for(int y=0; y < H; y++){
      for(int x=0; x < W; x++){
        scanf("%d",&stage[y][x]);
      }
    }

    priority_queue<State,vector<State>,greater<State> > que;

    memset(dp,0x3f,sizeof(dp));
    for(int sx = 0; sx < W; sx++){
      State root(sx,-1,initial_volume,0);
      root.init();
      que.push(root);
      
      while(!que.empty()){
        State s = que.top();
        que.pop();
        
        int x = s.x;
        int y = s.y;
        for(int i = 0; i < 3; i++){
          if(y == -1 && i != 1) continue;
          int dx = tx[i] + x;
          int dy = ty[i] + y;
          if(dx < 0 || dx >= W
             || dy < 0 || dy >= H) continue;
          
          int next_cost = s.cost;
          int next_volume = s.volume - 1;
          
          if(next_volume <= 0) continue;
          
          if(stage[dy][dx] < 0){
            next_cost += -stage[dy][dx];
          }
          else{
            if(s.visited[dy] & (1<<dx)) continue;
            next_volume += stage[dy][dx];
            if(next_volume > capacity) next_volume = capacity;
          }
          
          if(next_cost > upper_cost) continue;
          
          int next_visited = (s.visited[dy] | (1<<dx));
          if(dp[next_visited][dx][dy] <= next_cost) continue;
          dp[next_visited][dx][dy] = next_cost;
          que.push(State(dx,dy,next_volume,next_cost,s.visited));
        }
      }
    }

    int res = INF;
    for(int S = 0; S <= (1 << 10) - 1; S++){
      for(int x = 0; x < W; x++){
        if(res > dp[S][x][H-1]){
          res = dp[S][x][H-1];

        }
      }
    }

    if(res == INF){
      printf("NA\n");
    }
    else{
      printf("%d\n",res);
    }
  }
}

Measured memory_bytes: 2200
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
iまででj個表が出る確率
3000*3000
*/

ll n;
double p[3010],dp[3010][3010],ans=0;

int main(void){
	cin>>n;
	reg(i,1,n)cin>>p[i];
	//
	dp[0][0]=1;
	dp[0][1]=0;
	//
	reg(i,1,n){
		reg(j,0,i){
			dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
		}
	}
	reg(i,n/2,n){
		if(i*2<=n)continue;
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 69120
# coding:utf-8
k, n = map(int, input().split())
a = list(map(int, input().split()))
lmax = 0
point = 0
for i in range(n - 1):
    tmp = a[i + 1] - a[i]
    lmax = max(tmp, lmax)
lmax = max(lmax, a[0] + (k - a[-1]))
print(k - lmax)

Measured memory_bytes: 26060
n, m = map(int, input().split())
H = [int(i) for i in input().split()]
ans = [True]*n
for  i in range(m):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = False
    elif H[a-1] > H[b-1]:
        ans[b-1] = False
    elif H[a-1] == H[b-1]:
        ans[a-1] = False
        ans[b-1] = False
print(ans.count(True))

Measured memory_bytes: 20084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll Mode = 1e9 + 7;


int main(){
	ll n,m;
	string s;
	cin>>s;
	ll len = s.length();
	ll sum = 0;
	string tmp = "";
	string now = "";
	rep2(i,0,len){
		now += s[i];
		if(now != tmp){
			sum++;
			tmp = now;
			now = "";
		}
	}
	cout<<sum<<endl;




	return 0;
}








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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int target=a[n-1]/2;
  int i;
  for(i=0;i<n-1;i++){
    if(a[i]>target) break;
  }
  cout << a[n-1] << " " << ((a[i]==a[n-1]||(a[i]-target>target-a[i-1]))?a[i-1]:a[i]) << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= N; i+=2){
            int count = 0;
            for(int j = 1; j <= i; j++){
                if(i%j == 0)
                    count++;
            }
            if(count == 8)
                ans++;
        }
        System.out.println(ans);
    }
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  string s;
  cin >> s;
  ll res = 0;
  int a = 0;
  for (int i = 0; i < (int) s.size(); ++i) {
    if (s[i] == 'A') {
      ++a;
      continue;
    }
    if (s[i] == 'B' && i + 1 < (int) s.size() && s[i + 1] == 'C') {
      ++i;
      res += a;
      continue;
    }
    a = 0;
  }
  cout << res << '\n';
}


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

int main(){
	int n;

	cin >> n;

	vector<int> a(n, 0);

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

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



Measured memory_bytes: 4052
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int num = Math.min(a - b, c);
    System.out.println(c - num);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int r = 0, b = 0;
	rep(i, n){
		if(s[i] == 'R'){
			r++;
		}else{
			b++;
		}
	}

	if(r > b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

int main() {
  int A, V;
  cin >> A >> V;

  int B, W;
  cin >> B >> W;

  int T;
  cin >> T;

  if (abs(A - B) > (int64_t) (V - W) * T) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;

namespace ABC140_B
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();

            long ans = 0;
            List<int> aList = new List<int>();
            List<long> bList = new List<long>();
            List<long> cList = new List<long>();
            for (long i = 0; i < n; i++) {
                aList.Add(int.Parse(input[i]));
            }
            input = Console.ReadLine().Split();
            for (long i = 0; i < n; i++) {
                bList.Add(long.Parse(input[i]));
            }
            input = Console.ReadLine().Split();
            for (long i = 0; i < n - 1; i++) {
                cList.Add(long.Parse(input[i]));
            }

            for(int i = 0; i < n; i++) {
                ans += bList[aList[i] - 1];

                if (i > 0 && aList[i - 1] == aList[i] - 1) {
                    ans += cList[aList[i - 1] - 1];
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
const int inf=1001001001;
const int mod=998244353;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}

int main(){
    string s;cin>>s;
    int n=s.size();
    rep(i,n-1)if(s[i]==s[i+1]){
        cout<<i+1<<' '<<i+2<<endl;
        return 0;
    }
    rep(i,n-2)if(s[i]==s[i+2]){
        cout<<i+1<<' '<<i+3<<endl;
        return 0;
    }
    cout<<-1<<' '<<-1<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int nax = 1000 * 1007;
int n;
char wcz[nax];
int tab[nax];
int main(void)
{
	scanf("%s", wcz + 1);
	n = strlen(wcz + 1);
	n++;
	for (int i = 1; i < n; i++)
	{
		if (wcz[i] == '<')
			tab[i + 1] = max(tab[i + 1], tab[i] + 1);
	}
	for (int i = n - 1; i; i--)
	{
		if (wcz[i] == '>')
			tab[i] = max(tab[i], tab[i + 1] + 1);
	}
	ll wyn = 0;
	for (int i = 1; i <= n; i++)
		wyn += tab[i];
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 4608
n = int(input())
a = list(map(int, input().split()))
d1 = [0] * (n + 1)
d2 = [0] * (n + 1)
ans1 = 0
ans2 = 0
n1 = 0
n2 = 0
# + - + - + - の順番
for i in range(n):
    n1 += a[i]
    if(i % 2 == 0 and n1 <= 0):
        ans1 += abs(n1) + 1
        n1 = 1
    if(i % 2 == 1 and n1 >= 0):
        ans1 += abs(n1) + 1
        n1 = -1

for i in range(n):
    n2 += a[i]
    if (i % 2 == 1 and n2 <= 0):
        ans2 += abs(n2) + 1
        n2 = 1
    if (i % 2 == 0 and n2 >= 0):
        ans2 += abs(n2) + 1
        n2 = -1

ans = min(ans1, ans2)
print(ans)



Measured memory_bytes: 14464
using System;

class Program
{
 static void Main(String[] args)
 {
   var cardNum = 0;
   var cnt = 0;
   var cardDiffNum = 0;
   string[] cardStr;
   
   cardNum = int.Parse(Console.ReadLine());
   cardStr = Console.ReadLine().Split(' ');
   
   int[] card = new int[cardNum];
   
   for( cnt = 0; cnt < cardNum; cnt++ )
   {
     card[cnt] = int.Parse(cardStr[cnt]);
   }
   
   Array.Sort(card);
   Array.Reverse(card);
   
   for( cnt = 0; cnt < cardNum; cnt++ )
   {
     if( ( cnt % 2 ) == 0 )
     {
       cardDiffNum += card[cnt];
     }
     else
     {
       cardDiffNum -= card[cnt];
     }
   }
   
   Console.WriteLine(cardDiffNum);
 }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>

int main() {
  char A[110], B[110];
  int Alength, Blength;
  int i;
  
  scanf("%s %s", A, B);
  Alength = strlen(A);
  Blength = strlen(B);
  if(Alength < Blength) {
    printf("LESS\n");
    return 0;
  } else if(Alength > Blength) {
    printf("GREATER\n");
    return 0;
  } else {
    for(i = 0; i < Alength; i++) {
      if(A[i] < B[i]) {
        printf("LESS\n");
        return 0;
      } else if(A[i] > B[i]) {
        printf("GREATER\n");
        return 0;
      }
    }
  }
  printf("EQUAL\n");
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

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

    vector <long long> a(n);
    vector <long long> sum(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (i == 0){
            sum[i] = a[i];
        }else{
            sum[i] = sum[i - 1] + a[i];
        }
    }

    long long count1 = 0, count2 = 0;
    long long add1 = 0, add2 = 0;

    for(int i = 0; i < n; i++){
        if (i % 2 == 0){
            if (sum[i] + add1 <= 0){
                int A = 1 - (sum[i] + add1);
                count1 += A;
                add1 += A;
            }

            if (sum[i] + add2 >= 0){
                int A = (sum[i] + add2) + 1;
                count2 += A;
                add2 -= A;
            }

        }else{
            if (sum[i] + add1 >= 0){
                int A = (sum[i] + add1) + 1;
                count1 += A;
                add1 -= A;
            }

            if (sum[i] + add2 <= 0){
                int A = 1 - (sum[i] + add2);
                count2 += A;
                add2 += A;
            }

        }
    }
    
    long long ans = min(count1, count2);

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
T power(T x, long long n) {
  T ret = 1;
  while (n) {
    if (n & 1) ret *= x;
    x  *= x;
    n >>= 1;
  }
  return ret;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> d(n);
  rep (i, n) cin >> d[i];
  lint sum = 0;
  rep (i, n) {
    rep (j, n) {
      if (i == j) continue;
      sum += d[i] * d[j];
    }
  }
  sum /= 2;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	bb := make([]int, n)
	ma := make([]int, n)
	mb := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}

	ans := 0

	ms := MergeSort{}
	ms.init(n)

	for i := 0; i < 30; i++ {
		t := 1 << uint(i)
		for ii := 0; ii < n; ii++ {
			ma[ii] = aa[ii] % (t << 1)
			mb[ii] = bb[ii] % (t << 1)
		}
		ms.sort(0, n, mb)

		c := 0
		for ii := 0; ii < n; ii++ {
			c += n
			for iii := 1; iii <= 3; iii++ {
				l := 0
				r := n
				for l < r {
					m := (l + r) >> 1
					if ma[ii]+mb[m] >= t*iii {
						r = m
						continue
					}
					l = m + 1
				}
				if iii%2 == 1 {
					c -= l
					continue
				}
				c += l
			}
		}
		c %= 2
		ans |= c << uint(i)
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func bsearch(a, n, t int, mb []int) int {
	l := 0
	r := n
	for l < r {
		m := (l + r) >> 1
		if a+mb[m] >= t {
			r = m
			continue
		}
		l = m + 1
	}
	return l
}

type MergeSort struct {
	n      int
	ll, rr []int
}

func (ms *MergeSort) init(n int) {
	ms.n = n
	ms.ll = make([]int, n/2+2)
	ms.rr = make([]int, n/2+2)
}

func (ms *MergeSort) sort(l, r int, aa []int) {
	if l+1 < r {
		m := (l + r) >> 1
		ms.sort(l, m, aa)
		ms.sort(m, r, aa)
	}
	ms.merge(l, r, aa)
}

func (ms *MergeSort) merge(l, r int, aa []int) {
	ll := ms.ll
	rr := ms.rr
	m := (l + r) >> 1
	for i := l; i < m; i++ {
		ll[i-l] = aa[i]
	}
	for i := m; i < r; i++ {
		rr[i-m] = aa[i]
	}

	ll[m-l] = 1 << 30
	rr[r-m] = 1 << 30
	lpos := 0
	rpos := 0
	for i := l; i < r; i++ {
		if ll[lpos] <= rr[rpos] {
			aa[i] = ll[lpos]
			lpos++
			continue
		}
		aa[i] = rr[rpos]
		rpos++
	}
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n,m;
    cin >> n >> m;
    int sum=0, cmax=0;;
    for(int i=0; i<m; i++){
        int t, dummy;
        cin >> t >> dummy;
        if(t>n) t=n;
        sum += n-t;
        cmax = max(cmax, n-t);
    }
    cout << sum-cmax << endl;
    return 0;
}

Measured memory_bytes: 3092
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
long long t,a,b,mul,c,ans;
int main(){
	scanf("%lld",&t);
	for(register int i=1;i<=t;i++){
		scanf("%lld%lld",&a,&b);
		mul=a*b;c=floor(sqrt(mul));
		switch(c*(c+1)<mul){
			case true:ans=2*c-1;break;
			case false:ans=2*c-2;break;
		}
		if(a!=b&&c*c==mul){
			ans--;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 2e5+7;
const ll inf = 1e9+7;


int main() {
	fastio;
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n + 1]={0};
	f(i,1,n+1){
		cin >> a[i];
		a[i] += a[i - 1];
	}
	ll b[m + 1]={0};
	f(i,1,m+1){
		cin >> b[i];
		b[i] += b[i - 1];
	}
	ll ans = 0;
	f(i,0,n+1){
		if (k >= a[i]) ans = max(ans, i + ll(upper_bound(b, b + m + 1, k - a[i]) - b - 1));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b;
    cin >> a >> b;
    if(a&b&1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n % 2) {
    cout << "No" << endl;
    return 0;
  }
  string l = ""; string r = "";
  rep(i,n/2) {
    l += s[i];
    r += s[i+n/2];
  } 
  cout << (l == r ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 1e5+2;
const int MOD = 1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

int N;
int A[MAXN];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    if (N==1) YES;

    for (int i = 0; i < N; i++) cin >> A[i];

    int ok = 1;
    for (int i = 1; i < N; i++) {
        if (A[i-1] > A[i]) ok = 0;
        else if (A[i] > A[i-1]) A[i]--;
    }

    if (ok) YES;
    FAILNO;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long minv=1000000000000000000,a,i;
	cin>>a;
	long long c,total;
	for(i=1;i*i<=a;i++)
		if(a%i==0)
		{
			c=a/i;
			total=i-1+c-1;
			if(total<minv)
			swap(total,minv); 
		}
		cout<<minv<<endl;
	return 0;
}

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

using namespace std;

int main() {
	long long n, m;

	cin >> n >> m;
	if (n >= m) {
		cout << m / 2 << endl;
	}
	else {
		if (n * 2 >= m) {
			cout << m / 2 << endl;
		}
		else {
			cout << n + (m - n * 2) / 4 << endl;
		}
	}

	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	vector<int> a( n );
	for( auto& v: a ) { cin >> v; }

	int q;
	cin >> q;

	while( q-- > 0 ) {
		int c, b, e;
		cin >> c >> b >> e;

		auto p = minmax_element( a.begin()+b, a.begin()+e );
		cout << (c == 0 ? *p.first : *p.second) << '\n';
	}

	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int A, B;
    cin >> A >> B;
    cout << A * B;
    return 0;
}



Measured memory_bytes: 3640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,W = inpl()
wv = [inpl() for _ in range(n)]
dp = [0] * (W+1)
for i in range(n):
    w,v = wv[i]
    for j in range(w,W+1)[::-1]:
        dp[j] = max(dp[j], dp[j-w] + v)
print(dp[W])

Measured memory_bytes: 67304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

std::vector < std::string > v;

int main() {
    std::string s;
    std::cin >> s;

    for (int i = 0; i < (int)s.size(); i++) {
        std::string u;
        for (int j = i; j < i + 7 && j < (int)s.size(); j++) {
            u.push_back(s[j]);
            v.push_back(u);
        }
    }
    int n;
    std::cin >> n;

    std::sort(v.begin(), v.end());
    v.resize(std::unique(v.begin(), v.end()) - v.begin());

    std::cout << v[n - 1];

    return 0;
}


Measured memory_bytes: 2300
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int n;
    cin >> n;
    int a[n];
    deque<int> d;
    for(int i = 0;i < n;i++)cin >> a[i];
    
    int back = 0;
    for(int i = 0;i < n;i++){
        back++;
        back %= 2;
        if(back == 0)d.push_front(a[i]);
        else d.push_back(a[i]);
    }
    
    if(back == 1)reverse(d.begin(),d.end());
    for(int i = 0;i < n;i++){
        cout << d[i];
        if(i == n-1)cout << endl;
        else cout << " ";
    }
 
}


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


int main() {
  int a, b;
  cin >> a >> b;
  int x = (a+b+2-1)/2;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n";
#define CNO cout << "No" \
                 << "\n";
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

int main()
{
    int n;
    cin >> n;
    cout << (n % 2 == 0 ? n / 2 : n / 2 + 1) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    ll n,ans;
    scanf("%lld",&n);

    for(ll i=0;i<=n;i++){
        if(i*i>n)break;
        ans=i*i;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);








int main()
{
//    FAST();

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

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







LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    ll psize=0,msize=0;
    ll p[100001],m[100001];
    rep(i,n){
        ll tmp;
        cin >> tmp;
        if(tmp<0){
            m[msize] = -tmp;
            msize++;
        }else{
            p[psize] = tmp;
            psize++;
        }
    }
    sort(m,m+msize);
    ll ans = 1000000000;
    
    rep(i,k){
        if(i<psize&&k-i-2<msize&&k-i-2>=0){
            ans = min({ans,2*m[k-i-2]+p[i],m[k-i-2]+2*p[i]});
        }
    }
    if(k<=psize) ans = min(ans,p[k-1]);
    if(k<=msize) ans = min(ans,m[k-1]);


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4404
N = int(input())
B = list(map(int, input().split()))
A = list(map(int, input().split()))
eq = [0] * N

i = 0
ans = 0
eq_flag = 0
while True:
    if A[i] < B[i]:
        ans = -1
        break
    elif A[i] == B[i]:
        i = (i + 1) % N
        if eq[i] == 0:
            eq_flag += 1
            eq[i] = 1
    else:
        if A[i] > A[(i-1) % N] and A[i] > A[(i + 1) % N]:
            A0 = A[(i-1)%N]
            A1 = A[i]
            A2 = A[(i+1)%N]
            temp = (A1 - B[i]) // (A0 + A2)
            if temp == 0:
                ans = -1
                break
            A[i] -= temp * (A0 + A2)
            ans += temp
            i = (i - 1) % N
        else:
            i = (i + 1) % N
    if eq_flag == N:
        break

print(ans)


Measured memory_bytes: 118392
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  int h;
  map <long long, bool> ad;
  for(int i=0;i<n;i++){
    cin >> h;
    ad[h]=1;
  }
  int l,u,ans=0;
  l=u=x;
  while(1){
    if(ad[l])l--;
    else{ans=l;break;};
    if(ad[u])u++;
    else{ans=u;break;};
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    std::string s;
    std::cin >> s;

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


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

class Cube{
    public:
    int f[6];
    Cube(){}
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void roll_e(){
        roll(0, 3, 5, 2);
    }
    void roll_w(){
        roll(0, 2, 5, 3);
    }
    void roll_s(){
        roll(0, 4, 5, 1);
    }
    void roll_n(){
        roll(0, 1, 5, 4);
    }
    void move(char ch){
        if(ch == 'E') roll_e();
        if(ch == 'W') roll_w();
        if(ch == 'S') roll_s();
        if(ch == 'N') roll_n();
    }
};

int main(){
    Cube c;
    string dir;
    for(int i = 0; i < 6; i++){
        cin >> c.f[i];
    }
    cin >> dir;
    for(int i = 0; i < dir.size(); i++){
        c.move(dir[i]);
    }
    cout << c.f[0] << endl;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int wa = a+b;
    int sa = a-b;
    int ka = a*b;
    int ans=max({wa,sa,ka});
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
local n = io.read("*n")
local m = io.read("*n")
local x = io.read("*n")
local y = io.read("*n")
local xt = {}
local yt = {}
for i = 1, n do
    table.insert(xt, io.read("*n"))
end

for i = 1, m do
    table.insert(yt, io.read("*n"))
end
table.sort(xt, function(a, b)
    return a > b
end)
table.sort(yt, function(a, b)
    return a < b
end)
local maxX = math.max(xt[1], x)
local minY = math.min(yt[1], y)
if maxX >= minY then
    print("War")
else
    print("No War")
end

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
ll const INF = 1000000000000000001;


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

int N;
cin >> N;
vl a(N);
ll total = 0;
rep(i,N) {
    cin >> a[i];
    total += a[i];
}

ll ans = INF;
ll sn = 0;
rep(i,N-1) {
    sn += a[i];
    ans = min(ans,abs(total-2*sn));
}
cout << ans << endl;
return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> yakusuu;
    int temp = 1;
    while(true){
        if(a % temp == 0 && b % temp == 0){
            yakusuu.pb(temp);
        }
        temp++;
        if(temp > a || temp > b) break;
    }
    print(yakusuu[yakusuu.size() - k]);
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int N,T;
	cin>>N>>T;
	int table[100100]={0};
	for(int i=0;i<=T;i++)table[i]=0;
	
	int left,right;
	for(int i=0;i<N;i++){
		cin>>left>>right;
		table[left]++;
		table[right]--;
	}
	
	for(int i=1;i<=T;i++)table[i]+=table[i-1];
	
	int maximum=0;
	for(int i=0;i<=T;i++)maximum=max(maximum,table[i]);
	cout<<maximum<<endl;
	return 0;
}


Measured memory_bytes: 3512
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] count = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
            count[a[i]]++;
        }
        
        long ans = 0;
        if(n % 2 == 0) {
            for(int i=1; i<n; i+=2) {
                if(count[i] == 2) {
                    ans++;
                }else {
                    ans = 0;
                    break;
                }
            }
            for(int i=0; i<n; i+=2) {
                if(count[i] != 0) {
                    ans = 0;
                    break;
                }
            }
        }else {
            if(count[0] == 1) {
                for(int i=2; i<n; i+=2) {
                    if(count[i] == 2) {
                        ans++;
                    }else {
                        ans = 0;
                        break;
                    }
                }
            }
            for(int i=1; i<n; i+=2) {
                if(count[i] != 0) {
                    ans = 0;
                    break;
                }
            }
        }
        if(ans == 0) {
            if(n == 1) {
                System.out.println(1);
            }else {System.out.println(0);}
        }else {
            long z = 1;
            while(ans > 0) {
                z *= 2;
                ans--;
                z = z % 1000000007;
            }
            System.out.println(z);
        }
 
        
    }
}

Measured memory_bytes: 45044