akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(a <= b){
      System.out.println(a);
    }else{
      System.out.println(a-1);
    }
    
  }
  
}

Measured memory_bytes: 35696
#include <stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
if(a==1 && b==2) printf("3");
if(a==2 && b==3) printf("1");
if(a==1 && b==3) printf("2");
if(a==2 && b==1) printf("3");
if(a==3 && b==1) printf("2");
if(a==3 && b==2) printf("1");
	
	
	return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <sstream>
#include <typeinfo>
#include <algorithm>
#include <numeric>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

struct count_t {
    int r = 0;
    int g = 0;
    int b = 0;
};

bool isRG(char x, char y){ return (x == 'R' && y == 'G') || (y == 'R' && x == 'G'); }
bool isGB(char x, char y){ return (x == 'G' && y == 'B') || (y == 'G' && x == 'B'); }
bool isBR(char x, char y){ return (x == 'B' && y == 'R') || (y == 'B' && x == 'R'); }

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

    int n;
    string s;
    cin >> n >> s;
    
    vector<count_t> counts_left(n);
    rep(i,s.size()){
        if(i > 0){
            counts_left[i] = counts_left[i-1];
        }
        if(s[i] == 'R'){
            counts_left[i].r += 1;
        }
        else if(s[i] == 'G'){
            counts_left[i].g += 1;
        }
        else if(s[i] == 'B'){
            counts_left[i].b += 1;
        }
    }

    uint64_t count_triple = 0;
    for(int j = 1; j < (int)s.size(); ++j){
        for(int k = j+1; k < (int)s.size(); ++k){
            if(s[k] == s[j]) continue;
            if(isRG(s[j], s[k])){
                count_triple += (counts_left[j-1].b - (s[j-(k-j)] == 'B' ? 1 : 0));
            }
            else if(isGB(s[j], s[k])){
                count_triple += (counts_left[j-1].r - (s[j-(k-j)] == 'R' ? 1 : 0));
            }
            else if(isBR(s[j], s[k])){
                count_triple += (counts_left[j-1].g - (s[j-(k-j)] == 'G' ? 1 : 0));
            }
        }
    }
    cout << count_triple << '\n';

    return 0;
}


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

int main(){
	int n, m;
	cin >> n >> m;
	map<int,int> c;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		c[a]++;
		c[b]++;
	}
	int ok = 1;
	for(int i = 1; i <= n; i++){
		if(c[i] % 2) ok = 0;
	}
	cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void) {

    int n, i, j;
    int a[100];


    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    i = i - 1;

    while(i != 0){
        printf("%d ", a[i]);
        i--;
    }

    printf("%d", a[0]);
    printf("\n");

    return 0;
}




Measured memory_bytes: 2100
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= m; ++j){
            if(i * j + (n - i) * (m - j) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

void zero();

struct p{
	int x, y, cnt;
};
int H, W, N;
int tizu[1001][1001];
bool flag[1001][1001] = { false };
int main(){
	queue<p> que;
	char a;
	char h[10] = "123456789";
	cin >> H >> W >> N;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cin >> a;
			if (a == 'S'){
				tizu[i][j] = 0;
				p temp;
				temp.x = j;
				temp.y = i;
				temp.cnt = 0;
				que.push(temp);
			}
			else if (a == 'X'){
				tizu[i][j] = -1;
			}
			else if (a == '.'){
				tizu[i][j] = 0;
			}
			else {
				for (int k = 0; k < 9; k++){
					if (h[k] == a){
						tizu[i][j] = k + 1;
					}
				}

			}
			//cout << tizu[i][j];
		}
		//cout << endl;
	}
	int max = 1;
	int step = 0;
	while (!que.empty()){
		p temp = que.front();
		que.pop();
		if (tizu[temp.y][temp.x] == max){
			max++;
			while (!que.empty()) que.pop();
			if (max - 1 == N) {
				max = temp.cnt;
				break;
			}
			zero();
		}
		if (flag[temp.y][temp.x] == true) continue;
		flag[temp.y][temp.x] = true;
		for (int i = 0; i < 4; i++){
			int dx[4] = { 1, -1, 0, 0 };
			int dy[4] = { 0, 0, 1, -1 };
			int yy = temp.y + dy[i];
			int xx = temp.x + dx[i];
			if (yy > -1 && xx > -1 && yy < H && xx < W && tizu[yy][xx] != -1){
				p tt;
				tt.y = yy;
				tt.x = xx;
				tt.cnt = temp.cnt + 1;
				que.push(tt);
			}
		}
	}
	cout << max << endl;
	return 0;
}
void zero(){
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			flag[i][j] = false;
		}
	}
}

Measured memory_bytes: 7864
#include <iostream>
#include <cstdio>
#define N 505
using namespace std;

int h, w;
string a[N];
int main()
{
	int i, j;
	cin >> h >> w;
	for (i = 0; i < h; i++) cin >> a[i];
	for (i = 0; i < h; i++) {
		printf("#");
		for (j = 1; j < w - 1; j++) {
			if (!(i % 2) || a[i][j] == '#') printf("#");
			else printf(".");
		}
		puts(".");
	}
	puts("");
	for (i = 0; i < h; i++) {
		printf(".");
		for (j = 1; j < w - 1; j++) {
			if (i % 2 || a[i][j] == '#') printf("#");
			else printf(".");
		}
		puts("#");
	}
    return 0;
}

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

using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
long long fac[maxn],inv[maxn];
void pre()
{
    fac[0]=fac[1]=1;inv[1]=1;
    for(int i=2;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    }
    inv[0]=1;
    for(int i=2;i<maxn;i++)
        inv[i]=inv[i-1]*inv[i]%mod;
}
long long get(int a,int b)
{
    if(b>a||a<0||b<0) return 0;
    return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int n,l,r,a[maxn];
long long work(int num)
{
    long long ans=0;
    ans+=get(n+1-2,num);
    //printf("%lld\n",ans);
    ans+=get(n+1-2,num-2);
    //printf("%lld\n",ans);
    ans+=2*get(n+1-2,num-1);
    //printf("%lld %d %d\n",ans,n+1-2,num-1);
    ans-=get(n+1-(r-l+1),num-1);
    //printf("%lld\n",ans);
    ans=ans%mod;
    if(ans<0) ans+=mod;
    return ans;
}

int main() {
    pre();
    memset(a,-1,sizeof(a));
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
    {
        int x;
        scanf("%d",&x);
        if(a[x]==-1){
            a[x]=i;
        }
        else{
            l=a[x];r=i;
        }
    }
    for(int i=1;i<=n+1;i++)
        printf("%lld\n",work(i));
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long
int cnt[100000];
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i=0; i<k; i++) {
		int d;
		cin >> d;
		while(d--) {
			int t;
			cin >> t;
			cnt[t]++;
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++) {
		if(!cnt[i])
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3640
# A - Integer Product 
n = int(input())
a = [input() for _ in range(n)]

# bi=ai*(10**9)とすると、(aiは小数第9位までの小数だからbiは整数)
# ai*ajが整数<=>bi*bj/(10**18)が整数<=>bi*bjが素因数に2を18個、5を18個持つ。
# p2[i]:biを素因数分解したときの2の数。
# p5[i]:biを素因数分解したときの5の数。
# c25[i][j]:bi...bnのうち、素因数に2をi個以上、5をj個以上持つbiの数。
# biに対して、ペアになれるのはc25[18-p2[i]][18-p5[i]]個。
# ただし、自分自身は含めないのでbiが素因数として2を9個以上、5を9個以上もつときは―1する。
# また、(bi,bj)と(bj,bi)を重複して数えてしまうので、最後に//2する。

p2 = [0 for _ in range(n)]
p5 = [0 for _ in range(n)]

for i in range(n):
  # Decimalを使ったらTLEしてしまったので、文字列操作でbiを計算する。
  if '.' in a[i]:
    bi = int(a[i].replace('.','')+'0'*(9-(len(a[i])-a[i].index('.')-1)))
  else:
    bi = int(a[i])*(10**9)
  c = 0
  while(bi%2 == 0):
    c += 1
    bi //= 2
  p2[i] = c
  c = 0
  while(bi%5 == 0):
    c += 1
    bi //= 5
  p5[i] = c

c25 = [[0 for _ in range(50)] for _ in range(50)]
for i in range(n):
  c25[p2[i]][p5[i]] += 1
for i in range(48,-1,-1):
  for j in range(48,-1,-1):
    c25[i][j] += c25[i+1][j]+c25[i][j+1]-c25[i+1][j+1]

ans = 0
for i in range(n):
  ans += c25[max(18-p2[i],0)][max(18-p5[i],0)]
  if p2[i] >= 9 and p5[i] >= 9:
    ans -= 1
print(ans//2)


Measured memory_bytes: 121876
while True:
    try:
        T = input()
        P = input()

        Tlen = len(T)
        Plen = len(P)

    except Plen>Tlen:
        break

    count = 0
    List = []
    for i in range(Tlen-Plen+1):
        index = T.find(P)
        
        if index==0:
            List.append(count)
        
        Tlist = list(T)
        del(Tlist[0])
        T = ''.join(Tlist)
        
        count += 1

    Llen = len(List)

    if Llen==0:
        break

    else:
        for i in range(Llen):
            print(List[i])
    
    break


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

n,l = map(int,input().strip().split())

ringo=[]

for i in range(n):
	ringo.append(l+i)
min = abs(ringo[0])
min_num = 0
for i in range(len(ringo)):
	if min > abs(ringo[i]):
		min = abs(ringo[i])
		min_num = i
out = 0
for i in range(len(ringo)):
	if i != min_num:
		out = out + ringo[i]
print(out)


Measured memory_bytes: 3060
n,m = gets.chomp.split(" ").map(&:to_i)
a = n.times.map{gets.chomp}
b = m.times.map{gets.chomp}
for i in 0..n-m
  for j in 0..n-m
    c = a[i,m]
    for k in 0..m-1
      c[k] = c[k][j,m]
    end
    if c == b
      puts "Yes"
      exit
    end
  end
end
puts "No"

Measured memory_bytes: 2044
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    string s;
    cin>>s;
    bool ans=true;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L')ans=false;
        }else{
            if(s[i]=='R')ans=false;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    ll a, b;
    cin >> a >> b;
    if(a == 0 || b == 0) cout << "Zero" << endl;
    else if(a < 0 && b > 0) cout << "Zero" << endl;
    else if(a > 0 && b > 0) cout << "Positive" << endl;
    else{
        a = b - a + 1;
        if(a % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
		k: usize,
	}

	let mut v = vec![];
	for i in a..=min(b,a+k-1) {
		v.push(i);
	}
	if k < b {
		for i in max(a, b-k+1)..=b {
			v.push(i);
		}
	}
	v.sort();
	v.dedup();
	for i in v {
		println!("{}", i);
	}
}



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


int main() {
    long long int k, n, ans;
    cin >> k >> n;
    vector<long long int> a(n), b(n);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n-1; i++){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = k - a[n-1] + a[0];
    ans = k - *std::max_element(b.begin(), b.end());
    cout << ans << endl;
}

Measured memory_bytes: 3456
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll cosv[] = {1,0,-1,0},sinv[]={0,1,0,-1};
void spin(ll &x,ll &y,ll rec){
  ll tx = x,ty = y;
  x = tx*cosv[rec] - ty*sinv[rec];
  y = tx*sinv[rec] + ty*cosv[rec];
}
ll dec_type(ll x0,ll y0,ll x1,ll y1){
  ll res;
  if(x0==x1){
    if(y0<y1) res = 0;
    else res = 2;
  }else{
    if(x0<x1) res = 1;
    else res = 3;
  }
  return res;
}
void solve(){
  ll n,tx,ty;
  cin >> n;
  if(n==0) return;
  bool ans[n+1];
  fill(ans,ans+n+1,false);
  vector<ll> m(n+1),x[n+1],y[n+1];
  for(int i=0;i<=n;i++){
    cin >> m[i];
    for(int j=0;j<m[i];j++){
      cin >> tx >> ty;
      x[i].push_back(tx);
      y[i].push_back(ty);
    }
  }
  for(int i=0;i<=n;i++){
    tx = x[i][0];
    ty = y[i][0];
    for(int j=0;j<m[i];j++){
      x[i][j] -= tx;
      y[i][j] -= ty;
    }
  }
  for(int i=0;i<=n;i++){
    ll rec = dec_type(x[i][0],y[i][0],x[i][1],y[i][1]);
    for(int j=0;j<m[i];j++){
      spin(x[i][j],y[i][j],rec);
    }
  }
  for(int i=1;i<=n;i++){
    if(m[i]==m[0]){
      bool can = true;
      for(int j=0;j<m[i];j++){
        if((x[i][j] != x[0][j])||(y[i][j]!=y[0][j])){
          can = false;
          break;
        }
      }
      if(can){
        ans[i] = true;
      }
    }
  }
  for(int i=1;i<=n;i++){
    reverse(x[i].begin(),x[i].end());
    reverse(y[i].begin(),y[i].end());
  }
  for(int i=0;i<=n;i++){
    tx = x[i][0];
    ty = y[i][0];
    for(int j=0;j<m[i];j++){
      x[i][j] -= tx;
      y[i][j] -= ty;
    }
  }
  for(int i=0;i<=n;i++){
    ll rec = dec_type(x[i][0],y[i][0],x[i][1],y[i][1]);
    for(int j=0;j<m[i];j++){
      spin(x[i][j],y[i][j],rec);
    }
  }
  for(int i=1;i<=n;i++){
    if(m[i]==m[0]){
      bool can = true;
      for(int j=0;j<m[i];j++){
        if((x[i][j] != x[0][j])||(y[i][j]!=y[0][j])){
          can = false;
          break;
        }
      }
      if(can){
        ans[i] = true;
      }
    }
  }
  for(int i=1;i<=n;i++){
    if(ans[i]) cout << i << endl;
  }
  cout <<"+++++"<<endl;
  solve();
}
signed main(){
  init_io();
  solve();
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll MOD=9, sum=0;
	string str;
	cin >> str;
	for(int i=0; i<str.size(); i++){
        sum=(sum+(str[i]-'0'))%MOD;
	}
    if(!sum) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3744
import itertools
N, M, Q = map(int, input().split())

suretu = list(itertools.combinations_with_replacement(list(range(1,M+1)),N))
arr = [list(map(int, input().split())) for _ in range(Q)]

max_point = 0
for item in suretu:
    point =0
    for jtem in arr:
        if item[jtem[1]-1] - item[jtem[0]-1] == jtem[2]:
            point += jtem[3]

    if point > max_point:
        max_point = point

print(max_point)

Measured memory_bytes: 84612
#include<stdio.h>
 
int main(void)
{
 int a;
 int b;
 int t;
 int k;

 scanf("%d %d",&a,&b);
 
 t = a*b;
 k = 2*(a+b);
 printf("%d %d\n" ,t,k);
  return 0;
}



Measured memory_bytes: 2044
from collections import deque
import sys
n, q = map(int, input().split())
queue = deque([])
for _ in range(n):
    name, time = input().split()
    time = int(time)
    queue.append([name, time])
time = 0
while True:
    try:
        if queue[0][1] <= q:
            time += queue[0][1]
            print(queue[0][0], time)
            queue.popleft()
        else:
            time += q
            queue[0][1] -= q
            queue.rotate(-1)
    except:
        sys.exit()



Measured memory_bytes: 13276
n, k = map(int, input().split())


def count():
    if k == 0:
        return n * n

    c = 0
    for i in range(k+1, n+1):
        c += (n // i) * (i - k) + max((n % i) - k + 1, 0)

    return c


print(count())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
ll r=1;
a=a%m;
while(b>0)
{
if(b&1)
r=(r*a)%m;
b=b/2;
a=(a*a)%m;
}
return r%m;
}

vi bit;//1-based indexing

void bit_update(ll x,ll n,ll val)
{
    while(x<n)
    {
        bit[x]+=val;
        x+=(x&(~x+1));
    }
}

ll bit_sum(ll x)
{
    ll sum=0;
    while(x>0)
    {
        sum+=bit[x];
        x-=(x&(~x+1));
    }
    return sum;
}
bool pos(ll x,ll n,ll m)
{
    double nn=n;
    double xx=x;
    ll c=ceil(nn/xx);
    c--;
    ll y=n/(x);
    y=y*1LL*(x-1);
    ll t=n%(x);
    if(t>0)t--;
    ll z;
    if(x==1)
    {
        z=1;
    }
   else if(x==2)z=n+1;
    else if(x==3)z=2*n;
    else z=2*n+((x-3)*n)/2;

    if(y+t+c<=m&&z>=m)return true;
    return false;
}


int main(){
    IOS

     int n;
     cin>>n;
        vi a(n+1),b(n+1),c(n);
        rep(i,1,n+1)cin>>a[i];
        rep(i,1,n+1)cin>>b[i];
        rep(i,1,n)cin>>c[i];
        ll s=0;
        rep(i,1,n+1)
        {
            s+=b[a[i]];
            if(i!=1&&a[i]==a[i-1]+1)s+=c[a[i-1]];
        }
        cout<<s;
}



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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
{
	dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
}
cout<<dp[n-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

struct SegmentTree {
private:
	int n;
	vector<int> node;
public:
	SegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz)n *= 2;
		node.resize(2 * n - 1, 0);

		//葉にもともとの配列をセット
		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];

		//葉から根に向かって更新していく
		for (int i = n - 2; i >= 0; i--)node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}

	void add(int k, int val) {

		//葉の番号は+(n-1)すれば求まる
		k += (n - 1);

		//葉に値を足す
		node[k] += val;

		//上りながら更新する
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}

	//根から完全に覆えるまで降りていく感じ
	int getsum(int a, int b, int k = 0,int l = 0, int r = -1) {

		//初回の呼び出しのみr=nにする。
		if (r < 0)r = n;

		//[a b] [l r]
		//[l r] [a b]
		//みたいな状況だったら和の単位元の0を返す
		if (b <= l || r <= a) return 0;

		//完全に覆われてたら、計算済みの値を返す
		if (a <= l && r <= b)return node[k];

		//そうでなかったら左の子と右の子へ再帰で投げて
		//帰ってきた値を足す
		int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);

		return vl + vr;
	}

};

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

	//配列に初期値があればそれを受け取って渡す、今回は全部0
	SegmentTree seg(vector<int>(n, 0));

	for (int i = 0; i < q; i++) {
		int c, x, y; cin >> c >> x >> y;
		if (c == 0)seg.add(x - 1, y);
		else cout << seg.getsum(x - 1, y) << endl;
	}

	return 0;
}




Measured memory_bytes: 4088
#include <stdio.h>

#define N 100

main(){
  int i,j,v,n,A[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);

  }
  printf("%d",A[n-1]);
  printf("\n");
  
  for(i=1;i<n;i++){
    v = A[i];
    j = i-1;
    
    while(j >= 0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(j=0;j<n-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d", A[n-1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

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

    vector<ll> A;
    for (size_t i = 0; i < 3 * n; i++) {
        ll val;
        cin >> val;
        A.push_back(val);
    }

    sort(A.begin(), A.end(), greater<ll>());

    ll ans = 0;
    for (size_t i = 0; i < n; i++) {
        ans += A[2 * i + 1];
    }

    cout << ans << endl;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,k; cin>>n>>k;
	int lol=n/2+(n%2);
	if(lol>=k) {
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<string>

using namespace std;
int main()
{
	int n, t;
	bool back = true;
	deque<int> res;
	cin >> n;
	while (n--)
	{
		cin >> t;
		if (back)
			res.push_back(t);
		else
			res.push_front(t);
		back = !back;
	}
	back = !back;
	if (back)
	{
		cout << *(res.end()-1);
		res.pop_back();
		while (!res.empty())
		{
			cout <<' '<< *(res.end()-1);
			res.pop_back();
		}
	}
	else
	{
		cout << *res.begin() ;
		res.pop_front();
		while (!res.empty())
		{
			cout <<' '<< *res.begin();
			res.pop_front();
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    vector<int> a(n+1);
    rep(i, n)cin >> a[i+1];

    vector<bool> inBall(n+1);
    vector<ll> ans;
    for(ll i = n; i > 0; --i){
        ll cnt = 0;
        for(ll j = 2*i; j <= n; j+=i){
            if(inBall[j])cnt++;
        }

        if((cnt&1) != a[i]){
            ans.push_back(i);
            inBall[i] = true;
        }
    }

    cout << ans.size() << endl;
    rep(j, ans.size())cout << ans[ans.size()-j-1] << " ";
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int N,M;
int ans=0;
vector<int> connect[8];
int passed[8]={0};
int node=0;
int check(int n){
  passed[n]=1;
  node++;
  if(node==N){
    ans++;
  }
  for(int i=0;i<connect[n].size();i++){
    if(passed[connect[n][i]]==0){
      check(connect[n][i]);
    }
  }
  passed[n]=0;
  node--;
  return 0;
}
 
int main(){
  
  cin>>N>>M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    connect[a[i]-1].push_back(b[i]-1);
    connect[b[i]-1].push_back(a[i]-1);
  }
  check(0);
  cout<<ans<<endl;
  
 
  return 0;
}

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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int c,d,e,f,g,h,i,j,k;
    scanf("%d%d%d%d%d%d%d%d%d",&c,&d,&e,&f,&g,&h,&i,&j,&k);
    
    if (c-d==f-g&&f-g==i-j){
        if (d-e==g-h&&g-h==j-k){
            if(c-f==d-g&&d-g==e-h){
                if(f-i==g-j&&g-j==h-k){
                    printf ("Yes\n");
                    exit (0);
                }
            }
        }
    }
    printf ("No\n");
	return 0 ;
}

Measured memory_bytes: 128
n, m = [int(i) for i in input().split()]
ans = [10 for i in range(n)]

for i in range(m):
	s, c = [int(j) for j in input().split()]
	if s == 1 and c == 0 and n != 1:
		print("-1")
		break
	elif ans[s-1] != 10 and c != ans[s-1]:
		print("-1")
		break
	else:
		ans[s-1] = c
else:

	for i, num in enumerate(ans):
		if  num == 10 and i == 0 and n == 1:
			print(0, end ="")
		elif num == 10 and i == 0:
			print(1, end = "")
		elif num == 10:
			print(0, end="")
		else:
			print(num, end ="")
	print()





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

int main()
{
    int h, w, distance[10], c[10][10];
    std::fill(distance, distance + 10, 100000);
    scanf("%d%d", &h, &w);
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            scanf("%d", c[i] + j);

    distance[1] = 0;
    int pre_min{1};
    bool visited[10]{};
    visited[1] = true;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
            distance[j] = std::min(distance[j], distance[pre_min] + c[j][pre_min]);

        int min_j = 5000000, min = 10000000;
        for (int j = 0; j < 10; j++)
            if (!visited[j] && distance[j] < min)
            {
                min_j = j;
                min = distance[j];
            }
        pre_min = min_j;
        visited[min_j] = true;
    }

    int num[10]{};
    long long ans{};
    for (int i = 0; i < h * w; i++)
    {
        int a;
        scanf("%d", &a);
        if (a >= 0)
            num[a]++;
    }
    for (int i = 0; i < 10; i++)
        ans += num[i] * distance[i];

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int[] a = new int[n];
		input = Console.ReadLine().Split(' ');
		int all = 0;
		for(int i=0; i<n; i++)
		{
			a[i] = int.Parse(input[i]);
			all = all ^ a[i];
		} 
		int[] sunuke = new int[n];
		StringBuilder ansSB = new StringBuilder();
		for(int i=0; i<n; i++)
		{
			sunuke[i] = all ^ a[i];
			if(i!=0) ansSB.Append(" ");
			ansSB.Append(sunuke[i].ToString());
		}
		Console.WriteLine(ansSB.ToString());
	}
}


Measured memory_bytes: 66008
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int search(vector<int> *target, int k) {
    int min = 0;
    int max = target->size();
    int prev = -1;

    while (1) {
        int now = (min+max)/2;

        if (k < target->at(now)) {
            max = now;
        } else if (k > target->at(now)) {
            min = now;
        } else {
            return now;
        }

        if (max - min <= 1) return now;

        prev = now;
    }
}

int main() {
    while (1) {
        int i;
        int d, n, m;
        vector<int> store;
        int sum = 0;

        scanf("%d", &d);
        if (d == 0) return 0;

        scanf("%d", &n);
        scanf("%d", &m);

        store.push_back(0);
        for (i=1;i<n;i++) {
            int dn;

            scanf("%d", &dn);
            store.push_back(dn);
        }

        sort(store.begin(), store.end());

        for (i=0;i<m;i++) {
            int k;
            int greater_pos;
            int less_pos;
            int less_dis;
            int greater_dis;

            scanf("%d", &k);
            greater_pos = search(&store, k);
            if (store[greater_pos] < k) greater_pos++;
            less_pos = greater_pos - 1;

            if (less_pos < 0) less_pos = store.size()-1;

            less_dis = store[less_pos] - k;


            if (greater_pos == store.size()) greater_pos = 0;

            greater_dis = store[greater_pos] - k;

            greater_dis = abs(greater_dis);
            less_dis = abs(less_dis);

            if (greater_dis > d - greater_dis) greater_dis = d - greater_dis;
            if (less_dis > d - less_dis) less_dis = d - less_dis;

            sum += min(greater_dis, less_dis);
        }

        printf("%d\n", sum);
    }
}

Measured memory_bytes: 1568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    double N;
    int K;
    cin >> N >> K;

    double p_dice = 1 / N;
    double res = 0.0;
    
    //さいころの目についてfor文
    for(int i = 1; i <= N; i++){

        double p_ans = p_dice;
        int point = i;

        while(point < K){
            point *= 2;
            p_ans *= 0.5;
        }
        res += p_ans;
    }

    printf("%.15lf\n", res);

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const map = {};
    for (const char of input.trim()) {
        if (map[char] === undefined) {
            map[char] = false;
        } else if (map[char] === false) {
            map[char] = true;
        } else {
            map[char] = false;
        }
    }
    let result = "Yes";
    for (const key of Object.keys(map)) {
        if (!map[key]) {
            result = "No";
            break;
        }
    }
    console.log(result);
}

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

Measured memory_bytes: 7372
import java.util.Arrays;
import java.util.Scanner;





public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n + 10][3];
        for (int i = 0; i < n; i++) {
            arr[i] = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        }

        int[][] dp = new int[n + 10][3];
//        dp[0][0] = arr[0][0];
//        dp[0][1] = arr[0][1];
//        dp[0][2] = arr[0][2];
        // dp[i][j] ... i日目にjをする場合に得られる最大の幸福度 => ans = dp[n]
        for (int i = 0; i < n; i++) {
            dp[i + 1][0] = Math.max(dp[i][1], dp[i][2]) + arr[i][0];
            dp[i + 1][1] = Math.max(dp[i][0], dp[i][2]) + arr[i][1];
            dp[i + 1][2] = Math.max(dp[i][0], dp[i][1]) + arr[i][2];
        }
//        debug(dp);
        int ans = Math.max(Math.max(dp[n][0], dp[n][1]), dp[n][2]);
        System.out.println(ans);

    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 103020
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll mod_pow(ll a,ll b){
    ll ret=1;
    if(a==0){return 0;}
    while(b>0){
        if(b&1){ret*=a;}
        a*=a;
        b>>=1;
    }
    return ret;
}



int main(){
    ll n,k;
    cin>>n>>k;
    cout<<mod_pow(k-1,n-1)*k<<endl;
    
    
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n&&n){
    vary(ll,v,n,inf);
    rep(i,n){
      cin>>v[i];
    }
    sort(all(v));
    ll sum = 0,ans=0;
    REP(i,1,n){
      sum = v[i-1] + sum;
      ans += sum;
    }
    cout << ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
S = input()
K = int(input())

are_all_one = True
for i in range(len(S)):
    if S[i] != '1':
        are_all_one = False
        break

nth = i + 1
if are_all_one or K < nth:
    print(1)
    exit()

answer = S[i]
print(answer)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    //cout << s << endl;
    //cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double x;
int a[100001];
int b[5002],c[5002];
main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lf",&x);
        x*=1000;
        a[i]=(int)(round(x));
        b[a[i]]++;
    }
    for(int i=0;i<=4000;i++) c[i]=b[i];
    for(int i=1;i<=4000;i++) b[i]+=b[i-1];
    for(int i=0;i<n;i++){
      int sum=0;
      if(a[i]>0)sum+=b[a[i]-1]*3;
      sum+=c[a[i]]-1;
      cout<<sum<<endl;
    }
}

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


vector<int>v[209];
int used[100009];
int n;
string s[1009];


void END(){
	cout<<-1<<endl;
	exit(0);
}

void dfs(int now,int col){//cout<<col<<endl;
	used[now]=col;
	r(i,v[now].size()){
		int nex=v[now][i];
		if(used[nex]==-1)dfs(nex,col^1);
		else if(used[nex]==col)END();
	}
}

set<int>z[10009];
map<int,int>M;


signed main(){
	memset(used,-1,sizeof(used));
  cin>>n;

  r(i,n)cin>>s[i];
  r(i,n)r(j,n){
  	if(s[i][j]=='0')continue;
  	//if(i<j)B.add_edge(i,j);
  	v[i].push_back(j);
  }
  dfs(0,0);

  int ans=-1;

  r( t , n ){

  	  int dist[n];
  	  r(i,n)dist[i]=-1;
  	  dist[t]=0; 
	  queue<int>q;
	  q.push(t);
	  int MAX=0;
	  while(!q.empty()){
	  	int now=q.front();q.pop();
	  	MAX=max(MAX,dist[now]);
	  	r(i,v[now].size()){
	  		int nex=v[now][i];
	  		if(dist[nex]!=-1)continue;
	  		dist[nex]=dist[now]+1;
	  		q.push(nex);
	  	}
	  }
	  //cout<<dist[0]<<dist[1]<<endl;
	  int flag=0;
	  r(j,n){
	  	r(k,n){
	  		if(dist[k]==dist[j]){
	  			if(s[k][j]=='1')flag=1;
	  		}
	  	}
	  }
	  if(flag)continue;
	  ans=max(ans,MAX+1);
	}

	if(ans==-1)END();

	cout<< ans <<endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    float a,b,t;
    cin>>a>>b>>t;
    cout<<int((t+0.5)/a)*b;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

counter = 0
maximum = max(h)

while maximum > 0:
    array = []
    for i in range(N):
        if h[i] == maximum:
            if i-1 not in array:
                counter += 1
            h[i] -= 1
            array.append(i)

    maximum -= 1

print(counter)


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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define N 100005

int n;
int dp[N][3];
int a,b,c;

int32_t main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(i==0){
            dp[i][0]=a;
            dp[i][1]=b;
            dp[i][2]=c;
        }
        else{
            dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
        }
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

Measured memory_bytes: 2560
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}

int ans = 0;

int main(void){
  
  int n;
  cin>>n;
  string s;
  cin>>s;

  for(int i=1;i<s.size();i++){
    set<char> v;
    for(int j=0;j<i;j++){
      for(int k=i;k<s.size();k++){
        if(s[j]==s[k]){
          v.insert(s[j]);
          break;
        }
      }
    }
    int x = v.size();
    ans = max(ans, x);

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


}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();

	if(a%2!=0 || b%2!=0 || c%2!=0) {

	    System.out.println(0);
            return;
	}
	if(a == b && b==c) {
	    System.out.println(-1);
	    return;
	}
	int cnt = 0;
	while(a%2==0 && b%2==0 && c%2==0) {
	    int tmpa = a;
	    int tmpb = b;
	    int tmpc = c;
	    a = tmpb/2 + tmpc/2;
	    b =tmpa/2 + tmpc/2;
	    c =tmpb/2 + tmpa/2;
	    cnt++;
	}

	System.out.println(cnt);

    }
}

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

int main(){
	int a,b,s[5002],t[5002],ans=0;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",&s[i]);
	for(int i=0;i<b;i++)scanf("%d",&t[i]);
	for(int i=0;i<b;i++){
		int k=0,ret=0;
		for(int j=i;j<b;j++){
			while(t[j]!=s[k]){k++; if(k>=a)break;}
			if(k>=a)break;
			ret++; k++;
		}
		if(ret>ans)ans=ret;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1212
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll keta(ll x){
    ll cnt=1;
    while(x/10>0){
        x/=10;
        cnt++;
    }
    return cnt;
}
ll sumdigit(ll y){
    ll sum=0;
    while(y>0){
        sum+=y%10;
        y/=10;
    }
    return sum;
}
int main(){
    ll N; cin>>N;
    //cout<<keta(N)<<endl;
    ll k=keta(N);
    ll ans =1;
    rep(i,k){
        ans*=10;
    }
    ll minus=ans/10;
    ans--;
    //cout<<minus<<" "<<ans<<endl;
    while(ans>N){
        ans-=minus;
    }
    //cout<<ans<<endl;
    cout<<sumdigit(ans)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int a,b;cin>>a>>b;
    cout<<6-a-b<<endl;
}

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



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

int main(void){
	queue<int> que;
	int b,c,n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin >> b;
			que.push(b);
		}
		b = c = 0;
		bool flag = false;
		while(!que.empty()){
			if(que.front() > b){
				b = que.front();
				que.pop();
			}else if(que.front() > c){
				c = que.front();
				que.pop();
			}else{
				flag = true;
				break;
			}
		}
		if(flag){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}
}

Measured memory_bytes: 1192
n = gets.to_i
ds = gets.split.map(&:to_i)
if ds.first != 0 || ds.count(0) != 1
  puts 0
  exit
end
hash = Hash.new(0)
ds.each do |d|
  hash[d] += 1
end
previous = 1
ans = 1
zero_existence = false
(1..(n - 1)).each do |index|
  if hash[index] == 0
    zero_existence = true
    next
  else
    if zero_existence == true
      puts 0
      exit
    end
    ans *= previous ** hash[index]
    previous = hash[index]
    ans %= 998244353
  end
end
puts ans


Measured memory_bytes: 14604
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
string a[300];

int main(){
  int co=0;
  int n;
  cin>>n;
  lp(i,n){
    cin>>a[i];
  }
  int m;
  cin>>m;
  lp(i,m){
    string x;
    cin>>x;
    int check=0;
    lp(j,n){
      if(a[j]==x){
	check=1;
	break;
      }
    }
    if(check==1) {
      if(co==0){
	cout<<"Opened by "<<x<<endl;
	co=1;
      }
      else if(co==1){
	cout<<"Closed by "<<x<<endl;
	co=0;
      }
    }
    else cout<<"Unknown "<<x<<endl;
  }
  return 0;
}



Measured memory_bytes: 3200
from collections import Counter
def factorization(n) -> list:
	if n==1:return [1]
	ret = []
	i = 2
	while i*i<=n:
		while n%i==0:
			n //= i
			ret.append(i)
		i += 1
	if n!=1:ret.append(n)
	return ret
	
from operator import mul
from functools import reduce
def cmb(n,r):
	if n < r:return 0
	r = min(n-r,r)
	if r==0:return 1
	u = reduce(mul, range(n, n-r, -1))
	d = reduce(mul, range(1,r+1))
	return u//d

def main():
	n,m = map(int,input().split())
	mod = 10**9+7
	if m==1:
		print(1)
		exit()
	ans=1
	for v in Counter(factorization(m)).values():
		ans*=cmb(n+v-1,v)
		ans%=mod
	print(ans)
	
if __name__=="__main__":main()

Measured memory_bytes: 3564
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()
    answer = 0
    assert N == len(S)
    for i in range(N-2):
        if S[i] == "A":
            if S[i+1] == "B" and S[i+2] == "C":
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
a=[0]*3
b=[0]*3

a[0],b[0]=map(int,input().split())
a[1],b[1]=map(int,input().split())
a[2],b[2]=map(int,input().split())

d=dict()
c=a+b
for i in c:
  if i not in d:
    d[i]=1
  else:
    d[i]+=1

mini=100
maxi=0
for j in d:
  mini=min(mini,d[j])
  maxi=max(maxi,d[j])


if mini==1 and maxi==2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
//#include <unordered_set>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double eps = 0.005;
const int maxn = 2010;
const ll mod = 1e9+7;
const int INF = 1e9;
const double pi = acos(-1);
typedef double Matrix[maxn][maxn];
int n,m;

struct RectangeSum {
    vvi sum;
    void init(int h, int w, vvi &a) {
        sum.assign(h + 1, vi(w + 1));
        for (int y = 1; y <= h; y++) {
            for (int x = 1; x <= w; x++) {
                sum[y][x] =
                sum[y - 1][x] + sum[y][x - 1] - sum[y - 1][x - 1] + a[y - 1][x - 1];
            }
        }
    }
    //[l, r), [t, b)
    inline int get(int t, int l, int b, int r) const {
        return sum[b][r] - sum[b][l] - sum[t][r] + sum[t][l];
    }
};

char ch[maxn][maxn];
vvi s1,s2,s3;
int main() {
    scanf("%d%d",&n,&m);
    int q;
    scanf("%d",&q);
    s1.assign(n, vi(m));
    s2 = s1;
    s3 = s1;
    for (int i = 0; i < n; i++) {
        scanf("%s",ch[i]);
        for (int j = 0; j < m; j++) {
            s1[i][j] = ch[i][j]-'0';
            s2[i][j] = j>0 && ch[i][j] == '1' && ch[i][j-1] == '1';
            s3[i][j] = i>0 && ch[i][j] == '1' && ch[i-1][j] == '1';
        }
    }
    RectangeSum sum1,sum2,sum3;
    sum1.init(n, m, s1);
    sum2.init(n, m, s2);
    sum3.init(n, m, s3);
    int x1,y1,x2,y2;
    for (int i = 0; i < q; i++) {
        scanf("%d%d%d%d",&y1,&x1,&y2,&x2);
        y1--; x1--; y2--; x2--;
        int ans = sum1.get(y1, x1, y2+1, x2+1);
        ans -= sum2.get(y1, x1+1, y2+1, x2+1);
        ans -= sum3.get(y1+1, x1, y2+1, x2+1);
        printf("%d\n",ans);
    }
    return 0;
}






Measured memory_bytes: 101120
n = int(input())
b = list(map(int,input().split()))
a = [0]*n
i = 0
a[0]=b[0]
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
a[n-1]=b[n-2]
#print(a)
print(sum(a))

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

int main()
{
  string s;
  cin >> s;
  int a{0}, b{0};
  for (int i = 0; i < s.size(); i++)
    (s[i] == i % 2 + '0' ? a : b)++;
  cout << min(a, b) << endl;
}


Measured memory_bytes: 512
N, M = map(int, input().split())
S = input().strip()
T = S[::-1]

l = []
i = 0
while i < N:
  t = T[i+1: i+M+1][::-1]
  if '0' not in t:
    print(-1)
    exit()
  else:
    x = min(M - t.index('0'), len(t))
    l.append(x)
    i += x
print(*l[::-1])

Measured memory_bytes: 6476