akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 100001;

ii A[MN];
bitset<MN> used;

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i].f >> A[i].s;

    ll x = 0, y = 0;
    for (int i = 0; i < N; ++i) x += A[i].f, y += A[i].s;
    ll ans = min(x, y);

    vector<ii> v;
    for (int i = 0; i < N; ++i) v.emplace_back(A[i].f, i), v.emplace_back(A[i].s, i);
    sort(begin(v), end(v));

    ll sum = 0;
    bool done = 0;
    for (int i = 0; i < N; ++i) {
        sum += v[i].f;
        if (used[v[i].s]) done = 1;
        used[v[i].s] = 1;
    }

    if (done) ans = min(sum, ans);
    else for (int i = 0; i < N; ++i) ans = min(sum+A[v[i].s].f+A[v[i].s].s-v[i].f-(i < N-1 ? v[N-1].f : v[N-2].f), ans);
    cout << ans;
}


Measured memory_bytes: 6120
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;

int main(void){
	string s;
	cin>>s;
	if(s.size()%2!=0){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s.size();i+=2){
		if(s.substr(i,2)!="hi"){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

using namespace std;

#define MX 35
#define MOD 1'000'000'007
#define F first
#define S second
#define br '\n'

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

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

	double r;
	cin >> r;
	cout << setprecision(10) << acos(-1) * r * 2 << endl;

	return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
 
    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (data[y] < data[x]) swap(x, y);  // マージテク
        data[x] += data[y];
        data[y] = x;
        return true;
    }
 
    // ある要素がどの集合に属しているかを答える
    int root(int x) {
        // 根に直接つなぎ直す
        return data[x]<0 ? x : (data[x]=root(data[x]));
    }
 
    // ある集合の大きさを答える
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>a(m),b(m),answer(m);
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind tree(n);

    answer[m-1]=n*(n-1)/2;

    for(int i=m-1;i>0;i--){
        if(tree.root(a[i])==tree.root(b[i])){
            answer[i-1]=answer[i];
            continue;
        }
        answer[i-1]=answer[i]-1ll*(ll)tree.size(a[i])*(ll)tree.size(b[i]);
        tree.merge(a[i],b[i]);
    }

    REP(i,m)cout << answer[i] << endl;

    return 0;
}

Measured memory_bytes: 4096
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#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;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string a, b;
		cin >> a >> b;

		ll n = a.length(), m = b.length();
		ll ans = INT_MAX;
		for (int i = 0; i <= n - m; i++)
		{
			int j;
			/* For current index i, check for
			pattern match */
			ll cnt = 0;
			for (j = 0; j < m; j++)
				if (a[i + j] != b[j])
					cnt++;
			ans = min(ans, cnt);
		}
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	cout << N * (N + 1) / 2 << endl;

	return 0;
}


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

constexpr long long inf = 1000000000LL;

int n, m;
std::vector<int> g[100005];
int dp[100005];
int deg[100005];
int main()
{
	std::cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y;
		std::cin >> x >> y;
		--x, --y;
		g[x].push_back(y);
		++deg[y];
	}

	std::queue<int> que;
	for (int i = 0; i < n; ++i)
		if (deg[i] == 0)
			que.push(i);

	while (!que.empty()) {
		auto v = que.front();
		que.pop();

		for (size_t i = 0, end = g[v].size(); i < end; ++i) {
			auto nv = g[v][i];

			--deg[nv];
			if (deg[nv] == 0) {
				que.push(nv);
				dp[nv] = std::max(dp[nv], dp[v] + 1);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = std::max(ans, dp[i]);

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


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

using namespace std;

int main(){

  int n;

  while(1){
	cin>>n;

	if(n==0)
	  break;
	
	int sum=0;
	int cnt=0;
	
	for(int i=1;i<n;++i){
	  sum=i;
	  for(int j=i+1;i<=n;++j){
		sum+=j;
		if(sum==n){
		  cnt++;
		  break;
		}
		else if(sum>n){
		  break;
		}
		
	  }
	  
	}
	cout<<cnt<<endl;
  }
}



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

int main(){
    int n;
    cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    else{
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = 0; i > n; i--)
#define REP(i,k,n) for (int i = k; i <= n; i++) 
#define REPR(i,k,n) for int i = k; i >= n; i--)

typedef long long int ll;

int main()
{
	string s;
	cin >> s;
 
	if(s == "RRR") cout << 3 << "\n";
	else if(s == "RRS" || s == "SRR") cout << 2 << "\n";
	else if(s == "RSR" || s == "SRS" || s == "RSS" || s == "SSR") cout << 1 << "\n";
	else if(s == "SSS") cout << 0 << "\n";
 
	return 0;
}


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


char ca(char cc){
  	if(cc=='S') return 'W';
    else return 'S';
}

int main(){
  int n;
  string c;
  cin >> n;
  cin >> c;
  string s(n,'S');
  bool flag=false;
  for(int i=0;i<4;i++){
    //SS...
    if(i==0){
      s[0]='S'; s[1] = 'S';
    }
    //SW...
    if(i==1){
      s[0]='S'; s[1] = 'W';
    }
    //WS...
    if(i==2){
      s[0]='W'; s[1] = 'S';
    }
    //WW...
    if(i==3){
      s[0]='W'; s[1] = 'W';
    }
    for(int j=2;j<n;j++){
    	s[j] = (s[j-1]=='S')==(c[j-1]=='o') ? s[j-2] : ca(s[j-2]);
    }
    if(s[0] == ((s[n-1]=='S')==(c[n-1]=='o') ? s[n-2] : ca(s[n-2]))
      &&
       s[n-1] == ((s[0]=='S')==(c[0]=='o') ? s[1] : ca(s[1]))
      ){
    	flag = true;
      	break;
    } 
  }
  if(flag) cout << s << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 576
import sys


def read():
    return sys.stdin.buffer.readline().rstrip()


def main():
    n, m = map(int, read().split())
    al = [[] for _ in range(n)]
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        al[a].append(b)
        al[b].append(a)
    cnt = 0
    seen = set()
    for i in range(n):
        if i in seen:
            continue
        todo = [i]
        while todo:
            p = todo.pop()
            if p in seen:
                continue
            seen.add(p)
            todo += al[p]
        cnt += 1
    print(cnt - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31788
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

ll a[ma],n;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll k,i,j,x,y,z;
    while(cin>>n)
    {
       for(i=1;i<=n;i++)cin>>a[i];
       ll ans=1000;

       for(i=1;i<=n;i++)
       {
           ll x=a[i];
           ll y=-1;
           for(j=i+1;j<=n;j++)
           {
               if(a[j]>a[j-1])
               {
                   y=a[j];
                   continue;
               }
               break;
           }
           i=j-1;
           if(y==-1)continue;
           ll p=(ans/x);
           ans=ans+(y-x)*p;
       }
       cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3572
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            double sum = arr[0];
            for (int i = 1; i < n; i++) {
                sum = (sum + arr[i]) / 2.0;
            }
            out.println(sum);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


Measured memory_bytes: 21460
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int a = 0;
      int b = 0;
      int c = 0;
      int d = 0;
      for(int i = 0;i < s.length();i++){
      	if(s.substring(i,i+1).equals("N"))a++;
        else if(s.substring(i,i+1).equals("W"))b++;
        else if(s.substring(i,i+1).equals("S"))c++;
        else d++;
      }
      if((a*c>0&&b*d>0)||(a*c>0&&b+d==0)||(a+c==0&&b*d>0))System.out.println("Yes");
      else System.out.println("No");
    }
}


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

using namespace std;

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

    int *v;
    v = new int[n];   
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    int c, ans=0;
    for(int i=0; i<n; i++){
        cin >> c;
        if (v[i]>c) ans += v[i]-c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
"""
制約
a,b,xはすべて整数
1≦a≦100
1≦b≦100
1≦x≦a^2b
 
mathライブラリ
tanから角度を求めるとき(math.atan())と
弧度を度数に変換するとき(math.degrees())を用いる。
"""
import math
 
#入力
a, b, x = map(int, input().split())
 
#計算&出力
if a * a * b < 2 * x:
  print(math.degrees(math.atan(2*b/a-2*x/a**3)))
else:
  print(math.degrees(math.atan(a*b*b/(2*x))))

Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main(void){
	long long k;
	scanf("%lld",&k);
	if (!k){
		printf("2\n0 0");
		return 0;
	}
	printf("50\n");
	long long pls=k/50,lft=k%50;
	for (int i=1;i<=50;i++){
		printf("%lld ",((i<=lft)?(48ll+pls+2):50ll+pls-lft-1));
	}
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
cnt = [0] * N
for i in range(1,N):
  cnt[i] = cnt[i-1]
  if S[i-1:i+1] == "AC":
    cnt[i] += 1
for i in range(Q):
  r, l = map(int, input().split())
  print (cnt[l-1] - cnt[r-1])

Measured memory_bytes: 6140
let NY: [Int] = readLine()!.characters.split(" ").map { Int(String($0))! }
var xRes: Int = -1
var yRes: Int = -1
var zRes: Int = -1

for x in 0...NY[0] {    // 10000円札の枚数 xのループ
    for y in 0...NY[0] {    // 5000円札の枚数 yのループ
        let z: Int = NY[0] - x - y  // お札の合計枚数が N枚から, 1000円札の枚数 zを求める
        if 0 <= z { // 1000円札の枚数が 0以上のときのみ
            let otoshidama: Int = 10000*x + 5000*y + 1000*z
            if otoshidama == NY[1] {	// 条件にあってるか(・・？)
                xRes = x
                yRes = y
                zRes = z
            }
        }
    }
}
print(xRes, yRes, zRes) // (๑•ૅㅁ•๑)

Measured memory_bytes: 4720
k = int(input())
n = 50
tmp = k // 50
a = [49 + tmp for _ in range(n)]
k %= 50
for i in range(k):
  m = min(a)
  isp = True
  for j in range(n):
    if a[j] == m and isp:
      a[j] += n
      isp = False
    else:
      a[j] -= 1
print(n)
print(*a, sep=' ')


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, two = 0, four = 0;
    cin >> n;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
            two++;
        if (a % 4 == 0)
            four++;
    }
    two -= four;
    int add = 0;
    if (four > 0)
    {
        add = 1;
    }
    if (four * 2 + two / 2 * 2 + add >= n)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t h, w, n;
    cin >> h >> w >> n;

    int64_t s_x, s_y;
    // 順番に注意
    cin >> s_y >> s_x;

    string s_a, s_b;
    cin >> s_a;
    cin >> s_b;

    // to right
    int64_t pos = s_x;
    for (auto i : irange(0L, n)) {
        if (s_a[i] == 'R') {
            ++pos;
        }

        if (pos > w) {
            cerr << "right" << endl;
            cout << "NO" << endl;
            return 0;
        }

        if (s_b[i] == 'L' && pos > 1) {
            --pos;
        }
    }

    // to left
    pos = s_x;
    for (auto i : irange(0L, n)) {
        if (s_a[i] == 'L') {
            --pos;
        }

        if (pos <= 0) {
            cerr << "left" << endl;
            cout << "NO" << endl;
            return 0;
        }

        if (s_b[i] == 'R' && pos < w) {
            ++pos;
        }
    }

    // to top
    pos = s_y;
    for (auto i : irange(0L, n)) {
        if (s_a[i] == 'U') {
            --pos;
        }

        if (pos <= 0) {
            cerr << "top" << endl;
            cout << "NO" << endl;
            return 0;
        }

        if (s_b[i] == 'D' && pos < h) {
            ++pos;
        }
    }

    // to bottom
    pos = s_y;
    for (auto i : irange(0L, n)) {
        if (s_a[i] == 'D') {
            ++pos;
        }

        if (pos > h) {
            cerr << "bottom" << endl;
            cout << "NO" << endl;
            return 0;
        }

        if (s_b[i] == 'U' && pos > 1) {
            --pos;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;
using pll = pair<ll,ll>;

bool comp(const pll &a,const pll &b){
    if(a.first < b.first)return true;
    return false;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<int> A(n),B(n);
    vector<pll> vec(n);
    ll amount = 0,price=0;
    rep(i,n){
        cin >> price >> amount;
        vec[i] = make_pair(price,amount);
    }

    sort(vec.begin(),vec.end(),
        comp
    );

    ll ans = 0;
    rep(i,n){
        int tmp = min(m,vec[i].second);
        m -= tmp;
        ans += vec[i].first * tmp; 
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#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 <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    bool ans=1;
    for(int i=0; i<n; i++){
        cin >> a[i];
       if(a[i]%2==0){
            if (a[i]%3!=0 && a[i]%5!=0){
            ans=0;
        }
       }
    }
    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
    
}


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

int main(){
  int i,n;
  cin >> n;
  vector<int> a(n),p(1000001,0);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    p.at(a.at(i))++;
  }
  
  for(i=1;i<=1000000;i++){
    if(p.at(i)!=0){
      if(p.at(i)!=1){
        p.at(i)=0;
      }
      int k=i*2;
      while(k<=1000000){
        p.at(k)=0;
        k += i;
      }
    }
  }
  
  int s=0;
  for(i=1;i<=1000000;i++){
    s += p.at(i);
  }
  
  cout << s << endl;
}

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

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

using namespace std;

using tri = tuple<int, int, int>;

template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

constexpr int N_MAX = 40;
constexpr int A_MAX = 10;
constexpr int B_MAX = 10;
constexpr int C_MAX = 100;
constexpr int INF = C_MAX * N_MAX + 1;

template <class Iterator>
vector<vector<int>> bit(Iterator first, Iterator last) {
    int n = distance(first, last);
    vector<vector<int>> result(A_MAX * N_MAX / 2 + 1, vector<int>(B_MAX * N_MAX / 2 + 1, INF));
    REP(bit, 1 << n) {
        int a = 0, b = 0, c = 0;
        REP(i, n) {
            if (bit & 1 << i) {
                tri t = *(first + i);
                a += get<0>(t);
                b += get<1>(t);
                c += get<2>(t);
            }
        }
        amin(result[a][b], c);
    }
    return result;
}

int main() {
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<tri> abc(N);
    REP(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        abc[i] = tri(a, b, c);
    }

    auto s1 = bit(abc.begin(), abc.begin() + N / 2);
    auto s2 = bit(abc.begin() + N / 2, abc.end());

    int result = INF;
    constexpr int K = A_MAX * N_MAX / 2;
    REP(a1, K + 1) REP(b1, K + 1) REP(a2, K + 1) {
        if ((a1 + a2) * Mb % Ma != 0) {
            continue;
        }
        int b2 = (a1 + a2) * Mb / Ma - b1;
        if (b2 < 0 || K < b2 || a1 + a2 == 0) {
            continue;
        }
        int c1 = s1[a1][b1];
        int c2 = s2[a2][b2];
        if (c1 != INF && c2 != INF) {
            amin(result, c1 + c2);
        }
    }
    if (result == INF) {
        cout << (-1) << endl;
    } else {
        cout << result << endl;
    }

    return 0;
}

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

vector<int> sankaku, shimen, odd;

int main()
{
  int n; cin >> n;
  double ans = 0;
  rep(i, n)
  {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC")
      ans += x * 380000;
    else
      ans += x;
  }
  printf("%.5lf\n", ans);
}

Measured memory_bytes: 256
#include <string>
#include <assert.h>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll L,R;
    cin >> L >> R;
    R = min(R, L + 4038);
    ll min_mod = 2018;
    for (ll i=L; i <= R; i++) {
        for (ll j = i + 1; j <= R; j++) {
            ll result;
            result = i * j % 2019;
            min_mod = min(result, min_mod);
        }
    }
    cout << min_mod << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans=0;
void dfs(int a,int b,int c,int step)
{
	if(step==0)
	{
		ans=max(ans,a+b+c);
		return;
	}
	dfs(a*2,b,c,step-1);
	dfs(a,b*2,c,step-1);
	dfs(a,b,c*2,step-1);
}
int main()
{
    ios::sync_with_stdio(false);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    dfs(a,b,c,k);
    cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(m), c(m);
    if (n == 1 && m == 0) {
        puts("0");
        return 0;
    }
    if (n != 1 && m == 0) {
        cout << pow(10,n)/10 << endl;
        return 0;
    }
    rep(i, m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    vector<int> ans(n, -1);
   
    bool ok = true;
    rep(i, m) {
        //printf("@@@ %d %d\n", s[i], c[s[i]]);
        if (n != 1 &&s[i] == 0 && c[s[i]] == 0) {
            ok=false;
            break;
        }
        //printf("@@@ %d %d %d\n", ans[s[i]] ,s[i], c[i]);
        if (ans[s[i]] == -1) ans[s[i]] = c[i];
        else if (ans[s[i]] == c[i]) {
            continue;
        }
        else {
            ok=false;
            break;
        }
    }
    if (!ok) {
        puts("-1");
        return 0;
    }
    rep(i, n) {
        if (i == 0 && ans[i] == -1) ans[i] = 1;
        else if (m == 0) ans[i] = 0;
        else if (ans[i] == -1) ans[i] = 0;
        cout << ans[i];
    }
    cout << endl;
}

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  
  int N = 100*r+10*g+b;
  
  if(N%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <climits>

using namespace std;
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define all(x) (x).begin(),(x).end()

using int64 = long long;


int main() {
    int n;
    cin >> n;
    vector<int64> t(n);
    for (int i=0; i<n; i++) cin >> t[i];

    int64 sum = accumulate(t.begin(), t.end(), 0LL);
    int m;
    cin>> m;
    for (int i=0; i<m; i++) {
        int p,w;
        cin >> p >> w;
        cout << sum - t[p-1] + w << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	static Scanner inp= new Scanner(System.in);
	static PrintWriter out= new PrintWriter(System.out);
	public static void main(String args[]) {		    	
	   	Main g=new Main();
	   	g.main();
	   	out.close();
	}

	
	
	//Main
	void main() {
		
		long mod=(long)1e9+7;
		int n=inp.nextInt();
		long a[]=new long[n];
		for(int i=0;i<n;i++) {
			a[i]=inp.nextLong();
		}
		long post[]=new long[n];
		post[n-1]=a[n-1];
		long gg=0;
		for(int i=n-2;i>=0;i--) {
			post[i]=(post[i+1]+a[i])%mod;
		}
		for(int i=0;i<n-1;i++) {
			gg+= (a[i]*post[i+1])%mod;
			gg%=mod;
		}
		System.out.println(gg);
	}
    
    
		
}


Measured memory_bytes: 61576
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main(){
  int H, W;
  cin >> H >> W;
  char S[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++) cin >> S[i][j];
  }
  
  int ans=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]=='#') continue;
      queue<pair<int, int>> que;
      vector<vector<int>> dist(H, vector<int>(W, -1));
      que.push({i, j});
      dist[i][j]=0;
      while(!que.empty()){
        int x, y;
        tie(y, x) = que.front();
        que.pop();
        for(int k=0; k<4; k++){
          int nx = x + dx[k], ny = y+dy[k];
          if(nx < 0 || W <= nx || ny < 0 || H <= ny || S[ny][nx] == '#'|| dist[ny][nx] != -1) continue;
          dist[ny][nx] = dist[y][x] + 1;
          que.push({ny, nx});
        }
      }
      int diss=0;
      for(int k=0; k<H; k++){
        for(int l=0; l<W; l++) diss=max(diss, dist[k][l]);
      }
      ans=max(ans, diss);
    }
  }
  cout << ans << endl;
}

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

long long n, a, b;

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

    if (a+b>n+1 || a*b < n)
    {
        cout << "-1\n";
        return 0;
    }
    if (a == 1)
    {
        for (int i=n; i>=1; i--)
        {
            cout << i << " ";
        }
        return 0;
    }
    vector<int> len(a, (n-b)/(a-1));
    len[0] = b;
    int c = accumulate(len.begin(), len.end(), 0);
    for (int i=1; i<= n - c; i++)
    {
        len[i]++;
    }
    int now = 0;
    for (auto l : len)
    {
        now += l;
        for (int i=0; i<l; i++)
        {
            cout << now - i << " ";
        }
    }

    cout << endl;
    return 0;
};

Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void)
{
  int x, a;
  scanf("%d %d", &x, &a);

  printf(x < a ? "0\n" : "10\n");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c,d,t;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(c-a)<=d)
    {
        t=1;
    }
    else if(abs(a-b)<=d)
    {
        if(abs(b-c)<=d)
            t=1;
            else t=0;
    }
    else t=0;
    if(t==1)
        printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1732
i=lambda:map(int,input().split());n,m=i();a=[0]+[1]*n;b=[0,1]+[0]*n
for _ in[0]*m:x,y=i();a[x]-=1;a[y]+=1;b[y]|=b[x];b[x]&=a[x]>0
print(sum(b))

Measured memory_bytes: 5348
use proconio::input;
fn main(){
    input!{
        n:usize,
        mut a_s:[i32;n]
    }
    let mut cnt = 1;
    let mut prev:i32 = -1;
    let mut ans = 0;
    a_s.push(-1);
    for a in a_s {
        if prev == a { 
            cnt += 1;
        } else {
            ans += (cnt)/2; 
            cnt = 1
        };
        prev = a;
    }
    println!("{}",ans)

}


Measured memory_bytes: 2112
#include <iostream>
#include <string>

using namespace std;

void A_Station_and_Bus(void) {

	string S;

	cin >> S;

	cout << ((S[0] == S[1] && S[0] == S[2]) ? "No" : "Yes");

	return;
}

void B_Count_Balls(void) {

	long n;
	//int a, b;
	long a, b;
	
	//long count = 0;

	cin >> n >> a >> b;

	//count = (n - (n % (a + b))) / (a + b);
	long count = long(n / (a + b));

	/*
	if (n % (a + b) <= a) {

		cout << n % (a + b) + count * a;
	}
	else {

		cout << a + count * a;
	}
	*/
	cout << ((n % (a + b) <= a) ? count * a + n % (a + b) : a * (count + 1));

	return;
}

void C_Tax_Increase(void) {

	int a, b;
	/*
	int pa[1000] = { -1 };
	int pb[1000] = { -1 };

	int flag = 0;
	int re = 0;
	*/
	cin >> a >> b;

	/*
	for (int loop = 1; loop < 1400; loop++) {

		if ((int)(loop * 0.08) == a && flag < 1000) {
			pa[flag] = loop;
			flag++;
		}
	}

	flag = 0;
	for (int loop = 1; loop < 1400; loop++) {

		if ((int)(loop * 0.1) == b && flag < 1000) {
			pb[flag] = loop;
			flag++;
		}
	}

	for (int xloop = 0; xloop < 1000; xloop++) {

		for (int yloop = 0; yloop < 1000; yloop++) {

			if (pa[xloop] != -1 && pa[xloop] == pb[yloop]) {

				re = pa[xloop];
			}
		}
	}

	for (int xloop = 0; xloop < 1000; xloop++) {

		for (int yloop = 0; yloop < 1000; yloop++) {

			if (pa[yloop] != -1 && pa[yloop] == pb[xloop]) {

				if (re > pa[yloop]) re = pa[yloop];
			}
		}
	}

	if (re > 0) {

		cout << re << flush;
	}
	else {

		cout << -1 << flush;
	}
	*/

	for (int loop = 0; loop < 1400; loop++) {

		if (int(loop * 0.08) == a && int(loop * 0.10) == b) {
			
			cout << loop << flush;
			return;
		}
	}

	cout << -1 << flush;
	return;
}

void D_String_Formation(void) {

	string S;
	int Q;

	cin >> S;
	cin >> Q;

	int T;
	int F;
	char C;

	int max = 0;
	char sBuff;

	int loop1 = 0;
	int loop2 = 0;

	for (loop1 = 0; loop1 < Q; loop1++) {

		cin >> T;

		if (T == 1) {

			max = (int)(S.size() * 0.5);

			for (loop2 = 0; loop2 < max; loop2++) {

				sBuff = S[loop2];
				S[loop2] = S[S.size() - loop2 - 1];
				S[S.size() - loop2 - 1] = sBuff;
			}
		}
		else {

			cin >> F >> C;

			if (F == 1) {

				S = C + S;
			}
			else {

				S = S + C;
			}
		}
	}

	cout << S;

	return;
}

int main(void) {

	//A_Station_and_Bus();
	//B_Count_Balls();
	C_Tax_Increase();
	//D_String_Formation();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,M,X,Y,t;
 cin>>N>>M>>X>>Y;
 int x=X, y=Y;
 while(N--){
  cin>>t;if(x<t)x=t;
 }
 while(M--){
  cin>>t;if(y>t)y=t;
 }
 cout << ((x<y)?"No War":"War");
}

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

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

  vector<int> d(102);//配列値は0で初期化される
  //vectorに入力で含まれる要素を特定する
  rep(i,n) {
    int p;
    cin >> p;
    d[p] = 1;
  }
  P ans(9999,-1);//Pairを利用して２つの値を保持する
  for (int i =0; i<= 101; ++i) {
    if (d[i] == 1) continue;
    int dif = abs(x-i);
    ans = min(ans, P(dif,i));
  }
  cout << ans.second << endl;//Pairの２盤目(値の小さい方)を表示するやり方
}

Measured memory_bytes: 3636
s = input()[::-1]

n = len(s)
cnt = [0] * 2019
cnt[0] = 1
total = 0
ans = 0
x = 1

for i in range(n):
    total += int(s[i]) * x
    total %= 2019
    x *= 10
    x %= 2019
    ans += cnt[total]
    cnt[total] += 1

print(ans)


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

int K, X;

int main() {
	cin >> K >> X;
	for (int i = X - (K - 1); i <= X + (K - 1); i++) {
		if (i != X - (K - 1)) cout << " ";
		cout << i;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
 	int j,n,t,s=0;
  	cin>>n;
  	int a[n];
  	for(int i=0;i<n;++i){
      cin>>a[i];
      t=0;
      for(j=0;j<i;j++){
       	if(a[i]<a[j])break;
        t++;
      }
      if(t==i)s++;
    }
  	cout<<s;
  	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4];
int main() {
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	int ans=(1<<30);
	do{
		ans=min(ans,abs(a[2]-a[1])+abs(a[3]-a[2]));
	}while(next_permutation(a+1,a+4));
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  string S, tmp;
  cin >> S;

  int minn = 999, dif;

  for (int i = 0; i < S.length() - 2; i++) {
    tmp  = S.substr(i, 3);
    dif  = abs(753 - stoi(tmp));
    minn = min(minn, dif);
  }
  cout << minn << endl;

  return 0;
}

Measured memory_bytes: 888
import string
import collections

n = int(input())
ans=[]
for i in range(n):
  s=input()
  c = collections.Counter(s)
  ans.append("".join(map(str,[c[i] for i in string.ascii_lowercase])))

c2 = collections.Counter(ans)
cnt=0
for k, v in c2.items():
  cnt+=(v-1)*v//2

print(cnt)

Measured memory_bytes: 83032
import Control.Monad
import Control.Applicative
import Data.List

printMatrix = mapM_ putStrLn . map (unwords . map show)

main = do
	[n, m, l] <- (map read . words) <$> getLine
	a <- replicateM n $ (map read . words) <$> getLine
	b <- replicateM m $ (map read . words) <$> getLine
	printMatrix $ [[sum (zipWith (*) a' b') | b' <- transpose b ] | a' <- a]

Measured memory_bytes: 12312
#include<iostream>

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

using namespace std;

int main()
{
    int a, b;   cin >> a >> b;

    if(a < 10 && b < 10){
        cout << a * b;
    }
    else{
        cout << -1;
    }
    cout << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n):
    for j in range(i):
        if a[j]>a[i]:
            count+=(k*(k+1))//2
    for j in range(i+1,n):
        if a[j]>a[i] :
            count+=((k-1)*k)//2
print(count%(10**9+7))

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

int main() {
  int a;
  int b;
  int c;
  int d;
  
  cin >> a;
  cin >> b;
  cin >> c;
  d = 0;
  
  for (int i = a; i <= b; i++) {
    int e = i;
    if (e%c == 0) {
      d++; 
    }
  }
  
  cout << d;
   
  return 0;
}

Measured memory_bytes: 3596
n = int(input())
D = []

def FindOtvet(i, j, otv):
    if i == 0:
        return ''
    if j == 0:
        if (otv + D[i - 1][j]) < n:
            otv += D[i - 1][j]
            return str(j + 1) + FindOtvet(i - 1, j + 1, otv)
        else:
            return str(j) + FindOtvet(i - 1, j, otv)
    elif j == 9:
        if (otv + D[i - 1][j - 1]) < n:
            otv += D[i - 1][j - 1]
            return str(j) + FindOtvet(i - 1, j, otv)
        else:
            return str(j - 1) + FindOtvet(i - 1, j - 1, otv)
    else:
        if (otv + D[i - 1][j - 1]) < n:
            otv += D[i - 1][j - 1]
            if (otv + D[i - 1][j]) < n:
                otv += D[i - 1][j]
                return str(j + 1) + FindOtvet(i - 1, j + 1, otv)
            else:
                return str(j) + FindOtvet(i - 1, j, otv)
        else:
            return str(j - 1) + FindOtvet(i - 1, j - 1, otv)

arr = []
if n < 10:
    print(n)
    exit()
for i in range(10):
    arr.append(1)
D.append(arr)
totalSum = 9
i = 1
respI = 0
respJ = 0
while respI == 0 and respJ == 0:
    arr = []
    for j in range(10):
        if j == 0:
            arr.append(D[i - 1][j] + D[i - 1][j + 1])
        elif j < 9:
            arr.append(D[i - 1][j - 1] + D[i - 1][j] + D[i - 1][j + 1])
        else:
            arr.append(D[i - 1][j - 1] + D[i - 1][j])
        if j > 0:
            if (totalSum + arr[j]) >= n:
                respI = i
                respJ = j
                break
            totalSum += arr[j]
    D.append(arr)
    i += 1
respStr = str(respJ)
print(respStr + FindOtvet(respI, respJ, totalSum))


Measured memory_bytes: 3192
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vc=vector<char>;


int main(void)
{
	int n, k, c;
	while(scanf("%d%d%d\n", &n, &k, &c)==3)
	{
		vc s(n+2);
		scanf("%[ox]\n", &s[0]);

		vi a(n, -1);
		int x=0;
		for(int i=1;i<=k;i++)
		{
			for(;;x++)
			{
				if(s[x]=='o')
				{
					a[x]=i;
					x+=c+1;
					break;
				}
			}
		}

		vi b(n);
		x=n-1;
		for(int i=k;i>=1;i--)
		{
			for(;;x--)
			{
				if(s[x]=='o')
				{
					b[x]=i;
					x-=c+1;
					break;
				}
			}
		}

		for(int i=0;i<n;i++)
		{
			if(a[i]==b[i] && a[i]>0) printf("%d\n", i+1);
		}
	}
	return 0;
}


Measured memory_bytes: 3200
n = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0

for j in range(n):
    if j%2 == 0:
        alice += cards.pop(cards.index(max(cards)))
    else:
        bob += cards.pop(cards.index(max(cards)))

print(alice - bob)


Measured memory_bytes: 2940
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

const ll modd=1e9+7;
const ll inf=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*    
         -> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
         -> cout<<"Case #"<<casee<<": "<<ans<<endl; // for google kickstart

*/

/*-----------------------------------------------------------------------------------------------*/

const ll N=1e5+5;

ll coloring[N];
vector <pii> adj[N];

void dfs(ll node,ll par,ll colorr){
   for(auto j : adj[node] ){
      if(j.fi==par)  continue;
      if(j.se%2==0)  coloring[j.fi]=coloring[node];
      else           coloring[j.fi]=1-coloring[node];
      dfs(j.fi,node,coloring[node]);
   }
}

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

   for(ll i=1;i<n;i++){
      ll x,y,z;
      cin>>x>>y>>z;
      adj[x].pb({y,z});
      adj[y].pb({x,z});
   }

   coloring[1]=0;

   dfs(1,-1,coloring[1]);

   for(ll i=1;i<=n;i++)
      cout<<coloring[i]<<endl;
 
   return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#include <atcoder/all>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using namespace atcoder;

using ll = long long;
using P = pair<int,int>;

constexpr int INF = 1001001001;

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 (a>b) { a=b; return 1; } return 0; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> S(n, "");
    rep (i, n) cin >> S[i];
    
    int s = n*m, t = s+1;
    mf_graph<int> g(t+1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (S[i][j] == '#')
                continue;
            if ((i+j) % 2 == 0)
                g.add_edge(s, i*m+j, 1);
            else
                g.add_edge(i*m+j, t, 1);
            if (j+1 < m && S[i][j+1] == '.') {
                if ((i+j) % 2 == 0)
                    g.add_edge(i*m+j, i*m+j+1, 1);
                else
                    g.add_edge(i*m+j+1, i*m+j, 1);
            }
            if (i+1 < n && S[i+1][j] == '.') {
                if ((i+j) % 2 == 0)
                    g.add_edge(i*m+j, (i+1)*m+j, 1);
                else
                    g.add_edge((i+1)*m+j, i*m+j, 1);
            }
        }
    }
    
    g.flow(s, t);
    int cnt = 0;
    auto ans = S;
    auto E = g.edges();
    for (auto e : E) {
        int a = e.from, b = e.to;
        if (a == s || a == t || b == s || b == t || e.flow != 1)
            continue;
        cnt++;
        if (a > b)
            swap(a, b);
        if (m != 1 && a+1 == b) {
            ans[a/m][a%m] = '>';
            ans[b/m][b%m] = '<';
        }
        else {
            ans[a/m][a%m] = 'v';
            ans[b/m][b%m] = '^';
        }
    }
    
    cout << cnt << endl;
    for (auto ai : ans)
        cout << ai << endl;
    
    return 0;
}


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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const int inf = 1e9+5;

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

    int n, m, need;
    cin >> n >> m >> need;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    forn(i, n) {
        cin >> c[i];
        forn(j, m) {
            cin >> a[i][j];
        }
    }
    int ans = inf;
    forn(s, 1<<n) {
        vector<int> have(m);
        int cost = 0;
        forn(i, n) if(s>>i&1) {
            cost += c[i];
            forn(j, m) {
                have[j] += a[i][j];
            }
        }
        if(*min_element(have.begin(), have.end()) >= need) {
            min_self(ans, cost);
        }
    }
    
    cout << (ans == inf ? -1 : ans ) << endl;
}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

#define MAX 1000000000
#define MIN -10000000000

#define ll long long

using namespace std;
int main() {

        ll n,k,i,j,temp,last,maxx;
        do {
            cin>>n;
            if(n==0)break;
            vector<ll> a(n);
            vector<ll> s(n+1);
            for(i=0;i<n;i++){
                cin>>a[i];
            }
            s[0]=0;
            for(i=0;i<n;i++){
                s[i+1]=s[i]+a[i];
            }
            maxx=-100000;
            for(i=0;i<n;i++){
                for(j=i+1;j<=n;j++){
                    maxx=max(s[j]-s[i],maxx);
                }
            }
            cout << maxx << endl;



        }while(n!=0);

//cout << "aaa" << endl;

    return 0;
}


Measured memory_bytes: 3168