akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


using namespace std;
double pi=3.14159265358979323846264338;
long long sum;

long long n,k,st,h,w,m;
int tx,ty,gx,gy,cx,cy;

string s;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int arr[300001],arr2[300001];
vector<int>ar,ar2;
map<pair<int,int>,int>ma;
long long pr(long long a, long long b){
	long long k=1;
	if(b==0)return 1;
	
	for(int i=0;i<b;i++)k=k*10;
	return k;
}


int main(){
	cin>>h>>w>>m;
	for(int i=0;i<m;i++){
		cin>>tx>>ty;
		arr[tx]++;
		arr2[ty]++;
		ma[make_pair(tx,ty)]=1;
	}
	gx=0;
	gy=0;
	for(int i=1;i<=h;i++)gx=max(gx,arr[i]);
	for(int i=1;i<=w;i++)gy=max(gy,arr2[i]);
	for(int i=1;i<=h;i++)if(arr[i]==gx)ar.push_back(i);
	for(int i=1;i<=w;i++)if(arr2[i]==gy)ar2.push_back(i);
	for(int i=0;i<ar.size();i++)for(int j=0;j<ar2.size();j++)if(ma.find(make_pair(ar[i],ar2[j]))==ma.end()){cout<<gx+gy<<endl;return 0;}
	cout<<gx+gy-1<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	vector<vector<int>> X(N, vector<int>(D));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int dist2 = 0;
			for (int k = 0; k < D; ++k) {
				dist2 += ((X[i][k] - X[j][k]) * (X[i][k] - X[j][k]));
			}

			int k = 1;
			while (k <= dist2) {
				if (dist2 % k == 0 && dist2 / k == k) {
					ans++;
				}
				k++;
			}
		}
	}

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


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
/*#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")*/
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
int main()
{
    io;
    int i,j,n,m,k,a,l;
    cin>>n>>m;
    vector<vector<int> >v(n);
    vector<int>cnt;
    vector<int>p(m);
    rep(i,0,m)
    {
        cin>>k;
        rep(j,0,k)
        {
        cin>>a;
        v[a-1].pb(i);
        }
    }
    rep(i,0,m)
    cin>>p[i];
    a=1<<n;
    int cn=0;
    rep(i,0,a)
    {
        cnt.resize(m,0);
        rep(j,0,n)
            if(i&(1<<j))
            rep(l,0,v[j].size())
            cnt[v[j][l]]++;
        k=0;
        rep(j,0,m)
            if(cnt[j]%2==p[j])
                k++;
                if(k==m)
                    cn++;
        cnt.clear();
    }
    cout<<cn;
    return 0;
}


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 w[10],k[10];

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

	sort(w,w+10); sort(k,k+10);

	cout << w[7]+w[8]+w[9] << " " << k[7]+k[8]+k[9] << endl;

	return 0;

}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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


int main(){
  int n; cin >> n;
  vector<int> a(n);

  for(int i = 0; i < n; i++) cin >> a[i];
  int now = a[0];
  for(int i = 1; i < n; i++){
    now = gcd(now, a[i]);
  }
  cout << now << endl;
  return 0;
}


Measured memory_bytes: 640
n=int(input())
a=[]
for i in range(n):
  x,v=input().split()
  a.append([x,v])
ans=0
for i in range(n):
  if a[i][1]=='BTC':
    ans+=380000*float(a[i][0])
  else:
    ans+=int(a[i][0])
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Math;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextInt());
        }
        scanner.close();
        Collections.sort(list);
        List<Integer> resultList = new ArrayList<>();
        for(int i=0; i<n; i++){
            if(i == n-1){
                resultList.add(Math.abs(list.get(0)+k-list.get(n-1)));
            }else{
                resultList.add(Math.abs(list.get(i+1)-list.get(i)));
            }
        }
        Collections.sort(resultList);
        int result = k - resultList.get(n-1);
        System.out.println(result);
    }
}

Measured memory_bytes: 87984
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1010, mod = 1000000007;

int n, m, i, j, k;
char a[N];
bool v[N][N];
long long d[N][N];

inline int maxim(int x, int y){
    return (x > y ? x : y);
}

int main(){
    cin >> n >> m;
    for (i = 1; i <= n; ++i) {
        cin >> a + 1;
        for (j = 1; j <= m; ++j) {
            if (a[j] == '#') {
                v[i][j] = 1;
            }
        }
    }
    d[1][1] = 1;
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <= m; ++j) {
            if (i + j == 2) {
                continue;
            }
            if (v[i][j] == 0) {
                d[i][j] = (d[i - 1][j] + d[i][j - 1]) % mod;
            }
        }
    }
    cout << d[n][m] << "\n";
    return 0;
}


Measured memory_bytes: 9216
N, A, B, C = map(int, input().split())
opts = []
for _ in range(N):
    opt = input()
    opts.append((ord(opt[0]) - ord("A"), ord(opt[1]) - ord("A")))

choices = []
nums = [A, B, C]
for i, opt in enumerate(opts):
    if nums[opt[0]] == 0 and nums[opt[1]] == 0:
        print("No")
        break
    if nums[opt[0]] == 1 and nums[opt[1]] == 1:
        if i < N - 1 and opt != opts[i + 1]:
            choice = (set(opt) & set(opts[i + 1])).pop()
            nums[choice] += 1
            nums[choice ^ opt[0] ^ opt[1]] -= 1
            choices.append(choice)
            continue
    if nums[opt[0]] >= nums[opt[1]]:
        choices.append(opt[1])
        nums[opt[1]] += 1
        nums[opt[0]] -= 1
    else:
        choices.append(opt[0])
        nums[opt[0]] += 1
        nums[opt[1]] -= 1
else:
    print("Yes")
    for c in choices:
        print(chr(c + ord("A")))


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

int main(){
	int a,b,c,x;
	cin >> a>>b>>c;
	if (a>b)
	{
		x = a;
		a = b;
		b = x;
	}
	if (a>c)
	{
		x = a;
		a = c;
		c = x;
	}
	if (b > c)
	{
		x = b;
		b = c;
		c = x;
	}
	cout << a <<" "<< b <<" "<< c << endl;
}


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

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double n, m;
		n = b * d - a * e;
		m = c * d - f * a;
		double y = m / n;

		double l = c - b * y;
		double x = l / a;

		cout << fixed << setprecision(3) << x << ' ' << y << endl;
	}
}


Measured memory_bytes: 3276
N = int(input())
S = input()

dp = [[0] * N for _ in range(N)]

for j in range(N):
    if S[j] == S[-1]:
        dp[-1][j] = 1

for i in range(N - 2, -1, -1):
    for j in range(N - 1):
        if S[i] == S[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
    if S[i] == S[-1]:
        dp[i][-1] = 1

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], abs(i - j)))

print(ans)


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


int main(void) {
  string s;
  cin >> s;
  rep(i, s.length()) {
    if (s[i] == '9') {
      cout << "Yes" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 3568
def main():
    n, d = map(int, input().split())
    is_shorter = lambda dis, x, y : (x**2 + y**2) <= dis**2
    ans = sum([is_shorter(d, *map(int, input().split())) for _ in range(n)])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 10456
<?php

fscanf(STDIN, '%d %d', $N, $K);
fscanf(STDIN, '%s', $S);

$count = 1;

for ($i=1; $i < $N ; $i++) { 
    if ( $S[$i] !== $S[$i-1] ) {
        $counts[] = $count;
        $count = 1;
    } else {
        $count++;
    }
}
$counts[] = $count;

if ( $S[0] == 0 ) {
    array_unshift($counts, 0);
}


$lastIndex = count($counts);

$start = 0;
$end = 2 * $K;
$tempMax = array_sum(array_slice($counts, $start, $end - $start + 1));
$temp = $tempMax;

for ($i = 0; $i < $lastIndex + 1; $i++) {
    if ( $start + 2 * $i + 1 > $lastIndex ) {
        break;
    }

    $temp = $temp - $counts[$start + 2 * $i] - $counts[$start + 2 * $i + 1];
    $temp = $temp + $counts[$end + 2 * $i + 1] + $counts[$end + 2 * $i + 2];

    $tempMax = max($temp, $tempMax);
}

echo $tempMax;


Measured memory_bytes: 12788
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let s = buf.chars().collect::<Vec<char>>();


    if s[0] == s[1] && s[1] == s[2] && s[2] == s[3] {
        println!("No");
    }
    else if s[0] == s[1] && s[2] == s[3] {
        println!("Yes");
    }
    else if s[0] == s[2] && s[1] == s[3] {
        println!("Yes");
    }
    else if s[0] == s[3] && s[1] == s[2] {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	std::vector<int> A(N);
	
	for (int i=0; i<N; ++i) {
		cin >> A.at(i);
	}
	
	vector<int> before_max(N);
	vector<int> after_max(N);
	int temp_max = 0;
	for (int i=0; i<N; ++i) {
		before_max.at(i) = max(temp_max, A.at(i));
		temp_max = before_max.at(i);
	}
	
	temp_max = 0;
	for (int i=N-1;i>=0; i--) {
		after_max.at(i) = max(temp_max, A.at(i));
		temp_max = after_max.at(i);
	}
	
	for (int i=0; i<N; ++i) {
		if (i==0) {
			cout << after_max.at(i+1) << endl;
		} else if (i == N-1) {
			cout << before_max.at(i-1) << endl;
		} else {
			cout << max(before_max.at(i-1), after_max.at(i+1)) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3968
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 1e5+7;  
/*  
    time : 12 : 14    
    date : 19.01.2020
*/    
// int L,R,mid,target,idx ;
const int INF = 1e9 + 7 ;
int h[N],dp[N],k  ;   
int solve(int idx){
	if(idx <= 0  )
		return 0 ;  
	if(dp[idx] != -1) 
		return dp[idx]; 
	int result  = INF  ; 
	int j ; 
forn(j,1,k+1)
	if(idx-j >= 0 )	
	result =  min(result,abs(h[idx]-h[idx-j])+solve(idx-j)) ;
	return (dp[idx] = result) ;
}
int tests() 
{	
	int n ; 
	cin >> n  >> k ;
	int i ; 
	forn(i,0,n+1)
		dp[i]  = -1 ; 

	forn(i,0,n)
		cin >> h[i] ; 
 	cout << solve(n-1) << '\n'; 
	return 0 ; 
}
int32_t main(){
    I__O ;   
    int cases = 1 ; 
 	// cin >> cases;  
    while(cases--)
	    tests(); 
	return 0 ; 
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005
#define lim 10000
using namespace std;
 
typedef long long ll;

int n,m;

int main()
{

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	cin >> n;
	cout << n*n;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	llong h;
	cin>>h;
	
	int cnt=0;
	while(1){
		if(h>1){}
		else break;
		
		h/=2;
		cnt++;
	}
	//debug(cnt);
	
	llong ans=1;
	llong tmp=1;
	REP(i,cnt){
		ans+=tmp*2;
		tmp*=2;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,x,sum=0;
    cin>>N>>K;
    for(int i=0;i<N;i++)
    {
        cin>>x;
        if(x<K-x)
            sum+=x;
        else
            sum+=K-x;
    }
    cout<<sum*2<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class name
{

    static void Main()
    {

        int[] gakki = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] score = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int k = gakki[1];
        int n = gakki[0];
        for (int m = 0; m < n - k; m++) {
            if (score[k+m] > score[m])
            {

                Console.WriteLine("Yes");
                 
            }
            else
            {

                Console.WriteLine("No");

            }
                }

    }




}

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> s;
  vector<int> ord(n + 1, -1);
  int c = 1, l = 0;
  {
    int v = 1;
    while(ord[v] == -1) {
      ord[v] = s.size();
      s.push_back (v);
      v = a[v - 1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }
  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k%= c;
    cout << s[l + k] << endl;
  }    
  return 0;

}

Measured memory_bytes: 5864
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    ll m=n%10;
    string ans;
    if(m==2 || m==4 || m==5 || m==7 || m==9){
        ans="hon";
    }else if(m==0 || m==1 || m==6 || m==8){
        ans="pon";
    }else{
        ans="bon";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
def eval(t, a)
  t.each.with_index do |tt, i|
    if tt == 1
      a[i].each do |aa|
        index = aa[0] - 1
        if t[index] != aa[1]
          return false
        end
      end
    end
  end
  true
end

n = gets.to_i

a = Array.new(n).map{|_| Array.new}

(0...n).each do |i|
  ai = gets.to_i
  (1..ai).each do |_|
    a[i] << gets.chomp.split.map(&:to_i)
  end
end

ans = 0
(0...2**n).each do |i|
  s = ("%0#{n}b" % i).split("").map(&:to_i)
  if eval(s, a)
    h = s.select{|j| j == 1}.length
    ans = [ans, h].max
  end
end

p ans

Measured memory_bytes: 2044
N=int(input())
A=[]
for i in range(N):
  s,p=input().split()
  A.append([s,int(p),i+1])

A.sort(key=lambda x:x[1],reverse=True)
A.sort(key=lambda x:x[0],reverse=False)
for i in range(N):
  print(A[i][2])

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

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int set = Integer.parseInt(br.readLine());
					
		for(int i = 0; i < set; i++) {
			line = br.readLine();
			String[] numbers = line.split(" ");
			int[] numSet = new int[3];

			for (int j = 0; j < 3; j++){
				numSet[j] = Integer.parseInt(numbers[j]);
			}

			Arrays.sort(numSet);

			if(numSet[2]*numSet[2] == numSet[1]*numSet[1] + numSet[0]*numSet[0]){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 20196
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		String str = s.next();
		if(str.charAt(0) == str.charAt(1) ||
				str.charAt(1) == str.charAt(2)||
				str.charAt(2) == str.charAt(3)) {
			System.out.println("Bad");

		}else {
			System.out.println("Good");
		}
	}
}


Measured memory_bytes: 21844
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] l = new int[] {Math.Abs(a[0]-a[1]), Math.Abs(a[0]-a[2]), Math.Abs(a[1]-a[2])};
        Array.Sort(l);
        Console.WriteLine(l[0]+l[1]);
    }
}

Measured memory_bytes: 13396
k, n = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
sabun = []
(n-1).times do |i|
    sabun << a[i+1] - a[i]
end
puts [a[-1]-a[0], k-sabun.max].min

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int P[N];
    rep(i, N){
        int a; cin >> a; a--;
        P[i] = a;
    }
    UnionFind uf(N);
    rep(i, M){
        int x, y; cin >> x >> y;
        x--; y--;
        uf.merge(x, y);
    }
    int ans = 0;
    int appear[N];
    rep(i, N) appear[P[i]] = i;
    rep(i, N){
        if(uf.issame(i, appear[i])) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();
        int a[] = new int[N];
        String west ="W";
        for(int i=0;i<N;i++){
            if(S.charAt(i) == 'W'){
                a[i] = 1;
            }else{a[i]=0;}
        }
        int s[] = new int[N];
        for(int i =0;i<N;i++){
            if(i==0){s[i]=0;}
            else{
                s[i] = a[i-1] + s[i-1];
            }
        }
        int b[] = new int[N];
        String east ="E";
        for(int i=0;i<N;i++){
            if(S.charAt(i) == 'E'){
                b[i] = 1;
            }else{a[i]=0;}
        }
        int t[] = new int[N];
        for(int i =N - 1;i>=0;i--){
            if(i==N-1){t[i]=0;}
            else{
                t[i] = b[i+1] + t[i+1];
            }
        }
        int ans =(int)1e9;
        for(int i=0;i<N;i++){
            ans=Math.min(ans,s[i]+t[i]);
        }
        System.out.println(ans);
    }
}

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

long long int gcd(long long int, long long int);
long long int lcm(long long int, long long int);
long long int sum_set(long long int x, long long int a, long long int b);

int main(void)
{
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	long long int ans = B - A + 1 + sum_set(A - 1, C, D) - sum_set(B, C, D);
	//cout << sum_set(A - 1, C, D) << sum_set(B, C, D) << endl;
	cout << ans << endl;

	return 0;
}

long long int gcd(long long int x, long long int y)
{
	long long int a, b, r;
	if (x > y) {
		a = x;
		b = y;
	}
	else {
		a = y;
		b = x;
	}
	r = a % b;
	while (r > 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int x, long long int y)
{
	long long int GCD = gcd(x, y);
	return x * y / GCD;
}

long long int sum_set(long long int x, long long int a, long long int b) {
	long long int LCM = lcm(a, b);
	return x / a + x / b - x / LCM;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    print(3 * N * N);
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 5005, M = 1e9 + 7;
ll fact[N];
ll mul(ll a, ll b)
{
    a %= M;
    b %= M;
    return (a * b) % M;
}
void pre()
{
    fact[0] = 1;
    for(int i = 1;i < N;++i)
        fact[i] = mul(fact[i - 1], i);
}
ll fp(ll b, ll p)
{
    if(!p)      return 1;
    ll res = fp(b, p >> 1);
    res = mul(res, res);
    if(p & 1)   res = mul(res, b);
    return res;
}
ll inv(ll n)
{
    return fp(n, M - 2);
}
ll ncr(ll n, ll r)
{
    return mul(fact[n], mul(inv(fact[r]), inv(fact[n - r])));
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    pre();
    ll n, k;
    cin >> n >> k;
    for(int i = 1;i <= k;++i)
    {
        if(i <= n - k + 1)  cout << mul(ncr(k - 1, i - 1), ncr(n - k + 1, i));
        else                cout << 0;
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  print(n*(n-1)/2);
  return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7

def comb(n, r):
    r = min(r, n - r)
    a = b = 1
    for _ in range(r):
        a *= n; b *= r
        a %= mod; b %= mod
        n -= 1; r -= 1
    return a * pow(b, mod - 2, mod) % mod


S = int(input())

ans = 0
n = 1
while 3 * n <= S:
    r = S - 3 * n
    ans += comb(n + r - 1, r)
    ans %= mod
    n += 1

print(ans)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define db double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 1e18
#define eps 0.000001
#define endl '\n'
int main()
{  
    fastio;
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "rt", stdin);
    //    freopen("output.txt", "wt", stdout);
    //#endif
    string s;
    cin>>s;
    ll f=0;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]=='+')
            f++;
        else
            f--;
    }
    cout<<f;
}

Measured memory_bytes: 256
import collections
N = int(input())
A = collections.Counter(int(T) for T in input().split()).most_common()
Remove = 0
for T in range(0,len(A)):
    if A[T][0]>A[T][1]:
        Remove += A[T][1]
    elif A[T][0]<A[T][1]:
        Remove += A[T][1]-A[T][0]
print(Remove)

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

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

  if(a == b + c || b == a + c || c == a + b){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import qualified Data.Map.Strict as M
import Data.Maybe (fromJust)
import Data.Array.IO

type Memo = M.Map (Int, Int) Int

modN = 10^9+7

main = do
  n <- readLn :: IO Int
  let (ans, memo) = solve M.empty n n
  print ans

solve :: Memo -> Int -> Int -> (Int, Memo)
solve memo 0 0 = (1, M.insert (0, 0) 1 memo)
solve memo s x
  | s < 0 || x < 0 = (0, memo)
  | otherwise =
  let ans = M.lookup (s, x) memo
  in if ans == Nothing
       then let (a1, m1) = solve memo (div s 2) (div x 2)
                (a2, m2) = solve m1 (div (s-1) 2) (div (x-1) 2)
                (a3, m3) = solve m2 (div (s-2) 2) (div x 2)
                a = mod (a1+a2+a3) modN
            in (a, M.insert (s, x) a m3)
       else (fromJust ans, memo)


Measured memory_bytes: 764
#include<stdio.h>
int main(void){
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(-a+b>x)
    printf("dangerous");
    else if(-a+b>0)
    printf("safe");
    else if(-a+b<=0)
    printf("delicious");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;
int h,w,d;
string tt = "RGBY";
main()
{
    ios_base::sync_with_stdio(false); cin >> h >> w >> d;
    for(int y = 1; y <= h; ++y)
    {
        for(int x = 1; x <= w; ++x)
        {
            int a = (x+y+500)/d;
            int b = (x-y+500)/d;
            cout << tt[2*(a%2)+b%2];
        }
        cout << endl;
    }
}



Measured memory_bytes: 512
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto cnt = new long[](N);
    cnt[] = 1;
    auto red = new bool[](N);
    red[0] = true;
    foreach (_; 0 .. M)
    {
        long X, Y;
        scan(X, Y);
        X--, Y--;
        red[Y] = red[X] || red[Y];
        red[X] = (1 != cnt[X]) && red[X];
        cnt[X]--;
        cnt[Y]++;
    }
    red.sum().writeln();
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m;

ll bpow[2521];
ll comb[2521][2521];

ll modpow(ll a, ll b, ll m){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%m;
    a=a*a%m;
    b>>=1;
  }
  return r;
}

int main(){
  scanf("%d%d",&n,&m);
  bpow[0] = 1; REP(i,n+1)bpow[i+1] = bpow[i]*2ll%m;
  comb[0][0] = 1;
  FOR(i,1,n+1)REP(j,i+1){
    if(j==0 || j==i)comb[i][j]=1;
    else comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % m;
  }
  ll ans = 0;
  FOR(a,1,n){
    ll sum = 0;
    int B = n-a;
    FOR(b,1,B+1){
      ll add = 1;
      add *= modpow(bpow[b]-1, a, m); add %= m;
      ll mul = 1;
      if((B-b)%2==1)mul = m-1;
      mul = mul * comb[B][b] % m;
      sum += mul * add % m;
      sum %= m;
    }
    sum *= comb[n][a]; sum %= m;
    sum *= modpow(2ll, a*(a-1)/2, m); sum %= m;
    sum *= modpow(2ll, B*(B-1)/2, m); sum %= m;
    ans += sum; ans %= m;
  }
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 26808
import java.util.*;

public class Main {
    public static final int MAX_WEIGHT = 1_000_000_000;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] d = new int[n];
        int[] toMin = new int[n];
        int[] curMin = new int[n];
        int[] edgeMin = new int[n];
        Arrays.fill(curMin, Integer.MAX_VALUE);

        for (int i = 0; i < n; i++) {
            d[i] = scanner.nextInt();
        }

        int u, v;
        for (int i = 0; i < m; i++) {
            u = scanner.nextInt()-1;
            v = scanner.nextInt()-1;
            if(curMin[u]>d[v]){
                toMin[u] = v;
                curMin[u] = d[v];
                edgeMin[u] = i;
            }
            if(curMin[v]>d[u]){
                toMin[v] = u;
                curMin[v] = d[u];
                edgeMin[v] = i;
            }
        }

        for (int i = 0; i < n; i++) {
            if(d[i]<curMin[i]){
                System.out.println(-1);
                return;
            }
        }

        Boolean[] nodeColors = new Boolean[n];
        Integer[] edgeWeights = new Integer[m];
        Stack<Integer> stack = new Stack<>();

        for (int i = 0; i < n; i++) {
            if(nodeColors[i]!=null) continue;
            stack.push(i);
            while (!stack.isEmpty()){
                Integer peeked = stack.peek();
                if(nodeColors[toMin[peeked]]!=null){
                    nodeColors[peeked]=!nodeColors[toMin[peeked]];
                    edgeWeights[edgeMin[peeked]] = d[peeked];
                    stack.pop();
                }else{
                    if(d[toMin[peeked]]== d[peeked]){
                        toMin[toMin[peeked]] = peeked;
                        nodeColors[toMin[peeked]] = true;
                        nodeColors[peeked] = false;
                        edgeWeights[edgeMin[peeked]] = d[peeked];
                        stack.pop();
                    }else{
                        stack.push(toMin[peeked]);
                    }
                }
            }
        }

        for (int i = 0; i < m; i++) {
            if (edgeWeights[i] == null) edgeWeights[i] = MAX_WEIGHT;
        }

        StringBuilder sb = new StringBuilder(n);
        for (boolean color: nodeColors) {
            sb.append(color ? "B" : "W");
        }
        System.out.println(sb.toString());
        for (int w : edgeWeights) {
            System.out.println(w);
        }
    }
}

Measured memory_bytes: 163648
/*
💭             💭
    💭        💭
     💭     💭
  💭💭💭☁
💭🌘💭🌘☁
💭💭🌸💭☁
  ☁☁☁☁
      🎀🎀🎀☁
      💭💭💭💭☁
      🍴 💭🍴💭☁ 💭
      📨  ☁📨☁☁





😡😡😡😡😡😡😡
😁I'm so angry!😁
💀💀💀💀💀💀💀
😑😤😤😤😤😤😑
  🔥✂✂✂✂✂🔥
😡😡😡😡😡😡😡
*/#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define print(a) for(auto f:a)cout<<f<<" ";
#define sor(v) sort(v.begin(),v.end());
#define rsor(v) sort(v.rbegin(),v.rend());
#define rev(v) reverse(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define fi first
#define se second
#define lp(x,q) for(ll i=x ;i<q;i++)
#define pb(x) push_back(x)
#define pob pop_back()
#define res(v,a) v.resize(a)
#define md(q,w)  (q+w)/2;
#define lp(q,w) for(ll x=q;x<w;x++)
#define MY_TORNADO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define minn(v) *min_element(v.begin(),v.end())
#define maxx(v) *max_element(v.begin(),v.end())
vector<vector<int>>adj;
vector<bool>vis(1e5,false);
vector<int>level(1e4);
//global variable:
ll cou=0,mx=INT_MIN,mn=INT_MAX,sum=0,av=0,hi=0,lo=0,ans=0,w,flag;



int main()
{float a,s;
cin>>a>>s;
cout<<ceil(a/s);
}

















/*😢😖😩😫😩😖😢
😢💔💔😫💔💔😢
💔👤👥💔👤👥💔😢
💔👤👤👤👤👥💔😢
💔👤👤👤👤👥💔😢
😢💔👤👤👥💔😢
😢😖💔👥💔😖😢
😢😖😩💔😩😖😢
😢😖😩😫😩😖😢


*/


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

int main(){
  int N, M, count = 0;
  cin >> N >> M;
  
  if(N > 1){
    count += N * (N - 1);
  }
  if(M > 1){
    count += M * (M - 1);
  }
  
  cout << count / 2 << endl;
}


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

using namespace std;
int dp[100005],h[100005];
int main()
{
    int n,i,k = 2,j;
    cin >> n >> k;
    for(i = 1;i <= n;i++)
        cin >> h[i];
    for(i = 1;i <= n;i++){
        if(i > 1)
            dp[i] = 2e9;
        for(j = i - 1;j >= i - k;j--){
            if(j >= 1)
                dp[i] = min(dp[j] + abs(h[i] - h[j]),dp[i]);
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
    char text[1205];
    int len,i;
    fgets(text,1205,stdin);
    len = strlen(text)-1;
    for(i=0;i<len;i++){
        if(islower(text[i])){
            text[i]=toupper(text[i]);
        }else if(isupper(text[i])){
            text[i]=tolower(text[i]);
        }
    }
    printf("%s",text);
}

Measured memory_bytes: 952
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int i = sc.nextInt();
  
		// 出力
		System.out.println(n + 1 - i);
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define int64 long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;
    cout << H*W - (h*W + w*H) + h*w;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mkp make_pair
#define pb push_back
typedef long long ll;
int main()
{
	vector<char> s;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		char c;cin>>c;s.pb(c);
	}
	int sum = 0;
	for(int i=0;i<s.size()-2;i++)
	{
		if(s[i] == 'A'&&s[i+1] == 'B'&&s[i+2] == 'C')sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            a[i+1] = 10000;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N,D,X;
    cin >> N >> D >> X;
    int A[N],num[N],ans=X;
    for(int i=0;i<N;i++){
        cin >> A[i];
        num[i] = (D-1) / A[i] + 1;
        ans += num[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,m,s,t=map(int,input().split())
uvab=[list(map(int,input().split())) for _ in [0]*m]
g_yen=[[] for _ in [0]*n]
[g_yen[u-1].append([v-1,a]) for u,v,a,b in uvab]
[g_yen[v-1].append([u-1,a]) for u,v,a,b in uvab]

g_snk=[[] for _ in [0]*n]
[g_snk[u-1].append([v-1,b]) for u,v,a,b in uvab]
[g_snk[v-1].append([u-1,b]) for u,v,a,b in uvab]

import heapq
def dijkstra(g,start):
    inf=10**15
    dist=[inf for _ in [0]*n]
    h=[(0,start)]
    heapq.heapify(h)
    while h:
        d,i=heapq.heappop(h)
        if dist[i]==inf:
            dist[i]=d
            for x,y in g[i]:
                heapq.heappush(h,(d+y,x))
    return dist

yen=dijkstra(g_yen,s-1)
snk=dijkstra(g_snk,t-1)

cost=[yen[i]+snk[i] for i in range(n)]
m=cost[-1]
for i in range(n-1,-1,-1):
    m=min(m,cost[i])
    cost[i]=m
    
for i in cost:
    print(10**15-i)

Measured memory_bytes: 137716
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};


int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h+1);
    rep(i, h){
        cin >> s[i];
    }

    int ans = -1;
    rep(startH, h){
        rep(startW, w){
            if(s[startH][startW] == '#') continue;
            queue<pair<int, int>> que;
            vector<vector<int>> dis(h, vector<int>(w, -1));
            que.push(make_pair(startH,startW));
            dis[startH][startW] = 0;
            while(!que.empty()){
                pair<int, int> p = que.front(); que.pop();
                rep(j,4){
                    pair<int, int> next;
                    next.first = p.first + dx[j];
                    next.second = p.second + dy[j];
                    if(next.first < 0 || next.first >= h || next.second < 0 || next.second >= w) continue;
                    if(s[next.first][next.second] == '#' ) continue;
                    if(dis[next.first][next.second] != -1) continue;
                    que.push(next);
                    dis[next.first][next.second] = dis[p.first][p.second]+1;
                    if(dis[next.first][next.second] > ans) ans = dis[next.first][next.second];
                }
            }
            
        }
    }
    cout << ans << endl;

/*
    rep(i,h){
        cout << "print" << endl;
        rep(j,w) cout << dis[i][j];
        cout << endl;
    }
  */  









    /*
    rep(i,h){
        cout << s[i] << endl;
    }   
    */

}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int a, b, a2, b2, gcd, lcm, buf;

	while(scanf("%d %d", &a, &b) != EOF){
		a2 = a;
		b2 = b;
		while(a % b != 0){
			buf = a % b;
			a = b;
			b = buf;
		}
		gcd = b;
		a2 = a2 / gcd;
		b2 = b2 / gcd;
		lcm = gcd * a2 * b2;
		printf("%d %d\n", gcd, lcm);
	}
	return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  vector<vector<int>> terms(m,vector<int>(2));
  rep(j,m){
    int s,c; cin >> s >> c;
    terms[j][0]=s; terms[j][1]=c;
  }

  int init=0; bool check=false;
  if(n!=1) init=(int)pow(10,n-1);
  
  int endi=(n==1) ? 10 : init*10;
  if(!m) cout << init << endl;
  else{
    for(int i=init; i<endi; i++){
        vector<int> tmp(n); int ii=i;
        rep(k,n){
          tmp[k]=ii%10;
          ii/=10;
        }
      reverse(tmp.begin(),tmp.end());
      rep(j,m){
        if(tmp[terms[j][0]-1]!=terms[j][1]) break;
        if(j==m-1) check=true;
      }
    if(check){
      cout << i << endl;
      break;
    }
    if(i==endi-1) cout << -1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    unsigned long long n,x=1000000000000000000,arr[100005],ans=1,zero=0;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        if(arr[i]==0)
            zero = 1;
    }
    if(zero)
        cout << 0 << endl;
    else
    {
        for(int i=0; i<n; i++)
        {
            x/=arr[i];
            if(x==0)
                break;
            ans*=arr[i];
        }
        if(x>0)
            cout << ans << endl;
        else
            cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 4388
#include <iostream>
#include <vector>
#include <numeric>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> has_candy(N, 0);
  for (int i = 0; i < K; ++i) {
    int d;
    std::cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      std::cin >> a;
      a -= 1;
      if (has_candy.at(a) == 0) {
        has_candy.at(a) = 1;
      }
    }
  }

  std::cout << N - std::accumulate(has_candy.begin(), has_candy.end(), 0) << std::endl;

  return 0;
}


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

// return =>  0...false, 1...true
// list => list
// n => list's length
// now => now list's place
// sum => use number's sum
// Goal = imput number
int Checker(int list[], int n, int now,int sum, int Goal){
	int ret = 0;
	
	if(sum + list[now] == Goal){
		return 1;
	}else if(now + 1 == n){
		return 0;
	}
	//used
	if(sum + list[now] < Goal){
		ret = Checker(list, n, now + 1, sum + list[now], Goal);
		if(ret == 1){
			return 1;
		}
	}
	
	//unused
	ret = Checker(list, n, now + 1, sum, Goal);
	if(ret == 1){
		return 1;
	}else{
		return 0;
	}
}

int main() {
	int n,q;
	scanf("%d",&n);
	
	int list[n];
	
	for(int i = 0; i < n; i++){
		scanf("%d",&list[i]);
	}
	
	
	scanf("%d",&q);
	
	for(int i = 0; i < q; i++){
		int value;
		scanf("%d",&value);
		
		if(Checker(list,n,0,0,value) == 1){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}






Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, m;
    cin >> n >> m;
    
    vector<double> a(n);
    double sum = 0;
    REP(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int tmp = 0;

    REP(i, n) {
        if (a[i] >= sum*1/(4*m)) {
            tmp++;
        }
    }

    if (tmp >= m) {
        cout << "Yes" << endl;
        
    } else { 
        cout << "No" << endl;
        
    }

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

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n+1){
    if (i%15 == 0) {
      /* code */
    }
    else if (i%3 == 0) {
      /* code */
    }
    else if (i%5 == 0) {
      /* code */
    }
    else ans += i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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

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

using namespace std;
int main()
{
    map<string,int> mp;
    vector<int> v;
    string s;
    int n;
    cin>>n;int k,sum=0;
    for(int i=0;i<n;i+=1){
        cin>>s>>k;
        v.push_back(k);
        int v = mp[s];
        mp[s] = k;
        sum = sum+mp[s];
    }
    cin>>s;
    int sum1=0;
    for(int j=0;j<v.size();j+=1){
        sum1 = sum1+v[j];
        if(v[j]==mp[s]){
            break;
        }
    }
    cout<<sum-sum1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	int m;
	cin >> m;
	vector<int> a(m);
	vector<bool> st(n, true);
	vector<int> cnt(n);
	rep(i, m)
	{
		cin >> a[i];
		a[i]--;
		st[a[i]] = false;
	}
	ll ans = 1;

	if (!st[0] && st[+1])
	{
		cnt[0] = 0;
		cnt[1] = 1;
	}
	else if (st[0] and st[1])
	{
		cnt[0] = 1;
		cnt[1] = 2;
	}
	else if (!st[0] && !st[1])
	{
		cnt[0] = 0;
		cnt[1] = 0;
	}
	else if (st[0] && !st[1])
	{
		cnt[0] = 1;
		cnt[1] = 0;
	}
	FOR(i, 2, n)
	{
		if (st[i])
		{
			cnt[i] = cnt[i - 1] + cnt[i - 2];
		}else{
			cnt[i]=0;
		}
		cnt[i]%=M;
	}
	cout<<cnt[n-1]<<endl;
}


Measured memory_bytes: 1024