akhauriyash/Code-Regression huggingface dataset:
# abc148_b.py
# https://atcoder.jp/contests/abc148/tasks/abc148_b

# B - Strings with the Same Length /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 英小文字のみからなる長さ Nの文字列 S, Tが与えられます。
# Sの 1 文字目、T の 1 文字目、S の 2 文字目、T の2 文字目、S の 3 文字目、...、S のN 文字目、T のN 文字目
# というように、 S の各文字と Tの各文字を先頭から順に交互に文字を並べ、新しい文字列を作ります。
# この新しくできた文字列を出力してください。

# 制約
#     1≤N≤100
#     |S|=|T|=N
#     S, Tは英小文字のみからなる文字列

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S T

# 出力
# 新しくできた文字列を出力せよ。

# 入力例 1
# 2
# ip cc

# 出力例 1
# icpc

# 入力例 2
# 8
# hmhmnknk uuuuuuuu

# 出力例 2
# humuhumunukunuku

# 入力例 3
# 5
# aaaaa aaaaa

# 出力例 3
# aaaaaaaaaa


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    S, T = list(lines[1].split())
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = ''

    for s, t in zip(S, T):
        result += s + t

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', 'ip cc']
        lines_export = ['icpc']
    if pattern == 2:
        lines_input = ['8', 'hmhmnknk uuuuuuuu']
        lines_export = ['humuhumunukunuku']
    if pattern == 3:
        lines_input = ['5', 'aaaaa aaaaa']
        lines_export = ['aaaaaaaaaa']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var count = 0;
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            if (a.Length > b.Length) Console.WriteLine("GREATER");
            if (a.Length < b.Length) Console.WriteLine("LESS");
            if(a.Length == b.Length)
            {
                for (int i = 0; i <a.Length; i++)
                {
                    if (a[i] > b[i])
                    {
                        Console.WriteLine("GREATER");
                        break;
                    }
                    if (a[i] < b[i])
                    {
                        Console.WriteLine("LESS");
                        break;
                    }
                    count++;         
                }
            }
            if (count == a.Length) Console.WriteLine("EQUAL");
            

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13140
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var cc = new int[n];
        var ss = new int[n];
        var ff = new int[n];

        for(int i=0; i<n-1; i++) {
            var spl = input.ReadLine().Split(' ');
            cc[i] = int.Parse(spl[0]);
            ss[i] = int.Parse(spl[1]);
            ff[i] = int.Parse(spl[2]);
        }

        for(int i=0; i<n; i++) {
            var t = 0;
            for(int j=i; j<n-1; j++) {
                var c = cc[j];
                var s = ss[j];
                var f = ff[j];
                if (t < s) t = s;
                if (t % f != 0) t = f * (t / f) + f;
                t += c;
            }
            Console.WriteLine(t);
        }
        return null;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD=1000000007;
ll ans=0;
void cal(ll x,ll y){
	if(x<y)swap(x,y);
	if(y!=0){
		ans+=(x/y)*2*y;
		x=x%y;
		if(x==0)ans-=y;
		cal(y,x);
	}
}
int main(){
	ll n,x;
	cin>>n>>x;
	ans+=n;
	cal(n-x,x);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
hoge_list = [list(map(int,input().split())) 
             for nesya in range(n)]
f =[0]*m
for hoge in hoge_list:
  for i in range(len(hoge)-1):
    s = i + 1
    f[(hoge[s]-1)] += 1
ans = 0
for num in f:
  if num == n:
    ans += 1
print(ans)

Measured memory_bytes: 3064
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V

-- editorial

r :: IO [Int]
r = map read . words <$> getLine

main = do
    [_R,_G,_B,_N] <- r
    let r = V.sum $ solve _R _G _B _N
    print r


solve :: Int -> Int -> Int -> Int -> V.Vector Int
solve _R _G _B _N = V.generate (_N+1) id >>= (\r ->
                    V.generate (_N+1) id >>= (\g ->
                        let b = fromIntegral (_N - r*_R - g*_G) / fromIntegral _B
                        in if b >= 0 && b == fromIntegral (floor b) then V.singleton 1 else V.empty))

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

int main() {
    int A,B;
    scanf("%d %d",&A,&B);
    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        printf("Possible");
    }
    else printf("Impossible");
} 

Measured memory_bytes: 256
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    d = [(i >> j) & 1 for j in range(len(s)-1)]
    ans_ = 0
    tmp = int(s[0])
    for j in range(1, len(s)):
        if d[j-1]: tmp = tmp*10+int(s[j])
        else:
            ans_ += tmp
            tmp = int(s[j])
    ans += ans_ + tmp
print(ans)

Measured memory_bytes: 3064
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A&lang=jp
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  printf("%d %d %f\n",a/b,a%b,(double)a/(double)b);
  return 0;
}



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

int main()
{
    int A, B, C, D, F;
    float E;
    cin >> A >> B >> C >> D >> E >> F;

    vector<int> ans(2, 0);
    float water = 0.0;
    float sugar = 0.0;
    float max_density = E / (100 + E);
    float density = 0.0;
    for (int a = 0; a <= 30; a++)
    {
        for (int b = 0; b <= 30; b++)
        {
            for (int c = 0; c <= 100; c++)
            {
                for (int d = 0; d <= 100; d++)
                {
                    water = 100 * A * a + 100 * B * b;
                    sugar = C * c + D * d;

                    if (water + sugar > F)
                        continue;
                    else if (water + sugar == 0.0)
                        continue;
                    else
                    {
                        if ((0 <= sugar/(water + sugar)) && (max_density >= sugar/(water + sugar)))
                        {
                            if (sugar/(water + sugar) >= density)
                            {
                                density = sugar/(water + sugar);
                                ans.at(0) = water + sugar;
                                ans.at(1) = sugar;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << ans.at(0) << ' ' << ans.at(1) << endl;
}

Measured memory_bytes: 256
n=int(input())
k=int(input())
def nishinsu(i,n): #iの２進数を文字で返す n桁で
    return str(bin(i)[2:]).zfill(n)
l=[]
for i in range(0,int("1"*n,2)): #n回の操作を行うのに、必要な組み合わせ
    s=1
    for j in nishinsu(i,n): #10001などを左からみていく
        if j=="0":
            s=s*2
        else:
            s=s+k
    l.append(s)
print(min(l))

Measured memory_bytes: 3060
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    mut p: [usize; n]
    }
    p.sort();
    let ans = p[..k].iter().sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 2180
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n, k;
long a[MAXN];

int input() {
	if (scanf("%d %d", &n, &k) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%ld", &a[i]);
	return 1;
}

void init() {
}

long solve() {
	int m = 0, s;
	while (m<n && a[m]<0) m++;
	s = m;
	if (m<n && a[m]==0) {
		s++;
		k--;
	}
	long r = LONG_MAX;
	for (int i=0; i<=k; i++) {
		if (m-i>=0 && s+k-i-1<n) {
			long left = (i? -a[m-i]: 0);
			long x = (i==k)? left: left*2 + a[s+k-i-1];
			r = min(r, x);
			//p('x',x,a[s+k-i-1],'s',s,'r',r);
		}

		if (s+i-1<n && m-(k-i)>=0) {
			long right = (i? a[s+i-1]: 0);
			long y = (i==k)? right: right*2 - a[m-(k-i)];
			r = min(r, y);
			//p('y',y,a[s+k-i-1],'s',s,'r',r);
		}

		//p(i, r);
	}
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }

  map<string, ll> mp;

  for (int i=0; i<N; i++) {
    if(mp.count(s[i])==0) mp[s[i]]=1;
    else mp[s[i]]++;
  }

  ll ans = 0;
  for (int i=0; i<N; i++) {
    mp[s[i]]--;
    ans += mp[s[i]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18176
#include <stdio.h>

int main()
{
    int a, b, i, count;
    scanf("%d%d", &a, &b);
    count = 0;
    for (i=a; i<=b; i++)
    {
        if (i/10000 == i%10 && (i%10000)/1000 == (i%100)/10) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		String h = scanner.next();
		String n = scanner.next();

		System.out.println("A" + h.charAt(0) + "C");
	}
}


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

int main() {
    
	ll n, h; cin >> n >> h;
	vector<pair<ll, ll>> pa;
	for (ll i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		pa.push_back({ a,-1 });
		pa.push_back({ b,1 });
	}
	sort(pa.rbegin(), pa.rend());
	ll ans = 0;
	ll index = 0;
	while (0 < h) {
		if (pa[index].second == -1) {
			if (h % pa[index].first == 0) {
				ans += h / pa[index].first;
			}
			else {
				ans += h / pa[index].first + 1;
			}
			break;
		}
		else {
			h -= pa[index].first;
			index++;
		}
		ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7444
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N, K;
	cin >> N >> K;
	
	int ans = 1;
	for(int i = 0; i < N; i++){
		ans = min(ans * 2, ans + K);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N = 100;

int main(){
  int x[N][N];
  int i,j,n,k,u,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      x[i][j]=0;
    }

    for(i=0;i<n;i++){
      scanf("%d%d",&u,&k);
      u--;
      for(j=0;j<k;j++){
	scanf("%d",&v);
	v--;
	x[u][v] = 1;
      }
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(j) printf(" ");
	printf("%d",x[i][j]);
      }
      printf("\n");
    }
  
  return 0;
}



Measured memory_bytes: 2052
#include<cstdio>
#include<algorithm>
int const x_max=100001;
//dp[x]=大きいほうから順に走査していって、xが出てくる場合の数
long long dp[x_max],dp_old[x_max];
long long const mod = 1e9+7;
int main(){
    int n,x,s[200];
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&s[i]);
    std::sort(s,s+n);
    for(int i=0;i<x;i++)dp[0]=0;
    dp[x]=1;
    //小さいほうからi番目を使うかどうかを、大きいほうから決める
    for(int i=n-1;i>=0;i--){
        //初期化
        for(int j=0;j<=x;j++){
            dp_old[j]=dp[j];
            dp[j]=0;
        }
        for(int j=0;j<=x;j++){
            //i番目を使う場合
            dp[j%s[i]]+=dp_old[j];
            //i番目を使わない場合
            dp[j]+=dp_old[j]*i;
        }
        //後処理
        for(int j=0;j<=x;j++)dp[j]%=mod;
    }
    long long ans=0;
    for(int i=0;i<=x;i++)ans+=i*dp[i];
    printf("%lld\n",ans%mod);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main(){
  bool flag = false;
  int N; cin >> N;
  for(int i = 0; i < N; i++){
    int x; cin >> x;
    if(x % 2 == 1){
      flag = true;
      break;
    }
  }

  if(flag){
    cout << "first" << endl;
  }else{
    cout << "second" << endl;
  }
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

typedef pair<string, int> P;

int main() {
	int N;
	cin >> N;
	vector <string> S;
	for (int ii = 0; ii < N; ++ii){
		string hoge;
		cin >> hoge;
		S.push_back(hoge);
	}

	sort(S.begin(), S.end());
	S.push_back("hfoajdfioajsdioa");
	
	vector <P> poll;
	string prev = S[0];
	int cnt = 0;
	int maxcnt = 0;
	for (int ii = 1; ii < N+1; ++ii){
		string tmp = S[ii];
		if (prev == tmp){
			cnt++;
			if (maxcnt < cnt){
				maxcnt = cnt;
			}
		} else {
			poll.push_back(P(prev, cnt));
			prev = tmp;
			cnt = 0;
		}
	}

	for (int ii = 0; ii < poll.size(); ++ii){
		if (poll[ii].second == maxcnt){
			cout << poll[ii].first << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 18032
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
def high(h):
  return T - h*0.006
min_h = 10**4
ans = 0
for i, h in enumerate(H):
  if min_h > abs(A-high(h)):
    min_h = abs(A-high(h))
    ans = i+1
print(ans)
    

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int w,a,b;
	cin>>w>>a>>b;
	if(a>b)
	{
		int c=a;
		a=b;
		b=c;
	}
	a+=w;
	if(a-b>=0)
	{
		cout<<0;
	}
	else
	{
		cout<<b-a;
	}
 } 

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  n--;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < n; i++) {
    int t = 0, ans = 0;
    for (int j = i; j < n; j++) {
      if (t >= b[j]) {
        int d = ((t - 1) / c[j] + 1) * c[j];
        ans += d - t;
        t = d;
      }
      else {
        ans += b[j] - t;
        t = b[j];
      }
      ans += a[j];
      t += a[j];
    }
    cout << ans << '\n';
  }
  cout << 0 << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",std::max(0,std::min(b,d)-std::max(a,c)));
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0; i < 3; i++){
		if (s[i] == 'o'){
			ans += 100;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  

  string s;
  int n,i,j;
  cin>>s;
	  int num1,num2;
  num1= (s[0]-'0')*10 +(s[1]-'0');
  num2= (s[2]-'0')*10 +(s[3]-'0');
  if((num1==0 && num2>12) or (num1>12 && num2==0) or (num1==0 && num2==0) or (num1>12 && num2>12))
  {
  	cout<<"NA";
  }
  else if((num1==0 && num2<=12) or (num1>12 && num2<=12))
  {
  	cout<<"YYMM";
  }
  else if((num1<=12 && num2==0) or (num1<=12 && num2>12))
  {
  	cout<<"MMYY";
  }
  else if(num1<=12 && num2<=12)
  {
  	cout<<"AMBIGUOUS";
  }
  

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
a = ["SS", "SW", "WS", "WW"]
for i in a:
    ans = i
    for j in range(n - 2):
        if ans[j + 1] == "S":
            if s[j + 1] == "o":
                if ans[j] == "S":
                    ans += "S"
                else:
                    ans += "W"
            else:
                if ans[j] == "S":
                    ans += "W"
                else:
                    ans += "S"
        else:
            if s[j + 1] == "o":
                if ans[j] == "S":
                    ans += "W"
                else:
                    ans += "S"
            else:
                if ans[j] == "S":
                    ans += "S"
                else:
                    ans += "W"
    flag = True
    if ans[n - 1] == "S":
        if s[n - 1] == "o":
            if ans[n - 2] != ans[0]:
                flag = False
        else:
            if ans[n - 2] == ans[0]:
                flag = False
    else:
        if s[n - 1] == "o":
            if ans[n - 2] == ans[0]:
                flag = False
        else:
            if ans[n - 2] != ans[0]:
                flag = False
    if ans[0] == "S":
        if s[0] == "o":
            if ans[n - 1] != ans[1]:
                flag = False
        else:
            if ans[n - 1] == ans[1]:
                flag = False
    else:
        if s[0] == "o":
            if ans[n - 1] == ans[1]:
                flag = False
        else:
            if ans[n - 1] != ans[1]:
                flag = False
    if flag == True:
        print(ans)
        break
    else:
        continue
else:
    print(-1)

Measured memory_bytes: 9388
#include <iostream>

using namespace std;

int main(void) {
  int num = 0;
  int N;
  
  int A, B;

  cin >> A >> B;


  for (int i = 1; i <= B - A;++i) {
    num += i;
  }

  num -= B;
  
  std::cout << num << std::endl;
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	static int w,h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w=sc.nextInt();
			h=sc.nextInt();
			if(w==0&&h==0) break;
			int[][] map = new int[h+2][w+2];
			for(int j=1;j<=h;++j){
				for(int i=1;i<=w;++i){
					map[j][i]=sc.nextInt();
				}
			}
			int count=0;
			for(int j=1;j<=h;++j){
				for(int i=1;i<=w;++i){
					if(map[j][i]==1){
						map[j][i]=0;
						mapping(map,i,j);
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void mapping(int[][]map,int i,int j){
		for(int m=-1;m<=1;++m){
			for(int n=-1;n<=1;++n){
				if(map[j-m][i-n]==1){
					map[j-m][i-n]=0;
					mapping(map,i-n,j-m);
				}
			}
		}
	}
}


Measured memory_bytes: 45280
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll bg[9][9],bgn[9][9];
int main(){
  ll ans=0;
  rep(i,0,3){
    rep(j,0,3)cin>>bg[i][j];
  }
  ll n;
  cin>>n;
  rep(k,0,n){
    ll tmp;
    cin>>tmp;
    rep(i,0,3){
      rep(j,0,3){
        if(bg[i][j]==tmp)bgn[i][j]=1;
      }
    }
  }
  rep(i,0,3){
    if(bgn[i][0]*bgn[i][1]*bgn[i][2])ans++;
    if(bgn[0][i]*bgn[1][i]*bgn[2][i])ans++;
  }
  if(bgn[0][0]*bgn[1][1]*bgn[2][2])ans++;
  if(bgn[0][2]*bgn[1][1]*bgn[2][0])ans++;
 
  if(ans)cout<<"Yes";
  else cout<<"No";
  
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();
                int M = scan.nextInt();

                int sum = 0;
                
                for (int i= 0; i < M; i++) {
                	sum += scan.nextInt();
                }
                
                int holiday = N - sum;
                
                if (holiday < 0) {
                	holiday = -1;
                }
                
                System.out.println(holiday);
        }

}

Measured memory_bytes: 46180
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;

  vector <ll> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  
  int ans = 0;
  vector <ll> plus, minus;
  ll sump = 0, summ = 0;
  for (int i = 0; i < N; i++){
    if (A[i] == B[i]){
      ans++;
    }else if(A[i] > B[i]){
      plus.push_back(A[i] - B[i]);
      sump += A[i] - B[i];
      ans++;
    }else{
      minus.push_back(B[i] - A[i]);
      summ += B[i] - A[i];
    }
  }
  
  if (sump < summ){
    cout << -1 << endl;
  }else if (minus.size() == 0){
    cout << 0 << endl;
  }else{
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end(), greater<ll>());

    int cnt = 0;
    for (int i = 0; i < plus.size(); i++){
      while (plus[i] >= minus[cnt] && cnt < minus.size()){
        plus[i] -= minus[cnt];
        minus[cnt] = 0;
        cnt++;
      }
      ans--;
      if (cnt == minus.size()){
        break;
      }

      if (plus[i] > 0){
        minus[cnt] -= plus[i];
        plus[i] = 0;
      }
    }

    cout << N - ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2812
# coding: utf-8
# 34

while True:
    H,W = map(int,input().split())
    if H==0 and W==0:
        break
    for j in range(1,H+1):
        if j==1 or j==H:
            for i in range(1,W+1):
                print('#',end='')
            print()
        else:
            for i in range(1,W+1):
                if i==1 or i==W+1 or i%W==0:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
    print()
    




Measured memory_bytes: 7004
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
ll pow(int a,int b,int mod){
    vector<bool> bit;
    for(b=b;b>0;b>>=1){
        bit.push_back(b&1);
    }
    vector<ll> fac(bit.size()); fac[0] = a;
    ll res = 1;
    for(int i=1;i<bit.size();i++){
        fac[i] = (fac[i-1] * fac[i-1])%mod;
    }
    for(int i=0;i<bit.size();i++){
        if(bit[i]) res*=fac[i];
        res%=mod;
    }
    return res;
}
class BigCombination{
private:
    const int MAX = 510'000;
    long long fac[510000], inv[510000];
public:
    BigCombination(){
        fac[0] = fac[1] = 1;
        for(int i=2; i<MAX; i++){
            fac[i] = (fac[i-1] * i) % MOD;
        }
        inv[MAX-1] = pow(fac[MAX-1], MOD-2, MOD);
        for(int i=MAX-1;i>0;i--){
            inv[i-1] = (inv[i] * i) % MOD;
        }
        for(int i=0;i<=5;i++){
            // fac[]
        }
    }

    long long combination(int n,int r){
        if(n<r) return 0;
        if(n==r) return 1;
        return ((fac[n] * inv[r])%MOD * inv[n-r]) % MOD;
    }
};


//写像12相
long long ball_1(int n,int r){
    return pow(r,n,MOD);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,r;
    cin >> n >> r;

    int ans=ball_1(n,r);

    cout << ans << endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout if(false) cout
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int K,X;
	cin>>K>>X;

	int right = X-K+1;
	int left = X+K-1;

	for(int i = right; i < left+1; i++){
		cout<<i<<" ";
	}
	cout<<"\n";
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

from math import sin
from math import cos
from math import sqrt
from math import radians
c = radians(c)
S = a * b * sin(c) / 2
c_len = sqrt(a**2 + b**2 -2*a*b*cos(c))
L = a + b + c_len
h = 2*S/a

print(S, L, h)


Measured memory_bytes: 5704
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
n = len(s)
ans = 0

dp1 = [999999999999999999] * (n+1)
dp2 = [999999999999999999] * (n+1)


dp1[0] = 0
dp2[0] = 1

for i,c in enumerate(s):
    a = int(c)

    dp1[i+1] = min(dp1[i]+a, dp2[i]+a+1)
    dp2[i+1] = min(dp1[i]+a+1, dp2[i]+(10-a-1), dp2[i]+a+2)

print(min(dp1[n], dp2[n]+1))


Measured memory_bytes: 69356
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
ans=0
for i in range(n)[::-1]:
  a[i]+=ans
  if not a[i]%b[i]==0:
    ans+=b[i]-a[i]%b[i]
print(ans)

Measured memory_bytes: 14836
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll sum = a[0];
    for (int i=1; i<n/2 ; i++) {
        sum += 2*a[i];
    }
    if (n%2 == 1) sum += a[n/2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4840
List = []
for i in range (5):
  List.append(int(input()))
res = 10
n = 0
calc = 0
RES = 0
for i in range(5):
  n = List[i]%10
  RES += List[i]
  if n == 0:
    pass
  else:
    res = min(n,res)
    calc += 10-n
RES = RES + calc -10 + res
print(RES)

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

bool cmp(const pair<int,int> a, const pair<int,int> b)
{
    int x = a.first*b.second, y = b.first*a.second;
    return x>y;
}
vector<pair<int,int>> v;

map<pair<int ,int>, int> store;
int f(int j, int h)
{
    if(j >= (int)v.size()) return M;
    if(store.find({j, h}) != store.end()) return store[{j, h}];
    int ans = M;
    int ini_h = h;
    //ans += (h/v[i].first)*v[i].second;
    //h = h%v[i].first;
    //int z = v[i].second;
    //if(!h) z = 0;
    //pr(i, h, ans + z);
    //ans = ans + z;
    for(int i=0;;i++)
    {
        if(v[j].first*i > h) 
        {
            int t = (h/v[j].first)*v[j].second;
            if(h%v[j].first) t += v[j].second;
            ans = min(ans, t);
            break;
        }
        int temp = v[j].first*i;
        int at = v[j].second*i + f(j+1, h-temp); 
        ans = min(ans, at);

    }
    store[{j,h}] = ans;
    return ans; 
    //return min(ans + min(z, f(i+1, h)), f(i+1, ini_h)); 
}

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int h, n;
    cin >> h >> n;
    v.resize(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    vector<int> knapsack(h+1, M);
    knapsack[h] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=h;j>=0;j--)
        {
	       if(knapsack[j] != M)
           {
               int z = max(0LL, j-v[i].first);
               knapsack[z] = min(knapsack[z], knapsack[j] + v[i].second);
           }
        }	
    }

    cout << knapsack[0] << "\n";

    return 0;
}



Measured memory_bytes: 384
abc=[int(i) for i in input().split()]
num_five=0
num_seven=0

for i in range(3):
  if abc[i]==5:
    num_five+=1
  elif abc[i]==7:
    num_seven+=1

if num_five==2 and num_seven==1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
if N==0:
    print(1 if A[0]==1 else -1)
    exit()
if A[0] != 0:
    print(-1)
    exit()

#INF = 10**9
mxs = [1]
for a in A[1:]:
    p = mxs[-1]*2 - a
    if p < 0:
        print(-1)
        exit()
    mxs.append(p)

ans = p = A[-1]
for i in range(N-1,-1,-1):
    if mxs[i]+A[i] < (p+1)//2:
        print(-1)
        exit()
    n = min(p, mxs[i]) + A[i]
    ans += n
    p = n
print(ans)

Measured memory_bytes: 669512
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    int n, k;
    int a[200000];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n - k; i++) {
        if (a[i] < a[i + k])
            cout << "Yes";
        else cout << "No";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4408
N = int(input())
A = list(map(int, input().split()))

def insertion_sort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j]>v:
            A[j+1]=A[j]
            j -= 1
        A[j+1] = v
        print(' '.join(map(str, A)))

insertion_sort(A, N)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  cout << T << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    double n,m,d;
    
    cin>>n>>m>>d;
    
    if(d==0){
        cout<<setprecision(12)<<(m-1)/n;
        return 0;
    }
    
    double p=2*(n-d)/n;
    
    
    
    double a1=(m-1)/n;
    
    cout<<setprecision(12)<<p*a1;
    
    
    
    
   
    return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
if n>3:
  m=h.pop(0)
  for i in h:
    if m<i:
      m=i
    elif m-1>i:
      ans="No"
      break
elif n==3 and (h[0]-1>h[2] or h[1]-1>h[2]):
    ans="No"
elif n==2 and h[0]-1>h[1]:
    ans="No"
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
  
ll N;
 in(N);
  vl H(N);
  rep(i,N) in(H[i]);
  bool f = true;
  for(int i=N-1;i>=1;i--){
   if(H[i-1]-1>H[i]) f = false;
    else if(H[i-1]-1 == H[i]) H[i-1]--;
  }
  if(f) out("Yes");
  else out("No");
}

Measured memory_bytes: 1024
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()

def prime_factorization(n):
    i = 2
    res = []
    while i * i <= n:
        if n % i != 0:
            i += 1
            continue
        ex = 0
        while n % i == 0:
            ex += 1
            n //= i
        res.append((i, ex))
    if n != 1:
        res.append((n, 1))
    return res

ans = 0
fac = prime_factorization(n)
for a, ex in fac:
    i = 1
    while ex - i >= 0:
        ans += 1
        ex -= i
        i += 1

print(ans)

Measured memory_bytes: 9296
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        long a = scan.nextLong();
        long b = scan.nextLong();
        int n = scan.nextInt();
        int turn = 1;
        
        while(n-- > 0){
            if(turn == 1){
                a >>= 1;
                b += a;
            }
            else{
                b >>= 1;
                a += b;
            }
            turn ^= 1;
        }
        System.out.println(String.format("%d %d",a,b));        
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

int main(){
	std::vector<int> aList(5);

	for(int i=0; i<5; i++)
		std::cin>>aList[i];

	std::sort(aList.begin(), aList.end(), [](int a, int b){return (a-1)%10< (b-1)%10;});

	int ans= aList[0];

	for(int i=1; i<5; i++){

		ans+= ((aList[i]-1)/10+ 1)* 10;
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if (i+j)%2==0:
                print('#',end='')
            
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>

using namespace std;

void solve()
{
    int N;
    int W;

    cin >> N >> W;

    vector<int> w(N);
    vector<int> v(N);

    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    int pv = 0;
    for (auto x : v) {
        pv += x;
    }

    vector<long long> dp(N * 1000 + 1, 10e9 + 5);

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = pv - v[i]; j >= 0; --j) {
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
        }
    }

    long long ans = 0;

    for (int i = 0; i < pv + 1; ++i) {
        if (dp[i] <= W) {
            ans = max(ans, (long long)i);
        }
    }

    cout << ans;
}

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

    solve();
}


Measured memory_bytes: 3992
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {
	int n,k; cin >> n >> k ;
	int a[n]; rep(i,0,n) cin >> a[i];
	sort(a,a+n);
	int ans= 0 ;

	rep(i,0,k) ans += a[i];
	cout << ans ;
}
 
int32_t main() {

 
    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int x ;
    cin >> x ;
    int ans = 1 ;
    int now =1;
    if(x ==1){
        cout << 1 << endl;
    }else{
    for(int i = 2 ; i < x  ; i++){
        now = i * now ;
        while(now <= x){
            
            ans = max(now , ans) ;
            now = i * now ;
            

        }
        now = i + 1 ;
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

int valid[2000][10001];
int Z[20000];

void makeValid(const vector<string>& vs, int K){
	memset(valid, 0, sizeof(valid));
	int N = vs.size();
	valid[N-1][K] = 1;
	for(int i=N-2;i>=0;i--){
		for(int j=0;j<=K;j++){
			int p = j + vs[i+1].size();
			valid[i][j] = (valid[i+1][j] || (p <= K && valid[i+1][p]));
		}
	}
}

void makeZ(const string& S){
	Z[0] = S.size();
	int j=0, k=1;
	for(int i=1;i<S.size();i+=k,j=max(0,j-k)){
		while(i+j < S.size() && S[j] == S[i+j]) ++j;
		Z[i] = j;
		for(k=1;i+k < S.size() && k+Z[k] < j;k++) Z[i+k] = Z[k];
	}
	Z[S.size()] = 0;
}

int main(){
	int N, K;
	int use[2][10001];
	while(cin >> N >> K){
		vector<string> S(N);
		for(int i=0;i<N;i++) cin >> S[i];
		makeValid(S, K);
		memset(use, 0, sizeof(use));
		use[0][0] = 1;
		string best = "";
		for(int i=0;i<N;i++){
			int cur = i%2, next = 1-cur;
			memset(use[next], 0, sizeof(use[next]));
			makeZ(S[i] + best);
			int joinPos = -1;
			for(int j=best.size();j>=0;j--){
				if(!use[cur][j]) continue;
				if(j+S[i].size() > K || !valid[i][j+S[i].size()]) continue;
				if(joinPos == -1){
					int z = Z[S[i].size() + j];
					if(z+j >= best.size() || (z < S[i].size() && S[i][z] < best[z+j])){
						joinPos = j;
					}
				} else {
					int z = min((int)S[i].size(), Z[S[i].size() + j]);
					if(z+j < joinPos){
						if(z < S[i].size() && S[i][z] < best[z+j]){
							joinPos = j;
						}
					} else {
						int z2 = Z[joinPos - j];
						if(z2+joinPos-j < S[i].size() && S[i][z2+joinPos-j] < S[i][z2]){
							joinPos = j;
						}
					}
				}
			}
			for(int j=0;j<=best.size();j++){
				if(!use[cur][j]) continue;
				if(joinPos == -1 || j <= joinPos + Z[S[i].size()+joinPos]){
					if(valid[i][j]) use[next][j] = 1;
				}
				if(joinPos != -1 && j <= joinPos && j+S[i].size() <= K && valid[i][j+S[i].size()]){
					int z = min((int)S[i].size(), Z[S[i].size() + j]);
					if(z == S[i].size() && j+S[i].size() <= joinPos){
						use[next][j+S[i].size()] = 1;
					} else if(j+z >= joinPos){
						int z2 = Z[joinPos - j];
						if(joinPos + z2 >= j+S[i].size()) use[next][j+S[i].size()] = 1;
					}
				}
			}
			if(joinPos != -1) best = best.substr(0, joinPos) + S[i];
		}
		cout << best << endl;
	}
}

Measured memory_bytes: 79872
#include<stdio.h>

int main (){
  int n,x;
  int i,j,k;
  int cnt;
  while(1){
    scanf("%d %d",&n,&x);
    if(n == 0 && x == 0) break;
    cnt = 0;
    for(i = 1; i <= n; i++){
      for(j = i+1; j <= n; j++){
	for(k = j+1; k <= n; k++){
	  if (i+j+k == x){
	    cnt++;
	  }
	}
      }
      // printf("%d\n",cnt); 
    }
    printf("%d\n",cnt);
  }
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin >> n >> m;
    string s,t;cin >> s >> t;
    ll g=gcd(n,m);
    ll u=n/g,v=m/g;
    FOR(i,0,g){
        if(s[i*u]!=t[i*v]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << n*m/g << endl;
}

Measured memory_bytes: 3848