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

using namespace std;
/*******************************************
****************** BY **********************
******* FUTURE GOOGLE EMPLOYEE *************
****** KARTHICK KUPPURAJ M *****************
********************************************/
#define ms(s, n) memset(s, n, sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define prec(n) fixed<<setprecision(n)
#define sll(x) scanf("%lld",&x);
#define pll(x) printf("%lld",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int ll;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
int arr[400];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    for (int i = 0; i < 2*n; ++i)
    {
        cin>>arr[i];
    }
    sort(arr,arr+2*n);
    ll ans=0;
    for (int i = 0; i < 2*n; i+=2)
    {
        ans+=arr[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;
#include <queue>

int main(void){
    Cin(int, n, m, nr);
    Cins(int, nr, r); For(i, nr) r[i]--;
    Sort(r);
    vc<vc<int>> e(n, vc<int>(n, -1));
    Rep(m){
        Cin(int, a, b, c); a--, b--;
        e[a][b] = e[b][a] = c;
    }
    
    For(i, n){
        vc<int> d(n, 1e9);
        priority_queue<pair<int, int>> q;
        q.emplace(d[i] = 0, i);
        while(!q.empty()){
            int i; tie(ignore, i) = q.top(); q.pop();
            For(j, n){
                if(e[i][j] != -1 && d[j] > d[i] + e[i][j]){
                    d[j] = d[i] + e[i][j];
                    q.emplace(d[j], j);
                }
            }
        }
        e[i] = d;
    }
    
    int ans = 1e9;
    do{
        int t = 0;
        For(i, nr-1) t += e[r[i]][r[i+1]];
        Mini(ans, t);
    }
    while(next_permutation(Range(r)));
    Cout(ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int> 
#define pb push_back
#define w(t)   int t;cin>>t;while(t--) 
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second 
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7

void cal(string s,vector<string> &st,int m)
{
	if(s.size()==m)
	{
		st.pb(s); return ;
	}
	s+='0'; cal(s,st,m);
	s.pop_back();
	s+='1'; cal(s,st,m);
}

vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v; 
}

int main()
{
	fio
	int n,m,x;
	cin>>n>>m>>x;
	vector<vi> ar;
	for(int i=0;i<n;i++)
	{
		vi temp=inp(m+1);
		ar.pb(temp);
	}
	vector<string> st;
	string s="";
	cal(s,st,n);
	int mini=INT_MAX;
	int sts=st.size();
	for(int k=0;k<sts;k++)
	{
		string str=st[k]; vi temp;
		for(int j=0;j<m+1;j++) temp.pb(0);
		int strs=str.size();
		for(int i=0;i<strs;i++)
		{
			if(str[i]=='1')
			{
				for(int j=0;j<m+1;j++)
					temp[j]+=ar[i][j];
			}
		}
		int no=0,temps=temp.size();
		for(int f=1;f<temps;f++)
		{
			if(temp[f]<x){
				no=1; break;
				
			}
		}
		if(no==0)
		{
			if(mini>temp[0])
				mini= temp[0] ;
		}
	}
	if(mini!=INT_MAX)
		cout<<mini<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 3780
import math
pi=math.pi
def rtod(rad):
    return 180/pi*rad
a,b,x=map(int,input().split())


if b/2<x/a**2:
    ans=2*(a**2*b-x)/a**3
    ans=math.atan(ans)
    print(rtod(ans))
else:
    ans=b**2/(2*x)*a
    ans=math.atan(ans)
    print(rtod(ans))


Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _010_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long n = ReadInt();
            var array = ReadInts();
            long sum = 0;
            for (int i = 0; i < n; i++) sum += array[i];
            long div = n * (n + 1) / 2;
            if (sum % div > 0)
            {
                Console.WriteLine("NO");
                return;
            }
            long k = sum / div;
            long kk = k;
            for (int i = 0; i < n; i++)
            {
                long delta = array[(i + 1) % n] - array[i] - k;
                delta *= -1;
                long val = delta / n;
                if (delta < 0 || delta % n > 0 || val > kk)
                {
                    Console.WriteLine("NO");
                    return;
                }
                kk -= val;
            }
            Console.WriteLine("YES");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 18400
import math

def caracal_vs_monster():
    """
    2**0 個                       5
           　                 /       \
    2**1 個               2.5         2.5
           　             /     \      /    \
    2**2 個           1.25   1.25  1.25   1.25
          　          /    \   /   \  /  \   /   \
    2**3 個       0.625  0.625 ...
    """
    # 入力
    H = int(input())
    # H / 2 の何回目で1になるか
    count = int(math.log2(H))
    # 攻撃回数
    attack_count = 0
    for i in range(count+1):
        attack_count += 2 ** i
    return attack_count

result = caracal_vs_monster()
print(result)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int cnt[1000005];

ll gcd(ll i,ll j){
    if(j == 0) return i;
    return gcd(j,i%j);
}

struct Sieve {
        int n;
        vector<int> f,primes;
        
        Sieve(int n=1):n(n),f(n+1){
            f[0] = f[1] = -1;
            for(long long i=2;i<=n;++i){
                if(f[i]) continue;
                primes.push_back(i);
                f[i] = i;
                for(long long j = i*i;j <= n;j += i) {
                    if(!f[j]) f[j] = i;
                }
            }
        }
        
        bool isPrime(int x){return f[x] == x;}
        
        vector<int> factorList(int x){
            vector<int> res;
            while(x != 1){
                res.push_back(f[x]);
                x /= f[x];
            }
            return res;
        }
        
        vector<pair<int,int>> factor(int x){
            vector<int> fl = factorList(x);
            if(fl.size() == 0) return {};
            vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
            for(int p:fl){
                if(res.back().first == p){
                    res.back().second ++;
                }else{
                    res.emplace_back(p,1);
                }
            }
            return res;
        }

        long long divisorCalc(long long x){
            long long res = 1;
            long long now = -1;
            long long nowCnt = 0;
            while(x != 1){
                if(now==f[x]) ++ nowCnt;
                else{
                    res *= nowCnt + 1;
                    now = f[x];
                    nowCnt = 1;
                }
                x /= f[x];
            }
            res *= nowCnt+1;
            return res;
        }
        
};

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n) cnt[a[i]] ++;
    bool p = true;
    bool s = true;
    Sieve sieve(1000005);
    for(int k:sieve.primes){
        int pp = 0;
        for(int j=k;j<1000005;j+=k){
            if(cnt[j]>0) ++pp;
        }
        if(pp>1) p = false;
    }

    for(int i=2;i<1000005;i++){
        if(cnt[i]>1) p = false;
    }

    if(p){
        cout << "pairwise coprime" << endl;
        return 0;
    }

    ll now = a[0];
    for(int i=1;i<n;i++){
        now = gcd(now,a[i]);
    }

    if(now==1){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 19448
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,x,i,j,k,y,z,ans;
    cin>>n>>x;
    ans=0;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	for (i=0;i<n-1;i++)
	{
		y=arr[i]+arr[i+1];
		if (y>x)
		{
			z=y-x;
			ans+=z;
			if (arr[i+1]>=z)
			{
				arr[i+1]-=z;
			}
			else
			{
				arr[i+1]=0;
				z-=arr[i+1];
				arr[i]-=z;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

ll N;
map<ll,ll> A,B;


int main(){

	scanf("%lld",&N);

	ll tmp;
	vector<ll> V;

	for(int i = 0; i < N; i++){

		scanf("%lld",&tmp);
		A[i-tmp]++;
		B[i+tmp]++;
		V.push_back(i-tmp);
		V.push_back(i+tmp);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	ll ans = 0;
	for(int i = 0; i < V.size(); i++){

		ans += A[V[i]]*B[V[i]];
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 51752
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define N_MAX 51
#define X_MAX 51

ll dp[51][51][2501];

int main(){

    ll n,a;
    cin >> n >> a;
    vector<ll> ary(n);
    REP(i,n){
        cin >> ary[i];
    }
    dp[0][0][0] = 1;

    for(ll i = 1;i <= n;i++){

        for(ll j = 0;j <= n;j++){

            for(ll k = 0;k <= 2500;k++){

                if(i >= 1 && ary[i-1] > k){
                    dp[i][j][k] = dp[i-1][j][k];
                }else if(i >= 1 && j >= 1 && ary[i-1] <= k){
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-ary[i-1]];
                }else{
                    dp[i][j][k] = 0;
                }
            }
        }
    }


    ll ans = 0;
    for(ll i = 1;i <= n;i++){
        ans += dp[n][i][i*a];
    }
    cout << ans << endl;

   
    return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B;cin>>A>>B;
    if(A>B) swap(A,B);
    for(int i=0;i<B;i++){
        cout<<A;
    }
    cout<<endl;
}




Measured memory_bytes: 256
# Your code here!

n,k = gets.split.map(&:to_i)

dic = Hash.new(0)

for i in 0..n-1 do
    a,b = gets.split.map(&:to_i)
    dic[a]+=b
end

dic = dic.sort

sum = 0
dic.each do |key,value|
    sum+=value
    if(sum>=k)
        puts key
        exit
    end
end

Measured memory_bytes: 9992
import sys
def f(h,i,j,k):
 z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 a,b,c=f(p,q,r,s),f(r,s,t,u),f(t,u,p,q)
 print(['NO','YES'][a==b==c])


Measured memory_bytes: 5584
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
ll n,k,v[55];

ll solve(ll l,ll r)
{
   vector<ll> t;
   
   for(int i=0;i<=l;i++)    //枚举：左边取到了L，右边取到了R 
      t.push_back(v[i]);
   
   for(int i=r;i<n;i++)
      t.push_back(v[i]);
   
   sort(t.begin(),t.end());   //为什么要排序？ 贪心？ 
                              //放回操作如何处理？ 
   
   ll lim=k-t.size();          
   if(lim<0)return 0;        //枚举的两端元素过多了
   
   ll sum=0;
   for(int i=0;i<t.size();i++){
      if(t[i]<0&&lim>0){    //取出并“扔掉” 
         lim--;
      }else                 //正数留下 
	     sum+=t[i];
   }
   
   //cout<<l<<" "<<r<<" "<<sum<<endl;
   return sum;
}

int main()
{
   cin>>n>>k;
   
   for(int i=0;i<n;i++)  cin>>v[i];
   
   ll ans=0;
   
   for(int i=-1;i<n;i++)
     for(int j=i+1;j<=n;j++){
        ans=max(ans,solve(i,j));
     }
   
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
N = int(input())
W = [input() for i in range(N)]
flag = True

if len(set(W)) == N:
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
        
else:
    print('No')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
    string s;
    int ans = 0 ;
    cin >>s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?') s[i] = 'D';
    }
    cout<<s<<endl;
}



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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int x , y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char t[max];
    int m1, m2;
    
    scanf("%s", t);
    
    m1=strlen(t);
    
    rep(i, m1){
        if (t[i]=='?') {
            t[i]='D';
        }
        printf("%c", t[i]);
        
    }
    
   // printf("%s", t);
    
    return 0;
}



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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const int maxn=(int)3e3+10;

char s[maxn],t[maxn];
int lens,lent;
int dp[maxn][maxn];
bool isv[maxn][maxn][3];
char ans[maxn];

void solve(){
    int cnt=0;
    lens=strlen(s+1);
    lent=strlen(t+1);
    for(int i=1;i<=lens;i++){
        for(int j=1;j<=lent;j++){
            if(s[i]==t[j]){
                dp[i][j]=dp[i-1][j-1]+1;
                isv[i][j][0]=true;
            }
            else{
                if(dp[i][j-1]>dp[i-1][j]){
                    dp[i][j]=dp[i][j-1];
                    isv[i][j][1]=true;
                }
                else{
                    isv[i][j][2]=true;
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
    }
    int i=lens,j=lent;
    while(i>=1&&j>=1){
        if(isv[i][j][0]){
            ans[cnt++]=s[i];
            i--;
            j--;
        }
        else if(isv[i][j][1]){
            j--;
        }
        else{
            i--;
        }
    }
    ans[cnt]='\0'; 
    reverse(ans,ans+cnt);
    puts(ans);
}

int main(void){
    scanf("%s %s",s+1,t+1);
    solve();
    return 0;
}

Measured memory_bytes: 62080
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var dp = new long[Max(4, N + 1)];
		dp[0] = dp[1] = dp[2] = 1;
		dp[3] = 2;
		for (var i = 4; i <= N; i++) dp[i] = (dp[i - 1] + dp[i - 2] + dp[i - 4]) % MOD;
		var ans = 0L;
		var n = N - 1L;
		for (var i = 1; i < n; i++) ans = (ans + dp[i]) % MOD;
		ans = (ans * N % MOD + dp[n]) * n % MOD;
		WriteLine((ans + N + n * n) % MOD);
	}
}

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

int main()
{
    int n;
    cin >> n;
    double ans;
    if (n % 2 == 0) {
        ans = (n / 2) / (double)n;
    } else {
        ans = (n / 2 + 1) / (double)n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,ans = 0;
    cin >> n;

    vector<int>v(n);

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

    for(int i = 0;i < n-1;i++){
        for(int j = (i+1);j < n;j++){
            ans += v[i] * v[j];
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

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

		boolean flg = false;
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				if (i * j == n) {
					flg = true;
					break;
				}
			}
		}
		if (flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	ll X;
	cin >> X;

	for (ll A = 120; A >= -120; A--) {
		for (ll B = -120; B <= 120; B++) {
			if (A * A * A * A * A - B * B * B * B * B == X) {
				cout << A << " " << B << endl;
				return(0);
			}
		}
	}
	cout << "nothing" << endl;
	return(0);
}


Measured memory_bytes: 3576
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      double r = Double.parseDouble(sc.next());
      
      System.out.println(calCircumference(r));
      
    }
  private static double calCircumference(double r) {
        return 2 * Math.PI * r;
    }
}

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

int t[100005],x[100005],y[100005];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
 	{
 		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	}
	int i;
	for(i=1;i<=n;i++)
	{
		int z=y[i]+x[i]-y[i-1]-x[i-1];
		int zz=t[i]-t[i-1];
		if(zz-z<0 || (zz-z)%2!=0){
			printf("No\n");
			break;
		} 
		
		
	}
	if(i==n+1) printf("Yes\n");
    return 0;
}



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

int main()
{
    ll X;
    cin >> X;

    ll ans = 0;
    while (X >= 500)
    {
        X -= 500;
        ans += 1000;
    }
    while (X >= 5)
    {
        X -= 5;
        ans += 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B := ReadInt(), ReadInt()
	if A >= 13 {
		fmt.Println(B)
	} else if A > 5 {
		fmt.Println(B / 2)
	} else {
		fmt.Println(0)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main( ) {
    long long N;
    cin >> N;
    long long ans;
    if ( N%2 == 0 ){
        ans = ( N / 2 ) * ( N - 1 );
    } else {
        ans = N * ( ( N - 1 ) / 2 );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    long long a, b, x; cin >> a >> b >> x;
    double s=2.0*x/(a*a)-b;
    double ans;
    if(s<=0){
        s=sqrt(4.0*x*x/(a*a*b*b)+b*b);
        double l=2.0*x/(a*b);
        double rad=asin(l/s);
        ans=90-rad*180/M_PI;
    } else{
        double rad=atan((b-s)/a);
        ans=rad*180/M_PI;
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				begin(c), std::end(x)
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define V_TYPE				string
#define INF					1e4+1

using namespace std;
typedef long long ll;
typedef vector<V_TYPE> vdef;
typedef vector<vdef> vvdef;
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; }
template<typename T>inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T>inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	int n;
	cin >> n;
	vdef vstr(n);
	for (int i = 0; i < n; ++i) cin >> vstr[i];
	int check = -1;

	int fb = 0;
	int ba = 0;
	int fbba = 0;
	int sum = 0;

	for (int i = 0; i < n; ++i)
	{
		if (vstr[i][0] == 'B' && vstr[i][vstr[i].size() - 1] == 'A')
		{
			++fbba;
		}
		else if (vstr[i][0] == 'B')
		{
			++fb;
		}
		else if (vstr[i][vstr[i].size() - 1] == 'A')
		{
			++ba;
		}


		for (int j = 0; j < vstr[i].size() - 1; ++j)
		{
			if (vstr[i].substr(j, 2) == "AB")
				++sum;
		}
	}

	int ans = 0;
	if (fb + ba == 0)
		if (fbba > 0) ans = sum + fbba - 1;
		else ans = sum;
	else
	{
		chmin(fb, ba);
		ans = sum + fbba + fb;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


int main() {
  string s;  cin >> s;
  //~ int cnt = 0;
  for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == '?')
			s[i] = 'D';
	}
  //~ for (int i = 0; i < (int)s.size(); i++) {
		//~ if (s[i] =='D') {
			//~ cnt++;
		//~ }
		//~ if (i+1 < (int)s.size() && s[i] == 'P' && s[i+1] == 'D')
			//~ cnt++;
	//~ }
	cout<< s;
  return 0; 
} 





Measured memory_bytes: 3756
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_Q = 500;

/* typedef */

/* global variables */

int ss[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) cin >> ss[i];

  int q;
  cin >> q;

  int cnt = 0;
  while (q--) {
    int ti;
    cin >> ti;

    for (int i = 0; i < n; i++)
      if (ti == ss[i]) {
	cnt++;
	break;
      }
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, s, N) for(ll i{N - 1}; i > s - 1; i--)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N, M, C;
  cin >> N >> M >> C;
  vector<ll> B(M);
  for(auto&& i : B){
    cin >> i;
  }
  ll ans{};
  vector<vector<ll>> A(N, vector<ll>(M));
  for(auto&& i : A){
    rep(j, 0, M){
      ll temp;
      cin >> temp;
      i.at(j) = temp * B.at(j);
    }
    if(accumulate(i.begin(), i.end(), 0LL) + C > 0) ans++;
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long H = sc.nextInt();

        PriorityQueue<Entry> sords = new PriorityQueue<Entry>(new EntryComparator());
        for (int i = 0; i < N; i++) {
            sords.add(new Entry(sc.nextLong(), false));
            sords.add(new Entry(sc.nextLong(), true));
        }

        // a, b含めて大きいものを優先して使う
        // でも、bには限りがあるので、bを使い切ったらaで頑張る
        int cnt = 0;
        long aAttach = -1l;
        while (H > 0) {
            Entry entry = sords.poll();

            // Aだったら使いまわす
            if (!entry.isB) {
                aAttach = entry.attack;
                break;
            }

            H -= entry.attack;
            cnt++;
        }

        if (aAttach != -1) {
            cnt += (long) Math.ceil((double) H / aAttach);
        }

        out.println(cnt);
    }

    // 降順に並べる
    static class EntryComparator implements Comparator<Entry> {
        @Override
        public int compare(Entry t1, Entry t2) {
            if (t1.attack < t2.attack) {
                return 1;
            }
            return -1;
        }
    }

    static class Entry {
        long attack;
        boolean isB;

        Entry(long attack, boolean isB) {
            this.attack = attack;
            this.isB = isB;
        }
    }
}


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

int main(void){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    int T=0,px=0,py=0;
    for(int i=0;i<n;i++){
        int t,x,y;
        cin>>t>>x>>y;
        int dt=t-T;
        int dxy=abs(x-px)+abs(y-py);
        if(dt<dxy || dt%2!=dxy%2){
            cout<<"No"<<endl;
            return 0;
        }
        T=t;px=x;py=y;
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


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

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

  LL A, B;
  cin >> A >> B;
  if(A == B){
	cout << 1 << endl;
	return 0;
  }
  
  int tb = 61;
  for(;;--tb)
	if((A>>tb&1) != (B>>tb&1))
	  break;
  A = A & ((1ll<<(tb+1)) - 1);
  B = B & ((1ll<<(tb+1)) - 1);

  LL ans = (1ll<<tb) - A;
  int k = tb-1;
  for(;k>=0;--k)
	if(B>>k&1)
	  break;
  
  LL l1 = (1ll<<tb);
  LL r1 = (1ll<<(k+1)) + (1ll<<tb);
  LL l2 = (1ll<<tb) + A;
  LL r2 = (1ll<<(tb+1));
  if(r1 <= l2)
	ans += r1 - l1 + r2 - l2;
  else
	ans += - l1 + r2;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* common subsequence path recording */

const int maxn = 3005;
struct st { int i,j; st(const int i=-1, const int j=-1) : i(i),j(j) {} };
int dp[maxn][maxn]; st nxt[maxn][maxn]; string val[maxn][maxn], s,t;

int dfs(const int i, const int j)
{
    if (i >= s.size() || j >= t.size()) 
        return 0;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        if (s[i] == t[j]) {
            const int res = dfs(i+1,j+1)+1;
            if (res > ans) {
                ans = res; nxt[i][j] = st(i+1,j+1); val[i][j] = s[i];
            }
        }
        else {
            const int re1 = dfs(i+1,j);
            if (re1 > ans) {
                ans = re1; nxt[i][j] = st(i+1,j);
            }
            const int re2 = dfs(i,j+1);
            if (re2 > ans) {
                ans = re2; nxt[i][j] = st(i,j+1);
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> s >> t) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,s.size()+1) FOR(j,0,t.size())
            nxt[i][j] = st(), val[i][j] = "";
        int i = 0, j = 0; string ans;
        dfs(i,j);
        while (i >= 0 && j >= 0) {
            ans += val[i][j];
            const st& x = nxt[i][j];
            i = x.i; j = x.j;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

int A[200];

ll g(int n, int k){
    if (k == 0)
        return 1;
    if (k == 1)
        return n * 9;
    if (k == 2)
        return n * (n - 1)/2 * 9 * 9;
    assert(0);
}
 
ll f(int now, int n, int k){
    ll ans = 0;
    if (n < k){
        return 0;
    }
        
    if (k == 0){
        return 1;
    }

    // now == 0
    //if (now != 0)
    //    ans += f(now + 1, n - 1, k);
    if (0 && now != 0 && A[now] != 0){ //now != 0/* && A[now] != 0*/){
        ans += g(n - 1, k);
    }
    reps(i, 0, A[now] + 1){
        if (now == 0 && i == 0)continue;
        if (i == A[now]){
            if (i == 0){
                ans += f(now + 1, n - 1, k);
            } else {
                ans += f(now + 1, n - 1, k - 1);
            }

        } else {
            if (i == 0){
                ans += g(n - 1, k);
            } else {
            ans += g(n - 1, k - 1);
            }
        }
    }
    return ans;
}
    
//
int main() {
    string S;
    cin >> S;
    int N = S.size(), K;
    rep(i, N){
        A[i] = S[i] - '0';
        //cout << A[i];
    }
    //cout << endl;
    ll ans = 0;
    cin >> K;
    
    // N - 1 ���ȉ�  n-1 C k 9^k  
    if (K == 3){
        ans = (N - 1) * (N - 2) * (N - 3) / 6 * 9 * 9 * 9;
    } else if (K == 2){
        ans = (N - 1) * (N - 2) / 2 * 9 * 9;
    } else if (K == 1){
        ans = (N - 1) * 9;
    }
    //cout << ans << endl;
    ans += f(0, N, K);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B;
	string S;
	cin >> A >> B >> S;
	for(int i = 0; i < S.length(); i++) {
		if(i == A) {
			if(S[i] != ('-')) {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if(S[i] == '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0;
  int n;cin>>n;
  vector<int> a(n),b(n),c(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];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  for(int i=0;i<n;i++){
    auto itr1=lower_bound(a.begin(),a.end(),b[i]);
    auto itr2=upper_bound(c.begin(),c.end(),b[i]);
    ans+=((itr1-a.begin()))*(c.end()-itr2);
  }
  cout<<ans<<endl;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    vector<string> s(3);
    for(auto& x : s){
        cin >> x;
        reverse(x.begin(), x.end());
    }
    int t = 0;
    while(1){
        if(s[t].empty()){
            cout << char('A' + t) << endl;
            return 0;
        }
        int nex = (s[t].back() - 'a');
        s[t].pop_back();
        t = nex;
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
   ll n,m;
   cin>>n>>m;
   ll sum = 0;
   while(m--)
   {
       ll x;
       cin>>x;
       sum+=x;
   }
   n>=sum?cout<<n-sum<<"\n" : cout<<"-1\n";
    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int A[4][11], B[4][11], C[4][11], D[4][11];

int main() {
  int n;cin >> n;
  for(int i = 0; i < n; i++){
    int w, x, y, z; cin >> w >> x >> y >> z;
    if(w == 1) A[x][y] = A[x][y] + z;
    else if(w == 2) B[x][y] = B[x][y] + z; 
    else if(w == 3) C[x][y] = C[x][y] + z;
    else if(w == 4) D[x][y] = D[x][y] + z;
  }
  for (int i = 1; i <= 3; i++){
    for (int j = 1; j <= 10; j++) {
      cout << " " << A[i][j]; 
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 1; i <= 3; i++){
    for (int j = 1; j <= 10; j++) {
      cout << " " << B[i][j]; 
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 1; i <= 3; i++){
    for (int j = 1; j <= 10; j++) {
      cout << " " << C[i][j]; 
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 1; i <= 3; i++){
    for (int j = 1; j <= 10; j++) {
      cout << " " << D[i][j]; 
    }
    cout << endl;
  }
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

namespace ndifix{
int L1_distance(int x1,int y1,int x2,int y2){
	return (x1<x2?x2-x1:x1-x2)+(y1<y2?y2-y1:y1-y2);
}
}

int main(){
    int n,m;cin>>n>>m;
    vector<int> a(n),b(n),c(m),d(m);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)cin>>c[i]>>d[i];

    int ans=1;
    uint buf;
    for(int i=0;i<n;i++){
        buf=1<<30;
        for(int j=0;j<m;j++){
            if(buf > ndifix::L1_distance(a[i],b[i],c[j],d[j])){
                buf = ndifix::L1_distance(a[i],b[i],c[j],d[j]);
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int sum = 0;
        for(int i = 0; i < M; i++) sum += in.nextInt();
        System.out.println(Math.max(-1, N - sum));
    }
}


Measured memory_bytes: 46292
n = int(input())
A = list(map(int,input().split()))
flg = 0
cnt = 0
while True:
    for i in range(n):
        if A[i] % 2 == 1:
            flg = 1
        A[i] = int(A[i] / 2)
    if flg == 0:
        cnt += 1
    else:
        break
print(str(cnt))

Measured memory_bytes: 3060
N = int(input())
P = [float(p) for p in input().split()]

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j]*(1-P[i])
        dp[i+1][j+1] += dp[i][j]*P[i]

ans = 0
for j in range(N//2+1, N+1):
    ans += dp[N][j]

print(ans)

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

int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    int outlet = 1;
    while(outlet < B){
        outlet--;
        outlet += A;
       ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		sc.close();
		
		long sum = 1;
		int[] ab = new int[26];
		int len = A.length();
		ab[A.charAt(0)-'a'] ++;
		for(int i=1; i<len; i++) {
			sum += i-ab[A.charAt(i)-'a'];
			ab[A.charAt(i)-'a'] ++;
		}
		System.out.println(sum);
	}

}


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

int main() {
  vector<string> days={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string day;
  cin >> day;
  for(int i=0;i<7;i++) {
    if(days.at(i)==day) {
      int ans=7-i;
      cout << ans << endl;
    }
  }
}


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

int main(){
	string in;
	int sum=0, i=0;
	double ave = 0.0;
	while( getline(cin,in), in.length() ){
		int val, amo;
		sscanf(in.c_str(), "%d,%d", &val, &amo);
		sum += val*amo;
		ave += amo;
		i++;
	}
	ave /= i;
	int iAve = (int)(ave+0.5);
	cout << sum << endl;
	cout << iAve << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define inf 1e18
using namespace std;

int main(){
    int N;  cin >> N;
    vector<vector<ll>> A, D;
    A = vector<vector<ll>>(N, vector<ll>(N));
    D = vector<vector<ll>>(N, vector<ll>(N));
    for(int i=0; i<N; i++) for(int j=0; j<N; j++){
        cin >> A[i][j];
        D[i][j] = A[i][j];
    }
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++) for(int j=0; j<N; j++){
            if(D[i][j] > D[i][k] + D[k][j]){
                D[i][j] = D[i][k] + D[k][j];
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++) for(int j=i; j<N; j++){
        bool flag = true;
        for(int k=0; k<N; k++){
            if(i==k || j==k) continue;
            if(D[i][k] + D[k][j] < A[i][j]){
                cout << -1 << endl;
                return 0;
            }else if(D[i][k] + D[k][j] == A[i][j]){
                flag = false;
            }
        }
        if(flag) ans += A[i][j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1664
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e6+5 ;

int n ,x ,a ,b ;
vector<int> aa ,bb ,st ;
int main(){
    cin >> n ;
    for(int i=1;i<=n;++i)st.push_back(i);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        aa.push_back(x);
    }
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        bb.push_back(x);
    }
    int cur = 0 ;
    do{
        if(st==aa) a = cur ;
        if(st==bb) b = cur ;
        ++cur ;
    }while(next_permutation(st.begin(),st.end()));
    cout << abs(a-b) ;
    return 0;
}


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

const int maxn = 100009;
vector<int> e[maxn];
int n, m, a, b, cnt, flag, vis[maxn];

void dfs(int u, int last){
	if (vis[u] != -1){
		if (vis[u] == last) flag = 1;
		return;
	}
	vis[u] = last^1; cnt += vis[u];
	for (int i=0; i<e[u].size(); i++)
		dfs(e[u][i], vis[u]);
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++){
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	memset(vis, -1, sizeof vis);
	dfs(1, 1);
	if (flag) printf("%lld\n", 1LL*n*(n-1)/2 - m);
	else printf("%lld\n", 1LL*n*(n-1)/2 - m - 1LL*cnt*(cnt-1)/2 - 1LL*(n-cnt)*(n-cnt-1)/2);
	return 0;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

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

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

using ll=long long; 

bool hantei(vector<int> a, vector<int> b, int c){
	int sum=c;
	for(int i=0; i<a.size(); i++){
		sum+=a[i]*b[i];
	}
	return sum>0;
}

void solve(){
	int n,m,c;
	cin>>n>>m>>c;
	vector<int>b(m);
	for(int i=0; i<m; i++){
		cin>>b[i];
	}
	vector<vector<int>> a(n, vector<int>(m));
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>a[i][j];
		}
	}
	int cnt=0;
	for(int i=0; i<n; i++){
		if(hantei(a[i],b,c)){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256