akhauriyash/Code-Regression huggingface dataset:
def main():
    buf = input()
    N = int(buf)
    buf = input()
    A = buf
    buf = input()
    B = buf
    buf = input()
    C = buf
    sub_count = 0
    for i in range(N):
        if A[i] == B[i] and B[i] == C[i] and C[i] == A[i]:
            pass
        elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
            sub_count += 1
        else:
            sub_count += 2
    print(sub_count)

if __name__ == '__main__':
    main()


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,j,k,n,s=0,t;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t;
		s+=(t-1);
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll euclidian_gcd(ll a, ll b){
    if(a<b) return euclidian_gcd(b, a);
    else{
        ll r=a%b;
        if(r==0) return b;
        return euclidian_gcd(b, r);
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> T(N);
    for(int i=0; i<N; i++){
        cin >> T[i];
    }
    ll ans=1;
    for(int i=0; i<N; i++){
        ll tmp=euclidian_gcd(ans, T[i]);
        ans*=(T[i]/tmp);
    }
    cout << ans << endl;
    
    return 0;
}

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

int n;
int A,B;
int pieC;
int C[100];

int main() {

    cin >> n;
    cin >> A >> B;
    cin >> pieC;
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }
 
    // テゥツ卍催ゥツ??10,9,8,...)テ」ツ?ォテ」ツつステ」ツδシテ」ツδ暗」ツ?凖」ツつ?
    sort(C, C+n);
    reverse(C, C+n);

 	int calorie = pieC;
	int doll = A;
	int ans = calorie / doll;
	for (int i = 0; i < n; i++) {
		doll += B;
		calorie += C[i];
		
		if (calorie / doll > ans) {
			ans = calorie / doll;
		} 
	}

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

Measured memory_bytes: 3096
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		Map<Long,Long> map = new HashMap<>();
		long sum = 0;
		for(long i = 0 ; i < n ; i++) {
			long a = sc.nextLong();
			sum += a;
			map.put(a , map.getOrDefault(a, 0L) + 1L);
		}
		long q = sc.nextLong();

		for(long i = 0 ; i < q ; i++) {
			long b = sc.nextLong();
			long c = sc.nextLong();
			sum += (c - b) * map.getOrDefault(b, 0L);
			System.out.println(sum);
			map.put(c , map.getOrDefault(c, 0L) + map.getOrDefault(b, 0L));
			map.put(b, 0L);
		}


		sc.close();


	}

}


Measured memory_bytes: 66300
n = gets.to_i
ws = Array.new(n){gets.chomp}

ans = ws==ws.uniq ? "Yes" : "No"

ws.each_with_index do |w,i|
  if i < ws.length-1 && ws[i][-1] != ws[i+1][0]
    ans = "No"
  end
end

puts ans

Measured memory_bytes: 1788
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n, k;
    cin>>n>>k;
    vector<int> vec(n+1);
    for(int i = 1; i <= n; i++)
        cin>>vec[i];

    int idx = 1;
    int cycle_len = 0, pre_cycle = 0;
    vector<int> vis(n+1, -1);
    vis[1] = 0;
    while(true){
        idx = vec[idx];
        if(vis[idx] != -1){
            pre_cycle = vis[idx];
            cycle_len -= pre_cycle;
            ++cycle_len;
            break;
        }
        ++cycle_len;
        vis[idx] = cycle_len;
    }
    // cout<<cycle_len;
    // for(int i = 0; i <= n; i++)
    //     cout<<vis[i]<<" ";
        
    if(pre_cycle >= k)
        idx = 1;
    else{
        k -= pre_cycle;
        k = k%cycle_len;
    }

    while(k--)
        idx = vec[idx];
    cout<<idx;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 4776
#include"iostream"
#include"vector"
#include"algorithm"
using namespace std;

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

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

	for (int z = 0; z < 8; z++)
	{
		for (int i = 0; i < 10; i++)
		{
			for (int j = 0; j < 10; j++)
			{
				for (int k = 0; k < 10; k++)
				{
					c[i][j] = min({ c[i][j],c[i][k] + c[k][j] });
				}
			}
		}
	}

	int a[200][200];
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> a[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (a[i][j] != -1)
			{
				ans += c[(a[i][j])][1];
			}
		}
	}
	cout << ans << endl;
}


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

if 2*n <= k:
    print(n)

elif n < k:
    print(k-n)

elif n%k == 0:
    print(0)

else:
    n = n%k
    if 2*n <= k:
        print(n)
    else:
        print(k-n)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int k, t;
	cin >> k >> t;
	int a[t];
	for(int i = 0; i < t; i++){
		cin >> a[i];
	}
	sort(a, a+t);
	int ans = 0;
	int first = 0, last = t-1;
	for(int i = 0; i < k; i++){
		if(first == last) ans = a[first] - 1;
		else{
			if(a[first] != 0 && a[last] != 0){
				a[first]--;
				a[last]--;
				i++;
			}
			else{
				if(a[first] == 0){
					first++;
				}
				if(a[last] == 0){
					last--;
				}
				if(first == last) ans = a[first] - 1;
				else{
					a[first]--;
					a[last]--;
					i++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n";
#define MAX 10000001+9   //Maximum array size;
#define loop(n) for(ll i=0;i<n;i++)
#define loop2(n) for(ll i=0;i<n;i+=2)
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()
typedef vector<ll> vi;
typedef set<ll> si;

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(int a, int b) {
    int pow = 1;
    loop(b)pow *= a;
    return pow;
    //thanks m7md :)
}

int main() {
    fast();
  //freopen("input.txt","r",stdin);
    int n,k,counter=0;cin>>n>>k;
    int c[n];
    for (int i = 0; i <n ; ++i) {
        cin>>c[i];
        if(c[i]>=k)counter++;
    }
    cout<<counter;
}



Measured memory_bytes: 640
/* ABC142-C
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, id, *people, student, i;

    scanf( "%d" , &number);
    people = malloc(sizeof(int) * number);
    for(id=1; id <= number; id++){
        scanf( "%d" , &student); /* 教室にいた生徒の人数を入力 */
        people[student-1] = id; /* 出席番号idの生徒はstudent番目に来た */
    }
    printf( "%d" , people[0]); /* 1番目の生徒の出力 */
    for(i=1; i < number; i++){
        printf( " %d" , people[i]); /* (i+1)番目の生徒の出力 */
    }
    printf( "\n" );
    return 0;
}

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

#define ll long long
#define ar array

ll c[19][19];

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

	int n;
	cin >> n;
	ll ans=0;
	for(int i=0; i<n; ++i) {
		string s;
		cin >> s;
		int p=find(s.begin(), s.end(), '.')-s.begin();
		if(p>=s.size())
			s+='.';
		while(s.size()-p-1<9)
			s+='0';
		ll a=0;
		for(char c : s) {
			if(c=='.')
				continue;
			a=a*10+c-'0';
		}
		int p2=0, p5=0;
		while(p2<18&&a%2==0) {
			++p2;
			a/=2;
		}
		while(p5<18&&a%5==0) {
			++p5;
			a/=5;
		}
		if(p2>=9&&p5>=9)
			--ans;
		++c[p2][p5];
	}
	for(int i1=0; i1<=18; ++i1)
		for(int i2=0; i2<=18; ++i2)
			for(int j1=18-i1; j1<=18; ++j1)
				for(int j2=18-i2; j2<=18; ++j2)
					ans+=c[i1][i2]*c[j1][j2];
	cout << ans/2;
}

Measured memory_bytes: 3660
n=gets.to_i
h = Hash.new{ 0 }
n.times do
  s=gets.chomp
  h[s]+=1
end

m=gets.to_i
m.times do
  t=gets.chomp
  h[t]-=1
end

puts h.values.max < 0 ? 0 : h.values.max

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
//1000000000000000000
//124999999999999995
long long cnt5(long long n){
    long long ret = 0 ;
    while(n){
        n/=5;
        ret+=n;
    }
    return ret;
}
int main()
{
    long long n;
    cin >> n;
    if(n%2)
        cout << 0 << endl;
    else{
        long long sum = cnt5(n/2);
        long long num  =1;
//        for(int i=1;i<=n/10;i++){
//            cout << i*10 << endl;
//        }

        cout << sum <<endl;
        //int dd = 0;

    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
  unsigned long long k, n;
  scanf("%lld", &k);
  long long i;
  n = 100;
  for(i = 1; n < k; i++){
    n *= 1.01;
  }
  printf("%llu\n", i - 1);
  return 0;
}

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


typedef long long ll;

void bfs(int idx){
    if(idx<=12){
        cout<<idx<<endl;
        return;
    }
    priority_queue<ll, vector<ll>, greater<ll> > que;
    for(int i = 1; i<= 9; i++) que.push(i);
    int cnt = 0;
    while (!que.empty()) {
        ll num = que.top();
        que.pop();
        cnt++;
        if(cnt==idx){
            cout<<num<<endl;break;
        }
        int ld = num % 10;
        ll num1 = num*10 + ld;
        que.push(num1);
        if(ld != 0){
            num1 = num * 10 + ld - 1;
            que.push(num1);
        }
        if(ld != 9){
            num1 = num * 10 + ld + 1;
            que.push(num1);
        }
    }
}

int main(){
    int k ;
    cin>>k;
    bfs(k);
    return 0;
}

Measured memory_bytes: 2420
int main(int argc, const char * argv[]) {
    int n;
    int i;
    int a[100];
    
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    printf("%d", a[n-1]);
    for (i=n-2; i>=0; i--) {
        printf(" %d", a[i]);
    }
    printf("\n");
    return 0;
}


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

int main(){
    int x, y, buf;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }else if(x>y){
            buf = x;
            x = y;
            y = buf;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    print(d3,d1)
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = itertools.product([1, 0], repeat=2 * n)
    a = list(itertools.combinations(range(2*n), 2))
    d = defaultdict(int)
    def dfs(a):
        if len(a) == n:
            lis.append(a)
            return True
        for i in range(n):
            if d[i] == 0:
                d[i] = 1
                for k in range(n):
                    if d[k] == 0:
                        d[k] = 1
                        a.append((i, k))
                        dfs(a)
                        a.remove((i, k))
    lis = []
    dfs([])
    for si in s:
        for di in lis:
            b = list(si[::1])
            for x, y in di:
                for i in range(x, y + 1):
                    b[i] ^= 1
            if sum(b) < 1:
                print(si, di)
                break

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 42096
s = input()
K = int(input()) # 1 <= K <= 5

alpha = "abcdefghijklmnopqrstuvwxyz"
substring = ''
L = []
for i in alpha:
    indeces = [key for key, x in enumerate(s) if x == i]
    for j in indeces:
        for k in range(j,j+K):
            substring += s[j:k+1] + ','
    L += substring.split(',')[:-1] 
    if len(set(L)) >= K:
        break
    substring = ""
print(sorted(set(L))[K-1])



Measured memory_bytes: 4924
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadLong();
            Println(Lcm(N, 2));
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

typedef long long ll;

int a[200005];
int n,k;

int check( int x )
{
	int res=k;
	for( int i=1;i<=n;i++ )
	{
		res-=(a[i]+x-1)/x-1;
	}
	return res>=0;
}


int main()
{
	
	
	cin>>n>>k;
	for( int i=1;i<=n;i++ ) cin>>a[i];
	
	int l=1,r=1e9,ans=1;
	while( l<=r )
	{
		int mid=l+r>>1;
		if( check(mid) )
		{
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
	
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a <= 5) {
        cout << 0;
    } else {
        if(a <= 12) {
            cout << b / 2;
        } else {
            cout << b;
        }
    }
    return 0;
}


Measured memory_bytes: 3564
#include<stdio.h>
int main(){
	int x,y;
	while(1){
		int flag=0;
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)	break;
		for(int a=1;a<=x;a++){
			for(int b=1;b<=x;b++){
				for(int c=1;c<=x;c++){
					if(a!=b&&b!=c&&c!=a&&(a+b+c)==y)	flag++;
				}
			}
		}
		printf("%d\n",flag/6);
	}
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, K, R, S, P;
int pre[100000];
string T;

int main(){
    cin >> N >> K >> R >> S >> P >> T;
    ll total=0;
    REP(i,N)
    {
        if(i < K)
        {
            if(T[i]=='r'){pre[i]=2;total+=P;}
            else if(T[i]=='s'){pre[i]=0;total+=R;}
            else {pre[i]=1;total+=S;}
        }
        else
        {
            if(T[i]=='r'){
                if(pre[i%K]!=2)
                {
                    pre[i%K]=2;total+=P;
                }
                else if(i+K<=T.length()){
                    if(T[i+K]=='r'){pre[i%K]=0;}
                    else if(T[i+K]=='s'){pre[i%K]=1;}
                    else {pre[i%K]=2;}
                }
            }
            else if(T[i]=='s'){
                if(pre[i%K]!=0)
                {
                    pre[i%K]=0;total+=R;
                }
                else if(i+K<=T.length()){
                    if(T[i+K]=='r'){pre[i%K]=0;}
                    else if(T[i+K]=='s'){pre[i%K]=1;}
                    else {pre[i%K]=2;}
                }
            }
            else if(T[i]=='p'){
                if(pre[i%K]!=1)
                {
                    pre[i%K]=1;total+=S;
                }
                else if(i+K<=T.length()){
                    if(T[i+K]=='r'){pre[i%K]=0;}
                    else if(T[i+K]=='s'){pre[i%K]=1;}
                    else {pre[i%K]=2;}
                }
            }
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int N,i;
 
    cin >> N;
 
    vector<string> S(N);
 
    for(i=0;i<N;i++){
        cin >> S.at(i);
    }

    set<string> aaa;
 
    for(i=0;i<N;i++){
        aaa.insert(S.at(i));
    }
 
    cout << aaa.size() << endl;
    
 
    return 0;
}

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

int A, P;

int main(){
  cin >> A >> P;

  int frag;

  frag = P + 3*A;

  int ans = frag / 2;

  cout << ans << endl;
}


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

int main(){
	ll n,k;
	cin>>n>>k;
	
	ll count=0;
	ll bawah=0;
	ll atas=0;
	
	for(int i=1;i<k;i++) bawah+=i-1;
	for(int i=1;i<k;i++) atas+=n-i+1;
	
	for(int i=k;i<=n+1;i++){
		bawah+=i-1;
		atas+=n-i+1;
//		cout<<bawah<<" "<<atas<<endl;
		
		count+=atas-bawah+1;
		count=count%1000000007;
	}
	
	cout<<count<<endl;
}

Measured memory_bytes: 3624
/*input
bB
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	string s; cin >> s;
	for(auto val: s) {
		if(val >= 'a' && val <= 'z') {
			cout << 'a';
		}
		else {
			cout << 'A';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
typedef long long ll;

signed main()
{
    int n,m;
    int l[111111],r[111111];
    cin>>n>>m;
    int min=INF,max=0;
    rep(i,m){
        cin>>l[i]>>r[i];
        min=std::min(min,r[i]);
        max=std::max(max,l[i]);
    }
    if(min-max+1<=0)cout<<0<<endl;
    else cout<<min-max+1<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,t,temp,temp1,sum=0;
    cin >> n;
    ll a[n];
    map<ll,ll> m;
    rep(i,n) 
    {
        cin >> a[i] ;
        m[a[i]]++;
    }
    map<ll,ll> m1;
    map<ll,ll>::iterator itr;
    for(itr=m.begin();itr!=m.end();++itr)
    {
        t=itr->second;
        sum+=(t*(t-1))/2;
        
    }
    rep(i,n)
    {
        temp1=sum;
        temp=m[a[i]];
        temp1-=(temp*(temp-1))/2;
        temp--;
        temp1+=(temp*(temp-1))/2;
        cout << temp1 << endl ;
    }
    
    
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
int L[MAXN],R[MAXN],n,k,c;
char str[MAXN];
int main(){
    scanf("%d %d %d %s",&n,&k,&c,str+1);
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(str[i]=='o') L[++cnt]=i,i+=c;
        if(cnt==k) break;
    }
    cnt=k+1;
    for(int i=n;i>=1;i--){
        if(str[i]=='o') R[--cnt]=i,i-=c;
        if(cnt==1) break;
    }
    for(int i=1;i<=k;i++){
        if(L[i]==R[i]){
            printf("%d\n",L[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, X, Y;
	int sum;

	cin >> A >> B >> C >> X >> Y;

	if (2*C<A+B) {
		if (X > Y) {
			if (A >= 2 * C ) {
				sum = 2 * C * Y + 2*C*(X - Y);

			}
			else{
				sum = 2 * C * Y + A*(X - Y);
			}
		}
		else{
			if (B >= 2 * C) {
				sum = 2 * C*X + 2 * C*(Y - X);
			}
			else {
				sum = 2 * C*X + B*(Y - X);
			}
		}
	}
	else {
		sum = A*X + B*Y;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a,b;
    int c[3];
    cin>>a>>b;
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout<<c[2]<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let (k, s) = i::u2();

    let mut ans = 0usize;
    for i in 0..(k + 1) {
        for j in 0..(k + 1) {
            if i + j > s {
                continue;
            }
            if s - i - j > k {
                continue;
            }
            ans += 1;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

int n;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	if(n == 25)	cout<<"Christmas";
	if(n == 24)	cout<<"Christmas Eve";
	if(n == 23)	cout<<"Christmas Eve Eve";
	if(n == 22)	cout<<"Christmas Eve Eve Eve";
	cout<<"\n";
}

Measured memory_bytes: 256
import Data.List

f ::[Int]->Int->Int->Int
f [] a b=a-b
f (x:[]) a b = a+x-b
f (x:y:zs) a b= f zs (a+x) (b+y)


main = do
       n<-getLine
       a<-getLine
       let n1=read n::Int
           a1=reverse $ sort $ map read (words a)::[Int]
       putStrLn $ show $ f a1 0 0

Measured memory_bytes: 1020
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int N = 2e5 + 5;
LL dp[N][2];
void solve()
{
     int n;
	cin >> n;
	v64 arr(n + 1, 0);
	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	memset(dp, 0, sizeof(dp));
	dp[2][1] = arr[2];
	dp[2][0] = arr[1];
	for (int i = 3; i < n + 1; i++)
	{
		if (i & 1)
		{
			LL temp = max({dp[i - 3][1], dp[i - 3][0], dp[i - 2][1], dp[i - 2][0]});
			dp[i][1] = arr[i] + temp;
			dp[i][0] = max({arr[i - 1] + dp[i - 2][0], arr[i - 1] + dp[i - 3][1], arr[i - 1] + dp[i - 3][0], arr[i - 2] + dp[i - 3][0]});
		}
		else
		{
			dp[i][1] = arr[i] + max({dp[i - 2][1], dp[i - 2][0], dp[i - 1][0]});
			dp[i][0] = arr[i - 1] + dp[i - 2][0];
		}
	}
	cout << max(dp[n][1], dp[n][0]) << endl;
	return;
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 7924
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int ele;
  for (int i=0;i<5;i++)
  {
    scanf("%d",&ele);
    if (ele==0)
    {
      cout<<(i+1)<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 505;

int n, m;
char a[N][N];
char c[2][N][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m;
	MMS(c, '.');
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < m; j++) {
			c[i & 1][i][j] = '#';
			if (a[i][j] == '#')
				c[0][i][j] = c[1][i][j] = '#';
		}
		c[0][i][m] = c[1][i][m] = 0;
	}
	for (int i = 0; i < n; i++) {
		c[0][i][0] = c[1][i][m - 1] = '#';
		c[0][i][m - 1] = c[1][i][0] = '.';
	}
	for (int k = 0; k < 2; k++) {
		for (int i = 0; i < n; i++)
			cout << c[k][i] << "\n";
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 1536
S = input()
sum1 = 0
sum2 = 0
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == '0':
            sum1 += 1
        else:
            sum2 += 1
    else:
        if S[i] == '1':
            sum1 += 1
        else:
            sum2 += 1
print(min(sum1, sum2))

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

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

signed main() {
  ll n;
  string s;
  cin >> n >> s;

  ll one_cnt = 0;
  for (int i = 0; i < n; i++) {
    if(s[i] == '1') one_cnt++;
  }

  ll low = 0;
  if(one_cnt - 1 > 0) {
    for (ll i = 0; i < n; i++) {
      if(s[i] == '0') continue;
      low += modpow(2LL, (n - 1 - i), (one_cnt - 1));
      low %= (one_cnt - 1);
    }
  }

  ll high = 0;
  for (ll i = 0; i < n; i++) {
    if(s[i] == '0') continue;
    high += modpow(2LL, (n - 1 - i), (one_cnt + 1));
    high %= (one_cnt + 1);
  }

  for (int i = 0; i < n; i++) {
    ll mod = 0;
    ll val = 0;
    ll two = 0;

    if (s[i] == '1') {
      if (one_cnt - 1 == 0) {
        cout << 0 << '\n';
        continue;
      }
      mod = (one_cnt - 1);
      val = low;
      two = modpow(2LL, (n - 1 - i), mod);
      val = (val - two + mod) % mod;
    } else {
      mod = (one_cnt + 1);
      val = high;
      two = modpow(2LL, (n - 1 - i), mod);
      val = (val + two) % mod;
    }

    ll ans = 1;
    mod = __builtin_popcount(val);

    while(val != 0 && mod != 0) {
      val = val % mod;
      mod = __builtin_popcount(val);
      ans++;
    }
    cout << ans << '\n';
  }

  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<string> vec(h);
 
  for (int i=0; i<h; i++) {
    string a;
    cin >> a;
    vec.at(i) = a;    
  }
  string x = "";
  for (int i=0; i<w+2; i++) {
    x +=  "#";
  }
  cout << x << endl;
  for (int i=0; i<h; i++) {
    cout << "#" << vec.at(i) << "#" << endl;
  }
  cout << x << endl;
 }
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9'){
		k=k*10+(s-'0');
		s=getchar();
	}
	return k*base;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		write(-x);
	}
	else
	{
		if(x/10)write(x/10);
		putchar(x%10+'0');
	}
}
const int maxn=3010;
int n,m;
const int p=1000000007;
int f[maxn][maxn][2];//f[i][j][k] j:偶数位0失配数
int ans;
int main()
{
	n=read();m=read();
	f[0][0][1]=1;
	for (int i=1;i<=n;i++) f[0][i][0]=1;
	for (int i=0;i<m;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=1;k++)
			{
				if (j) (f[i+1][j-1][k|(j==1)]+=f[i][j][k])%=p;//01
				if (j) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=p;//00
				if (n-j) (f[i+1][j+1][k]+=f[i][j][k])%=p;//10
				if (n-j) (f[i+1][j][k]+=f[i][j][k])%=p;//11
			}
	for (int i=0;i<=n;i++) 
	{
		ans+=f[m][i][1];
		if (ans>p) ans-=p;
	}
	if (ans>p) ans-=p;
	printf("%d\n",ans);
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL vec(n);rep(i,n)cin>>vec[i]
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n;
  cin>>n;
  cinv(n,a);
  SORT(a);
  int idx=n/2;
  int ans=a[idx]-a[idx-1];
  if(n&1)ans=0;
  out(ans);


  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,Q;
    cin>>N>>Q;
    vector<vector<int>> G(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    map<int,long long> mp;
    for(int i=0;i<Q;i++){
        int a;
        long long b;
        cin>>a>>b;
        mp[a-1]+=b;
    }
    vector<int> visited(N,0);
    //visited[0]=1;
    vector<long long> score(N,0);
    queue<int> q;
    
    for(int y=0;y<N;y++){
    if(!visited[y]){
    visited[y]=1;
    score[y]=mp[y];
    q.push(y);
    while(!q.empty()){
        int temp=q.front();
        q.pop();
        long long count=score[temp];
        for(int i=0;i<G[temp].size();i++){
            int  x=G[temp][i];
            if(!visited[x]){
                visited[x]=1;
                score[x]=mp[x]+count;
                q.push(x);
            }
        }
    }
    }
    }
    for(int i=0;i<N;i++){
        cout<<score[i]<<" ";
    }
    return 0;
    
    
}

Measured memory_bytes: 29556
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

struct Edge {
  int to;
  i64 cost;

  Edge(int _to, i64 _cost) : to(_to), cost(_cost) {}
};

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

  int n, w;
  cin >> n >> w;
  vt<int> weight(n), value(n);
  rep(i, 0, n) cin >> weight[i] >> value[i];

  int sum = 0;
  rep(i, 0, n) sum += value[i];

  vvt<i64> dp(n + 1, vt<i64>(sum + 1, INF));
  dp[0][0] = 0;
  rep(i, 0, n) {
    rep(j, 0, sum + 1) {
      if(j < value[i]) dp[i + 1][j] = dp[i][j];
      else dp[i + 1][j] = min(dp[i][j], dp[i][j - value[i]] + weight[i]);
    }
  }
  
  for(int i = sum; i >= 0; --i) {
    if(dp[n][i] <= w) return cout << i << endl, 0;
  }
}


Measured memory_bytes: 80256
def factorials(n,mod=10**9+7):
    # 0~n!のリスト
    f = [1,1]
    for i in range(2,n+1):
        f.append(f[-1]*i%mod)

    # 0~n!の逆元のリスト
    g = [1]
    for i in range(n):
        g.append(pow(f[i+1],mod-2,mod))

    return f,g


def combination_mod(f,g,n,r,mod=10**9+7):
    # nCr mod modを求める
    nCr = f[n] * g[n-r] * g[r]
    nCr %= mod
    return nCr


def permutation_mod(f,g,n,r,mod=10**9+7):
    # nPr mod modを求める
    nPr = f[n] * g[n-r]
    nPr %= mod
    return nPr


n,k = map(int, input().split())
a = list(map(int, input().split()))
m = 10**9+7

a.sort()

f,g = factorials(n)
ans = 0

for i in range(k-1,n):
    ans += combination_mod(f,g,i,k-1)*a[i]
for i in range(n-k+1):
    ans -= combination_mod(f,g,n-i-1,k-1)*a[i]
while ans < 0:
    ans += m
print(ans%m)




Measured memory_bytes: 65576
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  string X;
  cin >> X;
  int N = X.size();
  vector<char> answer;
  rep(i, N) {
    if (X[i] == 'S') {
      answer.emplace_back('S');
    } else if (X[i] == 'T') {
      if (answer.empty() || answer.back() == 'T')
        answer.emplace_back('T');
      else
        answer.pop_back();
    }
  }
  cout << answer.size() << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	ll n, p;
	cin >> n >> p;
	if (p == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	ll ans = 1;
	VLL v(1000010, 0);
	ll a = 2;
	while (p!=1&&a<=1000009) {
		if (p%a == 0) {
			v[a]++;
			p /= a;
		}
		else {
			a++;
		}
	}
	for (ll i = 2; i <= 1000005; i++) {
		if (v[i] >= n) {
			REP(j, v[i] / n) {
				ans *= i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main (void)

{

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);



if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0)

{

printf("Yes\n");

}

else{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 1000 + 5;

int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < 3; i++)
		cout << s[i];
	cout << endl;
	return 0;
} 

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
char s[maxn];
int N;
int main(){
	//freopen("in","r",stdin);
	N=read();
	scanf("%s",s+1);
	int ans=0;
	for(int i=1;i<=N;i++){
		int j=i+1;
		while(s[j]==s[i])
			j++;
		j--;
		ans++;
		i=j;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
t = read().rstrip().decode()
ans = []
for i in range(len(s) - len(t) + 1):
    for j, (ss, tt) in enumerate(zip(s[i:], t)):
        if ss not in ('?', tt):
            break
    else:
        memo = s[:i] + t + s[i + len(t):]
        ans.append(memo.replace('?', 'a'))
print(min(ans) if ans else 'UNRESTORABLE')


Measured memory_bytes: 3064
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion
class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC
def main():
# Enter your code here. Read input from STDIN. Print output to STDOUT
    # for t in range(int(input())):
        
        # n = int(input())
        n,x,t = [int(j) for j in input().split()]
        print(((n+x-1)//x)*t)
        # l = [int(j) for j in input().split()]




        # b = [int(j) for j in input().split()]

            # s = n-1

        # s = input()




        # a = list(a)
        # print(a)
        # for i in a:



        



if __name__ == "__main__":
    main()

Measured memory_bytes: 66144
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(a-x) < abs(b-x))cout << "A\n";
    else cout << "B\n";
    return 0;
}

Measured memory_bytes: 256