akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(0) == '7' || s.charAt(1) == '7' || s.charAt(2) == '7'){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 26936
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	int a, b, c, k;

	cin >> a >> b >> c >> k;

	cout << pow(2, k)*max(a, max(b, c)) + (a + b + c) - max(a, max(b, c)) << endl;

	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

bool dp[100005];
int n,k,a[105];

int main() {
	IOS
	cin >> n >> k;
	fori(i,1,n,1) {
		cin >> a[i];
	}
	fori(i,a[1],100000,1) {
		bool ada=0;
		fori(j,1,n,1) {
			if(i-a[j] < 0)
				break;
			if(!dp[i-a[j]]) {
				ada=1;
			}
		}
		dp[i] = ada;
	}
	cout << (dp[k] ? "First\n":"Second\n");
}


Measured memory_bytes: 384
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll x;cin>>x;
    ll p=x%11;
    ll c=x/11;
    if(p==0){
        cout<<c*2;
    }else if(p<=6){
        cout<<c*2+1;
    }else{
        cout<<c*2+2;
    }cout<<"\n";

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int m,d;
  cin >> m >> d;
  int d_10 = d /10, d_1 = d % 10;
  int answer = 0;
  for(int i = 4; i <= m; i++){
      for(int j = 22; j <= d; j++){
        if(i == (j % 10) * (j / 10)){
          if(j % 10 > 1) answer++;
        }
	  }
  }
  
  cout << answer << endl;
  
  return 0;
}

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

vector<int> adj[100001];
vector<int> in(1e5 + 1, 1), d(1e5 + 1, 0);

void dfs(int nd) {
	for (int nb : adj[nd]) {
		d[nb] = max(d[nb], d[nd] + 1);
		if (--in[nb] == 0) dfs(nb);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> foo(n);
	iota(foo.begin(), foo.end(), 1);
	adj[0] = foo, in[0] = 0;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		in[b]++;
	}
	
	dfs(0);
	
	int ans{};
	for (int i : d) ans = max(ans, i);
	cout << ans - 1;
}

Measured memory_bytes: 11628
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    string s,t;cin>>s>>t;
    bool ok=false;
    lol(i,s.size()){
	bool x=true;
	lol(j,t.size()){
	    if(t[(j+i)%t.size()]!=s[j])x=false;
	}
	ok|=x;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


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

using namespace std; 
const int MAX_N = 100005;

int n; 
int a[MAX_N]; 

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

	long long val = 1LL * n * (n + 1) / 2; 
	if (sum % val) {
		printf("NO"); 
		return 0;
	}

	long long k = sum / val; 
	long long A = 0; 
	for (int i = 0; i < n; i++) {
		long long tmp = a[i] - a[(i + 1) % n] + k; 
		if (tmp < 0 || tmp % n) {
			printf("NO"); 
			return 0; 
		}

		A += tmp / n; 
	}

	if (A != k) {
		printf("NO"); 
	}
	else {
		printf("YES");
	}
	return 0; 
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.util.stream.Stream;
import java.util.stream.IntStream;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {
        
         int a=0;
        int b=0;
        int k=0;
        
         try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] tokens = line.split(" ");
                a = Integer.parseInt(tokens[0]);
                b = Integer.parseInt(tokens[1]);
                k = Integer.parseInt(tokens[2]);
            
            }
        }          
                
                
            int start1 = a+k-1;
            int start2 = b-k+1;
            
            if(start1>b){
                start1=b;
            }
            
            if(start2<a){
                start2=a;
            }

            
            List<Integer> list1 = IntStream.rangeClosed(a, start1).mapToObj(Integer::valueOf).collect(Collectors.toList());
            List<Integer> list2 = IntStream.rangeClosed(start2, b).mapToObj(Integer::valueOf).collect(Collectors.toList());
            
            
            

    		List<Integer> newList = new ArrayList<Integer>();
		    newList.addAll(list1);
		    newList.addAll(list2);
        
        
            newList = newList.stream().distinct().collect(Collectors.toList());
        
            Collections.sort(newList);
            newList.forEach(s -> {
            System.out.println(s);
            });


    }
}

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

int main() {
    int N,M;
    cin >> N >> M ;

    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    long sum = 0;

    for(int i=0; i<N; i++){
        sum+=A.at(i);
    }

    if(4 * M * A.at(M-1) >= sum ) cout << "Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 256
h, w = map(int, input().split())
l = []
for i in range(h):
  l.append(list(input().split()))

for i in range(h):
  row = l[i]
  if 'snuke' in row:
    print('{}{}'.format(chr(row.index('snuke')+65),i+1))
    break

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

int main(){
    int n;
    vector<long long> l;
    cin >> n;
    for(int i= 0 ;i < n ; i++){
        long long li;
        cin >> li;
        l.push_back(li);
    }

    long long ans = 0;

    for(int i = 0 ; i < n ; i++){
        for(int j = i + 1 ; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]){
                    continue;
                }

                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[i] + l[k] > l[j]){
                    ans += 1;
                }




            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#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)));
using namespace std;
using ll = long long;
int main(){
    string s,sd;
    string t;
    cin >> sd >> t;
    int remi=-1;
    bool f=true;
    REP(i,sd.length()-t.length()+1){
        string temp;
        temp=sd.substr(i,i+t.length());
        f=true;
        REP(j,t.length()){
            if(temp[j]=='?' || temp[j]==t[j]){
                
            }
            else{
                f=false;
                break;
            }
        }
        if(f){
                remi = i;
        }
    }
    if(remi==-1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sd.replace(remi,t.length(),t);
    REP(i,sd.length()){
        if(sd[i] == '?'){
            sd[i] = 'a';
        }
    }
    cout << sd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll INF = 1e18 + 5;
const int MAX_N = 2e3 + 5;

int arr [MAX_N];
int prem [MAX_N][MAX_N];

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

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    prem[i][0] = arr[i];
  }

  for (int i = 0; i < n; i++) {
    for (int k = 1; k < n; k++) {
      prem[i][k] = min(prem[i][k - 1], arr[(n + i - k) % n]);
    }
  }

  ll ans = INF;
  for (int k = 0; k < n; k++) {
    ll cur = x * (ll) k;
    for (int i = 0; i < n; i++) {
      cur += prem[i][k];
    }
    ans = min(ans, cur);
  }
  cout << ans << endl;
}


Measured memory_bytes: 19284
a=[int(e) for e in input().split()]

if a[0]==a[1]:
  if a[1]==a[2]:
    print("No")
  else:
    print("Yes")
else:
  if a[1]==a[2] :
    print("Yes")
  else:
    if a[0]==a[2]:
      print("Yes")
    else:
      print("No")

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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int[] x = sc.intarr;
        int D = x[0];
        int N = x[1];

        int ans = (int)Math.Pow(100, D) * N;
        if (N == 100) ans += (int)Math.Pow(100, D);
        wr.wri(ans);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    n=int(input())
    array=list(map(int,input().split()))
    
    answer=INF
    
    for a in range(-100,101):
        temp=0
        for b in array:
            temp+=(a-b)**2
        if temp<answer:
            answer=temp
    print(answer)
            

if __name__=="__main__":
    main()
    

Measured memory_bytes: 2940
import java.util.*;

public class Main {
	static boolean[] vis;
	static SegTree seg;
	static int n, k;
	static int idx = 0;
	static int[] ans;
	static int[] p;
	static int[] q;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		p = new int[n];
		vis = new boolean[n];
		ans = new int[n];
		for (int i = 0; i < n; ++i) {
			p[i] = sc.nextInt() - 1;
		}
		q = new int[n];
		for (int i = 0; i < n; ++i) {
			q[p[i]] = i;
		}
		seg = new SegTree(n);
		for (int i = 0; i < n; ++i) {
			seg.setVal(i, q[i]);
		}
		for (int i = 0; i < n; ++i) {
			if (!vis[i]) {
				dfs(i);
			}
		}
		StringBuilder sb = new StringBuilder();
		int[] t = new int[n];
		for (int i = 0; i < n; ++i) {
			t[ans[i]] = i;
		}
		ans = Arrays.copyOf(t, t.length);
		for (int i : ans) {
			sb.append((i + 1) + "\n");
		}
		System.out.println(sb);
	}

	static void dfs(int i) {
		while (true) {
			int min = seg.query(0, p[i]);
			if (min < i + k) {
				dfs(min);
			} else
				break;
		}
		ans[idx++] = i;
		vis[i] = true;
		seg.setVal(p[i], Integer.MAX_VALUE / 10);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	static class SegTree {
		int n = 1;
		int[] val;

		public SegTree(int n_) {
			while (n < n_) {
				n *= 2;
			}
			val = new int[2 * n - 1];
		}

		void setVal(int k, int v) {
			k += n - 1;
			val[k] = v;
			while (k > 0) {
				k = (k - 1) / 2;
				val[k] = Math.min(val[2 * k + 1], val[2 * k + 2]);
			}
		}

		int query(int a, int b) {
			return query(a, b, 0, n, 0);
		}

		int query(int a, int b, int l, int r, int k) {
			if (a <= l && r <= b) {
				return val[k];
			} else if (r <= a || b <= l) {
				return Integer.MAX_VALUE / 10;
			} else {
				int vl = query(a, b, l, (l + r) / 2, 2 * k + 1);
				int vr = query(a, b, (l + r) / 2, r, 2 * k + 2);
				return Math.min(vl, vr);
			}
		}
	}

}


Measured memory_bytes: 180560
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;
const int md = 1e9 + 7;
int go(int x, int y);
int get_link(int x);

const int SZ = 1e5;

int n, c[10];
int all;
int nxt[SZ][10];
int sa[SZ][10];
int link[SZ], pred[SZ], s[SZ];
bool t[SZ];
bool used[SZ];
int dp[41][SZ][2];

void recurs(int x, int y, int z, int cv) {
    if (z == c[y]) {
        if (y == 2) { t[cv] = true; }
        else recurs(x, y + 1, 0, cv);
        return;
    }
    for (int i = 1; i <= c[y] - z; ++i) {
        if (!nxt[cv][i - 1]) {
            nxt[cv][i - 1] = ++all;
            link[all] = -1;
            pred[all] = cv;
            s[all] = i - 1;
            for (int j = 0; j < 10; ++j) sa[all][j] = -1;
        }
        recurs(x + 1, y, z + i, nxt[cv][i - 1]);
    }
    return;
}

int get_link(int x) {
    if (link[x] != -1) return link[x];
    if (x == 0 || pred[x] == 0) return link[x] = 0;
    return link[x] = go(get_link(pred[x]), s[x]);
}

int go(int x, int y) {
    if (sa[x][y] != -1) return sa[x][y];
    if (nxt[x][y]) return sa[x][y] = nxt[x][y];
    if (x == 0) return sa[x][y] = 0;
    return sa[x][y] = go(get_link(x), y);
}

bool check(int x) {
    if (used[x]) return t[x];
    used[x] = true;
    if (t[x]) return true;
    int y = get_link(x);
    return t[x] = check(y);
}

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> c[0] >> c[1] >> c[2];
    pred[0] = link[0] = -1;
    for (int i = 0; i < 10; ++i)
        sa[0][i] = -1;
    recurs(0, 0, 0, 0);
    for (int i = 0; i <= all; ++i)
        get_link(i);
    used[0] = true;
    for (int i = 0; i <= all; ++i)
        check(i);
    dp[0][0][0] = 1;
    int x = go(0, 4);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= all; ++j) {
            for (int k = 0; k < 2; ++k) if (dp[i][j][k]) {
                for (int z = 0; z < 10; ++z) {
                    x = go(j, z);
                    if (t[x]) {
                        dp[i + 1][x][1] += dp[i][j][k];
                        if (dp[i + 1][x][1] >= md) dp[i + 1][x][1] -= md;
                    } else {
                        dp[i + 1][x][k] += dp[i][j][k];
                        if (dp[i + 1][x][k] >= md) dp[i + 1][x][k] -= md;
                    }
                }
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i <= all; ++i)
        ans += dp[n][i][1];
    ans %= md;
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 35200
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 a, b;
	std::cin >> a >> b;
	while (a >= 500) {
		a -= 500;
	}

	std::cout<< (a<=b?"Yes":"No") <<"\n";
	return 0;
}

Measured memory_bytes: 256
INF = 10**18

n, m, x = map(int, input().split())
costs = []
a = []
for i in range(n):
    cost, *tmp = map(int, input().split())
    costs.append(cost)
    a.append(tmp)

ans = INF
for i in range(1 << n):
    cost = 0
    ms = [0] * m
    for j in range(n):
        if (i >> j) & 1 == 1:
            cost += costs[j]
            for k in range(m):
                ms[k] += a[j][k]
    can_learn = True
    for j in range(m):
        if ms[j] < x:
            can_learn = False
            break
    if can_learn:
        ans = min(ans, cost)

print(-1 if ans == INF else ans)


Measured memory_bytes: 9232
#include <stdio.h>
int main(void){
    double pai,r, l, S;
    scanf("%lf", &r);
    pai = 3.141592653589;
    l = 2 * pai * r;
    S = pai * r * r;
    printf("%.6lf %.6lf\n", S, l);
    return 0;
}


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

struct Union_Find
{
	ll ans;
    vector <ll> parent;
	vector<ll> sz;
    Union_Find(ll N) : parent(N)
    {
		sz.resize(N,1);
        for(ll i = 0; i < N; i++) parent[i] = i;
		ans=N*(N-1)/2;
    }
    ll root(ll n)
    {
        if (parent[n]==n) return n;
        else
        {
            return root(parent[n]);
        }
    }

    void unite(ll i,ll j)
    {
        ll rx,ry;
        rx=root(i);
        ry=root(j);
        if (rx==ry) return;
        else
        {
            ll k;
            if (rx<ry)
            {
				ans-=sz[rx]*sz[ry];
				sz[rx]+=sz[ry];
				sz[ry]=0;
                parent[ry]=rx;
                return;
            }
            else
            {
				ans-=sz[rx]*sz[ry];
				sz[ry]+=sz[rx];
				sz[rx]=0;
                parent[rx]=ry;
                return;
            }
        }
    }
    bool same(ll i, ll j)
    {
        if (root(i)==root(j)) return true;
        else return false;
    }
};

int main()
{
	ll n,m; cin>> n >> m;
	vector<pair<ll,ll>> edge(m);
	ll u,v;
	for (ll i=0;i<m;i++)
	{
		cin >> u >>v;
		u--;v--;
		edge[i].first=u;
		edge[i].second=v;
	}
	Union_Find solve(n);
	vector<ll> ans(m);
	for (ll i=m-1;i>=0;i--)
	{
		ans[i]=solve.ans;
		solve.unite(edge[i].first,edge[i].second);
	}
	for (ll i=0;i<m;i++) cout << ans[i] << endl;
	return 0;
}




Measured memory_bytes: 5248
N, Y = map(int, input().split())
Y //= 1000

# 10x + 5y + z = Y
#   x +  y + z = N
#  9x + 4y     = Y - N
# (x, y) = (-4k + Y - N, 9k - 2(Y - N))
# ceil((Y-N)/5) <= k <= floor(Y/5)
# ceil((Y-2N)/4) <= k <= floor((Y-N)/4)
# ceil(2(Y-N)/9) <= k <= floor((2Y-N)/9)

l1, r1 = -((N-Y)//5), Y//5
l2, r2 = -((2*N-Y)//4), (Y-N)//4
l3, r3 = -((2*(N-Y))//9), (2*Y-N)//9
b1 = r2 < l1 or r1 < l2
b2 = r3 < l2 or r2 < l3
b3 = r1 < l3 or r3 < l1
if b1 or b2 or b3:
  print(-1, -1, -1)
else:
  k = max(l1, l2, l3)
  x, y = - 4 * k + Y - N, 9 * k - 2 * (Y - N)
  z = N - x - y
  print(x, y, z)

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

int main(){
    ll n,m,a[3],s,c;
    cin>>n>>m;
    rep(i,3){
        a[i]=-1;
    }
    rep(i,m){
        cin>>s>>c;
        if(a[s-1]!=-1&&a[s-1]!=c){
            cout<<"-1";
            return 0;
        }
        if(n==2&&s==1&&c==0){
            cout<<"-1";
            return 0;
        }
        if(n==3&&s==1&&c==0){
            cout<<"-1";
            return 0;
        }
        a[s-1]=c;
    }
    rep(i,n){
        if(a[i]==-1){
          if(i==0&&n>1){
            a[0]=1;
          }else{
            a[i]=0;
          }
        }
        cout<<a[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3636
from itertools import permutations

N,M = map(int,input().split())

L = [[False for j in range(N)] for i in range(N)]

for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    
    L[a][b] = True
    L[b][a] = True

P = list(permutations(range(1,N)))

ans = 0

for perm in P :
    perm = list(perm)
    
    for s,g in zip([0] + perm, perm) :
        if not L[s][g] :
            break
    else :
        ans += 1

print(ans)
        

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,W; cin >> H >> W;
    int dis[10][10];
    rep(i,10) rep(j,10) cin >> dis[i][j];
    rep(i,10) rep(j,10) rep(k,10){ 
        dis[j][k] = min(dis[j][k],dis[j][i]+dis[i][k]);
    }
    int A[H][W];
    rep(i,H) rep(j,W) cin >> A[i][j];
    int ans=0;
    rep(i,H) rep(j,W){
        if(A[i][j]==-1) continue;
        ans+=dis[A[i][j]][1];
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
from sys import stdin
input = stdin.readline

N = int(input())
A = list(map(int, input().split()))

sum_ue = [1]
sum_shita = [A[N]]

for i in range(N):
    sum_ue.append((sum_ue[i] - A[i]) * 2)
    sum_shita.append(sum_shita[i] + A[N - 1 - i])

sum_shita.reverse()
# print(sum_ue)
# print(sum_shita)

ans = 0

for i in range(N + 1):
    if i == N:
        if sum_ue[i] < A[i]:
            print(-1)
            exit()
    else:
        if sum_ue[i] <= A[i]:
            print(-1)
            exit()

for i in range(N + 1):
    ans += min(sum_ue[i], sum_shita[i])

print(ans)


Measured memory_bytes: 680076
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n;
int coin[6] = {500, 100, 50, 10, 5, 1};

int main(int argc, char const* argv[])
{
	while(true){
			cin >> n;
			if(n == 0)break;
			n = 1000 - n;
			int res = 0;
			for(int i = 0; i < 6; i++){
					res += n / coin[i];
					n = n % coin[i];
			}
			cout << res << endl;
	}
	return 0;
}



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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N, temp;
    cin >> N;
    int P[N];
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> P[i];
        A[i] = P[i];
    }
    sort(A, A + N);
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            temp = P[i];
            P[i] = P[j];
            P[j] = temp;
            for(int k = 0; k < N; k++){
                if(A[k] != P[k])
                    break;
                if(k >= N - 1){
                    cout << "YES" << endl;
                    return 0;
                }
            }
            temp = P[i];
            P[i] = P[j];
            P[j] = temp;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ax = A * N;
    cout << min(ax, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <iomanip>
#include <array>

using namespace std;
int main() {
	string joiioi;
	while (cin >> joiioi) {
		int joi = 0, ioi = 0;
		for (int i = 0; i < joiioi.size() - 2; ++i) {
			if (joiioi[i] == 'J') {
				if (joiioi[i + 1] == 'O'&&joiioi[i + 2] == 'I') {
					joi += 1;
				}
			}
			if (joiioi[i] == 'I') {
				if (joiioi[i + 1] == 'O'&&joiioi[i + 2] == 'I') {
					ioi += 1;
				}
			}
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
n,m=map(int,input().split())
G=[[] for i in range(n)]
for i in range(m):
  l,r,d=map(int,input().split())
  G[l-1].append([r-1,d])
  G[r-1].append([l-1,-d])

dist=[None]*n
from collections import deque
# 各頂点からの距離で矛盾が発生しないかシミュレーション
for i in range(n):
  q=deque()
  if dist[i]==None:
    dist[i]=0
    q.append(i)
  while q:
    cur=q.popleft()
    for nx,nxd in G[cur]:
      if dist[nx]==None:
        dist[nx]=dist[cur]+nxd
        q.append(nx)
      elif dist[nx]!=dist[cur]+nxd:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 77308
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	float a,b,c,d,e,f,x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
		y=(a*f-d*c)/(e*a-d*b);
		x=(c-b*y)/a;
		printf("%.3f %.3f\n",x,y);
	}
}

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

using namespace std;


int main() {
  
        int n,i,cnt=0;
        scanf("%d",&n);
        string a,b,c;
        cin>>a>>b>>c;
        for(i=0;i<n;++i)
            {
                if(a[i]==b[i] && b[i]!=c[i])
                   cnt++;
                   
                else if(a[i]!=b[i] && b[i]==c[i])
                          cnt++;
                          
                else if(a[i]==c[i] && b[i]!=c[i])
                          cnt++;          
                          
                else if(a[i]!=b[i] && b[i]!=c[i])
                          cnt+=2;          
            }
            
            printf("%d",cnt);
           
    
    	return 0;
} 

Measured memory_bytes: 256
# keyence2019C - Exam and Wizard
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    ans, shortage, pos = 0, 0, []
    for i, j in zip(A, B):
        x = i - j
        if x >= 0:
            pos += [x]
        else:
            ans += 1
            shortage += x
    if sum(pos) + shortage < 0:
        print(-1)
        return
    for i in sorted(pos, reverse=1):
        if shortage >= 0:
            break
        ans += 1
        shortage += i
    print(ans if shortage >= 0 else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18708
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;

int n, x, t;

signed main()
{
    cin >> n >> x >> t;
    cout << (((n-1)/x)+1)*t << '\n';
}

Measured memory_bytes: 3580
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef pair<int,int> pii;

int sum[33][33],ub;
pii dp[32][32][33][33];

inline int rectsum(int t,int l,int b,int r){
	return sum[b][r]-sum[t][r]-sum[b][l]+sum[t][l];
}

pii solve(int t,int l,int b,int r){
	if(~dp[t][l][b][r].first) return dp[t][l][b][r];

	if(rectsum(t,l,b,r)<ub) return make_pair(-1,-1);

	pii ans(1,rectsum(t,l,b,r)-ub); // ツつアツづェツ暗按湘」ツ閉ェツ環つオツづ按つ「
	// ツ可。ツ陛サツ古シツづ可閉ェツ環つキツづゥ
	for(int i=t+1;i<b;i++){
		pii tmp1=solve(t,l,i,r);
		pii tmp2=solve(i,l,b,r);
		ans=max(ans,make_pair(tmp1.first+tmp2.first,min(tmp1.second,tmp2.second)));
	}
	// ツ縦ツ陛サツ古シツづ可閉ェツ環つキツづゥ
	for(int j=l+1;j<r;j++){
		pii tmp1=solve(t,l,b,j);
		pii tmp2=solve(t,j,b,r);
		ans=max(ans,make_pair(tmp1.first+tmp2.first,min(tmp1.second,tmp2.second)));
	}
	return dp[t][l][b][r]=ans;
}

int main(){
	for(int h,w,s;scanf("%d%d%d",&h,&w,&s),h;){
		rep(i,h) rep(j,w) rep(k,h+1) rep(l,w+1) dp[i][j][k][l].first=-1;

		rep(i,h) rep(j,w) {
			int u; scanf("%d",&u);
			sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+u;
		}
		ub=sum[h][w]-s;

		pii ans=solve(0,0,h,w);
		printf("%d %d\n",ans.first,ans.second);
	}

	return 0;
}

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

#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M)
{
  int ret = n % m;
  if (ret < 0)
    ret += m;
  return ret;
}

int exp(int n, int k)
{
  if (k == 0)
    return 1;
  if (k == 1)
    return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2)
    ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

int solve(const vector<ii> &v)
{
  int max_row = 0;
  int max_col = 0;
  for (ii p : v)
  {
    max_row = max(max_row, p.ff);
    max_col = max(max_col, p.ss);
  }
  vector<int> c(max_col + 1, 0);
  set<ii, greater<ii>> s;
  auto update = [&](int pos, int val) {
    int cur = c[pos];
    if (s.count(ii(cur, pos)))
      s.erase(ii(cur, pos));
    cur += val;
    c[pos] = cur;
    s.insert(ii(cur, pos));
  };
  for (ii p : v)
  {
    update(p.ss, 1);
    max_row = max(max_row, p.ff);
  }
  int n = v.size();
  vector<ii> rows[max_row + 1];
  for (ii p : v)
  {
    rows[p.ff].pb(p);
  }
  int ans = 0;
  for (int i = 0; i <= max_row; i++)
  {
    int id = i;
    int cur_ans = 0;
    for (auto coord : rows[i])
    {
      update(coord.ss, -1);
    }
    ans = max(ans, (int)(rows[i].size()) + s.begin()->ff);
    for (auto coord : rows[i])
    {
      update(coord.ss, +1);
    }
  }
  return ans;
}
//#define MULTIPLE_TEST_CASE
void solution()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<ii> v(k);
  for (int i = 0; i < k; i++)
  {
    cin >> v[i].ff >> v[i].ss;
  }
  int ans = solve(v);
  for (ii &p : v)
    swap(p.ff, p.ss);
  ans = max(ans, solve(v));
  cout << ans << endl;
}

int32_t main()
{
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--)
    solution();
}


Measured memory_bytes: 37292
import sys
import heapq

input = sys.stdin.readline


def main():

    N = int(input())
    nb = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        nb[a].append((c, b))
        nb[b].append((c, a))
    for x in nb:
        x.sort()

    Q, K = map(int, input().split())
    K -= 1

    dist = [2 ** 62] * N
    h = [(0, K, -1)]
    while h:
        d0, node, parent = heapq.heappop(h)
        if d0 >= dist[node]:
            continue
        dist[node] = d0
        for d1, child in nb[node]:
            if child != parent and d0 + d1 < dist[child]:
                heapq.heappush(h, (d0 + d1, child, node))

    for i in range(Q):
        x, y = map(int, input().split())
        # print(f"{x}->K = {dist[x]}, K->{y} = {dist[y]}")
        print(dist[x - 1] + dist[y - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84180
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    a -= b;
    auto check = [&](ll x) -> bool {
        vector<ll> temp = h;
        rep(i,n) temp[i] -= x*b;
        rep(i,n){
            if(0 < temp[i])x -= (temp[i] + a - 1)/a;
        }
        return 0 <= x;
    };
    ll ok = 1e9 + 1000;
    ll ng = 0;
    while(abs(ok - ng) > 1){
        ll x = (ok+ng)/2;
        if(check(x))ok = x;
        else ng = x;
        // print(ok,ng,x);
        // print(check(x));
    }

    cout << ok << endl;
}

Measured memory_bytes: 1792
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
p=C.index(max(C))
for i in range(26):
  if C[i]!=0:
    k+=C[i]
for i in range(26):
    A[i]=int(C[i]/k*D)

for i in range(26):
  for j in range(A[i]):
    m=max([l if B[l]==0 and l<(D+1)//A[i]*j else 0 for l in range(D)])
    B[m]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=p+1

for i in range(D):
  print(B[i])


Measured memory_bytes: 9248
from itertools import accumulate

n = int(input())

cumsum_ = accumulate(range(1, 10**7+1))
cumsum = []
for x in cumsum_:
    if x >= n:
        cumsum.append(x)
        break
    else:
        cumsum.append(x)

x = cumsum[-1] - n
for i in range(1, len(cumsum)+1):
    if i != x:
        print(i)

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

std::vector<int> oe(200000, 1);
multimap<int, int> go;
//_____________________________________________________________
#define MAX_NODE 200000
struct tree{
  int number;
  std::vector<int> c;
  std::vector<int> child;
  int P=-1;
};
std::vector<tree> T(MAX_NODE+1);
std::vector<int> check_init(MAX_NODE+1,0);

void dfs(int num){
  for(int i=0;i<T[num].child.size();i++) dfs(T[num].child[i]);
  if(T[num].P==-1) return;
  if(oe[num]==-1) go.emplace(num, T[num].P), oe[num]*=-1;
  else oe[T[num].P]*=-1, go.emplace(T[num].P, num);
}
void tree_(int num){
  if(check_init[num]==0){
    check_init[num]=1;
    for(int i=0;i<T[num].c.size();i++) {
      if(check_init[T[num].c[i]]==0) {
        T[num].child.push_back(T[num].c[i]);
        T[T[num].c[i]].P = num;
      }
      tree_(T[num].c[i]);
    }
  }
}
void tree_init(){
  for(int i=1;i<=MAX_NODE;i++) T[i].number=i;
  tree_(1);
}

///////////////////////////////////////
#define MAX_N 1000000
int par[MAX_N];
int dep[MAX_N];

void init(int nu) {
  for(int iu=0;iu<nu;iu++){
    par[iu] = iu;
    dep[iu] = 0;
  }
}
int find(int xu){
  if(par[xu] == xu) return xu;
  return par[xu] = find(par[xu]);
}
void unite(int xu, int yu){
  xu=find(xu);
  yu=find(yu);
  if(xu == yu) return;
  if(dep[xu] < dep[yu]){
    par[xu] = yu;
  }else{
    par[yu] = xu;
    if(dep[xu] == dep[yu]) dep[xu]++;
  }
}
bool same(int xu, int yu){
  return find(xu) == find(yu);
}
//_____________________________________________________________

int main(int argc, char const *argv[]) {
  ll N, M, a, b;
  std::cin >> N >> M;
  init(N+1);
  for(int i=0;i<M;i++){
    std::cin >> a >> b;
    if(!same(a, b)) {
      T[a].c.push_back(b);
      T[b].c.push_back(a);
      unite(a, b);
    }
    else {
      oe[a] *=-1;
      go.emplace(a, b);
    }
  }
  if(M%2==1){
    std::cout << -1 << '\n';
    return 0;
  }
  tree_init();
  dfs(1);
  auto itr = go.begin();
  for(int i=0;i<go.size();i++){
    std::cout << (*itr).first << " " << (*itr).second << '\n';
    itr++;
  }
  return 0;
}


Measured memory_bytes: 34816
let input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
 let num = input[0];

let arr = [];
for (let i=1; i<=num; i++) {
    if (input[i][0] === '0') {
        let tmp = input[i].split(' ');
        arr.push(tmp[1]);
    }
    if (input[i][0] === '1') {
        let tmp = input[i].split(' ').map(Number);
        console.log(arr[tmp[1]]);

    }
    if (input[i][0] === '2') {
        arr.pop();
    }
    
}




Measured memory_bytes: 79364
a = input()
mm = int(a[:2])
yy = int(a[2:])

can1 = True
can2 = True

if mm>12:
  can1 = False
if mm<1:
  can1= False

if yy>12:
  can2 = False
if yy<1:
  can2 = False

if can1 and can2:
  print("AMBIGUOUS")
elif can2:
  print("YYMM")
elif can1:
  print("MMYY")
else:
  print("NA")

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

int main(){
  ll p = pow(10, 9) + 7;
  vector<ll> fac(2020);
  vector<ll> inv(2020);
  vector<ll> fac_inv(2020);
  fac[0] = 1; fac[1] = 1;
  inv[0] = 1; inv[1] = 1;
  fac_inv[0] = 1;  fac_inv[1] = 1;
  for(ll i = 2; i <= 2010; i++){
    fac[i] = fac[i-1] * i % p;

    inv[i] = p - inv[p % i] * (p / i) % p;
    
    fac_inv[i] = fac_inv[i-1] * inv[i] % p;
  }

  ll n, k;
  cin >> n >> k;

  ll res;
  for(ll i = 1; i <= k; i++){
    ll a, b;
    if(n-k+1>=i){
    a = ((fac[n-k+1] * (fac_inv[i] * fac_inv[n-k+1-i] % p) % p)%p);
    }
    else{a = 0;}
    if(k-1>=i-1){
    b = ((fac[k-1] * (fac_inv[i-1] * fac_inv[k-1-i+1] % p) % p)%p);
    }
    else{b = 0;}
    res = a*b;
    res %= p;
    cout << res << endl;
  }

}    

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<ll> A(N), B(N),C;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	ll sum = 0, ans = 0;

	REP(i,N) {
		if (A[i] > B[i]) C.push_back(A[i] - B[i]);
		else if(A[i] < B[i]){
			sum += B[i] - A[i];
			ans++;
		}		
	}
	sort(ALL(C),greater<ll>());
	REP(i,C.size()){
		if (sum <= 0) break;
		sum -= C[i];
		ans++;
	}
	cout << (sum <= 0 ? ans : -1) << endl;

	return 0;
}

Measured memory_bytes: 2428
a = int(input())
b = list(map(int, input().split()))
c = {0: 1}
d = 0
for i in range(len(b)):
    d += b[i]
    if d not in c:
        c[d] = 1
    else:
        c[d] += 1
e = 0
for k in c.keys():
    if c[k] >= 2:
        e += c[k] * (c[k] - 1) // 2
print(e)


Measured memory_bytes: 38644
import sys
from math import atan, degrees

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    a, b, x = map(int, readline().split())
    if x > a * a * b / 2:
        print(degrees(atan(2 * (a * a * b - x) / a ** 3)))
    else:
        print(degrees(atan(a * b * b / (2 * x))))

    return


if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin>>N;
  vector<double> x(N);
  vector<string> u(N);
  double sum=0;
  for(int i=0;i<N;++i){
    cin>>x.at(i)>>u.at(i);
    if(u.at(i)=="JPY"){sum=sum+x.at(i);}
    else{sum=sum+380000*x.at(i);}
  }

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

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int A,B,C; cin >> A >> B >> C;

    if(C >= A && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int A, B, C;
   cin >> A >> B >> C;
   for (int b = 1; b <= B; b++) {
      if ((A * b) % B == C) {
         cout << "YES" << endl;
         return 0;
      }
   }
   cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

template<typename T>
map<T,ll> factorize(T x){
    map<T,ll> res;
    for(ll i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            res[i]++;
        }
    }
    if(x!=1) res[x]++;
    return res;
}

int main(){
    ll a,b; cin >> a >> b;
    ll k=GCD(a,b);
    auto m=factorize(k);
    cout << m.size()+1 << endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
L = [A[0]]
for i in range(1, N):
    if L[-1] < A[i]:
        L.append(A[i])
    else:
        L[bisect.bisect_left(L, A[i])] = A[i]
print(len(L))

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

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string ans = "ABC";
            if (N >= 1000) { ans = "ABD"; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <map>

using namespace std;

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

  map<int, int> mp;
  for(int i = 1; i <= n; i++){
    int a;
    cin >> a;

    mp[a] = i;
  }

  for(auto p : mp){
    cout << p.second << " ";
  }

  cout << endl;

  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

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

    priority_queue<ll> que;
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        que.push(A[i]);
    }
    rep(i, M) {
        ll tmp = que.top();
        tmp /= 2;
        que.pop();
        que.push(tmp);
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 2168
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	char ss[10];
	while(~scanf("%s",ss)){
		int flag=0;
		for(int i=1;i<4;i++){
			if(ss[i]==ss[i-1]){
				flag=1;
			}
		}
		if(flag) printf("Bad\n");
		else printf("Good\n");
	}
	return 0;
}

Measured memory_bytes: 128