akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
flag = True
ans = 1
a.sort()
for i in range(n):
	ans *= a[i]
	if ans == 0:
		break
	if ans > 1000000000000000000:
		flag = False
		break
print(ans if flag else -1)

Measured memory_bytes: 21752
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int N;
    vector<int> b;
    cin >> N;

    for(int i = 0; i < N; i++){
        int xx;cin >> xx;
        b.push_back(xx);
    }

    vector<int> res;
    while(true){
        if(b.empty()){
            break;
        }
        bool ok = false;
        for(int i = b.size()-1; i >= 0; i--){
            if(b[i] == i+1){
                res.push_back(i+1);
                b.erase(b.begin() + i);
                ok = true;
                break;
            }
        }
        if(!ok){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i = N-1; i >= 0; i--){
        cout << res[i] << endl;
    }








    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2) cout << "IMPOSSIBLE" << endl;
    else cout << (A + B) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    vector<string> subset;
    string s,t;
    int k,count=0;
    cin >> s >> k;
    if(k==1){
        int temp=0;
        vector<int> use(26,0);
        for(int i=0; i<s.length(); i++){
            use[ s[i]-'a' ]++;
        }
        for(int i=0; i<26; i++){
            if(use[i]){
                char ans='a'+i;
                cout <<  ans << endl;
                return 0;
            }
        }
    }
    for(int i=0; i<s.length(); i++){
        for(int j=1; j<=k; j++){
            if(i+j>s.length())break;
            t=s.substr(i,j);
            subset.push_back(t);
        }
    }
    sort(subset.begin(),subset.end());
    for(int i=0; i<subset.size(); i++){
        if(i==0){
            count++;
            continue;
        }
        if(subset[i-1]==subset[i])continue;
        count++;
        if(count==k){
            cout << subset[i] << endl;
            return 0;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1660
// Vicfred
// https://atcoder.jp/contests/abc175/tasks/abc175_c
// math
import std.algorithm;
import std.math;
import std.stdio;

void main() {
    long X, K, D;
    readf("%s %s %s\n", &X, &K, &D);

    X = abs(X);

    long need = X/D;

    if(need > K)
        writefln("%s\n", X - D*K);
    else {
        K -= need;
        X -= need*D;
        if(K % 2 == 1)
            X = abs(X - D);
        X.writeln;
    }
}



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

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

    int N, X, Y;
    cin >> N >> X >> Y;

    vector<int> cnt(N, 0);
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            int d = min(abs(i - j), min(abs(i - X) + abs(Y - j) + 1, abs(i - Y) + abs(X - j) + 1));
            cnt.at(d)++;
        }
    }

    for (int i = 1; i < N; ++i) {
        cout << cnt.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
INF = float('inf')
MAXAB = 10
n, ma, mb = map(int, input().split())
t = [[INF] * (n * MAXAB + 1) for _ in range(n * MAXAB + 1)]
t[0][0] = 0
for _ in range(n):
  a, b, c = map(int, input().split())
  for aa in range(n * MAXAB, -1, -1):
    for bb in range(n * MAXAB, -1, -1):
      if t[aa][bb] == INF:
        continue
      if t[a + aa][b + bb] > t[aa][bb] + c:
        t[a + aa][b + bb] = t[aa][bb] + c
result = INF
for a in range(1, n * MAXAB + 1):
  for b in range(1, n * MAXAB + 1):
    if a * mb == b * ma and result > t[a][b]:
      result = t[a][b]
if result == INF:
  result = -1
print(result)


Measured memory_bytes: 4844
N, M = [int(_) for _ in input().split()]
A = sorted([int(_) for _ in input().split()], reverse=True)
B = sorted([int(_) for _ in input().split()], reverse=True)
mod = 10**9 + 7
i_a = 0
i_b = 0
ans = 1
for x in range(N * M, 0, -1):
    if i_a == N and i_b == M:
        break
    elif i_a < N and i_b < M and A[i_a] == B[i_b] == x:
        i_a += 1
        i_b += 1
    elif i_a < N and A[i_a] == x:
        i_a += 1
        ans *= i_b
        ans %= mod
    elif i_b < M and B[i_b] == x:
        i_b += 1
        ans *= i_a
        ans %= mod
    else:
        ans *= i_a * i_b - (N * M - x)
        ans %= mod
for y in range(x, 1, -1):
    ans *= y
    ans %= mod
print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int A =sc.nextInt();
      int B =sc.nextInt();
      
      int m1 =A+B;
      int m2 =A-B;
      int m3 =A*B;
      
      if(m1<m2&&m3<m2){
      System.out.print(m2);
      }
      else if(m2<m3&&m1<m3){
      System.out.print(m3);
      }
      else{
      System.out.print(m1);
      }
    }
}

Measured memory_bytes: 22612
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m,R;
    cin>>n>>m>>R;
    vector<int> r(R);
    REP(i,R) cin >> r[i];
    sort(all(r));
    vector<int> dist[n];
    REP(i,n) dist[i].assign(n,INF);
    
    REP(i,n) dist[i][i] = 0;

    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    
    REP(k,n){
      REP(i,n){
        REP(j,n){
          dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
        }
      }
    }

    int g=1;
    rep(i,R+1){
        if(i==0) continue;
        g*=i;
    }
    ll ans=INF;
    rep(i,g){
        ll fg=0;
        rep(j,R-1){
            fg+=dist[r[j]-1][r[j+1]-1];
        }
        chmin(ans,fg);
        next_permutation(all(r));
    }
    cout<<ans<<endl;

    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<int>answer[100001];
int v[100001]={0};
int ans=0;
int dfs(int s)
{
    v[s]=1;
    if(v[2]==1)
        return 0;
    int i;
    for(i=0;i<answer[s].size();i++)
    {
        if(v[answer[s][i]]==0 )
        {

            ans++;
            dfs(answer[s][i]);
        }

    }
}
int main()
{
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        answer[i+1].push_back(a[i]);
    }
    dfs(1);
    if(v[2]==1)
          cout<<ans<<endl;
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
stack<int> s1;
stack<pair<int,int> > s2;

int main()
{
    string s;
    cin >> s;
    int len=s.size(), total_water=0;
    for(int i=0; i<len; ++i)
    {
        if(s[i]=='\\')
            s1.push(i);
        else if(s[i]=='/' && s1.size()>0)
        {
            int x=s1.top();
            s1.pop();
            int water=i-x;
            total_water+=water;

            while(s2.size()>0 && s2.top().first>x)
            {
                water+=s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(x, water));
        }
    }
    vector<int> v;
    while(s2.size()>0)
    {
        v.push_back(s2.top().second);
        s2.pop();
    }
    reverse(v.begin(), v.end());
    printf("%d\n", total_water);
    int l=v.size();
    printf("%d", l);
    for(int i=0; i<l; ++i)
        printf(" %d", v[i]);
    printf("\n");

    return 0;
}



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


int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n)cin>>l[i];
    int ans=0;
   
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                int len=l[i]+l[j]+l[k];
                int ma=max(l[i],max(l[j],l[k]));
                int res=len-ma;
                if(l[i]==l[j] || l[j]==l[k] || l[i]==l[k])continue;
                
                if(ma<res){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    
    }


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

int main() {
	int H, W;
  	cin >> H >> W;
  	
  	vector<vector<char>> C(H, vector<char>(W));

 for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> C.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << C.at(i).at(j);
      if( j == W -1 ) cout << endl;
    }
    for (int j = 0; j < W; j++) {
      cout << C.at(i).at(j);
      if( j == W -1 ) cout << endl;
    }
  }
  
}

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


int main(){
    int x;
    cin >> x;
    if(400 <= x && x <= 599){
        cout << 8 << endl;
    }else if(600 <= x && x <= 799){
        cout << 7 << endl;
    }else if(800 <= x && x <= 999){
        cout << 6 << endl;
    }else if(1000 <= x && x <= 1199){
        cout << 5 << endl;
    }else if(1200 <= x && x <= 1399){
        cout << 4 << endl;
    }else if(1400 <= x && x <= 1599){
        cout << 3 << endl;
    }else if(1600 <= x && x <= 1799){
        cout << 2 << endl;
    }else if(1800 <= x && x <= 1999){
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int [][]po=new int[n][2];
        for(int i=0;i<n;i++){
            po[i][0]=sc.nextInt();
            po[i][1]=sc.nextInt();
        }
        long dp[][]=new long[n+1][k+1];
        for(int i=1;i<=n;i++){
            for(int j=0;j<=k;j++){
                if(j-po[i-1][0]>=0)dp[i][j]=Math.max(dp[i-1][j],dp[i-1][j-po[i-1][0]]+po[i-1][1]);
                else dp[i][j]=dp[i-1][j];
            }
        }
        System.out.println(dp[n][k]);
    }
}


Measured memory_bytes: 126932
import java.util.Scanner;

public class Main {

	static long[] ans;
	static boolean[] seen;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int R = in.nextInt();
		int G = in.nextInt();
		int B = in.nextInt();
		int N = in.nextInt();
		int[] bArray = new int[N + 1];
		for (int i = 0; i <= N; i += B) {
			bArray[i]++;
		}
		long ans = 0;
		for (int i = 0; i * R <= N; i++) {
			for (int j = 0; j * G + R * i <= N; j++) {
				int diff = N - (R * i + j * G);
				if (bArray[diff] != 0) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x ;
        x = x * x ;
        n = n >> 1;
    }
    return ans;
}
int ans = 0;
int n,x;


void dfs(int lv,int y){
    cerr << lv << " " << y << endl;
    if(lv < 0){
        cerr << "error" << endl;
        return;
    }
    if(y == 0)return;
    if(y == 1 && lv != 0)return;
    if(y == 1 && lv == 0){
        ans += 1;
        return;
    }
    if(y == bitpow(2,lv+1) - 1){
        ans += bitpow(2,lv);
        return;
    }
    if(y == bitpow(2,lv+1) - 2){
        ans += bitpow(2,lv)-1;
        return;
    }
    if(y == bitpow(2,lv+2) - 3 || y == bitpow(2,lv+2) - 4){
        ans += bitpow(2,lv+1) - 1;
        return;
    }

    if(y <= bitpow(2,lv+1) - 2){
        dfs(lv-1,y-1);
    }else{
        ans += bitpow(2,lv);
        dfs(lv-1,y-(bitpow(2,lv+1) - 1));
    }
}

signed main(){

    cin >> n >> x;
    int lvn_all = bitpow(2,n+2) - 3;
    int lvn_p = bitpow(2,n+1) - 1;
    
    dfs(n,x);

    cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
# coding:utf-8


def inpl(): return list(map(int, input().split()))


n, x = inpl()


def func(a, b):
    if a < b:
        a, b = b, a
    if a == b:
        return a
    else:
        if a % b == 0:
            return (a // b * 2 - 1) * b
        else:
            q, mod = divmod(a, b)
            return 2 * q * b + func(b, mod)
            # return 2*b + func(a-b, b)#再帰回数が10000を超えるとエラー(20000000001, 4)など


if x == n / 2:
    print(3 * x)
else:
    print(n + func(x, n - x))


Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include<string.h>
#include <stack>
#define ll long long
using namespace std;
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (b % a == 0)
		printf("%d\n", a + b);
	else
		printf("%d\n", b - a);

}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;

int N;
int P;
string S;
struct restaurant{
    int num, value;
    string name;

    bool operator<( const restaurant& right ) const {
        return name == right.name ? value > right.value : name < right.name;
    }
};

vector<restaurant> V;
int main(void){
    cin >> N;
    REP(i,N){
        cin >> S >> P;
        restaurant r;
        r.num = i+1;
        r.value = P;
        r.name = S;
        V.push_back(r);
    }
    sort(V.begin(), V.end());
    REP(i,N) cout << V[i].num << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
using lint=int64_t;
using namespace std;

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

	map<lint,lint> indexof;
	for(lint i=1;i<=N;i++)
	{
		lint val;
		cin >> val;
		indexof[val]=i;
	}

	multiset<lint> ipool;
	ipool.insert(0);
	ipool.insert(0);
	ipool.insert(N+1);
	ipool.insert(N+1);
	
	lint ans=0;
	for(lint i=N;i>=1;i--)
	{
		lint l2,l1,r1,r2;
		auto itr=ipool.lower_bound(indexof[i]);
		r1=*itr;
		++itr;
		r2=*itr;
		--itr;--itr;
		l1=*itr;
		--itr;
		l2=*itr;

		ans+=(indexof[i]-l1)*(r2-r1)*i;
		ans+=(l1-l2)*(r1-indexof[i])*i;

		ipool.insert(indexof[i]);
	}

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



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

void swap(char *a,char *b){
  char temp = *a;
  *a = *b;
  *b = temp;
}



char cards1[40][5];
char cards2[40][5];

int main(){
  
  char sp;  
  int n; cin >> n;
  
  for(int i=0;i<n;i++){
    scanf("%s",cards1[i]);
    scanf("%c",&sp);
    cards2[i][0] = cards1[i][0];
    cards2[i][1] = cards1[i][1];
    
 }
 
 for(int i=0;i<n;i++){
   for(int j=n-1;j>=0;j--){
     if(cards1[j][1]<cards1[j-1][1]){
       swap(&cards1[j][0],&cards1[j-1][0]);
       swap(&cards1[j][1],&cards1[j-1][1]);
     }
   }
 }
 

 int flag = 0;
 
 for(int i=0;i<n;i++){
   int minindex = i;
   int sameindex = i;
    int checker = 0;
   for(int j=i+1;j<n;j++){
     if(cards2[j][1]<cards2[minindex][1])minindex = j;
     if(cards2[j][1]==cards2[sameindex][1] && !checker){
       checker++;
       sameindex = j;
     }
     
   }
   if(minindex>sameindex && sameindex!=i)flag++;
   if(minindex!=i){
     swap(&cards2[i][0],&cards2[minindex][0]);
     swap(&cards2[i][1],&cards2[minindex][1]);
   }
   
 }
 
 for(int i=0;i<n;i++){
   if(i==n-1)printf("%s\n",cards1[i]);
   else printf("%s ",cards1[i]);
 }
 printf("Stable\n"); 
 for(int i=0;i<n;i++){
   if(i==n-1)printf("%s\n",cards2[i]);
   else printf("%s ",cards2[i]);
 }
 if(!flag)printf("Stable\n");
 else printf("Not stable\n");
 
  
  
  
  
  return 0;
}


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

struct person{ int num,get; };

person dat[3000000];
int n,max_n;

void update(int i,int x){
	i += max_n - 1;
	dat[i].get += x;
	while(i > 0){
		i = (i - 1) / 2;
		if(dat[i * 2 + 1].get < dat[i * 2 + 2].get) dat[i] = dat[i * 2 + 2];
		else if(dat[i * 2 + 1].get > dat[i * 2 + 2].get) dat[i] = dat[i * 2 + 1];
		else if(dat[i * 2 + 1].num < dat[i * 2 + 2].num) dat[i] = dat[i * 2 + 1];
		else dat[i] = dat[i * 2 + 2];
	}
}

void init(){
	max_n = 1;
	while(max_n < n) max_n *= 2;
	for(int i = 0;i < 2 * max_n - 1;i++){
		dat[i].num = 100000000;
		dat[i].get = 0;
	}
	for(int i = 0;i < n;i++) dat[i + max_n - 1].num = i;
	for(int i = 0;i < n;i++) update(i,0);
}

int main(){
	int q;
	cin >> n >> q;
	init();
	for(int i = 0;i < q;i++){
		int a,b;
		cin >> a >> b;
		update(a - 1,b);
		cout << dat[0].num + 1 << " " << dat[0].get << endl;
	}
	return 0;
}

Measured memory_bytes: 19468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 210000

vector<ll> a(N);
vector<ll> f(N);

ll query(ll x, ll n, ll k){
	ll z = 0; ll y = 0;
	REP(i,n) {
		z+=max(y,a[i]-x/f[i]);
		//cout << x << " " << i << " " << max(y,a[i]-x/f[i]) << endl;
	}
	if (z<=k) return true;
	return false;
}
int main(){
	ll n, k, mid; cin >> n >> k;
	REP(i,n) cin >> a[i];
	REP(i,n) cin >> f[i];
	sort(a.begin(),a.begin()+n);
	sort(f.begin(),f.begin()+n);
	reverse(f.begin(),f.begin()+n);
	//REP(i,n) cout << a[i] << " " << f[i] << endl;
	ll right = 0;
	REP(i,n) right = max(right,a[i]*f[i]);
	ll left = 0; right++;
	while(right-left>1){
		mid = (right+left)/2;
		if (query(mid,n,k)) right=mid;
		else left=mid;
	}
	if (right==1&&query(0,n,k)) cout << 0 << endl;
	else cout << right << endl;
}

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

vector<long> inputVector(long n)
{
    vector<long> vec(n);
    rep(i, n)
    {
        scanf("%d", &vec.at(i));
    }
    return vec;
}

int main()
{
    long n, m;
    // scanf("%d", &x);
    cin >> n >> m;
    long ans = n;
    vector<long> a = inputVector(m);
    rep(i, m)
    {
        ans -= a.at(i);
    }
    if (ans < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
    // printf("%d\n", x * x * x);
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define Fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sz      200005

ll arr[sz];
int brr[sz];


int main(){
    Fast;
    ll n,k,i;

    cin>>n>>k;
    for(i=1; i<=n; i++){
        cin>>arr[i];
    }
    memset(brr,0,sizeof(brr));

    i=1;
    while(k && brr[i]==0){
        k--;
        brr[i]=1;
        i=arr[i];
    }
    if(k==0){
        cout<<i<<endl;
        return 0;
    }

    ll cnt=0;
    memset(brr,0,sizeof(brr));
    while(k && brr[i]==0){
        k--;
        cnt++;
        brr[i]=1;
        i=arr[i];
    }
    if(k==0){
        cout<<i<<endl;
        return 0;
    }
    k=k%cnt;
    memset(brr,0,sizeof(brr));
    while(k && brr[i]==0){
        k--;
        brr[i]=1;
        i=arr[i];
    }
    cout<<i<<endl;

    return 0;
}



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


 
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
  
  int n,h;
  int mx=0;
  int count=0;
  scanf("%d %d",&n,&h);
  //cin >> n >> h;
  for(int i=1;i<n;i++){
    int hh=0;
    scanf("%d",&hh);
    //cin >> hh;
  	if(hh<=h){
    	count++;
    }else{
    	mx=max(count,mx);
    	//if(count>mx){mx=count;}
    	count=0;
    }
    h=hh;
  }
  mx=max(count,mx);
  //if(count>mx){mx=count;}
  printf("%d",mx);
  //cout << mx;
  
  

}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define forep(i, a, b) for(int64_t i=(a);i<(b);++i)
#define all(obj) (obj).begin(), (obj).end()
#define in(x) cin >> (x)
#define out(y) cout << (y) << "\n"
#define i64 int64_t
#define str string
using namespace std;
void Main() {
	/*----------------------------------------------------------------------------------------------------*/
	i64 N, K;
	in(N); in(K);
	vector<i64> p(N);
	rep(i, N) in(p[i]);
	sort(p.begin(), p.end());
	i64 sum = 0;
	rep(i, K) sum += p[i];
	out(sum);
	/*----------------------------------------------------------------------------------------------------*/
}
int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
	return 0;
}

Measured memory_bytes: 3644
N, M = map(int,input().split())
mat = [list(map(int,input().split())) for o in range(M)]
lmax = mat[0][0]
for i in range(M):
    if mat[i][0] > lmax:
        lmax = mat[i][0]
rmin = mat[0][1]
for i in range(M):
    if mat[i][1] < rmin:
        rmin = mat[i][1]

ans = rmin - lmax + 1
if ans >= 1:
    print(ans)
else:
    print(0)

Measured memory_bytes: 27340
from statistics import variance
import math
while(1):
    n=int(input())
    if(n==0):
        break
    elif(n==1):
        data=list(map(int,input().split()))
        print(0)
    else:
      data=list(map(int,input().split()))
      print(math.sqrt(variance(data) *(n-1) /n))


Measured memory_bytes: 7072
#include <stdio.h>

int main(void){
  int N,ans = 0;
  int counter = 0;
  scanf("%d",&N);

  for(int i = 105;i <= N;i++){
    counter = 0;
    for(int j = 1;j <= N;j+=2){
      if(i%j == 0){
        counter++;
      }
    }
    if(counter == 8){
      ans++;
    }
  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    int ans = s.size();
    rep(i, s.size() - 1){
        if(s[i] != s[i + 1]){
            int tmp = max(i + 1, (int)s.size() - (i + 1));
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    map< pair<ll, ll>, ll > mp;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        string s = to_string(i);
        int p = s[0] - '0';
        int q = s.back() - '0';
        mp[{p, q}]++;
    }
    ll res = 0;
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            res += (mp[{i, j}] * mp[{j, i}]);
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 100000

int parent(int i) {
	return i / 2;
}
int left(int i) {
	return 2 * i;
}
int right(int i) {
	return 2 * i + 1;
}

int main() {
	int H;
	cin >> H;
	int A[MAX+1];
	for (int i = 1;i <= H;i++) {
		cin >> A[i];
	}
	for (int i = 1;i <= H;i++) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) {
			cout << "parent key = " << A[parent(i)] << ", ";
		}
		if (left(i) <= H) {
			cout << "left key = " << A[left(i)] << ", ";
		}
		if (right(i) <= H) {
			cout << "right key = " << A[right(i)] << ", ";
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

unordered_map<int64_t, int64_t> cache;

int64_t dfs(int64_t H) {
  if (cache.find(H) != cache.end()) return cache[H];

  if (H == 1) {
    cache[H] = 1;
    return cache[H];
  }

  int64_t h1 = H / 2;
  cache[H] = dfs(h1) * 2 + 1;
  return cache[H];
}

int main() {
  int64_t H;
  cin >> H;

  int64_t answer = dfs(H);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::collections::VecDeque;
 
fn main() {
    let mut input = Input::new();
    let n = input.next().parse::<usize>().unwrap() + 1;
    let m = input.next().parse::<usize>().unwrap() + 1;
    let q = input.next().parse::<usize>().unwrap();
    let mut s = vec![vec![0; m + 5]; n + 5];
    for i in 1..n {
        let t: Vec<_> = input.next().chars().collect();
        for j in 1..m {
            s[i][j] = if t[j - 1] == '1' {1} else {0};
        }
    }
    let mut bit = vec![vec![0; m]; n];
    let mut sid = vec![vec![0; m]; n];
    let mut ver = vec![vec![0; m]; n];
    for i in 1..n {
        for j in 1..m {
            bit[i][j] = bit[i-1][j] + bit[i][j-1] - bit[i-1][j-1] + s[i][j];
            sid[i][j] = sid[i-1][j] + sid[i][j-1] - sid[i-1][j-1] + if s[i][j] == 1 && s[i][j-1] == 1 {1} else {0};
            ver[i][j] = ver[i-1][j] + ver[i][j-1] - ver[i-1][j-1] + if s[i][j] == 1 && s[i-1][j] == 1 {1} else {0};
        }
    }
    for _ in 0..q {
        let x1 = input.next().parse::<usize>().unwrap() - 1;
        let y1 = input.next().parse::<usize>().unwrap() - 1;
        let x2 = input.next().parse::<usize>().unwrap();
        let y2 = input.next().parse::<usize>().unwrap();
        let a = bit[x2][y2] - bit[x2][y1] - bit[x1][y2] + bit[x1][y1];
        let b = sid[x2][y2] - sid[x2][y1+1] - sid[x1][y2] + sid[x1][y1+1];
        let c = ver[x2][y2] - ver[x2][y1] - ver[x1+1][y2] + ver[x1+1][y1];
        println!("{}", a - b - c);
    }
}
 
struct Input {
    queue: VecDeque<String>,
}
 
impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }
 
    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
}

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

int main(){
while(1){
	int n,m,h,k,r[1002],p[1002],e[1002],c,d,ans=0,ma=0;
	vector<int> a[1000],aa,bb;
	scanf("%d%d%d%d",&n,&m,&h,&k);
if(n==0)break;
	for(int i=1;i<=n;i++){r[i]=i; scanf("%d",&p[i]);}
	for(int i=0;i<m;i++){scanf("%d%d",&c,&d); a[d].push_back(c);}
	for(int i=0;i<1000;i++){
		int s=a[i].size();
		for(int j=0;j<s;j++){
			aa.push_back(r[a[i][j]]);
			bb.push_back(r[a[i][j]+1]);
			int t=r[a[i][j]];
			r[a[i][j]]=r[a[i][j]+1];
			r[a[i][j]+1]=t;}}
	for(int i=1;i<=n;i++)e[r[i]]=i;
	for(int i=1;i<=k;i++)ans+=p[e[i]];
	for(int i=0;i<m;i++){
		int f=p[e[aa[i]]]-p[e[bb[i]]];
		if(aa[i]<=k&&bb[i]>k&&f>ma)ma=f;
		else if(bb[i]<=k&&aa[i]>k&&-f>ma)ma=-f;
	}
	printf("%d\n",ans-ma);
}
}

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

if N < 3:
  print(0)
  exit()
  
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if max(L[i],L[j],L[k]) * 2 < L[i]+L[j]+L[k]:
                ans += 1 

print(ans)

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

int main() {
    int a,b;
    cin>>a>>b;

    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }
    else {
        cout<<"IMPOSSIBLE"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define pb push_back
#define f first
#define s second
#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i<= n; i++)
#define MOD 1000000007
const int MAX = 2123;
string s;
int n;
int l, r;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	n = s.size();
	l = 0;
	r = n-1;
	for(l = 0; l < n; l++){
		if(s[l] == 'A') break;
	}
	for(r = n-1; r >= 0; r--){
		if(s[r] == 'Z') break;
	}

	cout << r-l+1 << endl;
}


Measured memory_bytes: 720
// WA

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool solve(string& s) {
  for (size_t i = 0; i <= s.size(); ++i) {
    for (size_t l = i; l <= s.size(); ++l) {
      string t;
      for (size_t k = 0; k < s.size(); ++k) {
        if (k >= i && k <= l)
          continue;
        t += s[k];
      }
      // cout << t << endl;
      if (t == "keyence") return true;
    }
  }
  return false;
}

int main() {
  string s;
  cin >> s;
  cout << (solve(s) ? "YES" : "NO") << endl;
}

// keyencekeyencekeyence yes
// aaakeyence yes
// keyenceaaa yes
// eaaakeyenceaaa no
// bbbkeyenaaace no


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    vector<LL> cnt(45);
    rep(i, 0, n){
        cin >> a[i];
        LL t = a[i];
        LL j = 0;
        while (t)
        {
            if(t & 1)
                cnt[j]++;
            j++;
            t >>= 1;
        }
    }
    LL ans = 0;
    bool less = 0;
    for(int i = 44; i >= 0; i--){
        LL x = (1LL << i);
        // if(x <= k && x ^ ans <= k && cnt[i] * 2 < n){
        //     ans ^= x;
        // }
        if(cnt[i] * 2 >= n){
            // ans += cnt[i] * x;
            if(x & k)   less = 1;
        }
        else if(x & k || less) 
            // ans +=  (n-cnt[i]) * x;
            ans ^= x;
        // else ans += cnt[i] * x;
    }
    LL res = 0;
    rep(i, 0, n)
        res += ans ^ a[i];
    cout << res << endl;
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    vector<int> beki;
    for (int i = 1; i <= 1000; ++i) {
        if (i == 1) {
            beki.pb(1);
            continue;
        }
        for (int j = 2; pow(i, j) <= 1000; ++j) {
            beki.pb(pow(i, j));
        }
    }
    sort(beki.begin(), beki.end());
    int p = upper_bound(beki.begin(), beki.end(), x) - beki.begin();
    cout << beki[p-1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int

using namespace std;


//約数列挙アルゴリズム　O（√N）
vector <ll > divisor(ll n) {
  vector <ll> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    ll N,M;
    cin>>N>>M;
    vector <ll> divide = divisor(M);
    reverse(divide.begin(),divide.end());
    ll ans = 1;
    for(int i=0;i<divide.size();i++){
        ll sum = M/divide[i];
        if(sum >= N) {ans = divide[i];break;}

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	string s;
	cin >> s;
	vector<vi> v;
	char nx = 'a';
	REP(i, s.size())
	{
		if (s[i] != nx)
		{
			vi t;
			t.push_back(s[i] == 'c' ? 1 : 0);
			v.push_back(t);
		}
		else
		{
			v.back().push_back(1 - v.back().back());
		}
		if (s[i] == 'c')
		{
			i += 6;
			nx = 'e';
		}
		else
		{
			i += 2;
			nx = 'c';
		}
	}
	int mx = 0;
	REP(i, v.size())
	{
		chmax(mx, (int)v[i].size());
	}
	REP(i, v.size())
	{
		if (v[i].size() == mx)
		{
			if (v[i].back() == 0) puts("egg");
			else puts("chicken");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<string> T;
  T.push_back("");
  T[0].push_back(S[0]);
  T.push_back("");
  for (int i = 1; i < N; i++){
    T.back().push_back(S[i]);
    if (T[T.size() - 2] != T[T.size() - 1]){
      T.push_back("");
    }
  }
  if (T.back() == ""){
    T.pop_back();
  }
  if (T.size() >= 2){
    if (T[T.size() - 2] == T[T.size() - 1]){
      T.pop_back();
    }
  }
  cout << T.size() << endl;
}

Measured memory_bytes: 10996
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>

struct Point
{
    double x;
    double y;
};
Point GetU(const Point& s, const Point& t)
{
    const double thete = 60. / 180. * M_PI;
    Point st = {t.x - s.x, t.y - s.y};
    Point su = {st.x * std::cos(thete) - st.y * std::sin(thete), st.x * std::sin(thete) + st.y * std::cos(thete)};
    Point u = {s.x + su.x, s.y + su.y};
    return u;
}
void Print(const Point& p)
{
    std::cout << p.x << " " << p.y << std::endl;
    
}
void KochCurve(const Point& p1, const Point& p2, int n)
{
    if(!n) return;
    double x = (p2.x - p1.x) / 3;
    double y = (p2.y - p1.y) / 3;
    Point s = {p1.x + x, p1.y + y};
    Point t = {p2.x - x, p2.y - y};
    Point u = GetU(s, t);
    
    // Print(p1);
    KochCurve(p1, s, n - 1);
    Print(s);
    KochCurve(s, u, n - 1);
    Print(u);
    KochCurve(u, t, n - 1);
    Print(t);
    KochCurve(t, p2, n - 1);
    // Print(p2);
}

int main()
{
    int n;
    std::cin >> n;
    Point alpha = {  0, 0};
    Point omega = {100, 0};
    Print(alpha);
    KochCurve(alpha, omega, n);
    Print(omega);
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;
#define get(vv, times) for(int ii = 0; ii < times; ++ii) {int jj; cin >> jj; (vv).pb(jj);}

int n, k, a[300100], r[300100], b[300100], sum, ans;
priority_queue <int, vector <int>, greater <int>> qp;
priority_queue <int> pq;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    ans = -1e18l;
    for(int i = 0; i < 3 * n; ++i) cin >> a[i];
    sum = 0;
    for(int i = 0; i < 3 * n; ++i) {
        qp.push(a[i]);
        sum += a[i];
        if (qp.size() > n) {
            sum -= qp.top();
            qp.pop();
        }
        // cout << i << '\n';
        r[i] = sum;
    }
    sum = 0;
    for(int i = 3 * n - 1; i >= 0; --i) {
        // cout << a[i] << '\n';
        pq.push(a[i]);
        sum += a[i];
        // cout << "a[i]: " << a[i] << " sum: " << sum << " pq.size(): " << pq.size() << '\n';
        if (pq.size() > n) {
            // cout << i << " hello\n";
            // assert(0);
            sum -= pq.top();
            pq.pop();
        }
        // cout << i - n << '\n';
        // cout << sum << '\n';
        b[i] = sum;
    }
    // for (int i = 0; i < n * 3; ++i) cout << r[i] << ' ';
    // cout << '\n';
    // for (int i = 0; i < n * 3; ++i) cout << b[i] << ' ';
    for(int i = n-1; i < 2 * n; ++i) {
        ans = max(ans, r[i] - b[i+1]);
    }
    cout << ans;
    // time
}


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

using namespace std;

int main(void){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for(int i = 0; i < N; i++) cin >> x[i];
  for(int i = 0; i < M; i++) cin >> y[i];
  for(int Z = X + 1; Z <= Y; Z++){
    if(*max_element(x.begin(), x.end()) < Z && Z <= *min_element(y.begin(), y.end())){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <stdio.h>
using namespace std;
#include <string>
#include <vector>
int main(void) {
    int n;
    int a;
    int count=0;
    cin >>n;
    for(int i=1;i<n;i++){
        a=i;
        for(int j=1;j<double(n)/double(a);j++){
            count=count+1;
            }
    
    }
    cout<<count;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<iomanip>

using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;

string k,l;
int main(){
	ll l;
	cin>>l;
	double a = l/3.0;
	double d = a * a * a;
	cout <<fixed<<setprecision(12)<<d<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(a>c){
		d=a;
		a=c;
		c=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    if(s.size()==2){
        if(s[0]==s[1]){
            cout<<"1 2";
        }
        else{
            cout<<"-1 -1";
        }
        return 0;
    }
    for(int i=0; i<s.size()-2; i++){
        if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;

    return 0;
}

Measured memory_bytes: 512
h, w = map(int, input().split())
S = [input().split() for _ in range(h)]
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(h):
  for j in range(w):
    if S[i][j] == "snuke":
      print(alpha[j] + str(i + 1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[210000];

ll pow_mod(ll n, ll k, ll mod)
{
    if (k == 0)
    {
        return 1;
    }
    else if (k % 2 == 1)
    {
        return pow_mod(n, k - 1, mod) * n % mod;
    }
    else
    {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

ll modinv(ll x)
{
    return pow_mod(x, MOD - 2, MOD);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, a;
    cin >> n >> k >> a;
    dp[0] = 1;
    for (ll i = 0; i < k; i++)
    {
        ll p = dp[i] * modinv(n) % MOD;
        if (i > 0)
        {
            (p *= a * modinv(100) % MOD) %= MOD;
        }
        (dp[i + 1] += p) %= MOD;
        (dp[i + n + 1] += MOD - p) %= MOD;
        if (i > 0)
        {
            (dp[i + 1] += dp[i]) %= MOD;
        }
    }
    ll ans = 0;
    for (ll i = k; i <= n + k; i++)
    {
        (ans += dp[i]) %= MOD;
        (dp[i + 1] += dp[i]) %= MOD;
    }
    cout << ans << endl;
}


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

using namespace std;

int n, ball[10];

bool solve(int idx, int l, int r) {

    if(idx == 10) return true;

    bool ret = false;
    if(ball[idx] > l) ret = ret || solve(idx + 1, ball[idx], r);
    if(ball[idx] > r) ret = ret || solve(idx + 1, l, ball[idx]);
    return ret;

}

int main() {

    cin >> n;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 10; ++j) {
            cin >> ball[j];
        }
        cout << (solve(0, 0, 0) ? "YES" : "NO") << endl;
    }

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int k;
  cin >> k;
  queue<ll> que;
  for(int i=1; i<=9; i++){
    que.push(i);
  }
  rep(i,k){
    ll x = que.front();
    que.pop();
    if(i==k-1){
      cout << x << endl;
    }
    for(int j=-1; j<=1; j++){
      ll nx = x%10+j;
      if(nx<0||nx>9){
        continue;
      }
      que.push(10*x+nx);
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int main() {
    int N, M, X, Y;
    while (cin >> N >> M >> X >> Y) {
        vector<int> x(N); for (int i = 0; i < N; ++i) cin >> x[i];
        vector<int> y(M); for (int i = 0; i < M; ++i) cin >> y[i];
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        int minz = x.back() + 1;
        int maxz = y[0];
        bool ok = false;
        for (int z = X+1; z <= Y; ++z) {
            if (z >= minz && z <= maxz) ok = true;
        }
        if (ok) puts("No War");
        else puts("War");
    }
}
            


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
全体のxorが不変量。
N-1数が127のときに等号
"""

T = int(input())
ND = [[int(x) for x in input().split()] for _ in range(T)]

answer = []
for N,D in ND:
    x = 127 * (N-1)
    if N&1:
        x += D
    else:
        x += 127^D
    answer.append(x)

print('\n'.join(map(str,answer)))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String inStr;
		inStr = inp();
		String[] in;
		in = inStr.split(" ");

		int a = Integer.valueOf(in[0]);
		int b = Integer.valueOf(in[1]);
		System.out.println((a * b) + " " + (2 * a + 2 * b));

	}

	private static String inp() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}

Measured memory_bytes: 24136