akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	}
	else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	}
	else {
		s[k - 1] = 'c';
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath> 
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int INF = 0x3f3f3f3f;
int n;
int cc[maxn];
int main()
{
	cin>>n;
	int d;
	for(int i=2;i<=n;i++)
	{
		cin>>d;
		cc[d]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<cc[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3876
#include<stdio.h>

int main(){
	int A,B,K;
	int i,c,k=1,ans;
	scanf("%d %d %d",&A,&B,&K);
	while(A!=0){
		B=B%A;
		c=A,A=B,B=c;
	}
	for(i=c;i>=1;i--){
		if(c%i==0){
			if(k==K){
				ans=i;
				break;
			}
			k++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
r=set()
r2=0

for i in a:
    if i>=3200:
        r2+=1
    else:
        r.add(i//400)

if len(r)==0:
    mi=1
else:
    mi=len(r)

ma=len(r)+r2

print(mi,ma)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#define N 10000
main(){
  int i,j,n,c[N],count=0,yaku;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&c[i]);
  }
  for(i = 0; i < n; i++){
    yaku = 0;
    if(c[i] == 2)count++;
    else if(c[i]%2 == 0)continue;
    else if(c[i]%2 != 0){
      for(j = 3; j <= sqrt(c[i]); j += 2){
	if(c[i]%j == 0){
	  yaku = 1;
	  break;
	}
      }
      if(yaku == 0)count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[300030];
    cin >> n;
    for (int i = 0; i < 3*n; i++) cin >> a[i];
    
    sort(a, a + 3*n);
    
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[3 * n - 2 - 2 * i];
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		long result = Long.parseLong(s);
		int pattern = (int) Math.pow(2, s.length()-1);
		for (int j=1;j<pattern;j++) {
			result +=Main.sum(s, j);
		}
		System.out.println(result);
	}

	public static long sum (String s,int i) {
		if (s.length()==1) {
			return Long.parseLong(s);
		}
		int a[] = new int[s.length()-1];
		for (int j=0;j<s.length()-1;j++) {
			a[j] = i%2;
			i=i/2;
		}
		long sum =0;
		long temp =s.charAt(0)-'0';
		for (int j=0;j<s.length()-1;j++) {
			if (a[j]==1) {
				sum +=temp;
				temp=s.charAt(j+1)-'0';
			} else {
				temp = temp *10+s.charAt(j+1)-'0';
			}
		}
		sum +=temp;
		return sum;
	}
}

Measured memory_bytes: 21844
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] xs) {

    int ans = xs.sum;
    for (int i = 0; i < xs.length; i++) {
        auto buf = xs.dup;
        if (buf[i] > 0) {
            buf[i]--;
            for (int j = i + 1; j < buf.length; j++) {
                buf[j] = 9;
            }

            ans = max(ans, buf.sum);
        }
    }

    return ans;
}

void main() {
    auto s = readln.chomp;
    auto xs = s.map!(e => cast(int)(e - '0')).array;

    auto ans = calc(xs);
    writeln(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int k,s; cin >> k >> s;
    int ans = 0;
    rep(i,k+1)rep(j,k+1) {
        if (s-i-j>=0 && s-i-j<=k) {
            ans++;
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3576
N = int(input())
A = []
for i in range(N):
    a  = int(input())
    Alst = []
    for j in range(a):
        x,y = map(int,input().split())
        Alst.append([x-1,y])
    A.append(Alst)

honest = 0
  
for i in range(2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1:
            for x,y in A[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Measured memory_bytes: 9124
import java.util.*;

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

        String abc = "abcdefghijklmnopqrstuvwxyz";
        char[] C = abc.toCharArray();
        String ans = "None";
        for (char tar : C) {
            if(!S.contains(String.valueOf(tar))){
                ans = String.valueOf(tar);
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

const int M = 1e9 + 7;
LL H, W, K;
struct Combine {
    using LL = long long;
    int m;
    vector<LL> F;
    Combine(int n, int m) : m(m), F(n, 1) { for (int i = 1; i < n; i++) F[i] = F[i - 1] * i % m; }
    int inv(LL x) { return x > m ? inv(x % m) : x > 1 ? inv(m % x) * (m - m / x) % m : x; }
    int com(LL n, LL k) { if (k > n) return 0; return F.at(n) * inv(F.at(n - k) * F[k]) % m; }
    int per(LL n, LL k) { assert(k <= n); return F.at(n) * inv(F.at(k)) % m; }
} cb(2e7 + 5, M);

int main() {
    cin >> H >> W >> K;
    LL n = H + W;
    LL f = 1LL * cb.com(K, 2) * inv(cb.com(n, 2), M) % M +
           1LL * cb.com(K, 3) * inv(cb.com(n, 3), M) % M * inv(3, M) % M * (n - 2) % M;
    LL g = 1LL * K * inv(n, M) % M +
           1LL * cb.com(K, 2) * inv(cb.com(n, 2), M) % M * inv(2, M) % M * (n - 1) % M;
    LL ans = f * H % M * W % M + g * n % M + K;
    FI(i, 1, K) ans = ans * (n + 1 - i) % M;
    cout << ans << endl;
}


Measured memory_bytes: 156544
#include<stdio.h>

int main(){
	
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(b*2 <= a){
		
		printf("%d\n",a-(b*2));
		
	}	
	
	else{
		printf("0\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
x,y = map(int,input().split())
import sys

a = (2*x-y)/3
b = (2*y-x)/3
if not (a.is_integer() and  b.is_integer()) or 2*x<y or 2*y<x:
    print(0)
    sys.exit()
    
a = int(a)
b = int(b)

from functools import reduce
def mycmb(n,r,p):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(lambda x,y:x*y%p,range(n,n-r,-1))
    under = reduce(lambda x,y:x*y%p,range(1,r+1))
    return (over * pow(under,p-2,p))%p

mod = 10**9+7
print(mycmb(a+b,a,mod))


Measured memory_bytes: 9480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        int h[] = getInput();
        int cnt = 0;
        while (true) {
            int idx = 0;
            while (idx < h.length && h[idx] == 0) idx++;
            if (idx == h.length) {
                break;
            }
            while (idx < h.length && h[idx] > 0) {
                h[idx]--;
                idx++;
            }
            cnt++;
        }
        System.out.println(cnt);
        return;
    }

    private static int[] getInput()
    {
        int[] ret = null;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int n = Integer.parseInt(br.readLine());
            ret = new int[n];
            String hString[] = br.readLine().split("\\s");
            for (int i = 0; i < n; i++) {
                ret[i] = Integer.parseInt(hString[i]);
            }
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
        return ret;
    }

}


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

int main()
{
    string s;
    string t;
    cin>>s>>t;
    int n=s.length(), m=t.length();
    int mm=INT_MAX;
    int cnt=0;
    for(int i=0;i<n-m+1;i++)//Checking Window.
    {
        cnt=0;
        for(int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j])
            {
                cnt++;
            }
        }
         mm=min(mm,cnt);
    }
    cout<<mm;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<tuple<int, int, int>> pyramid(N);
    for(int i = 0; i < N; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        pyramid.at(i) = make_tuple(h, x, y);
    }
    sort(pyramid.begin(), pyramid.end());
    reverse(pyramid.begin(), pyramid.end());
    
    for(int cx = 0; cx <= 100; cx++) {
        for(int cy = 0; cy <= 100; cy++) {
            bool ok = true;
            int H;
            for(int i = 0; i < N; i++) {
                int x = get<1>(pyramid.at(i));
                int y = get<2>(pyramid.at(i));
                int h = get<0>(pyramid.at(i));
                
                if(i==0) H = h + abs(x - cx) + abs(y - cy);
                else if(max(H - abs(x - cx) - abs(y - cy), 0) != h) {
                    ok = false;
                    break;
                }
            }
            if(ok) cout << cx << " " << cy << " " << H << endl;
        }
    }
    
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
string s;
map<pair<string,string>, ll> mp1;
ll ans;
int main() {
    cin>>N>>s;
    REP(mask,0,1<<N){
        string ss="", ss2="";
        REP(i,0,N){
            if(mask & (1<<i)) ss+=s[i];
            else ss2+=s[i];
        }
        mp1[make_pair(ss,ss2)]++;
    }
    REP(mask,0,1<<N){
        string ss="", ss2="";
        REP(i,0,N){
            if(mask & (1<<i)) ss=s[i+N]+ss;
            else ss2=s[i+N]+ss2;
        }

        ans+=mp1[make_pair(ss2,ss)];
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 87040
_, w = gets.split.map(&:to_i)
gets
a = gets.split

array = a.map.with_index(1){ |a_i, i| [i] * a_i.to_i }.flatten

array.each_slice(w).with_index do |row, i|
  puts (i.even? ? row : row.reverse) * " "
end

Measured memory_bytes: 3452
import math

a, b, x = map(int, input().split())

y = x / a

def solve_triangle(a, b, y):
    l = y / b * 2
    return math.atan(b / l) / math.pi * 180

def solve_trapezium(a, b, y):
    r = a * b - y
    l = r / a * 2
    return math.atan(l / a) / math.pi * 180

if a * b / 2 > y:
    print(solve_triangle(a, b, y))

else:
    print(solve_trapezium(a, b, y))


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int s[100], t[100];

int main(){

    while(1){

        int n, m;
        cin>> n>> m;
        if(n==0&&m==0) break;
        for(int i=0; i<n; i++) cin>> s[i];
        for(int i=0; i<m; i++) cin>> t[i];

        int mi=300;
        vector<pair<int, int>> ans;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                swap(s[i], t[j]);
                int s1=accumulate(s, s+n, 0);
                int s2=accumulate(t, t+m, 0);
                if(s1==s2){
                    if(s[i]+t[j]<mi){
                        ans.push_back(make_pair(t[j], s[i]));
                        mi=s[i]+t[j];
                    }
                }
                swap(s[i], t[j]);
            }
        }
        if(ans.size()==0){
            cout<< -1<< endl;
        }else{
            cout<< ans[0].first<< " "<< ans[0].second<< endl;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		A solver = new A();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class A
	{
		int D;
		int T;
		int S;
		
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{
			D = in.Int();
			T = in.Int();
			S = in.Int();
			out.println(D <= T*S ? "Yes" : "No");
		}
	}
	
	static class MyScanner
	{
		private BufferedReader in;
		private StringTokenizer st;
		
		public MyScanner(InputStream stream)
		{
			in = new BufferedReader(new InputStreamReader(stream));
		}
		
		public String next()
		{
			while( st == null || !st.hasMoreTokens() )
			{
				try
				{
					String rl = in.readLine();
					if( rl == null )
					{
						return null;
					}
					st = new StringTokenizer(rl);
				}
				catch( IOException e )
				{
					return null;
				}
			}
			return st.nextToken();
		}
		
		public int Int()
		{
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 32820
N = int(input())
A = [int(a) for a in input().split()]

for i in range(N-1):
    if A[i] - A[i+1] >= 2:
        print("No")
        break
    if A[i] - A[i+1] == 1 and i >= 2 and A[i-1] >= A[i]:
        print("No")
        break
    if i == 0 or A[i] > A[i-1]:
        A[i] -= 1
else:
    print("Yes")

Measured memory_bytes: 14396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long ll;

using namespace std;

template<typename TwoDimensionalVector>
void sort_by_column(TwoDimensionalVector &vector, int column, bool reverse = false) {
    if (reverse) {
        sort(vector.begin(), vector.end(), [&](auto x, auto y) { return x[column] > y[column]; });
    } else {
        sort(vector.begin(), vector.end(), [&](auto x, auto y) { return x[column] < y[column]; });
    }
}

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

    int N, M;
    cin >> N >> M;

    ll x, y, z;
    vector<vector<ll>> source;
    for (int _ = 0; _ < N; _++) {
        cin >> x >> y >> z;
        vector<ll> tmp = {x + y + z,
                          x + y - z,
                          x - y + z,
                          x - y - z,
                          -x + y + z,
                          -x + y - z,
                          -x - y + z,
                          -x - y - z};
        source.push_back(tmp);
    }

    ll absolute_maximum = 0;
    ll initial_value = 0;

    for (int column = 0; column < 8; column++) {
        sort_by_column(source, column, true);
        ll maximum = accumulate(source.begin(), next(source.begin(), M), initial_value,
                                 [&](ll sum, auto x) { return sum + x[column]; });
        ll minimum = accumulate(prev(source.end(), M), source.end(), initial_value,
                                 [&](ll sum, auto x) { return sum + x[column]; });
        ll tmp = max(maximum, -minimum);
        if (tmp > absolute_maximum) {
            absolute_maximum = tmp;
        }
    }

    cout << absolute_maximum << endl;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    vector<string> S(N);
    ll ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, N){
        string S;
        cin >> S;
        if(S == "AC") ac++;
        else if(S == "WA") wa++;
        else if(S == "TLE") tle++;
        else re++;
    }
    cout << "AC x " << ac << endl; 
    cout << "WA x " << wa << endl; 
    cout << "TLE x " << tle << endl; 
    cout << "RE x " << re << endl; 

}

Measured memory_bytes: 6424
#include  <iostream>

using namespace std;

int main()
{
	int r, d;
	int x[11];

	cin >> r >> d >> x[0];

	for (int i = 0; i < 10; i++) {
		x[i + 1] = r * x[i] - d;
		cout << x[i + 1] << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
struct grid{
	int x,y;
};
int main(){
	while(true){
		int w,h;	cin>>w>>h;
		if(w==0)	return 0;
		vector<string> s(h);
		for(int i=0;i<h;i++)	cin>>s[i];
		queue<grid> q;
		bool visited[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				visited[i][j]=false;
				if(s[i][j]=='@'){
					visited[i][j]=true;
					q.push((grid){j,i});
				}
			}
		}
		while(!q.empty()){
			grid c=q.front();	q.pop();
			for(int i=0;i<4;i++){
				int ny=c.y+dy[i],nx=c.x+dx[i];
				if(ny<0||h<=ny)	continue;
				if(nx<0||w<=nx)	continue;
				if(s[ny][nx]=='#')	continue;
				if(!visited[ny][nx]){
					visited[ny][nx]=true;
					q.push((grid){nx,ny});
				}
			}
		}
		int cnt=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(visited[i][j])	cnt++;
			}
		}
		cout<<cnt<<endl;
	}
}

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

using namespace std;

typedef long long lint;

int n;

lint up;
lint down;

int a[109];

int main()
{
    cin >> n;

    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        up += a[i];
    }

    down = n;

    int mnu = 9999999, mnd = 1, mnx = 0;
    for(int i = 1; i <= n; i ++)
    {
        if(abs(a[i] * n - up) < mnu)
        {
            mnu = abs(a[i] * n - up);
            mnx = i - 1;
        }
    }

    cout << mnx << "\n";

    return 0;
}


Measured memory_bytes: 764
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    a = [i for i in range(102)]
    for i in range(n):
        a[p[i]] = 0
    minimum = 100
    result = 100
    for i in reversed(range(102)):
            d = abs(x - a[i])
            if d <= minimum:
                minimum = d
                result = a[i]
    print(result)

Measured memory_bytes: 61900
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int x, y;

	cin >> x >> y;
	cout << gcd(x, y) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n,m;
	cin>>n>>m;
	cout<<(1<<m)*((n-m)*100+1900*m)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<int> vi;
const int MOD=1000000007;

vector<ll> prima;
ll n,m,ans,cnt,tmp,a[100005];
bool gak=false;

ll dnc(ll x,ll y){
    ll tmp,t;
    if(y==0) return 1;
    if(y%2==1) tmp=x;
    else tmp=1;
    t=dnc(x,y/2)%MOD;
    return ((t*t)%MOD * tmp)%MOD;
}
 
ll fac[200005],invfac[200005];
void fact(ll x){
    fac[0]=1;
    invfac[0]=1;
    for(ll i=1;i<=x;i++){
        fac[i]=(fac[i-1]*i)%MOD;
        invfac[i]=dnc(fac[i],MOD-2)%MOD;
    }
}
 
ll kombin(ll x,ll y){
    return (((fac[x]*invfac[x-y])%MOD) * invfac[y])%MOD;
}

void init(){
	fact(2e5);
	prima.push_back(2);
	prima.push_back(3);
	for(ll i=4;i<=1e5;i++){
		gak=false;
		for(int j=0;j<(int)prima.size();j++){
			if(prima[j]*prima[j]>i) break;
			if(i%prima[j]==0){
				gak=true;
				break;
			}
		}
		if(!gak) prima.push_back(i);
	}
	
}

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

	cin>>n>>m;
	init();
	tmp=m;
	for(int i=0;i<(int)prima.size();i++){
		ll prim=prima[i];
		if(prim*prim>tmp) break;
		cnt=0;
		while(tmp%prim==0){
			tmp/=prim;
			cnt++;
		}
		//cout<<prim<<endl;
		a[prim]=cnt;
	}
	ans=1;
	for(int i=0;i<(int)prima.size();i++){
		ll prim=prima[i];
		if(prim*prim>m) break;
		if(m%prim==0){
		//	cout<<prim<<" "<<a[prim]<<endl;
			ans*=(kombin(n+a[prim]-1,n-1))%MOD;
			ans%=MOD;
		}
	}
	if(tmp>1){
		ans*=(kombin(n,n-1))%MOD;
		ans%=MOD;
	}

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

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n, r=0, g=0, b=0;
	long long int ans = 3, tmp;
	vector<long long int> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	r++;

	if (v[0] != 0) {
		cout << "0" << endl;
		return 0;
	}

	for (int i = 1;i < v.size();i++) {
		tmp = 0;
		if (v[i] == r) {
			tmp++;
			r++;
		}
		if (v[i] == g) {
			tmp++;
			if (tmp == 1) g++;
		}
		if (v[i] == b) {
			tmp++;
			if (tmp == 1) b++;
		}

		ans = ans * tmp;
		ans = ans % 1000000007;
		//if (tmp > 1) cout << "h" << endl;
	}

	cout<< ans << endl;


}


Measured memory_bytes: 1024
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B>C+D) printf("Left\n");
  else if(A+B<C+D) printf("Right\n");
  else printf("Balanced\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int X, Y;
	scanf("%d%d", &X, &Y);
	if ((Y - 2*X) % 2 == 0 && Y >= 2*X && Y <= 4*X) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 998244353;

int n;
int a[maxN];
int b[maxN];
vector<int> v[maxN];
int vis[maxN];
int c[maxN];
ll d[maxN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	b[0] = 0;
	for(int i=1;i<=n;i++)
	{
		b[i] = b[i-1] + a[i];
	}
	int ans = INF;
	for(int i=1;i<n;i++)
	{
		int x = b[i] - b[0];
		int y = b[n] - b[i];
		ans = min(ans,abs(x-y));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    int grundy = 0;
    rep(i, n) grundy = grundy | (a[i] & 1);
    if (grundy > 0) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
const int Maxn=110;
int n,m,ans;
bool vis[Maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		int cnt;
		scanf("%d",&cnt);
		while(cnt--)
		{
			int x;
			scanf("%d",&x);
			vis[x]=1;
		}
	}
	for(int i=1;i<=n;++i)
	if(!vis[i])++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;


namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

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

            var p = cin.SplitRead();
            int N = p[0];
            int K = p[1];



            long lim = (N - 1) * (N - 2) / 2;
            if (K > lim)
            {
                Console.WriteLine(-1);
                return;
            }

            Queue<Tuple<int, int>> E = new Queue<Tuple<int, int>>();

            for(var i = 2; i <= N; i++)
            {
                E.Enqueue(new Tuple<int, int>(1, i));
            }

            long res = lim - K;
            for (var i = 2; i <= N - 1; i++)
            {
                for (var j = i + 1; j <= N; j++)
                {
                    E.Enqueue(new Tuple<int, int>(i, j));
                }
            }
            long M = (N - 1) + res;
            Console.WriteLine(M);
            for(var i = 0; i < M; i++)
            {
                var e = E.Dequeue();
                Console.WriteLine($"{e.Item1} {e.Item2}");
            }
            

        }
    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


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


int main() {
	
	int R;
	scanf("%d",&R);
	
	printf("%.15f",R*2*3.1415926535);
	
	return 0;
}

Measured memory_bytes: 1748
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<string> S(n);
  for(int i=0; i<n; i++){
    cin >> S[i];
  }
  int ans=0;
  sort(S[0].begin(),S[0].end());
  vector<bool> can_sum((int)S[0].size(),true);
  for(int i=1; i<n; i++){
    int j=0,k=0;
    sort(S[i].begin(),S[i].end());
    vector<bool> can((int)S[0].size(),false);
    while(j<(int)S[0].size() && k<(int)S[i].size()){
      if(S[0][j] == S[i][k]){
        can[j] = true;
        j++;
        k++;
      }else if(S[0][j]-'a' > S[i][k]-'a'){
        k++;
      }else{
        j++;
      }
    }
    for(int l=0; l<(int)S[0].size(); l++){
      if(!(can[l] && can_sum[l])){
        can_sum[l] = false;
      }
    }
  }
  for(int i=0; i<(int)S[0].size(); i++){
    if(can_sum[i]){
      cout << S[0][i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
N,K=map(int,input().split())
S=input()
nums=[]
if S[0]=="0":
    nums.append(0)
i=0
while(i<len(S)):
    j=i
    while(j<len(S) and S[j]==S[i]):
        j+=1
    nums.append(j-i)
    i=j
if S[-1]=="0":
    nums.append(0)
sums=[0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1]=sums[i]+nums[i]
res=0
for left in range(0,len(sums),2):
    right=left+K*2+1
    if right>=len(sums):
        right=len(sums)-1
    res=max(res,sums[right]-sums[left])
print(res)


Measured memory_bytes: 46548
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>

using namespace std;

int main()
{
    int n, k;

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

    vector<int> l;

    for (int i = 0; i < n; i++) {
        int l_i;
        scanf(" %d", &l_i);
        l.push_back(l_i);
    }

    sort(begin(l), end(l), greater<int>());

    int ret = 0;
    for (int i = 0; i < k; i++) {
        ret += l[i];
    }

    printf("%d", ret);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,cnt = 0,x;
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> x;
        if(x != i + 1){
            cnt++;
        }
    }
    if(cnt > 2) cout << "NO";
    else cout << "YES";
    return 0;
}

Measured memory_bytes: 256
n = input()
a = [int(A) for A in input().split()]

max_ele = 0
for i in range(len(a)):
    if a[i] > max_ele:
        max_ele = a[i]

mid = 0
mid_val = max_ele / 2

for j in range(len(a)):
    if abs(mid_val - a[j]) < abs(mid_val - mid):
        mid = a[j]

print(str(max_ele) + " " + str(mid))

Measured memory_bytes: 14064
#include <iostream>
using namespace std;
int main(){
	const int N_SIZE_MAX = 10000;
	int n[N_SIZE_MAX];
	int nSize;
	int min, max;
	long int sum = 0;
	cin >> nSize;
	for (int i = 0; i < nSize; i++) cin >> n[i];
	min = n[0];
	max = n[0];
	for (int i = 0; i < nSize; i++){
		if (min > n[i]) min = n[i];
		if (max < n[i]) max = n[i];
		sum += n[i];
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9;
const int maxN = 500 + 5;

int n, k;
ll a[maxN];

bool chk(ll divi){
    vector<ll> vv;
    ll inc = 0;
    for(int i = 1; i <= n; i++){
        vv.push_back(a[i] % divi);
        inc += divi - vv.back();
    }

    sort(vv.begin(), vv.end());
    ll dec = 0;
    for(int i = 0, L = (int)vv.size(); i < L; i++){
        dec += vv[i];
        inc -= (divi - vv[i]);

        if(dec == inc && dec <= k){
            return true;
        }
    }

    return false;
}

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

    cin >> n >> k;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    ll sum = 0;

    for(int i = 1; i <= n; i++){
        sum += a[i];
    }

    ll ans = 0;
    for(ll i = 1; i * i <= sum; i++){
        if(sum % i){
            continue;
        }

        if(chk(i)){
            ans = max(ans, i);
        }
        if(chk(sum / i)){
            ans = max(ans, sum / i);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,M;
	cin>>N>>M;
	ll ar[M];
	cn(ar,M);
	ll sum=0;
	for(ll i=0;i<M;i++)
	    sum+=ar[i];
	if(sum>=N)
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#define inf 0x3f3f3f
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef double db;
const int mod = 1e9;
const int maxn = 1e4+5;
int a,b,c,d;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int cnt = a/d + (a%d != 0),num = c/b + (c % b != 0);
	if(cnt >= num)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


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

int main(){
  int64_t N,ans=0;
  cin >> N;
  vector<int64_t> A(N),dp(N,0);
  for(int64_t i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)+i<N){
      dp.at(A.at(i)+i)++;
    }
    if(i-A.at(i)>0){
      ans+=dp.at(i-A.at(i));
    }
  }
  
    
  cout << ans << endl;
}

Measured memory_bytes: 6328
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
#include <vector>
#include <numeric>

using namespace std;

int n;
vector<int> a;

bool check(int k) {
    if (n%k) return false;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n / k; j++) {
            if (a[i*(n / k) + j] != a[j]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    while (cin >> n) {
        a.resize(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for (int i = 1; i <= n; i++) {
            if (check(i)) {
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
N=int(input())
s=0
i=1
while(i<=N):
    s=s+i
    i=i+1
a=N//3
b=N//5
c=N//15
p=0
x=1
while(x<=a):
    p=p+x
    x=x+1
p=p*3
q=0
y=1
while(y<=b):
    q=q+y
    y=y+1
q=q*5
r=0
z=1
while(z<=c):
    r=r+z
    z=z+1
r=r*15
print(s-p-q+r)

Measured memory_bytes: 9220
from collections import defaultdict
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
dic = defaultdict(list)

total = 0
candidates = []
heapq.heapify(candidates)

for i in range(n):
    a, b = map(int, input().split())
    dic[a].append(b)

for day in range(1, m+1):
    if day in dic:
        for x in dic[day]:
            heapq.heappush(candidates, -x)
    
    if candidates:
        total -= heapq.heappop(candidates)

print(total)

Measured memory_bytes: 27588
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	atemp,btemp = map(int,input().split())
	a.append(atemp)
	b.append(btemp)
amax = max(a)
b.sort()
total = 0
counter = 0
i = n-1
while i >= 0 and b[i] >= amax and total < h:
	total += b[i]
	counter += 1
	i += -1
if total < h:
	if (h-total)%amax == 0:
		counter = counter + (h-total)//amax
	else:
		counter = counter + (h-total)//amax + 1
print(counter)

Measured memory_bytes: 11356
#include <bits/stdc++.h>
#define N 1010
#define int long long
using namespace std;

signed main(){
  int n,v;
  cin>>n>>v;
  int A[N],B[N],C[N],D[N];
  for(int i=0;i<n;i++) cin>>A[i];
  for(int i=0;i<n;i++) cin>>B[i];
  for(int i=0;i<n;i++) cin>>C[i];
  for(int i=0;i<n;i++) cin>>D[i];
  
  map<int,int>M;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) M[A[i]+B[j]]++;

  int ans = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)ans += M[v-C[i]-D[j]];
  cout<<ans<<endl;  
  
  return 0;
}

Measured memory_bytes: 128052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,m;
    
    cin>>a>>b>>m;
    vector<int> ai(a),bi(b);
    for(int i=0;i<a;i++){
        cin>>ai.at(i);
    }
    for(int i=0;i<b;i++){
        cin>>bi.at(i);
    }
    vector<int> ans(m);
    for(int i=0;i<m;i++){
        int d,e,f;
        cin>>d>>e>>f;
        int g=ai.at(d-1)+bi.at(e-1)-f;
        ans.at(i)=g;
    }
    sort(ans.begin(),ans.end());
    sort(ai.begin(),ai.end());
    sort(bi.begin(),bi.end());
    int ta=ai.at(0)+bi.at(0);
    if(ta<ans.at(0)){
        cout<<ta<<endl;
        return 0;
    }
    cout<<ans.at(0)<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a1,a2,a3,b1,b2;
  int ans,h1,h2;
  cin >> a1 >> a2 >> a3 >> b1 >> b2;
  h1 = min(a1,a2);
  h1 = min(h1,a3);
  h2 = min(b1,b2);

  ans = h1 + h2 - 50;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3092
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}


const int N = 2e4 + 10;
int dp[N];


struct stone
{
    int s;
    int w;
    int v;
};

bool cmp(stone a, stone b)
{

    return a.s + a.w < b.s + b.w;
}

int32_t SALI()
{
    int n; cin >> n;
    stone a[n]; for(int i = 0; i < n; i++) cin >> a[i].w >> a[i].s >> a[i].v;
    sort(a,a+n,cmp);
    for(int i = 0; i < n; i++){
        for(int j = N-1; j >= 0; j--){
            if(j <= a[i].s){
                dp[j+a[i].w] = max(dp[j+a[i].w], dp[j] + a[i].v);
            }
        }
    }

    int ans = 0; for(int i = 0; i < N; i++) ans = max(ans,dp[i]);
    cout << ans;
}



/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 3796
n,m,x = map(int,input().split())
l = [[]]*n
for i in range(n):
    l[i] = list(map(int,input().split()))
cnt_min = 10**7
for j in range(2**n):
    u = [x]*m
    cnt = 0
    b = str(bin(j))[2:].zfill(n)
    for k in range(n):
        if b[k] == '1':
            cnt += l[k][0]
            for o in range(m):
                u[o] -= l[k][o+1]
    flg = 1
    for p in range(m):
        if u[p] > 0:
            flg = 0
    if flg == 1:
        if cnt < cnt_min: 
            cnt_min = cnt
if cnt_min == 10**7:
    print(-1)
else:
    print(cnt_min)

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  int max_cnt = 0;
  int ans = 1;
  repp(i, 1, N) {
    int temp = i;
    int cnt = 0;
    while (true) {
      if (temp % 2 == 0) {
        cnt++;
        temp /= 2;
      } else {
        break;
      }
    }
    if (chmax(max_cnt, cnt))
      ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  pair<string,int> p[n],q[n];
  rep(i,n){
    cin >> (p[i].first) >> p[i].second;
    p[i].second*=-1;
    q[i].first=p[i].first;
    q[i].second=p[i].second;
  }
  sort(p,p+n);
  rep(i,n){
    rep(j,n){
      if(q[j].first==p[i].first && q[j].second==p[i].second)cout << j+1 << endl;
    }
  }
return 0;}


Measured memory_bytes: 256
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

mod=10**9+7
n=int(input())
dic={}
cnt=0
for _ in range(n):
  a,b=map(int,input().split())
  if a!=0 and b!=0:
    g=gcd(abs(a),abs(b))
    if (a>0 and b>0) or (a<0 and b<0):
      if (abs(a)//g,abs(b)//g) not in dic:
        dic[(abs(a)//g,abs(b)//g)]=1
      else:
        dic[(abs(a)//g,abs(b)//g)]+=1
    elif (a<0 and b>0) or (a>0 and b<0):
      if (-abs(a)//g,abs(b)//g) not in dic:
        dic[(-abs(a)//g,abs(b)//g)]=1
      else:
        dic[(-abs(a)//g,abs(b)//g)]+=1
  else:
    if a==0 and b==0:
      cnt+=1
    elif a==0:
      if (1,0) not in dic:
        dic[(1,0)]=1
      else:
        dic[(1,0)]+=1
    elif b==0:
      if (0,1) not in dic:
        dic[(0,1)]=1
      else:
        dic[(0,1)]+=1
ans=1
s=set()
for a,b in dic.keys():
  if (a,b) in s:
    continue
  s.add((a,b))
  if a!=0 and b!=0:
    if a>0:
      if (-b,a) in dic:
        s.add((-b,a))
        cnt1=dic[(a,b)]
        cnt2=dic[(-b,a)]
        ans*=(pow(2,cnt1,mod)+pow(2,cnt2,mod)-1)%mod
        ans%=mod
      else:
        ans*=pow(2,dic[(a,b)])
        ans%=mod
    elif a<0:
      if (b,-a) in dic:
        s.add((b,-a))
        cnt1=dic[(a,b)]
        cnt2=dic[(b,-a)]
        ans*=(pow(2,cnt1,mod)+pow(2,cnt2,mod)-1)%mod
        ans%=mod
      else:
        ans*=pow(2,dic[(a,b)],mod)
        ans%=mod
  else:
    if (b,a) in dic:
      s.add((b,a))
      cnt1=dic[(a,b)]
      cnt2=dic[(b,a)]
      ans*=(pow(2,cnt1,mod)+pow(2,cnt2,mod)-1)%mod
      ans%=mod
    else:
      ans*=pow(2,dic[(a,b)],mod)
      ans%=mod
print((ans+cnt-1)%mod)

Measured memory_bytes: 150788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int d[n];
    for (auto &di:d) cin >> di;
    int ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<i; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
  
var bfr=[];
for(var i=0;i<4;i++){
   bfr.push([]);
   for(var j=0;j<3;j++){
      bfr[i].push([]);
      for(var k=0;k<10;k++)bfr[i][j].push(0);
   }
}
  
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   var b=arr[0]-1;
   var f=arr[1]-1;
   var r=arr[2]-1;
   var v=arr[3];
   bfr[b][f][r]=bfr[b][f][r]+v;
   if(bfr[b][f][r]>9)bfr[b][f][r]=9;
   if(bfr[b][f][r]<0)bfr[b][f][r]=0;
}
for(var i=0;i<4;i++){
for(var j=0;j<3;j++){
console.log(" "+bfr[i][j].join(" "));
}
if(i!==3)console.log("####################");
}

Measured memory_bytes: 8684
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int x[21],y[21];
double d[21][21];
double dp[10001][21][21];

double dir(int i,int j)
{
    return sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
}

double ang(int i,int j,int k)
{
    double dott = (x[j]-x[i])*(x[k]-x[j]) + (y[j]-y[i])*(y[k]-y[j]);
    double cs = dott / d[i][j] / d[j][k];
    return acos(cs);
}

int main()
{
    int n;
    double r,th;
	scanf("%d",&n);
    scanf("%lf%lf",&r,&th);
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]);
	}
    rep(i,n){
        rep(j,n){
            d[i][j] = dir(i,j);
        }
    }
    rep(i,10001){
        rep(j,n){
            rep(k,n){
                dp[i][j][k] = INF;
            }
        }
    }
    bool hoge = false;
    rep(i,n-1){
        if(d[0][i+1] < r+EPS){
            dp[1][0][i+1] = d[0][i+1];
            hoge = true;
        }
    }
    if(!hoge){
        printf("0\n");
        return 0;
    }
    vector<int> vec[21][21];
    rep(i,n){
        rep(j,n){
            if(j != i){
                rep(k,n){
                    if(ang(i,j,k)*180.0 / M_PI < th+EPS){
                        vec[i][j].push_back(k);
                    }
                }
            }
        }
    }
    int res;
    rep(i,10000){
        bool flag = false;
        rep(j,n){
            rep(k,n){
                if(k != j){
                    rep(l,vec[j][k].size()){
                        if(dp[i+1][j][k] + d[k][vec[j][k][l]] < r+EPS){
                            dp[i+2][k][vec[j][k][l]] = min(dp[i+2][k][vec[j][k][l]],dp[i+1][j][k] + d[k][vec[j][k][l]]);
                            flag = true;
                        }
                    }
                }
            }
        }
        if(!flag){
            res = i+1;
            break;
        }
    }
    printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 38080
n = int(input())
lst = list(map(int, input().split()))
lst += [0]*2
ans = [float('inf')]*(n+2)
ans[0] = 0

def dp():
  for i in range(n):
    ans[i+1] = min(ans[i+1], ans[i] + abs(lst[i+1]-lst[i]))
    ans[i+2] = min(ans[i+2], ans[i] + abs(lst[i+2]-lst[i]))

dp()

print(ans[n-1])

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

int main() {
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++) {
    for(int j=0;j<s.size();j++) {
      if(i!=j) {
        if(s.at(i)==s.at(j)) {
          ans++;
        }
      }
    }
  }
  if(ans==0) {
    cout<<"yes"<<endl;
  }
  else if(ans>0) {
    cout<<"no"<<endl;
  }
}

Measured memory_bytes: 256