akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> ga[5];
bool vis[5];
int deg[5];
void dfs(int u){
	vis[u]=true;
	for(int i=0;i<ga[u].size();i++)
	   if(vis[ga[u][i]]==false)
	      dfs(ga[u][i]);
}
int main()
{
	int a,b;
	for(int i=1;i<=3;i++){
		cin>>a>>b;
		ga[a].push_back(b);
		ga[b].push_back(a);
	    deg[a]++;
	    deg[b]++;
	}
	dfs(1);
	int cnt2=0,cnt1=0;
	for(int i=1;i<=4;i++) 
	   if(!vis[i])
	    {
	    	cout<<"NO"<<endl;
	    	return 0;
	    }
	   else if(deg[i]==2)
	   {
	    	cnt2++;
	    }
	    else
	       cnt1++;
	if(cnt2==cnt1)
	   cout<<"YES"<<endl;
	else
	   cout<<"NO"<<endl;
	return 0;
}


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

int N, K;
double ans;

int main() {
  cin >> N >> K;
  
  for (int i = 1; i < N + 1; ++i) {
    double count = 1;
    int I = i;
    while (I < K) {
      count /= 2;
      I *= 2;
    }
    ans += count / N;
  }
  
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

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

class Mondai
{
    static void Main()
    {
        var S = Console.ReadLine();
        var mae = string.Empty;
        var ushiro = string.Empty;
        for (int i=0;i<4;++i)
        {
            if (i < 2) mae += S[i];
            else ushiro+= S[i];
        }
        var ans = "AMBIGUOUS";
        var maeNum = Int32.Parse(mae);
        var ushiroNum = Int32.Parse(ushiro);
        if ((12 < maeNum && 12 < ushiroNum) || (maeNum <= 0 && ushiroNum <= 0) || (12 < maeNum && ushiroNum <= 0) || (12 < ushiroNum && maeNum <= 0)) ans = "NA";
        else if (maeNum <= 0 || 12 < maeNum) ans = "YYMM";
        else if (ushiroNum <= 0 || 12 < ushiroNum) ans = "MMYY";
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
n = int(input())
l = list(map(int,input().split()))
l[0] -= 1
for i in range(n):
  if i == n-1:
    print('Yes')
    break
  if l[i] < l[i+1]:
    l[i+1]-=1
  if l[i] > l[i+1]:
    print('No')
    break

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


vector<ll> fac(300001);
vector<ll> ifac(300001);

ll mod_pow(ll x,ll n,ll mod){//x^n(mod mod)
    ll ans=1;
    while(n!=0){
        if(n&1)ans=ans*x%mod;//例えば、n=5の場合、n=0b101となり、xを2^0回掛けた後に、xを2^2回かける。
                             //x^5=x^(2^2)+x^(2^0)
        x=x*x%mod;//計算量を減らすために、xの累乗計算は
        n=n>>1;//ひとつ上のbitの判定をするためにビットシフト
    }
    return ans;
}

ll mod_c(ll a,ll b,ll mod){
    if(a==0 && b==0) return 1;
    if(a<b||a<0) return 0;
    ll tmp=ifac[a-b]*ifac[b]%mod;
    return tmp*fac[a]%mod;
}

int main(){
    const ll mod=998244353;
    ll n,m,k;
    ll ans=0;
    cin>>n>>m>>k;

    fac[0]=1;
    ifac[0]=1;

    for (ll i=0;i<300000;i++){
        fac[i+1]=fac[i]*(i+1)%mod;
        ifac[i+1]=ifac[i]*mod_pow(i+1,mod-2,mod)%mod;//(i+1)!^-1 =(i+1)!^(M-2)=(i+1)^(M-2) * (i!)^(M-2) #(mod M)
    }

    for(ll x=0;x<=k;x++){
        ans+=mod_c(n-1,x,mod)*m%mod*mod_pow(m-1,n-x-1,mod)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    vector<int> b(N+1);
    for(int i = 1; i < N+1; i++) cin >> b.at(i);
    vector<int> ans(N);

    bool check;
    for(int i = 0; i < N ; i++){
        check = false;
        for(int j = N-i; j >= 1; j--){
            if(b[j] == j){
                b.erase(b.begin() + j);
                ans.at(i) = j;
                check = true;
                break;
            }
        }
        if(check){
            continue;
        }
        else{
            printf("-1\n");
            return 0;
        }
    }

    for (int i = N-1; i >= 0; i--)
    {
        printf("%d\n", ans.at(i));
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];

		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
			c[i] = scan.nextInt();
		}

		int[] sumA = new int[N];
		int[] sumB = new int[N];
		int[] sumC = new int[N];
		int count;

		if(N==1) {
			System.out.println(Math.max(a[0], Math.max(b[0], c[0])));
			scan.close();
		}else {

		for(count=1; count<N;count++) {
			if(count==1) {
				sumA[0] = a[1];
				sumB[0] = b[1];
				sumC[0] = c[1];

				sumA[1] = Math.max(sumA[0]+b[0],sumA[0]+c[0]);
				sumB[1] = Math.max(sumB[0]+a[0],sumB[0]+c[0]);
				sumC[1] = Math.max(sumC[0]+a[0],sumC[0]+b[0]);

//				System.out.println("count="+count+" "+sumA[count]+" "+sumB[count]+" "+sumC[count]+" ");
			}else {
			sumA[count] = Math.max(a[count]+sumB[count-1],a[count]+sumC[count-1]);
			sumB[count] = Math.max(b[count]+sumA[count-1],b[count]+sumC[count-1]);
			sumC[count] = Math.max(c[count]+sumA[count-1],c[count]+sumB[count-1]);

//			System.out.println("count="+count+" "+sumA[count]+" "+sumB[count]+" "+sumC[count]+" ");
			}
		}

		System.out.print(Math.max(sumA[N-1], Math.max(sumB[N-1], sumC[N-1])));
		scan.close();
		}
	}

}


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

int main()
{
    int n; cin >> n;
    vector<int> x(n), l(n);
    rep(i,n) cin >> x[i] >> l[i];
    pair<int, int> ps[n];
    rep(i,n) {
        ps[i] = pair<int, int>(x[i] + l[i], x[i] - l[i]);
    }
    sort(ps, ps + n);

    int ans = 0;
    int a = ps[0].first;

    for (int i = 1; i < n; i++) {
        if (a <= ps[i].second) {
            ans++;
            a = ps[i].first;
        }
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 1920
n = int(input())
s = input()
cou = 0
for i in range(1000):
  i = "{0:03d}".format(i)
  t = 0
  r = 0
  while r!=n:
    if s[r]==i[t]:
      t += 1
    if t==3:
      cou += 1
      r = n-1
    r += 1            
print(cou)


Measured memory_bytes: 68100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int x;
int main(){
	x=read();
	printf("%d\n",360/__gcd(360,x));
	return 0;
}



Measured memory_bytes: 3752
'''
def main():
    S = input()
    cnt = 0
    ans = 0
    f = 1
    for i in range(3):
        if S[i] == 'R':
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)
'''
def main():
    S = input()
    p = S[0] == 'R'
    q = S[1] == 'R'
    r = S[2] == 'R'

    if p and q and r :
        print(3)
    elif (p and q) or (q and r):
        print(2)
    elif p or q or r:
        print(1)
    else:
        print(0)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
#include <iostream>                                                             
#include <iomanip>
using namespace std;
 
int main()
{
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a-d*b;
    f = (double)a/b;
    cout << d << " " << r << " ";
    cout << fixed << f << endl;
    return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  int weight[] = {200, 300, 500, 1000, 1200, 1500};
  int price[] = {380, 550, 850, 380*5*0.8, 550*4*0.85, 850*3*0.88};
  const int MAXW = 5000;
  const int INF = 1<<23;
  vector<int> dp(2*MAXW, INF);
      
  for(int i=0; i<6; i++) dp[weight[i]] = price[i];
  for(int i=0; i<6; i++) {
    for(int j=0; j<=MAXW; j+=100) {
      if(j-weight[i] >= 0) {
	dp[j] = min(dp[j], dp[j-weight[i]] + price[i]);
      }
    }
  }
  
  while(cin >> n, n) {
    cout << dp[n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define int long long
char c[114][114];
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int l=0;l<m;l++){
            if(c[i][l]=='#'){
                if(i==0){
                    if(l==0){
                        if(c[i+1][l]=='.'&&c[i][l+1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(l==m-1){
                        if(c[i+1][l]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(c[i+1][l]=='.'&&c[i][l+1]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
                else if(i==n-1){
                    if(l==0){
                        if(c[i-1][l]=='.'&&c[i][l+1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(l==m-1){
                        if(c[i-1][l]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(c[i-1][l]=='.'&&c[i][l+1]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
                else{
                    if(l==0){
                        if(c[i-1][l]=='.'&&c[i+1][l]=='.'&&c[i][l+1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else if(l==m-1){
                        if(c[i-1][l]=='.'&&c[i+1][l]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                    else{
                        if(c[i-1][l]=='.'&&c[i+1][l]=='.'&&c[i][l+1]=='.'&&c[i][l-1]=='.'){
                            cout<<"No"<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
while True:
    count = 0
    n,x = map(int,input().split())
    if [n,x] == [0,0]:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    count += 1
    print(count)



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

int main() {
    ll N;
    cin >> N;
    vl H(N);
    rep(i, N){
        cin >> H[i];
    }
    ll ans = 0;
    rep(i, N){
        bool ok = true;
        rep(j, i){
            if(!(H[j] <= H[i])){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

int main(){
  int n,p[10005];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
    
  }

  sort(p,p+n);

  int ans=0;
  for(int i=0;i<n;i++){
    ans+=p[i];
    if(i==n-1) ans=ans-p[i]/2;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){

long long l,r; cin>>l>>r;

int mn=2020;
for(long long  i=l;i<=r;i++){
  for(long long  j=l+1;j<=r;j++){
    if(j<=i) continue;
    if(((i*j)%2019) < mn) mn=(i*j)%2019;
    if(mn==0) {cout<<0<<endl; return 0;}
  }
}
cout<<mn<<endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int s;
    string a, b;
    cin >> s >> a >> b;
    
    for (int i = 0; i < s; ++i)
        cout << a[i] << b[i];
}

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

int main(){
        string s, t;
        cin >> s >> t;
        int ans = t.size();
        for(int start = 0; start <= s.size() - t.size(); start++){
            int diff = 0;
            for(int i = 0; i< t.size(); i++){
                if(t[i] != s[start + i]){
                    diff++;
                }
            }
            ans = min(ans, diff);
        }
        cout << ans <<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  vector<int> v(3);
  rep(i,3) cin >> v[i];
  sort(v);
  reverse(v);
  int k;
  cin >> k;
  cout << v[0]*pow(2,k) + v[1] + v[2];
}

Measured memory_bytes: 256
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f+'=7')
            exit()
    
    else:
        dfs(i+1, f+'-'+s[i+1], sum-int(s[i+1]))
        dfs(i+1, f+'+'+s[i+1], sum+int(s[i+1]))

s = input()
dfs(0, s[0], int(s[0]))

Measured memory_bytes: 61884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n;
cin>>n;
ll m =0,a=0,r=0,c=0,h=0;
for(ll i =0;i<n;i++)
{
    string s;
    cin>>s;
   if (s[0]== 'M') m ++;
   if (s[0]== 'A') a ++;
   if (s[0]== 'R') r ++;
if ( s[0]== 'C') c ++;
if ( s[0]== 'H') h ++;
}
ll d[5] = {m,a,r,c,h};
/*for(int i =0;i<n;i++)
{
    cout<<d[i]<<" ";
}*/
int x[10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
int y[10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
int z[10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};
ll ans =0;
for(int i =0;i<10;i++)
{
    ans+=(d[x[i]]*d[y[i]]*d[z[i]]);
}
cout<<ans;
return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> point;

string s;
vector <int> v;
int cnt = 1;

void done(){
  cout << -1;
  exit(0);
}

int main(){
  cin >> s;
  FOR(i, 1, sz(s) - 1){
    if(s[i] != s[ sz(s) - (i + 1) - 1 ])
      done();
  }
  if(s[0] == '0' || s[ sz(s) - 1 ] == '1')
    done();

  int last = 0;
  cout << 1 _ 2 << "\n";
  FOR(i, 1, sz(s) - 1){
    cout << last + 1 _ i + 2 << "\n";
    if(s[i] == '1')
      last = i + 1;
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define int long long
#define endl "\n"

int32_t main()
{
    IOS;
    
    int a,n;
    cin>>a>>n;
    int b=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        b+=x;
    }
    if(b>=a)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 100000
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int n,m;
string hi[105];
int cnt[30], odn, twn, x, y;
int32_t main(void){
    cin>>n>>m;
    REP(i,n) cin>>hi[i];
    REP(i,n) REP(j,m){
        cnt[ hi[i][j] - 'a' ]++;
    }
    if(n==1||m==1){
        REP(i,26){
            if(cnt[i]&1) odn++;
        }
        if(odn>1) puts("No");
        else puts("Yes");
    } else {
        x = ( (n&1) && (m&1) );
        if( n%2 && m%2 ){
            y+= n+m-2;
        }
        else if(n&1){
            y+=m;
        }
        else if(m&1){
            y+=n;
        }
        REP(i,26){
            x-= (cnt[i]&1);
            if(cnt[i]%4>1) y-=2;
        }
        if(x||y<0) puts("No");
        else puts("Yes");
    }
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B, C; cin >> A >> B >> C;
    cout << (C<=A+B ? "Yes":"No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

ll power(ll x, ll y, ll z){
    ll res = 1;
    while(y > 0){
        if(y&1){
            res = (res * x) % z;
        }
        x = (x * x) % z;
        y = (y >> 1);
    }
    return res;
}

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

    int tc = 1;
    //cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        string s;
        cin >> s;
        ll x = count(all(s), '1');
        ll case0 = 0, case1 = 0;
        reverse(all(s));
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                if(x - 1 > 0){
                    case0 = (case0 + power(2ll, (ll)i, x - 1)) % (x - 1);
                }
                case1 = (case1 + power(2ll, (ll)i, x + 1)) % (x + 1);
            }
        }
        for(int i = n - 1; i >= 0; i--){
            int ans = 0;
            ll val = 0;
            if(s[i] == '0'){
                val = (case1 + power(2ll, (ll)i, x + 1)) % (x + 1);
                ans++;
            }else{
                if(x - 1 > 0){
                    val = (((case0 - power(2ll, (ll)i, x - 1)) % (x - 1)) + (x - 1)) % (x - 1);
                    ans++;
                }
            }
            while(val > 0){
                int cnt = __builtin_popcount(val);
                val = val % cnt;
                ans++;
            }
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 3768
#include<cstdio>
int f[4][4];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            printf("%d",f[i][j]);
            putchar(' ');
        }
        puts("");
    }
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vector<P> v(n);
  rep(i, n) {
    int x, y; cin >> x >> y;
    v[i].first = x;
    v[i].second = y;
  }
  sort(v.begin(), v.end());
  ll ans = 0;
  ll count = 0;
  for(int i = 0; ; ++i) {
    for(int j = 0; j < v[i].second; ++j) {
      ++count;
      ans += v[i].first;
      if(count == m) {
	cout << ans;
	return 0;
      }
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long f(long long a, long long c)
{
	if (a < 0) return 0;
	return a / c + 1;
}
int main()
{
	long long a, b, x, an;
	scanf("%lld%lld%lld", &a, &b, &x);
	an = f(b, x) - f(a - 1, x);
	printf("%lld", an);
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	a := ReadInts(N)
	s := make([]int, 1e5+5)
	for _, ai := range a {
		l := ai - 1
		r := l + 3
		if l < 0 {
			l = 0
		}
		s[l]++
		s[r]--
	}
	sum := 0
	max := -1
	for _, vi := range s {
		sum += vi
		if max < sum {
			max = sum
		}
	}
	fmt.Println(max)
}

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: 4040
import math

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

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = V.count(replace)

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = max_list.count(replace)

def combinations(n, m):
    return math.factorial(n) // (math.factorial(n - m) * math.factorial(m))

if replace * A != max_sum:
    ans = combinations(num_replace, num_replace_in_list)
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += combinations(num_replace, i)

print(ans)


Measured memory_bytes: 38640
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int[][] map;
    static int[][] label;


    static ArrayList<String> list;

    static int M;
    static int N;
    static int T;
    static int P;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        System.out.println((int) Math.pow(2, M) * ((1900 * M) + (N - M) * 100));

    }



}


Measured memory_bytes: 21972
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003
 */
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

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

	for (int i = 0; i < n; i++) {
		string line;
		getline(cin, line);

		vector<int> sides(3);
		istringstream iss(line);
		for ( int i = 0; i < 3; i++ ) iss >> sides[i];
		sort( sides.begin(), sides.end() );
		int test = pow( sides[0], 2 ) + pow( sides[1], 2 ) - pow( sides[2], 2 );
		cout << ( test == 0 ? "YES" : "NO" ) << endl;
	}
}

Measured memory_bytes: 3168
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int ab = a + b;
        if (ab % 2 != 0) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println(ab / 2);
        }
    }
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int A[3 * 3] = {};
    int checked[3 * 3] = {};

    rep(i, 9) {
        cin >> A[i];
    }

    int N;
    cin >> N;

    rep(i, N) {
        int b;
        cin >> b;
        rep(k, 9) {
            if (A[k] == b) {
                checked[k] = 1;
                break;
            }
        }
    }

    bool flag = false;
    rep(i, 3) {
        // 
        if (checked[i * 3] && checked[i * 3 + 1] && checked[i * 3 + 2]) {
            flag = true;
            break;
        }
        if (checked[i] && checked[i + 3] && checked[i + 6]) {
            flag = true;
            break;
        }
    }

    if (checked[0] && checked[4] && checked[8]) flag = true;
    if (checked[2] && checked[4] && checked[6]) flag = true;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    map<string, int> cnt;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        cnt[s]++;
    }
    int mx=0;
    for(const auto &x : cnt) if(x.second > mx) mx = x.second;
    for(auto itr=cnt.begin(); itr!=cnt.end(); itr++)
        if(itr->second == mx) cout << itr->first << '\n';
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int s = 0;
  vector<int> a(m);
  rep(i,m) {
    cin >> a.at(i);
    s +=a.at(i);
  }
  if(s>n) {
    cout << -1 <<endl;
  }
  else {
    cout << n-s <<endl;
}
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
int main(){
int a,b=0,i=3,c=0;
while(scanf("%d\n",&a)!=EOF){
if(a==2){
b++;
}
else if(a==1 || a%2==0){
}
else{
while(i<=sqrt(a)){
if(a%i==0){
c++;
break;
}
i=i+2;
}
if(c!=1){
b++;
}
c=0,i=3;
}
}
printf("%d\n",b);
return 0;
}



Measured memory_bytes: 1928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp

#define MAX 105
int A[MAX];
int N;

static int bubble() {
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        for (int j = N-1; j >= i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                cnt++;
            }
        }
    }
    return cnt;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    int c = bubble();
    arrdump(N, A);
    cout << c << "\n";
   return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long 
#define MAXN 310
#define INF 0X3f3f3f3f
const ll inf=1e18;
using namespace std;

int n,m;
ll l;
ll e[MAXN][MAXN];
int ans[MAXN][MAXN];

int main(){
	scanf("%d%d%lld",&n,&m,&l);
	int a,b;
	ll c;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)continue;//注意:在floyd中，a[i][i]必须是0，不能为其他数 
			e[i][j]=inf;
			ans[i][j]=INF;
		}
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d%lld",&a,&b,&c);
		e[a][b]=c;
		e[b][a]=c;
	}
	for(int k=1;k<=n;k++){//第一次floyd
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)continue;
			if(e[i][j]<=l)ans[i][j]=1;
		}
	}
	for(int k=1;k<=n;k++){//第二次floyd 
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]);
			}
		}
	}
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&a,&b);
		if(ans[a][b]>=INF){
			printf("-1\n");
			continue;
		}
		printf("%d\n",ans[a][b]-1);
	}

	
	
}

Measured memory_bytes: 4892
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],ans=1;
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]==a[1]&&a[1]==a[2]){
	    cout<<0<<endl;
	    return 0;
	}
	while(1){
	    sort(a,a+3);
	    a[2]=a[2]-a[0];
	    a[1]=a[1]-a[0];
	    a[0]=0;
	    if((a[0]==0&&a[1]==2&&a[2]==2)||(a[0]==0&&a[1]==0&&a[2]==1)){
	        cout<<ans<<endl;
	        return 0;
	    }
	    a[0]+=2;
        ans++;
	}
	return 0;
}

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

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

void dfs(int x, int y){
	
	if (c[y][x] != 0){
		c[y][x] = 0;
		for (int i = 0; i < 8; i++){
			dfs(x + dx[i], y + dy[i]);
		}
	}

	return;
}

int main(){

	int w, h;

	while (cin >> w >> h, w, h){

		for (int j = 1; j <= h; j++){
			for (int i = 1; i <= w; i++){
				cin >> c[j][i];
			}
		}

		int result = 0;
		for (int j = 1; j <= h; j++){
			for (int i = 1; i <= w; i++){
				if (c[j][i] != 0) {
					dfs(i, j);
					result++;
				}
			}
		}

		cout << result << endl;

	}

	return 0;
}

//??????????????°??£????????????
//???????????±?????????????????????WA?????????
/*
int main(void){

	int w, h;

	while (cin >> w >> h, w, h){
		int c[100][100] = { 0 };
		vector<bool> island;
		island.push_back(false);

		for (int j = 1; j <= h; j++){
			for (int i = 1; i <= w; i++){
				cin >> c[j][i];
			}
		}

		int count = 1;
		for (int j = 1; j <= h; j++){
			for (int i = 1; i <= w; i++){
				if (c[j][i] != 0){

					if (c[j][i - 1] != 0) c[j][i] = c[j][i - 1];
					else if (c[j - 1][i + 1] != 0) c[j][i] = c[j - 1][i + 1];
					else if (c[j - 1][i] != 0) c[j][i] = c[j - 1][i];
					else if (c[j - 1][i - 1] != 0) c[j][i] = c[j - 1][i - 1];
					else{
						c[j][i] = count;
						count++;
						island.push_back(true);
					}

					bool buff = island[c[j][i]];

					island[c[j][i - 1]] = island[c[j - 1][i + 1]] = island[c[j - 1][i]] = island[c[j - 1][i - 1]] = false;
					island[c[j][i]] = buff && true;

				}
			}
		}

		int result = 0;
		vector<bool>::iterator it;
		for (it = island.begin(); it != island.end(); ++it) 	if (*it == true) result++;
		
		cout << result << endl;

	}

	return 0;
}
*/


/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1256
#include<stdio.h>
int N,i,l,r,p;
int G[30][2],pc[30]={0};

char S[4][100]={"Preorder","Inorder","Postorder"};

void pre(int n)
{
	if(n==-1)return;
	printf(" %d",n);
	pre(G[n][0]);
	pre(G[n][1]);
	return;
}

void ino(int n)
{
	if(n==-1)return;
	ino(G[n][0]);
	printf(" %d",n);
	ino(G[n][1]);
	return;
}

void pos(int n)
{
	if(n==-1)return;
	pos(G[n][0]);
	pos(G[n][1]);
	printf(" %d",n);
	return;
}



int main()
{
	void (*funcs[])(int)={pre,ino,pos};
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&p,&l,&r);
		pc[l]=pc[r]=1;
		G[p][0]=l;
		G[p][1]=r;
	}
	for(i=0;i<N;i++)if(!pc[i])p=i;
	for(i=0;i<3;i++)
	{
		puts(S[i]);
		(*(funcs[i]))(p);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 612
while True:
    num = int(input())
    if num == 0:
        break
    else:
        x = input().split()
        for i in range(num):
            x[i] = int(x[i])
        ave = sum(x)/num
        count = 0
        for i in range(num):
            if x[i]<=ave:
                count += 1
        print(count)


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N;
    cin >> N;
    
    vector<i64> A(N);
    rep(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());

    i64 ans = 0;
    vector<i64> vec;
    for(int i = 1; i < (N+2)/2; i++){
        ans += A[i-1];
        vec.emplace_back(A[i]);
    }

    for(int i = 0; i < N - (N+2)/2; i++) ans += vec[i];

    cout << ans << endl;
}


Measured memory_bytes: 5876
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ci cin
#define co cout
#define ed endl
#define vc vector
#define sr string
#define pb push_back
#define st(a,n) sort(a,a+n)
#define ms(a) memset(a,0,sizeof(a))
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,n,k) for(int i=n;i>=k;--i)
#define inf 0x3f3f3f3f
#define exp 1e-6
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod =1e9+7;
const int maxn = 2e5+10;
int main()
{
    int n;
    ci>>n;
    while(n--)
    {
        ll a,b;
        ci>>a>>b;
        if(a==b) co<<2*a-2<<ed;
        else if(min(a,b)+1==max(a,b)) co<<2*min(a,b)-2<<ed;
        else
        {
            ll k=a*b;
            ll t=sqrt(k);
            if(t*t==k) co<<2*t-3<<ed;
            else if(t*(t+1)>=k) co<<2*t-2<<ed;
            else co<<2*t-1<<ed;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

void sort(int64_t* a, int64_t* b, int64_t* c) {
	int64_t t;
	if (*a > *b) { t = *a; *a = *b; *b = t; }
	if (*b > *c) { t = *b; *b = *c; *c = t; }
	if (*a > *b) { t = *a; *a = *b; *b = t; }
}

int main(void) {
	int64_t H, W;
	int64_t i, answer;
	if(scanf("%" SCNd64 "%" SCNd64, &H, &W) != 2) return 1;
	if (H % 3 == 0 || W % 3 == 0) {
		puts("0");
		return 0;
	}
	answer = H < W ? H : W;
	for (i = 1; i < W; i++) {
		int64_t a = i * (H / 2);
		int64_t b = i * (H - H / 2);
		int64_t c = (W - i) * H;
		sort(&a, &b, &c);
		if (c - a < answer) answer = c - a;
	}
	for (i = 1; i < H; i++) {
		int64_t a = i * (W / 2);
		int64_t b = i * (W - W / 2);
		int64_t c = (H - i) * W;
		sort(&a, &b, &c);
		if (c - a < answer) answer = c - a;
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}


Measured memory_bytes: 128
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:53:09 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

X, A, B = nin(3)

print((X - A) % B)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e5 + 5, M = 1e9 + 7;
ll h[N], dp[N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, k;
    cin >> n >> k;
    for (ll i = 1; i <= n; i++)
        cin >> h[i], dp[i] = M;
    dp[n] = 0;
    for (ll i = n; i; i--)
        for (ll j = 1; j <= k; j++)
            if (i + j <= n)
                dp[i] = min(dp[i], dp[i + j] + abs(h[i] - h[i + j]));
    cout << dp[1];
}

Measured memory_bytes: 1920
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
using namespace std;

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>

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

	int numNeg = 0;
	int minAbs = std::numeric_limits<int>::max();
	long long result = 0;
	for(int i = 0; i < N; i++) {
		int a;
		std::cin >> a;
		if(a < 0) {
			numNeg++;
		}

		const int aa = std::abs(a);
		result += aa;
		minAbs = std::min(aa, minAbs);
	}

	if(numNeg % 2 != 0) {
		result -= minAbs * 2;
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

# define INF 0x3f3f3f3f

int N, Z, W;

ll A[2010] = {};
ll dp[2010][2] = {};

ll solve(int idx, int player, ll s1, ll s2) {
  if (idx == N) return abs(s1 - s2);
  if (dp[idx][player] != -1) return dp[idx][player];

  if (player == 0) {
    ll score = -1;
    for (int i = idx; i < N; i++) {
      score = max(score, solve(i + 1, 1, A[i], s2));
    }
    dp[idx][player] = score;
    return score;
  } else {
    ll score = INF;
    for (int i = idx; i < N; i++) {
      score = min(score, solve(i + 1, 0, s1, A[i]));
    }
    dp[idx][player] = score;
    return score;
  }
}

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

  cin >> N >> Z >> W;
  REP(i, N) {
    cin >> A[i];
  }

  REP(i, N) {
    REP(j, 2) {
      dp[i][j] = -1;
    }
  }
  ll score = solve(0, 0, Z, W);
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
n,k = map(int,input().split())
l = list(map(int,input().split()))
if n <= k:
    print("0")
    sys.exit()
l = sorted(l,reverse = True)
hissatu = 0
for i in range(k):
    hissatu += l[i]
total = 0
for j in l:
    total += j
print(total-hissatu)

Measured memory_bytes: 31632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int c[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
	}
	int ret=0;
	for(int i=0;i<a;i++){
		bool ok=true;
		for(int j=0;j<i;j++){
			if(c[j]>c[i])ok=false;
		}
		if(ok)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, l, t; cin >> n >> l >> t;
	vl x(n), w(n); REP(i, n) cin >> x[i] >> w[i];
	
	vl tox(n);
	REP(i, n) {
		tox[i] = (x[i] + t % l * (w[i] == 1 ? 1 : -1) + l) % l;
	}
	

	ll idx = 0;
	REP(i, n) {
		if (w[i] == 1) {
			idx = i;
			break;
		}
	}

	ll cnt = 0;
	REP(i, n) if (w[i] != w[idx]) {
		if (t * 2 <= (x[i] - x[idx] + l) % l) continue;
		ll tr = t * 2 - ((x[i] - x[idx] + l) % l);
		cnt++;
		cnt += tr / l - (tr % l == 0);
	}

	ll i_kizyun = (idx + cnt % n) % n;
	ll i_pos = tox[idx];
	sort(ALL(tox));

	ll idx2;
	REP(i, n) {
		if (tox[i] == i_pos) {
			idx2 = i; break;
		}
	}
	REP(i, n) {
		cout << tox[(i - i_kizyun + idx2 + n) % n] << "\n";
	}

	cout << flush;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<LL> V;
int main(){
    int N;
    cin>>N;
    V a(N);
    cin>>a;
    LL x=a[0];
    LL y=0;

    FOR(i,1,N)y+=a[i];
    LL res=abs(x-y);
    FOR(i,1,N-1){
        x+=a[i];
        y-=a[i];
        chmin(res,abs(x-y));
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)

main ()

Measured memory_bytes: 21628
#include<iostream>
using namespace std;
#include<stdio.h>
#include<algorithm>
int s[1000],a[100000],b[100000],f[100000];
int main()
{
	int j,n,m,i,d,c;
	while(1)
	{
		d=0;
		c=0;
		cin>>n>>m;
		if(n==0&&m==0)
			break;
		for(i=1;i<=n;i++)
			s[i]=0;
		for(i=1;i<=m;i++)
		{
			cin>>a[i]>>b[i];
			if(a[i]==1)
			{
				d++;
				f[d]=b[i];
				s[f[d]]=1;
			}
			if(b[i]==1)
			{
				d++;
				f[d]=a[i];
				s[f[d]]=1;
			}
		}
		for(i=1;i<=m;i++)
		{
			for(j=1;j<=d;j++)
			{
				if(a[i]!=1&&b[i]!=1)
				{
					if(a[i]==f[j])
						s[b[i]]=1;
					if(b[i]==f[j])
						s[a[i]]=1;
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			if(s[i]>=1)
				c++;
		}
		cout<<c<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=3005;
LL n,mo,fac[N],inv[N],c[N][N],g[N][N];
LL qpow(LL x,LL k,LL p)
{
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=p;
		x*=x,x%=p;k>>=1;
	}
	return ret;
}
int main()
{
	cin>>n>>mo;
	fac[0]=1;
	for(int i=1;i<=n+1;i++) fac[i]=(fac[i-1]*i)%mo;
	inv[n+1]=qpow(fac[n+1],mo-2,mo);
	for(int i=n;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mo;
	c[0][0]=1;
	for(int i=1;i<=n;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		  c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
	}
	for(int i=0;i<=n;i++){
		g[i][0]=1;
		for(int j=1;j<=i;j++){
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1))%mo;
		}
	}
	LL ans=0;
	for(int i=0;i<=n;i++){
		LL x=0,f=0,k=1,y=0;
		x=qpow(2,qpow(2,n-i,mo-1),mo);
		y=qpow(2,n-i,mo);
		for(int j=0;j<=i;j++){
			f=(f+(g[i][j]*k)%mo)%mo;
//			cout<<f<<' ';
			(k*=y)%=mo;
		}
		LL ret=c[n][i]*x%mo*f%mo;
//		cout<<i<<' '<<ret<<' '<<f<<' '<<x<<' '<<c[n][i]<<endl;
		if(i&1) ans=(ans-ret+mo)%mo;
		else ans=(ans+ret)%mo;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 139648
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){

  double a[100] = {0};

  while(cin >> a[0]){
    
    for(int i=1;i<10;i++){
      if(i%2 == 1) a[i] = a[i - 1] * 2;
      else a[i] = a[i - 1] / 3;
    }

    for(int i=1;i<10;i++) a[0] += a[i];

    printf("%.8f\n",a[0]);
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int W,H,N;
    cin >> W >> H >> N;
    set<int> st;
    st.insert({W,H,N});
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll x;
  cin >> x;

  for (ll a = -1000; a < 1000; a++) {
    for (ll b = -1000; b < 1000; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << ln;
        return 0;
      }
    }
  }

  return 0;
}

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

using namespace std;

vector< vector<char> > field;
int h,w;
int dx[4] = { 0, 0, 1, -1};
int dy[4] = { 1, -1, 0, 0};
int ans = 0;

int dfs( int y, int x, char c){
  int ny, nx;
  field[y][x] = '.';
  
  for( int i = 0; i < 4; ++i){
    ny = y + dy[i];
    nx = x + dx[i];
    if( 0 <= ny && ny < h && 0 <= nx && nx < w ){
      if( field[ny][nx] == c){
	dfs( ny, nx, c);
      }
    }
  }
  return 0;
}


int main(){
  char tmp;

  while(1){
    ans = 0;
    cin >> h >> w;
    if( h == 0 && w == 0){
      break;
    }
    field.resize(h);
    for( int i = 0; i < h; ++i){
      field[i].resize(w);
      for(int j = 0; j < w; ++j){
	cin >> tmp;
	field[i][j] = tmp;
      }
    }

    for( int i = 0; i < h; ++i){
      for( int j = 0; j < w; ++j){
	if( field[i][j] != '.'){
	  ++ans;
	  dfs( i, j, field[i][j]);
	}
      }
    }

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

Measured memory_bytes: 3640
import heapq
n, m = map(int, input().split())
byte = [[] for _ in range(m+2)]

for _ in range(n):
    a, b = map(int, input().split())
    if a > m+1:
        continue
    byte[a].append(b)
search = []
day = 1
ans = 0
while day-1 != m:
    for b in byte[day]:
        heapq.heappush(search, -b)
    if not search:
        day += 1
        continue
    tmp = -heapq.heappop(search)
    ans += tmp
    day += 1

print(ans)





Measured memory_bytes: 24192
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a, b, c, s;
    cin >> a >> b >> c;
    s = (a + b + c) / 2;
    int ans = sqrt(s * (s - a) * (s - b) * (s - c));
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int gcd(int x,int y)
{
	return y==0?x:gcd(y,x%y);
}
int main()
{
	int n,x;
	scanf("%d",&n);
	scanf("%d",&x);
	n--;
	while(n--)
	{
		int x1;
		scanf("%d",&x1);
		x=gcd(x,x1);
	}
	printf("%d",x);
}


Measured memory_bytes: 256