akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

const ll INF = 1E18+5;
const ll mod = 1E9+7;

int main(){
    int n;
    cin>>n;
    int i, j, k;
    vector<ll> a(n+1);
    a[0] = 0;
    for(i = 1; i <= n; ++i)
        cin>>a[i];
    ll dp[n+1][n+1];
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j] = INF;
    for(i=1;i<=n;i++)
        dp[i][i] = 0;
//    for(i=1;i<=n-1;i++)
//        dp[i][i+1] = a[i]+a[i+1];
    ll pre[n],len = 0;
    pre[0] = 0;
    for(i=1;i<=n;i++)
        pre[i] = pre[i-1] + a[i];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=j;k<j+i;k++)
            {
                if(j+i>n)
                    break;
                dp[j][j+i] = min(dp[j][j+i],dp[j][k]+pre[j+i]-pre[j-1]+dp[k+1][j+i]);
            }
        }
    }
    cout<<dp[1][n];
}




Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  // [l ,r]
  Int l=2,r=2;
  reverse(a.begin(),a.end());
  for(Int i=0;i<n;i++){
    Int x=(l+a[i]-1)/a[i]*a[i];
    Int y=r/a[i]*a[i]+(a[i]-1);
    if(x>r){
      cout<<-1<<endl;
      return 0;
    }
    l=x;
    r=y;
  }
  cout<<l<<" "<<r<<endl;
  return 0;
}


Measured memory_bytes: 1024
#https://atcoder.jp/contests/abc141/submissions/7539109
#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    #見つかる限りこの処理
            ans = max(ans,len(a))
            break
        else:               #ダメなら次の文字を接頭辞に、短いものは調べなくてよい
            a = a[1:]
print(ans)

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << b << endl;
    }
    else {
        if (b == 'H') {
            cout << "D" << endl;
        }
        else {
            cout << "H" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int main(){

	for(int se = 0; se<5; se++){

		int n,k,B[100001],t = -999999;
		cin >> n >> k;

		if(n == 0 && k == 0)break;

		B[0] = 0;
		for(int i=0; i<n; i++){
			int a;
			cin >> a;
			B[i+1] = B[i] + a;
		}
		for(int i = 1; i+k-1<n; i++){
			t = max(B[i+k-1]-B[i-1],t);
		}
		cout << t << endl;
	}
	return 0;
}


Measured memory_bytes: 3460
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.weight = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            if self.same_check(x, y) != True:
               self.size[x] += self.size[y]
               self.size[y] = 0
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
               self.rank[rx] += 1

    def size(self, x):
        x = self.find(x)
        return self.size(x)

    def diff(self, x, y):
        if self.same_check(x, y) == True:
            return self.weight[x] - self.weight[y]
        else:
            print("inf")

#処理内容
def main():
	N, M = getlist()
	judge = "Yes"
	UF = WeightedUnionFind(N)
	for i in range(M):
		L, R, D = getlist()
		if UF.same_check(L - 1, R - 1):
			if UF.diff(L - 1, R - 1) != D:
				judge = "No"
				break
		else:
			UF.union(L - 1, R - 1, D)
	print(judge)



if __name__ == '__main__':
	main()

Measured memory_bytes: 12512
//                        DushtuBunny
//                        Rahul Halder    
//    Indian Institute of Engineering Science & Technology,Shibpur


#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll int64_t
#define f first
#define se second
#define LB lower_bound
#define UB upper_bound
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vi vector<int>
#define vc vector<char>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
const unsigned int MOD = 1000000007;

using namespace std;

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    IOS;
    int T;
    // cin>>T;
    T=1;

    while(T--)
    {
        string s,t;cin>>s>>t;
        if(s.size()+1 != t.size())
            cout<<"No";
        else
        {
            ll flag = 1;
            for(int i = 0;i<s.size();i++)
            {
                if(s[i]!=t[i])
                {
                    flag = 0;
                    break;
                }
            }
            if(flag)
                cout<<"Yes";
            else
                cout<<"No";
        }
    }
  
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

void display(vector<int> ary_i) {
  for (int i = 0; i < ary_i.size(); i++) {
    if (i > 0) cout << " ";
    cout << ary_i[i];
  }

  cout << endl;
}

void insertSort(vector<int> ary) {
  int v, i, j;
  for (i = 0; i < ary.size(); i++) {
    v = ary[i];
    j = i - 1;
    while (j >= 0 && v < ary[j]) {
      ary[j + 1] = ary[j];
      j--;
    }
    ary[j + 1] = v;
    display(ary);
  }
}

int main(void) {
  int len, buf;
  vector<int> ary_i;
  char s[2000];

  cin >> len;

  for (int i = 0; i < len; i++) {
    cin >> s;
    ary_i.push_back(atoi(s));
  }

  insertSort(ary_i);

  return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
n = int(input())
p = sorted(list(map(int, input().split())) for _ in range(n))

lmax = n - 1
rmin = 0
for i in range(n):
    if p[i][1] <= p[rmin][1]:
        rmin = i

ans = 0

# same(lmax, rmin)
dmax = 0
for i in range(n):
    if i == lmax or i == rmin:
        continue
    if p[i][1] - p[i][0] > p[dmax][1] - p[dmax][0]:
        dmax = i
d1 = max(0, p[rmin][1] - p[lmax][0] + 1)
d2 = max(0, p[dmax][1] - p[dmax][0] + 1)
ans = max(ans, d1 + d2)

# !same(lmax, rmin)
m = lmax
for i in range(rmin, lmax)[::-1]:
    if p[i + 1][1] < p[m][1]:
        m = i + 1
    d1 = max(0, p[rmin][1] - p[i][0] + 1)
    d2 = max(0, p[m][1] - p[lmax][0] + 1)
    ans = max(ans, d1 + d2)

print(ans)


Measured memory_bytes: 27824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var data = new Dictionary<char, int>();
            for(int i = 0; i < 4; i++)
            {
                if (data.ContainsKey(s[i])) data[s[i]]++;
                else data.Add(s[i], 1);
            }
            if (data.Count == 2) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }

       


           



        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


Measured memory_bytes: 13152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int dice[10];

int main() {
	int n;
	while(n=in()){
		int i;
		string str;
		dice[0]=1;
		dice[1]=2;
		dice[2]=4;
		dice[3]=5;
		dice[4]=3;
		dice[5]=6;
		int buf;
		int res=1;
		for(i=0;i<n;i++){
			cin>>str;
			if(str=="North"){
				buf=dice[0];
				dice[0]=dice[1];
				dice[1]=dice[5];
				dice[5]=dice[3];
				dice[3]=buf;
			}
			if(str=="East"){
				buf=dice[0];
				dice[0]=dice[2];
				dice[2]=dice[5];
				dice[5]=dice[4];
				dice[4]=buf;
			}
			if(str=="West"){
				buf=dice[0];
				dice[0]=dice[4];
				dice[4]=dice[5];
				dice[5]=dice[2];
				dice[2]=buf;
			}
			if(str=="South"){
				buf=dice[0];
				dice[0]=dice[3];
				dice[3]=dice[5];
				dice[5]=dice[1];
				dice[1]=buf;
			}
			if(str=="Right"){
				buf=dice[1];
				dice[1]=dice[4];
				dice[4]=dice[3];
				dice[3]=dice[2];
				dice[2]=buf;
			}
			if(str=="Left"){
				buf=dice[1];
				dice[1]=dice[2];
				dice[2]=dice[3];
				dice[3]=dice[4];
				dice[4]=buf;
			}
			res+=dice[0];
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
A = list(map(int, input().split()))
q = int(input())
for i in range(q) :
    com = list(map(int, input().split()))
    if com[0] == 0 :
        print(min(A[com[1]:com[2]]))
    else :
        print(max(A[com[1]:com[2]]))


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

const int MO=1e9+7;
const int M=2e5+5;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

int qp(int a,int n)
{
	int ans=1;
	while(n)
	{
		if(n&1) mulv(ans,a);
		mulv(a,a);
		n>>=1;
	}
	return ans;
}

int cnt[M];

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int tot=0;
	for(int i=k;i>=1;i--)
	{
		cnt[i]=qp(k/i,n);
		for(int j=i+i;j<=k;j+=i)
			subv(cnt[i],cnt[j]);
		addv(tot,mul(cnt[i],i));
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 4148
import sys
n=int(input())
a=list(map(int,input().split()))
def nibai(n):
  return n*2
a.sort(reverse=True)
sc=a[0]
if n==2:
  print(sc)
  sys.exit() 
a=a[1:]
b=list(map(nibai,a))
sc+=sum(b[:(n//2)-1])
if n%2==0:
  print(sc)
else:
  print(sc+a[(n//2)-1])

  

Measured memory_bytes: 103860
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

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

int main() {

	string s, t;
	int a, b;
	string u;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if(u == s) {
		cout << a-1 << " " << b;
	} else {
		cout << a << " " << b-1;
	}



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
ll n;
string s, t;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> s >> t;
  REP(i,n) {
    cout << s[i];
    cout << t[i];
  }


  return 0;
}



Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

bool isPrime(int n) {
    if (n == 2)return true;
    if (n % 2 == 0)return false;
    for (int i = 3; i*i <= n; i += 2)if (n%i == 0)return false;
    return true;
}

void solve() {
    int X;
    cin >> X;

    for (int i = X;; i++) {
        if (isPrime(i)) {
            cout << i;
            return;
        }
    }
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n){
    cin >> s[i];
  }

  for(int i = 0; i < n; ++i){
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  
  ll ans = 0;
  string pre = s[0];
  int count = 0;
  int i = 1;
  while(i < s.size()){
    if(s[i] == pre){
      count++;
    } else {
      for(int j = 1; j <= count ; ++j){
        ans += j;
      }
      pre = s[i];
      count = 0;
    }
    ++i;
  }

  if(count != 0){
    for(int j = 1; j <= count ; ++j){
        ans += j;
      }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 7296
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	int temp;
	vector<int> x;
	for(int i=0;i!=n;++i){
		cin>>temp;
		x.push_back(temp);
	}
	int ans=1E9;
	for(int i=-100;i<=100;++i){
		int cur=0;
		for(auto j:x)
			cur+=abs(i-j)*abs(i-j);
		ans=min(cur,ans);
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(n+1):
    if pow(2,i) < a[i]:
        print(-1)
        exit()
    if pow(2,i) > 10**9:
        break

cnt=[]
now=0
for i in reversed(range(n+1)):
    now+=a[i]
    cnt.append(now)
cnt.reverse()
ans=sum(cnt)
nxt_max=1
for i in range(len(cnt)):
    c=cnt[i]
    if c > nxt_max:
        ans-=(c-nxt_max)
    else:
        nxt_max=c
    nxt_max-=a[i]
    nxt_max*=2
    if i!=len(cnt)-1 and nxt_max <=0:
        print(-1)
        exit()

if nxt_max!=0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 83480
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;


int main(){
  int prime[1000000];
  fill(prime,prime+1000000,1) ;
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i*i < 1000000 ; i++ ){
    if(prime[i])for(int j = i*2; j <1000000; j+=i)prime[j] = 0;
  }

  int n;
  while( cin >> n ){
    int cnt = 0;
    for(int i = 2 ; i <= n ; i++ ){
      if(prime[i])cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 5064
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
#include<utility>
using namespace std;

void wfs(int start, vector<int>& dist, const vector<vector<int>>& edge)
{
	vector<bool> table(edge.size(), true);

	queue<pair<int, int>> que;
	que.push(make_pair(0, start));

	while(que.empty() != true)
	{
		int term = que.front().first;
		int index = que.front().second;
		que.pop();

		if(table[index] == false)
			continue;

		dist[index] = term;
		table[index] = false;

		for(auto it=edge[index].begin(); it!=edge[index].end(); it++)
			que.push(make_pair(term+1, *it));
	}
}

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

	vector<vector<int>> edge(N, vector<int>());
	for(int i=0; i<N-1; i++)
	{
		int a, b;
		cin >> a >> b;

		a--;
		b--;

		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	vector<vector<int>> dist(2, vector<int>(N, 0));
	wfs(0, dist[0], edge);
	wfs(N-1, dist[1], edge);

	int cnt[2] = {0};
	for(int i=0; i<N; i++)
	{
		if(dist[0][i] <= dist[1][i])
			cnt[0]++;
		else
			cnt[1]++;
	}
	
	string ret;
	if(cnt[0] > cnt[1])
		ret = "Fennec";
	else
		ret = "Snuke";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
int main(void)
{
	int x,a,b,p;
	scanf("%d %d %d2",&x,&a,&b);
	if(x>a)  a=x-a;
	else  a=a-x;
	if(x>b)  b=x-b;
	else  b=b-x;
	if(a<b)  printf("A\n");
	else  printf("B\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <set>
using namespace std;

struct person{
    long long start;
    long long end;
    long long way;
    bool finished;
};
person person[100005];
long long n,t,q,key[1005];
int main(){
    //cout<<endl;
    cin>>n>>t>>q;
    priority_queue<long long> crash;
    crash.push(-9000000000000000000);
    for(int i=1; i<=n; i++) {cin>>person[i].start>>person[i].way; person[i].finished=false;}
    for(int i=1; i<=n; i++){
        if(i==1&&person[i].way==2) {person[i].end=person[i].start-t; person[i].finished=true; continue;}
        if(person[i].way==2){
            if(person[i-1].way==1){
                if((person[i].start-person[i-1].start)/2>t) {
                    person[i].end=person[i].start-t;
                    person[i-1].end=person[i-1].start+t;
                }else{
                    person[i].end=(person[i].start+person[i-1].start)/2;
                    person[i-1].end=(person[i].start+person[i-1].start)/2;
                    crash.pop();
                    crash.push((person[i].start+person[i-1].start)/2);
                    for(int j=1; j<i-1; j++){
                        if(person[j].finished!=true&&person[j].way==1) {
                            if(person[j].start+t>=crash.top()){person[j].end=crash.top(); person[j].finished=true;}
                            else person[j].end=person[j].start+t; person[j].finished=true;
                        }
                    }
                }
                person[i].finished=true;
                person[i-1].finished=true;
                continue;
            }else if(person[i].start-t<=crash.top()) {person[i].end=crash.top(); person[i].finished=true; continue;
            }else {
                person[i].end=person[i].start-t;
                person[i].finished=true;
            }}
    }
    for(int i=1; i<=n; i++){
        if(person[i].finished!=true){
            if(person[i].way==1) {person[i].end=person[i].start+t; person[i].finished=true;}
            else {person[i].end=person[i].start-t; person[i].finished=true;}
        }
    }
    //for(int i=1; i<=n; i++) cout<<"person["<<i<<"].end=="<<person[i].end<<endl;
    for(int i=1; i<=q; i++) {
        cin>>key[i];
        cout<<person[key[i]].end<<endl;
    }
}

Measured memory_bytes: 6204
n,q = map(int,input().split())
s = input()
lr = [tuple(map(int,input().split())) for _ in range(q)]
x = [0,0]
for i in range(1,len(s)):
  if s[i-1] == "A" and s[i] == "C":
    x.append(x[-1]+1)
  else:
    x.append(x[-1])
for i,j in lr:
  print(x[j]-x[i])

Measured memory_bytes: 67160
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll k;
    cin >> s >> k;
    k--;
    for (int i = 0; i < s.size(); ++i)
    {
        if (i == k)
            return cout << s[i], 0;
        if (s[i] != '1')
            return cout << s[i], 0;
    }
}


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

int main()
{
  char s[101], t[101];

  cin >> s >> t;
  sort(s, s+strlen(s));
  sort(t, t+strlen(t));

  bool lt=false;
  rep(i,strlen(s)){
    rep(j,strlen(t)){
      if(s[i]<t[j]) lt=true;
    }
  }
  if(strlen(s)<strlen(t))
    if(strncmp(s,t,strlen(s))==0) {
      cout << "Yes" << endl;
      return 0;
    }
  if(lt) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

void printVector(const vector<int>& vec) {
	 for (int value : vec) {
		 cout << value << " ";
	 }
	 cout << endl;
}

int main() {
	int n, k;
	cin >> n >> k;
	map<int, int> cnt;

	for (int i=1; i<=n; i++) {
		cnt[i] = 0;
	}

	// vector<vector<int>> a(k, vector<int>(d));
	vector<vector<int>> a(2*k, vector<int>(n));
	for (int i=0; i<k; i++) {
		int d;
		cin >> d;
		// cout << "d:"<< d << endl;
		for (int j=0; j<d; j++) {
			// cin >> a[i][j];
			int p;
			cin >> p;
			cnt[p]++;
		}
	}


	int ans=0;
	for( auto i = cnt.begin(); i != cnt.end() ; ++i ) {
		if (i->second == 0) ans++;
	}

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

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

class node {
    public:
    ll cost;
    ll algo[12];

    bool operator<(const node b) {
        return cost<b.cost;
    }

};

bool canminus(ll cost[], ll m, ll a[], ll x)
{
    for(ll i=0;i<m;i++)
        if(cost[i]-a[i]<x)
            return false;
    return true;
}

void dominus(ll cost[], ll m, ll a[])
{
    for(ll i=0;i<m;i++)
        cost[i]-=a[i];
}

void test_case()
{
    ll n,m,x;
    cin>>n>>m>>x;
    vector<node> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i].cost;
        for(int j=0; j<m; j++) {
            cin>>a[i].algo[j];
        }
    }
    ll ans=INT_MAX;
    for(ll mask=0; mask<(1<<n); mask++) {
        vector<ll> level(m,0);
        ll cost=0;

        for(ll i=0;i<n;i++) {
            if((mask>>i)&1) {
                cost+=a[i].cost;
                for(ll j=0;j<m;j++)
                    level[j]+=a[i].algo[j];
            }
        }
        bool ok=true;
        for(ll j=0;j<m;j++)
        if(level[j]<x) {
            ok=0;
            break;
        }
        if(ok) {
            ans=min(ans, cost);
        }
    }
    if(ans==INT_MAX)
        cout<<"-1\n";
    else
        cout<<ans<<"\n";
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


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

int a[200001],v[1000001];
bool b[1000001];

int main()
{
	int n,maxn;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		v[a[i]]++;
		maxn=max(maxn,a[i]);
	}
	
	if(n==1)
	{
		cout<<1<<endl;
		return 0;
	}
	
	for(int now=1;now<=n;now++)
	{
		int i=a[now];
		bool f=true;
		v[i]--;
		
		for(int j=1;j*j<=i;j++)
		{
			if(i%j!=0)
				continue;
			
			if(v[j]>0 || v[i/j]>0)
			{
				f=false;
				break;
			}
		}
		if(f)
			b[i]=1;
		v[i]++;
	}
	
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(b[a[i]])
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 9192
N,A,B,C = map(int,input().split())
L = []
for i in range(N):
  L.append(int(input()))
MP = float('inf')
n = 4  
def Base_10_to_n(X,n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n),n)+str(X%n)
  return str(X%n)

for X in range(4**N):
  STR = Base_10_to_n(X,n).zfill(N)
  nU = []
  uA = []
  uB = []
  uC = []
  SUBMP = 0
  for l in range(N):
    if STR[l] == '0':
      nU.append(L[l])
    elif STR[l] == '1':
      uA.append(L[l])
    elif STR[l] == '2':
      uB.append(L[l])
    else:
      uC.append(L[l])
    if len(uA) != 0 and len(uB) != 0 and len(uC) != 0:
      SUBMP = (len(uA)+len(uB)+len(uC)-3)*10+abs(sum(uA)-A)+abs(sum(uB)-B)+abs(sum(uC)-C)
      if SUBMP <= MP:
        MP = SUBMP
print(MP)

Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int b,i,j,a,flag=1;
    char c[101][101];
    scanf("%d %d",&a,&b);
    for(i=0;i<100;i++)
    {
       for(j=0;j<100;j++)
       {
           if(j<50)
            c[i][j]='.';
           else c[i][j]='#';
       }
    }

    for(i=0;i<50;i=i+2)
    {
        for(j=0;j<98;j+=2)
            {
                if(b==1)
                    {flag=0;
                    break;
                    }
                c[j][i]='#';
                b--;

            }
            if(flag==0)
                break;
    }
    flag=1;
        for(i=52;i<100;i=i+2)
    {
        for(j=0;j<98;j+=2)
            {
                if(a==1)
                    {flag=0;
                    break;
                    }
                c[j][i]='.';
                a--;

            }
            if(flag==0)
                break;
    }
    printf("100 100\n");
    for(i=0;i<100;i++)
    {
        for(j=0;j<100;j++)
            printf("%c",c[i][j]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+7;
int a[N],cnt[N];
int main()
{
	int n=ri(),i,mx=-1;
	for(i=1;i<=n;i++)	a[i]=ri(),cnt[a[i]]++;
	for(i=1;i<=N-3;i++)	mx=max(mx,cnt[i-1]+cnt[i]+cnt[i+1]);
	wi(mx);putchar('\n');
	return 0;
}


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

int main(){
  int N;cin >> N;
  vector<vector<string>> S(N,vector<string>(0));
  S[0].push_back("a");
  for(int i=1;i<N;i++){
    int K = S[i-1].size();
    //cout << "K=" <<K << endl;
    for(int j=0;j<K;j++){
      string X=S[i-1][j];
      //cout << "j=" << j << " X= " << X << endl;
      char y = 'a';
      for(int p=0;p<X.size();p++){
        if(y<X[p]){
          y = X[p];
        }
      }
      //cout << int(y) - int('a') << endl;
      for(int p=0;p<=int(y)-int('a')+1;p++){
        char add = 'a' + p;
        string addstr = X + add;
        //cout << addstr << endl;
        S[i].push_back(addstr);
      }
    }
  }
  sort(S[N-1].begin(),S[N-1].end());
  for(int i=0;i<S[N-1].size();i++){
    cout << S[N-1][i] << endl;
  }
}

Measured memory_bytes: 11380
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 19
#define E 259
#define M 40009
using namespace std;

int n,m,tot,lg2[E],num[M],a[N],f[M][N],g[2][M][E],h[2][M][E],dp[M];
int calc(int x,int y){
	return (ll)g[0][y][x&255]*g[1][y][x>>8]%mod;
}
int calceg(int x,int y){
	return (ll)h[0][y][x&255]*h[1][y][x>>8]%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k,l,x,y;
	for (i=1; i<=m; i++){
		scanf("%d%d",&x,&y); a[x]|=1<<y-1;
	}
	tot=1<<n;
	for (i=0; i<=8; i++) lg2[1<<i]=i;
	for (i=num[0]=1; i<tot; i++) num[i]=num[i^i&-i]<<1;
	for (i=0; i<tot; i++){
		for (j=1; j<=16; j++) f[i][j]=num[a[j]&i];
		for (j=g[0][i][0]=g[1][i][0]=h[0][i][0]=h[1][i][0]=1; j<256; j++){
			k=lg2[j&-j]+1; l=j^j&-j;
			g[0][i][j]=(ll)g[0][i][l]*(f[i][k]-1)%mod;
			g[1][i][j]=(ll)g[1][i][l]*(f[i][k+8]-1)%mod;
			h[0][i][j]=(ll)h[0][i][l]*f[i][k]%mod;
			h[1][i][j]=(ll)h[1][i][l]*f[i][k+8]%mod;
		}
	}
	dp[0]=1;
	for (i=1; i<tot; i++)
		for (j=i; j; j=(j-1)&i) if ((j&3)<3)
			dp[i]=(dp[i]+(ll)dp[i^j]*calc(i^j,j)%mod*calceg(j,i^j))%mod;
	printf("%d\n",dp[tot-1]);
	return 0;
}


Measured memory_bytes: 144384
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >>a;
    cin >> b;
    if (a > b) {
        cout << "a > b\n";
    }
    else if (a < b) {
        cout << "a < b\n";
    }
    else if (a == b) {
        cout << "a == b\n";
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	getline (cin, s);
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'a' && s[i] <= 'z'){
			s[i] -= 32;
		} else if(s[i] >= 'A' && s[i] <= 'Z'){
			s[i] += 32;
		} 
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        for(char c : s) {
            System.out.print((char)((c-'A'+n)%26 + 'A'));
        }
        System.out.println();
    }
}


Measured memory_bytes: 26788
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

constexpr int MOD = (1e9+7);
constexpr int MAXN = 1007;

using namespace std;

int main() {
    int H, W;
    char c;
    scanf("%d%d", &H, &W);
    vector<string> A(H);
    for (int i = 0; i < H; ++i) {
        cin >> A[i];
    }
    vector<vector<long long>> dp(2, vector<long long>(W+1, 0));
    for (int i = 0; i < W && A[0][i] == '.'; ++i) {
        dp[0][i+1] = 1;
    }
    for (int i = 1; i < H; ++i) {
        int di = i&1;
        for (int j = 1; j <= W; ++j) {
            if (A[i][j-1] == '.') {
                dp[di][j] = (dp[di^1][j] + dp[di][j-1]) % MOD;
            }
            else {
                dp[di][j] = 0;
            }
        }
    }
    cout << dp[(H-1)&1][W];
}

Measured memory_bytes: 1280
N, Q = map(int, input().split(" "))
S = input()
st, en = [], []
for i in range(Q) :
    _st, _en = map(int, input().split(" "))
    st.append(_st)
    en.append(_en)
    
prev_char = ''
cnt = 0
cum_list = []
for c in S :
    if prev_char == 'A' and c == 'C' :
        cnt += 1
    cum_list.append(cnt)
    prev_char = c
    
for s, e in zip(st, en) :
    print(cum_list[e - 1] - cum_list[s - 1])

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

int main() {
  int X;
  cin >> X;
  if (400 <= X && X < 600) {
    cout << 8 << endl;
  }
  if (600 <= X && X < 800) {
    cout << 7 << endl;
  }
  if (800 <= X && X < 1000) {
    cout << 6 << endl;
  }
  if (X >= 1000) {
    int ans = 5 - (X - 1000)/200;
    cout << ans << endl;
  }
}
    


Measured memory_bytes: 3632
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
map<string, int> mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    mp[tmp]++;
  }

  int m = 0;
  for (auto &e : mp) {
    m = max(m, e.second);
  }
  for (auto &e : mp) {
    if (e.second == m) {
      cout << e.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 17664
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) cin >> X[i][j];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int power = 0;
            for (int k = 0; k < D; k++) power += pow((X[i][k] - X[j][k]), 2);
            int judge = sqrt(power);
            if (pow(judge, 2) == power) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n;
	cin >> n;
	if(n >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

int main(){
    int n;cin>>n;int a;cin>>a;int b;cin>>b;
    if((b-a-1)%2==0){
        cout<<"Borys"<<endl;
    }else if((b-a-1)%2==1)
        cout<<"Alice"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  bool flag = true;
  if(s[0]!='A') flag = false;
  int count = 0;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C') count++;
  }
  if(count!=1) flag = false;
  count = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='C') continue;
    if(!('a'<=s[i]&&s[i]<='z')) count++;
  }
  if(count>0) flag = false;
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math

n = map(int, input())
a = list(map(int, input().split()))
N = 1000005
b = [0] * N

for x in a:
    if b[x] == 0:
        for y in list(range(2 * x, N, x)):
            b[y] += 1
    b[x] += 1

ans = 0
for x in a:
    if b[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 64976
#include <bits/stdc++.h>
#include <iostream>
#define pb push_back
#define INF 1000000000
#define mp make_pair
#define ll long long
#define tc int t; cin>>t; while(t--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define pi pair<int,int>
#define pii vector<pair<int,int>>

using namespace std;

#define nl '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: ", cout << to_string(__VA_ARGS__) << endl
/*compact version*/
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template<typename T> int SIZE(const T &t) { return t.size(); } string to_string(string &s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char* s) { string tmp(s); return to_string(tmp); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(char c) { return string({c}); } template<size_t N> string to_string(bitset<N> &b, int x1 = 0, int x2 = 1e9) { string t = ((x1 < b.size()) ? (b.to_string()).substr(x1, x2 - x1 + 1) : ""); reverse(begin(t), end(t)); return '"' + t + '"'; } template <typename A, typename... C> string to_string(A (&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += nl; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += nl; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += nl; return res; }
/*end of compact version*/

void prl(int x) {cout << x << endl;}
void pr(int x) { cout << x << " ";}

void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
}
const int sz = 10001000;
const int size = 1e6 + 1;


int main() {
    init();
    // tc
    {
        ll a, n, b;
        cin >> a >> b >> n;
        // int mx = -1;
        ll x = b - 1;
        x = min(x, n);
        ll ans = (a * x) / b;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  unordered_set<char> A;
  for(char &c:S){
    if(A.count(c)){
      cout<<"no"<<endl;
      return 0;
    }
    A.insert(c);
  }
  cout<<"yes"<<endl;
}

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

int main()
{

  int h, a;
  cin >> h >> a;

  if(h%a == 0)
    cout << h / a;
  else
  {
    int ans = h / a;
    cout << ans + 1;
  }
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
  int N, a, I, m{0}, m2;
  cin >> N;
  for (int i = 0; i != N; ++i) {
    cin >> a;
    if (m <= a) {
      m2 = m;
      m = a;
      I = i;
    } else if (m2 < a) m2 = a;
  }
  
  for (int i = 0; i != N; i++) {
    cout << (i==I ? m2:m) << endl;
  }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 10e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
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); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    ll total=0;
    ll m=INF;
    REP(i,N){
        ll s;
        cin>>s;
        total+=s;
        if(s%10!=0)m=min(m,s);
    }
    if(total%10==0){
        if(m==INF)total=0;
        else total-=m;
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <ll> v;

int main(){
    int n;
    sf(n);

    while(n--){
        ll a;
        scanf("%lld",&a);
        v.push_back(a);
    }

    int len=v.size();
    for(int i=0; i<len; i++){
        if(v[i]==0){
            pf("0\n");
            return 0;
        }
    }

    ll sum=1,ans=1e18;
    for(int i=0; i<len; i++){
        if(v[i]<=ans/sum){
            sum*=v[i];
        }
        else{
            pf("-1\n");
            return 0;
        }
    }
    pf("%lld\n",sum);

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

typedef pair<double, double> pd;
typedef vector<pd> vpd;


#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  string S;
  IN(S);

  ll B_sum = 0;
  for(auto c : S) if(c=='B') B_sum++;

  ll ans = 0;
  for(ll i=0; i<N; ++i){
    for(ll j=0; j<N; ++j){
      if(!(S[i]=='R' && S[j]=='G')) continue;
      ans += B_sum;

      ll k1 = min(i,j)-abs(i-j);
      if(k1>=0) if(S[k1]=='B') ans--;

      ll k2 = max(i,j)+abs(i-j);
      if(k2<N)  if(S[k2]=='B') ans--;

      ll k3 = (i+j)/2;
      if((i+j)%2==0) if(S[k3]=='B') ans--;
    }
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 3652
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A
#include <iostream>
#include <array>
#include <string>
#include <algorithm>


using namespace std;

// enum direction{
//     N, S, E, W
// };


class Dice{
private:
    std::array<int, 6> faces;
    //0???, 5???, 1south, 4north, 2east, 3west
public:
    Dice();
    Dice(std::array<int, 6> input){
        for(int i=0; i<6; i++) faces[i] = input[i];
    };
    ~Dice(){};
    void Rotate(const string &d){
        int buf;
        if(d == "N"){
            buf = faces[0];
            faces[0] = faces[1];
            faces[1] = faces[5];
            faces[5] = faces[4];
            faces[4] = buf;
        }
        if(d == "S"){
            buf = faces[0];
            faces[0] = faces[4];
            faces[4] = faces[5];
            faces[5] = faces[1];
            faces[1] = buf;
        }
        if(d == "E"){
            buf = faces[0];
            faces[0] = faces[3];
            faces[3] = faces[5];
            faces[5] = faces[2];
            faces[2] = buf;
        }
        if(d == "W"){
            buf = faces[0];
            faces[0] = faces[2];
            faces[2] = faces[5];
            faces[5] = faces[3];
            faces[3] = buf;
        }
    }

    void inline top(){cout << faces[0] << endl;};
};


int main(){

    std::array<int, 6> input;
    for(int i=0; i<6; i++){
        cin >> input[i];
    }
    Dice D(input);
    //???????????????

    string str;
    cin >> str;
    for(int i=0; i<str.size(); i++){
        string key = str.substr(i,1);
        D.Rotate(key);
    }
    D.top();
    return 0;
}

Measured memory_bytes: 1216
i = gets(chomp:true).to_i
array = gets.split.map(&:to_i)
n = 0
for j in 0...i
k = i - 1
l = i - 2
while l >= j 
if array[l] > array[k]
m = array[k]
array[k] = array[l]
array[l] = m
n += 1
end
l -= 1
k -= 1
end
end
puts array.join(" ")
puts n


Measured memory_bytes: 6868
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        for (int i = n - 1; i > 0; i--)
        {
            if (h[i] < h[i - 1])
            {
                h[i - 1]--;
                if (h[i] < h[i - 1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 27100