akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
        c[i]=a[i];
    }
    if(prev_permutation(a.begin(),a.end())){
        for(int i=0;i<n;i++) cout<<a[i]<<((i==n-1)?'\n':' ');
    }
    for(int i=0;i<n;i++) cout<<b[i]<<((i==n-1)?'\n':' ');
    if(next_permutation(c.begin(),c.end())){
       for(int i=0;i<n;i++) cout<<c[i]<<((i==n-1)?'\n':' '); 
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;

    ll l = lcm(n, m);
    bool flag = true;
    for(ll i = 0; i < gcd(n, m); i++){
        if(s[l / m * i] == t[l / n * i]) continue;
        else{
            flag = false;
            break;
        }
    }
    if(flag) cout << l << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3736
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    cnt = [0]*9
    for a in A:
        idx = min(a//400, 8)
        cnt[idx] += 1
    ans = sum(int(a > 0) for a in cnt[:-1])
    if ans != 0:
        print(ans, ans+cnt[-1])
    else:
        print(1, cnt[-1])


if __name__ == '__main__':
    main()


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e6 + 7;
int n, sumtop;

struct T {
  int o;
  int mn;
};

bool cmp1(T a, T b) {
  return a.mn > b.mn;
}

bool cmp2(T a, T b) {
  return a.o > b.o;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<T> a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    int o = 0, top = 0, mn = 0;
    for (auto &ch : s) {
      if (ch == '(') {
        top++;
      } else {
        top--;
      }
      mn = min(mn, top);
      if (ch == '(') {
        o++;
      } else {
        if (o) {
          o--;
        } 
      }
    }
    if (o >= -mn) {
      a.push_back({o, mn});
    } else {
      b.push_back({o, mn});
    }
    sumtop += o + mn;
  }
  if (sumtop != 0) {
    cout << "No\n";
    return 0;
  }
  sort(a.begin(), a.end(), cmp1);
  sort(b.begin(), b.end(), cmp2);
  int cur = 0;
  for (auto &it : a) {
    if (cur + it.mn < 0) {
      cout << "No\n";
      return 0;
    }
    cur += it.o + it.mn;
  }
  for (auto &it : b) {
    if (cur + it.mn < 0) {
      cout << "No\n";
      return 0;
    }
    cur += it.o + it.mn;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 11120
#include <stdio.h>

int main(void)
{
    int x, y;

    while(1)
    {    
        scanf("%d %d", &x, &y);
        
        if(x == 0 && y == 0)
        {
            break;
        }
        else
        {
            if(x <= y)
            {
                printf("%d %d\n", x, y);
            }
            else
            {
                printf("%d %d\n", y, x);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main{
	public static int M=12;
	  public static int N=12;
	public static void main(String[] a)throws java.io.IOException{

	Scanner scan=new Scanner(System.in);
	while(scan.hasNext()){
		            int ans =0;
		            int [][] field =new int[M][N];
		            for(int i=0;i<M;i++){
		             String line = scan.nextLine();
		                for(int j=0;j<N ;j++){
		                    field[i][j] = line.charAt(j);

		                }
		            }


		            for(int i=0;i<M;i++){
		                for(int j=0;j<N;j++){
		                    if(field[i][j] != '0'){
		                        ++ans;
		                        dfs(i,j,field);

		                    }
		                }
		            }
		            System.out.println(ans);
		            scan.nextLine();

		    }
	}


		  public static void dfs(int y,int x,int [][] field){
		      int crop = field[y][x];
		      field[y][x] = '0';
		      int [] dx = {1,0,-1,0};
		      int [] dy ={0,1,0,-1};
		      for(int i=0;i<4;i++){
                  int nx =x+dx[i];
                  int ny =y+dy[i];
		          if(0<=nx && nx< N &&0<=ny && ny <M  &&( field[ny][nx]==crop))
		              dfs(ny,nx,field);
		      }
		      return;
		  }
}

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

int main()
{
    long int n,ar[100005],check[100005]={0},i,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]>100000)
        {
            c++;
        }
        else if(ar[i]<=100000)
        {
            check[ar[i]]++;
        }
    }

    for(i=0;i<=100000;i++)
    {
        if(check[i]>i)
        {
            c = c+(check[i]-i);
        }
        else if(check[i]<i)
        {
            c = c+check[i];
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


map<char,ll>mp;


ll dp[102][5][5][5][5];

ll n;

string str;


ll ok(ll a,ll b,ll c,ll d)
{
   ll sum=0,num=0;

   sum=a;

   sum*=10;

   sum+=b;

   sum*=10;

   sum+=c;

   sum*=10;

   sum+=d;



   num=b;

   num*=10;

   num+=c;

   num*=10;

   num+=d;


   if(sum==123 || sum==132 || sum==213 ||
      sum==1243 || sum==1423 || sum==1223 || sum==1323)
        return -1;

   if(num==123 || num==132 || num==213)return -1;


      if(num<100)return 0;

      else return 1;



}

ll call(ll pos,ll a,ll b,ll c,ll d)
{

      if(ok(a,b,c,d)==-1)return 0;

      if(pos==n)
      {
          if(ok(a,b,c,d)==1)return 1;

          else return 0;
      }

      ll &ret=dp[pos][a][b][c][d];


      if(~ret)return ret;


      ret=0;

      for(ll i=0; i<4; i++)
      {
          ret=(ret+call(pos+1,b,c,d,mp[str[i]]))%Mod;
      }


        return ret%Mod;




}

int main()
{

   fastread();

   ll i,j,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;



      cin>>n;

      memset(dp,-1,sizeof(dp));

   str="AGCT";

    mp['A']=1;

    mp['G']=2;

    mp['C']=3;

    mp['T']=4;


    cout<<call(0,0,0,0,0)<<endl;
















}



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

bool cmp(int a,int b){
        return a>b;
}


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

    //Insert code
    
    ll n,res=0,tmp1=0,tmp2=0;
    ll a[100005],b[100005],c[100005];
    cin>>n;

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

    for (int i=0;i<n;i++){
        cin>>b[i];
        if (a[i]<b[i]) {
            //cout<<a[i]<<" "<<b[i]<<endl;
            tmp1+=a[i];
            tmp2+=b[i];
            a[i]==0;
            res++;
            c[i]=0;
        } else c[i]=a[i]-b[i];
    }
    //cout<<tmp1<<" "<<tmp2<<endl;
    if (tmp1>=tmp2){
        cout<<res;
        return 0;
    }

    sort(c,c+n);
   
    //for (int i=0;i<n;i++) cout<<c[i]<<" "<<endl;
    int i=n-1;
    while (tmp1<tmp2 && i>=0 && c[i]!=0){
        tmp1+=c[i];
        res++;
        i--;
    }
    
    //cout<<tmp1<<" "<<tmp2<<endl;

    if (tmp1<tmp2){
        cout<<-1;
        return 0;
    }

    cout<<res;

    //End code


    cerr << "\nTime elapsed: " << 1000*clock() / CLOCKS_PER_SEC << "ms\n";
    
}


Measured memory_bytes: 2560
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from math import gcd

n=int(input())
a=lnii()

g=a[0]
for i in range(n):
  g=gcd(g,a[i])

def factorization(n):
    p=2
    fcr=set()
    while p*p<=n:
        while n%p==0:
            fcr.add(p)
            n//=p
        p+=1
    if n>1:
        fcr.add(n)
    return fcr

def eratosthenes(lim):
  is_p=[1]*lim

  is_p[0]=0
  is_p[1]=0

  for i in a:
    fcr=factorization(i)
    for j in fcr:
      if is_p[j]:
        for k in range(j,lim,j):
          is_p[k]=0
      else:
        if g==1:
          print('setwise coprime')
        else:
          print('not coprime')
        exit()
  return is_p

lim=10**6+1
is_p=eratosthenes(lim)

print('pairwise coprime')

Measured memory_bytes: 182352
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int num = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();

		try(Scanner scan = new Scanner(System.in)) {
			while(true) {
				num = scan.nextInt();
				if(num == 0) {
					break;
				}
				list.add(num);
			}
			for(int i = 0; i < list.size(); i++) {
				System.out.println("Case " + (i + 1) + ": " + list.get(i));
			}
		}
	}

}

Measured memory_bytes: 43828
N, M = map(int, input().split())
lst = []
for i in range(M):
    a, b = map(int, input().split())
    lst.append([a, b])

lst.sort()
d = []
d.append(lst[0])
for i in range(1, M):
    if lst[i][0] != lst[i-1][0]:
        flag = 0
        for j in range(len(d)):
            if d[j][1] > lst[i][0]:
                d[j][0] = lst[i][0]
                if d[j][1] > lst[i][1]:
                    d[j][1] = lst[i][1]
                flag += 1
                break
        if flag == 0:
            d.append(lst[i])
print(len(d))

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::map<int, int> mp;
	for (size_t i = 0; i < n; i++) {
		int temp; std::cin >> temp;
		auto itr = mp.find(temp);
		if (itr != mp.end()) {
			mp[temp] += 1;
		}
		else {
			mp[temp] = 1;
		}
	}

	bool flag = false;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		//std::cout << i->first << ':' << i->second << '\n';
		int val = i->second;
		if (val > 1) {
			if (flag) {
				val--;
				flag = !flag;
			}
			// 奇数枚の時は、同じ数字を3つ選んで、2つ消すという操作を繰り返せば良い
			if (val % 2 == 1) {}
			/* 偶数枚の時
			 *	if 2枚
			 *		その2枚と、他の数字の一枚を選ぶ
			 *	else
			 *		同じ数字を3つ選んで2つ消すという操作を繰り返す
			 */
			else {
				flag = !flag;
			}
		}
	}

	if (flag) {
		std::cout << mp.size() - 1 << '\n';
	}
	else {
		std::cout << mp.size() << '\n';
	}
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    
    int ans = max(0,C-(A-B));
    cout << ans << "\n";
    return 0;
}


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

#define mod 1000000007

using namespace std;
using ll = long long;

int x = 0;
ll memo[100];

ll lucas(int n){
    if(n > 1){
        if(memo[n-1] == -1){
            memo[n-1] = lucas(n-1);
        }
        if(memo[n-2] == -1){
            memo[n-2] = lucas(n-2);
        }
        return memo[n-1]+memo[n-2];
    }else if(n == 1){
        return 1;
    }else if(n == 0){
        return 2;
    }
}

void solve(){
    int n;
    cin >> n;
    for(int i = 0; i < 100; i++){
        memo[i] = -1;
    }
    cout << lucas(n) << endl;
}

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


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int sum, ave;
int x, y;
int num;

int main()
{
  while(scanf(" %d,%d", &x, &y) == 2){
    sum += x * y;
    ave += y;
    num += 1;
  }

  cout << sum << endl << round(1.0 * ave / num) << endl;

  return 0;
}

Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctype.h>
#include <stack>
using namespace std;

char buf[100000];

int main() {
  while (1) {
    if (fgets(buf, sizeof(buf), stdin) == NULL) return 0;

    char *p;
    p = strchr(buf, '\n');
    if (p) *p = '\0';

    stack<double> st;
    int n = strlen(buf);
    p = buf;
    while (p < buf+n) {
      if (*p == ' ') {
        ++p;
        continue;
      }

      char *next;
      long t = strtol(p, &next, 10);
      if (p != next) {
        st.push(t);
        p = next;
      } else {
        double b = st.top(); st.pop();
        double a = st.top(); st.pop();

        if (*p == '+') st.push(a+b);
        else if (*p == '-') st.push(a-b);
        else if (*p == '*') st.push(a*b);
        else if (*p == '/') st.push(a/b);
        else {
          st.push(a);
          st.push(b);
        }
        ++p;
      }
    }

    printf("%f\n", st.top());
  }
}

Measured memory_bytes: 2580
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
        int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans = "";
        if (b > a) {
          int gap = b - a;
          if (gap > x) {
            ans = "dangerous";
          } else {
            ans = "safe";
          }
        } else {
          ans = "delicious";
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

string S;


int main(void) {

	cin >> S;

	if (S == "ABC") { cout << "ARC" << endl; }
	else { cout << "ABC" << endl; }

	return 0;
}

Measured memory_bytes: 3636
n = gets.chomp.to_i
h_array = gets.chomp.split.map(&:to_i)
result = []
count = 0
result.push(0) if n == 1
h_array.each_cons(2) do |h1, h2|
  if h1 >= h2
    count += 1
  else
    count = 0
  end
  result.push(count)
end

puts result.max

Measured memory_bytes: 10500
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
#include<functional>


using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;

	int n;
	cin >> n;

	queue<int> color;
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			color.push(i);
		}
	}
	
	int grid[100][100];
	for (int i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < w; j++) {
				int l;
				l = color.front();
				color.pop();
				grid[i][j] = l;
			}
		}
		else {
			for (int j = w - 1; j >= 0; j--) {
				int l;
				l = color.front();
				color.pop();
				grid[i][j] = l;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << grid[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

MOD = 10**9 + 7

def getPrimes(n):
    if (n < 2):
        return []

    flags = [False]*(n+1)
    primes = [2]

    for p in range(3, n+1, 2):
        if not flags[p]:
            primes.append(p)
            for k in range(p**2, n+1, p):
                flags[k] = True

    return primes


def modPow(a, b, mod):
    x = 1
    
    while b > 0:
        if b & 1:
            x = (x*a)%mod

        a = (a**2)%mod
        b //= 2

    return x


def getModInv(a, b):
    return 1 if (a == 1) else int((1-b*getModInv(b%a, a))/a%b)


def getFactors(x):
    factors = {}
    for p in P:
        if x < 2:
            break

        n = 0
        while x%p == 0:
            x //= p
            n += 1

        if n > 0:
            factors[p] = n

    if x > 1:
        factors[x] = 1

    return factors


P = getPrimes(1000)

N = int(input())
A = list(map(int, input().split()))

maxFacts = {}

for a in A:
    facts = getFactors(a)
    for p in facts:
        if not p in maxFacts or maxFacts[p] < facts[p]:
            maxFacts[p] = facts[p]

lcd = 1
for p in maxFacts:
    lcd = lcd * modPow(p, maxFacts[p], MOD)%MOD

lcd %= MOD

s = 0
for a in A:
    s += lcd*getModInv(a, MOD)%MOD

print(s%MOD)            
            


Measured memory_bytes: 4596
a, b = input().split()
a = int(a)
b = int(b)
ans = 0
if a > b:
    ans += a
    a = a - 1
else:
    ans += b
    b = b - 1
if a > b:
    ans += a
    a = a - 1
else:
    ans += b
    b = b - 1
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    static boolean[] b;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        b = new boolean[10];
        Arrays.fill(b, true);
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            b[d] = false;
        }
        for (;;n++) {
            if (check(n)) {
                System.out.println(n);
                return;
            }
        }
    }
    public static boolean check(int n) {
        boolean ret = true;
        while (n > 0) {
            if (!b[n % 10]) ret = false;
            n /= 10;
        }
        return ret;
    }
}

Measured memory_bytes: 21716
"use strict"
function Main(input){
  input=input.trim();
  input=input.replace(/\s+/,"").split("");
  var height=input.length;
  var one=0;
  var zero=0;
  while(input.length){
    if(input.pop()==="0")zero++;
    else one++;
  }
  console.log(Math.min(zero,one)*2);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 8268
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main (void) {
char S[200]={'\0'};
char T[200]={'\0'};
scanf("%s %s",S,T);
char result[400]={'\0'};
strcpy(result,T);
for (int i=0;i<strlen(S)+strlen(T);i++){
    result[strlen(T)+i]=S[i];
}
printf("%s",result);

return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main (){
  int x,y,i,v;
  
  scanf("%d%d",&x,&y);

  if(x < 1 || y < 1 || x > 1000000000 || y > 1000000000){
    printf("Please type 1 to 1000000000.");
    exit(1);
  }

  if(x > y){
    v = x;
    x = y;
    y = v;
  }


    for(i=1; i<=x/2;i++){
      if(x%i == 0 && y%i == 0){
	v = i;
      }
    }
    if(x == y)v=x;
  
   
  printf("%d\n",v);
  
  
  return 0;
}




Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
// #define iter(a) __typeof(a.begin())
#define FOR(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define F first
#define S second
#define SZ(a) static_cast<int>((a).size())
#define sz(a) SZ(a)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).begin(), (a).end()
using namespace std;

typedef int64_t ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef uint64_t ull;

#ifdef ONLINE_JUDGE
#define PR(...) (void(0))
#else
#define PR(...) \
  do { cerr << "line : " << __LINE__ << ", " << endl;  \
    pr(#__VA_ARGS__, __VA_ARGS__); } while (0)

template<class T>
void pr(const string& name, T t) {
  cerr << name << ": " << t << endl;
}
template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto p = names.find(',');
  cerr << names.substr(0, p) << ": " << t << ", ";
  pr(string(names, p + 1), rest ...);
}
#endif

template<class T, class U> ostream& operator<<(
    ostream& o, const pair<T, U>& v) {
  return o << "(" << v.F << ", " << v.S << ")";
}
template<class T> ostream& operator<<(
    ostream& o, const vector<T>& v) {
  o << "{"; rep(i, SZ(v)) o << (i?", ":"") << v[i]; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const unordered_map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> string to_s(const T& v) {
  ostringstream is; is << v; return is.str(); }

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

#define endl '\n'


int main(int argc, char *argv[])
{
  vector<ll> in(3);
  rep(i, 3) cin >> in[i];
  rep(i, 3) if(in[i]%2 == 0){
    cout << 0 << endl;
    return 0;
  }

  cout << min({in[0] * in[1], in[1] * in[2], in[0] * in[2]}) << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int k, n, maxv=0;
	cin >> k >> n;
	int a[n+1], b[n+1];
	cin >> a[1];
	for(int i=2; i<=n; i++){
		cin >> a[i];
		b[i]=a[i]-a[i-1];
	}
	b[1]=k-a[n]+a[1];
	for(int i=1; i<=n; i++)
		maxv=max(b[i],maxv);
	cout<<k-maxv<<endl;
	return 0;
}

Measured memory_bytes: 1792
import Control.Applicative ((<$>), (<*>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = solve <$> (map read <$> words <$> getLine) <*> (map (readi B.readInt) <$> B.lines <$> B.getContents) >>= print

solve :: [Int] -> [Int] -> Int
solve [_, k] ws = bsearch (f 0 0 ws) 0 (sum ws)
  where f ct sw [] p = ct + 1 <= k
        f ct sw (x:xs) p | ct > k = False
                         | sw + x > p = f (ct + 1) 0 (x:xs) p
                         | otherwise = f ct (sw + x) xs p

bsearch :: (Int -> Bool) -> Int -> Int -> Int
bsearch f fp pp | fp + 1 == pp = pp
                | f tp = bsearch f fp tp
                | otherwise = bsearch f tp pp
  where tp = (fp + pp) `div` 2

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n



Measured memory_bytes: 35660
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,ans;
priority_queue<long long> q;
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++){
		cin>>a;
		q.push(a);
	}
	for (int i=0;i<m;i++){
		a=q.top()/2;q.pop();
		q.push(a);
	}
	while (!q.empty()){
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define MOD 1000000007

char s[3010];
ll dp[3010][3010];//dp[i][j]=(i番目まで決めて、i番目より大きいものがj個残っている)

int main(){
	ll n;
	scanf("%lld %s",&n,s);
	rep(j,0,n)dp[1][j]=1;
	rep(i,1,n){
		ll temp[3010]={};
		rep(j,0,n-i+1)temp[j+1]=(temp[j]+dp[i][j])%MOD;
		if(s[i-1]=='<'){
			//大きいものから使うので、jは減る
			//配るDP
			//rep(j,0,n-i+1)rep(k,0,j)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
			//もらうDP
			//rep(k,0,n-1)rep(j,k+1,n-i+1)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
			//累積和を使って加速
			rep(k,0,n-i)dp[i+1][k]=(temp[n-i+1]-temp[k+1])%MOD;
		}else{
			//小さいものから使うので、jは増える
			//配るDP
			//rep(j,0,n-i+1)rep(k,j,n-i+1)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
			//もらうDP
			//rep(k,0,n-i)rep(j,0,j+1)dp[i+1][k]=(dp[i+1][k]+dp[i][j])%MOD;
			rep(k,0,n-i)dp[i+1][k]=temp[k+1];
		}
	}
	printf("%lld\n",(dp[n][0]+MOD)%MOD);
	return 0;
}

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

/*define*/
string S;
int K;
int N;

int main(){
    /*inpus*/
    std::cin >> K;
    std::cin >> S;

    /*syori*/
    N = S.length();
    if(N>K){
        S = S.substr(0,K)+"...";
    }

    std::cout << S;
}

Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    println!("{}", std::iter::repeat('x').take(s.len()).collect::<String>());
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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;
};

pair<vector<char>, vector<int>> Block(string s) {
  int num = 1;
  vector<char> v1;
  vector<int> v2;
  rep (i, 0, s.size()) {
    char c = s[i];
    if (i == 0) {
      v1.pb(c);
    } else if (c == s[i - 1]) {
      num++;
    } else {
      v2.pb(num);
      v1.pb(c);
      num = 1;
    }

    if (i == s.size() - 1) v2.pb(num);
  }

  return make_pair(v1, v2);
};

int main() {
  string s;
  cin >> s;
  auto block = Block(s);
  vector<int> ans(s.size(), 0);

  int idx = -1;

  rep(i, 0, block.first.size()) {
    char ch = block.first[i];
    if (ch == 'R') {
      int R_size = block.second[i];
      int L_size = block.second[i+1];
      int R_idx = idx + R_size;
      int L_idx = R_idx + 1;
      ans[R_idx] += ((R_size+1) / 2 + (L_size) / 2);
      ans[L_idx] += ((R_size) / 2 + (L_size + 1) / 2);
      idx += (R_size + L_size);
    }
  }

  PrintVec(ans);

  return 0;
};


Measured memory_bytes: 1528
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
s = input()
nums = []
now = 1

cnt = 0
for i in range(n):
    if s[i] == str(int('0') + now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    nums.append(cnt)

ans = 0
left = 0
right = 0
tmp = 0

for i in range(0, len(nums), 2):
    next_left = i
    next_right = min(i + 2 * k + 1, len(nums))

    while (left < next_left):
        tmp -= nums[left]
        left += 1

    while (right < next_right):
        tmp += nums[right]
        right += 1

    ans = max(ans, tmp)

print(ans)


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

int display(int n, int a[])
{
  for (int i = 0; i < n - 1; i++)
  {
    cout << a[i] << " ";
  }
  cout << a[n - 1] << endl;

  return 0;
}

int bubbleSort(int n, int a[])
{
  // 未整列要素が残っている
  bool flag = true;

  // 未整列部分の先頭のインデックス
  // 初期値は 0
  int i = 0;

  int count = 0;

  int tmp;
  while (flag)
  {
    // もし内側のループが完了しているなら、フラグは false のままで、ソートは終了する
    flag = false;
    // 配列の末尾から未整列要素の2番目までループ
    for (int j = n - 1; j >= i + 1; j--)
    {
      // 順番が逆になっている未整列要素があれば、交換
      if (a[j] < a[j - 1])
      {
        tmp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = tmp;
        // 内側で交換したら、外側のループを実行できるようフラグを true にする
        // 内側で交換しなかったら、ソートは完了しているので、この時点でソートを終了する
        flag = true;
        count++;
      }
    }
  }

  display(n, a);
  cout << count << endl;

  return 0;
}

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

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

  bubbleSort(n, a);

  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>

using namespace std;

const int IMAX = pow(2.0,31.0)-1;

#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n;
    cin >> n;
    int (*data)[3] = (int(*)[3])malloc(100010*3*sizeof(int));
    for(int i=0;i<n;i++){
        cin >> data[i][0] >> data[i][1] >> data[i][2];
    }
    int (*dp)[3] = (int(*)[3])malloc(100010*3*sizeof(int));
    for(int i=0;i<100010;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<100010;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k)dp[i+1][k]=max(dp[i+1][k],dp[i][j]+data[i][k]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        if(dp[n][i]>ans)ans=dp[n][i];
    }
    printf("%d",ans);
    free(data);
    free(dp);
    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL n;
	cin >>n;
	vector<string> s(n);
	for (LL i = 0; i < n; i++) {
		cin >>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s.begin(),s.end());
	LL count =0;
	for (LL i = 0; i < n; i++) {
		LL j=i+1;
		LL p=1;
		while (j<n&&s[i] == s[j]) {
			count+=p;
			p+=1;
			j++;
		}
		i=j-1;
	}
	cout <<count <<endl;

	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct note{
	unsigned int key;
	struct note *next;
	struct note *prev;
} *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer cur = nil->next;
	while(cur != nil){
		if(cur->key == key) return cur;
		cur = cur->next;
	}
	return NULL;
}

void init(){
	nil = malloc(sizeof(NodePointer));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if(cur == nil) break;
		if(!isf) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode(NodePointer t){
	NodePointer ne, pr;
	ne = t->next;
	pr = t->prev;
	pr->next = ne;
	ne->prev = pr;
}

void deleteFirst(){
	NodePointer t = nil->next;
	if(t == nil) return;
	deleteNode(t);
}

void deleteLast(){
	NodePointer t = nil->prev;
	if(t == nil) return;
	deleteNode(t);
}

void delete(int key){
	NodePointer t = listSearch(key);
	if(t) deleteNode(t);
}

void insert(int key){
	NodePointer x;
	x = malloc(sizeof(NodePointer));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main(void){
	int key, n, i;
	char cmd[20];
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", cmd, &key);
		if(cmd[0] == 'i') insert(key);
		else if(cmd[0] == 'd')
		{
			if(strlen(cmd) > 6)
			{
				if(cmd[6] == 'F') deleteFirst();
				else if(cmd[6] == 'L') deleteLast();
			}
			else delete(key);
		}
	}
	printList();
	return 0;
}



Measured memory_bytes: 36060
import Control.Monad
import Data.Monoid
import Data.List
 
getInt = read <$> getLine :: IO Int
getInts = map read . words <$> getLine :: IO [Int]
 
f s t 0 
    | slen < tlen = Nothing
    | any (\(x, y) -> x/='?' && x/=y) pairs = Nothing
    | otherwise = Just (t ++ (map g $ drop tlen s))
    where
        slen = length s
        tlen = length t
        pairs = zip s t
        g c = if c=='?' then 'a' else c
f [] t n = Nothing
f (c:s) t n = (c':) <$> f s t (n-1)
    where c' = if c=='?' then 'a' else c
    
    
main = do
    s' <- getLine
    t <- getLine
    putStrLn $ maybe "UNRESTORABLE" id $ getLast $ foldMap Last $ map (\n -> f s' t n) [0..(length s')]
    

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int k;
		cin >> k;
		cout << binary_search(a.begin(), a.end(), k) << endl;
	}
}


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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
    LL N, x;
    cin >> N >> x;
    
    multiset<LL> as;
    for (LL i = 0; i < N; ++i) {
        LL a;
        cin >> a;
        as.insert(a);
    }
    
    LL cnt = 0;
    for (LL a : as) {
        if (x < a) {
            break;
        }
        x -= a;
        ++cnt;
    }
    
    if (x != 0) {
        if (cnt != N) {
            
        } else if (cnt > 0) {
            cnt -= 1;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  vll A(N + 1);
  mll m;
  rep(i, N + 1) {
    if (i == 0) {
      A[i] = 0;
      m[0]++;
      continue;
    }
    ll a;
    cin >> a;
    A[i] = A[i - 1] + a;
    m[A[i] % M]++;
  }

  ll ans = 0;
  rep(i, N + 1) {
    ans += m[A[i] % M] - 1;
  }
  ans /= 2;
  ANS;
  return 0;
}

Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	string b("");
	int i;
	cin>>a;
	for(i=0;i<a.size();i++){
		if(a[i]=='B'){
			if(b!=""){
			    b.erase(b.size()-1);
			}	
		}else{
			b=b+a[i];
		}
	}
	cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    ll n, ff, ss;
    cin>>n;
    int arr[n], mini = 0 ;

    loop(i, n){
        cin>>arr[i];
    }


    loop(i, n){
        loop2(j,i+1,n-1){
            mini = max(abs(arr[i] - arr[j]), mini);
        }
    }

    cout<<mini;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char s[10];
signed main(){
	scanf("%s", s + 1);
	if(s[1] == '7' || s[2] == '7' || s[3] == '7') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>

int main(){

char O[51];
char E[51];
int len=0;
for (int i = 0; i < 51; i++){
    scanf("%c",&O[i]);
    len++;
    if(O[i]=='\n'){len--;break;}
}
for (int i = 0; i < 51; i++){
    scanf("%c",&E[i]);
    if(O[i]=='\n'){break;}
}


for (int i = 0; i < len; i++)
{
  printf("%c%c",O[i],E[i]);
}

return 0;

}

Measured memory_bytes: 1672
N = int(input()); MOD = pow(10,9)+7
C= list(map(int,input().split()))
C.sort()

#L = [48,20,8,3,1]
L = [1]
for i in range(1,N):
  temp = (i+2)*pow(2,i-1,MOD)
  L.append(temp)
  
L.reverse()
ans = 0
for i in range(N):
  ans = (ans + L[i]*pow(2,i,MOD)*C[i])%MOD
#ans = ans%MOD
print(ans*pow(2,N,MOD)%MOD)


Measured memory_bytes: 102384
#include<iostream>
#include<cstdio>
#include<math.h>

using namespace std;

class Sort {
public:
	int n, cnt = 0;
	int A[1000000];
	void Insertion(int g) {
		for (int i = g; i < n; i++) {
			int v = A[i];
			int j = i - g;
			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j + g] = v;
		}
	}
};

int main() {
	Sort S;
	int a = 1, b = 0, m = 0;
	cin >> S.n;
	for (int i = 0; i < S.n; i++) cin >> S.A[i];
	while (a <= S.n) {a = a * 3 + 1; m++;}
	int G[m];
	for (int i = m - 1; i >= 0; i--) {G[i] = 3 * b + 1; b = G[i];}
	for (int i = 0; i < m; i++) S.Insertion(G[i]);

	cout << m << endl;
	for (int a = 0; a < m; a++) {
		if (a > 0) cout << " ";
		cout << G[a];
	}
	cout << endl << S.cnt << endl;
	for (int b = 0; b < S.n; b++) cout << S.A[b] << endl;
	return 0;
}


Measured memory_bytes: 7000
import numpy as np
def calc_1(x):
    return x+1

N = int(input())
a = list(map(int, input().split()))

x = np.argsort(a)
hoge = list(map(calc_1,x))

ans = [str(a) for a in hoge]
ans = " ".join(ans)
print(ans)

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

#define LL long long

LL cost[39][39];
vector<pair<int,int> > v[3];
int n;
bool mark[509][509];
LL amount[3][39];
int arr[509][509];

void dfs(int x,int y,int type){
	mark[x][y] = true;
	v[type].push_back(make_pair(x,y));
	for(int i=-3;i<=3;i++){
		for(int j=-3;j<=3;j++){
			if((i+j)%3==0 && (x+i)>=1 && (x+i)<=n && (y+j)>=1 && (y+j)<=n && !mark[x+i][y+j]){
				dfs(x+i,y+j,type);
			}
		}
	}
}

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

	int c;
	cin>>n>>c;

	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			cin>>cost[i][j];
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>arr[i][j];
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(!mark[i][j]){
				dfs(i,j,(i+j)%3);
			}
		}
	}

	for(int i=0;i<3;i++){
		for(int j=1;j<=c;j++){
			for(int k=0;k<(int)v[i].size();k++){
				int x=v[i][k].first,y=v[i][k].second;
				amount[i][j]+=(cost[arr[x][y]][j]);
			}
		}
	}

	LL ans = LLONG_MAX;
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			for(int k=1;k<=c;k++){
				if(i!=j && j!=k && i!=k){
					//cout<<i<<","<<j<<","<<k<<" "<<amount[0][i]+amount[1][j]+amount[2][k]<<endl;
					ans = min(ans,amount[0][i] + amount[1][j] + amount[2][k]);
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 12148
#include <stdio.h>
#include <algorithm>
//thratarr
using namespace std;

int dp[1002][1002];
int n;
int m;
int i;
int j;
int k;
int x;
int y;
int sum;
char a[1002];
char b[1002];
int minn;

int main(){
	char* c;
	c = a;
	c++;
	scanf("%s",c);
	c = b;
	c++;
	scanf("%s",c);
	c = a;
	c++;
	while(*c!='\0') c++;
	n = c-a-1;
	c = b;
	c++;
	while(*c!='\0') c++;
	m = c-b-1;

//	printf("%d%d",n,m);
	for(i=1;i<=n;i++) dp[i][0] = i;
	for(j=1;j<=m;j++) dp[0][j] = j;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			minn = 3000;
			if(minn>dp[i][j-1]+1) minn = dp[i][j-1]+1;
			if(minn>dp[i-1][j]+1) minn = dp[i-1][j]+1;
			if(minn>dp[i-1][j-1]+int(!(a[i]==b[j]))) minn = dp[i-1][j-1]+int(!(a[i]==b[j]));
			dp[i][j] = minn;
			//printf("%d, %d : %d\n",i,j,dp[i][j]);
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}


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

int INF = 1e9;
 
int main(void){
    int n;
    cin>>n;
    if(n>=25) {
        cout<<0<<endl;
        return 0;
    }
    vector<vector<int> > d(13);
    rep(i, n){
        int a;
        cin>>a;
        d[a].push_back(i);
    }
    d[0].push_back(n);
    int ans = 0;
    if(d[0].size()>1){
        cout<<0<<endl;
        return 0;
    }
    rep(i, 13){
        if(d[i].size()>=3) {
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i = 0;i<(1<<12);i++){
        vector<int>v(12);
        rep(j, 12){
            if((i>>j)&1) v[j]=1;
        }
        int tmp = INF;
        vector<int> vec;
        rep(j, 13){
            if(d[j].size() == 0) continue;
            if(j == 0) vec.push_back(0);
            else if(v[j-1]){
                vec.push_back(24-j);
                if(d[j].size() == 2) vec.push_back(j);
            }
            else {
                vec.push_back(j);
                if(d[j].size() == 2) vec.push_back(24-j);
            }
        }
        rep(i, vec.size()-1){
            for(int j = i+1;j<vec.size();j++){
                tmp = min(tmp, min(abs(vec[i]-vec[j]), 24-abs(vec[i]-vec[j])));
            }
        }
        ans = max(ans, tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  auto f = [&](int n){
    return n*(n+1)/2;
  };

  int ans = 0;
  FOR(i, 1, N+1){
    ans += i*f(N/i);
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3608