akhauriyash/Code-Regression huggingface dataset:
def solve(string):
    a, b, q, *stx = map(int, string.split())
    s = [-10**10]+stx[:a] + [2 * 10**10]
    t = [-10**10]+stx[a:a + b] + [2 * 10**10]
    x = {_q: -1 for _q in stx[-q:]}
    i_s = 0
    i_t = 0
    for _x in sorted(x.keys()):
        while s[i_s] < _x:
            i_s += 1
        while t[i_t] < _x:
            i_t += 1
        l_s, r_s = s[i_s - 1], s[i_s]
        l_t, r_t = t[i_t - 1], t[i_t]
        r_max = max(r_s, r_t)
        l_min = min(l_s, l_t)
        x[_x] = min([
            r_max - _x, _x - l_min, r_t - l_s + min(r_t - _x, _x - l_s),
            r_s - l_t + min(r_s - _x, _x - l_t)
        ])
    return "\n".join([str(x[_x]) for _x in stx[-q:]])


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


Measured memory_bytes: 42640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
var [a,b]=[0,1];
arr.forEach(v=>{
   var [q,x]=v.split(" ").map(Number);
   if(q==1){
      b*=x;
      a*=x;
   }
   else if(q==2)a-=x;
   else if(q==3)a+=x;
});
console.log(a+" "+b);


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

int main(){
    long long A, B, K;
    cin >> A >> B >> K;
    long long C = min(A,B);
    long long i;//answer
    long long counta = 0;
    for(i = C; i >= 1; i--){
        if((A % i == 0) && (B % i == 0)){
            counta++;
        }
        if(counta == K){
            break;
        }
    }
    cout << i << endl;
    system("pause");
    return 0;
}

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

using namespace std;

int dp[123456], a[123456];
const int inf = 0x7f7f7f7f;
int main(){
//    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i)dp[i] = inf;
    dp[0] = 0;
    for(int i = 0; i < n ; ++i){
        for(int j = i + 1; j <= i + k; ++j){
            if(j < n)
            dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>
using namespace std;

int a[100],k=0,va=0,ans=30000;
bool vis[100];
void fun(int st, int n)
{
	if(n>=k){
		if (va<ans)ans=va; 
		return ; 
	}
	
	for(int i=0 ; i<k ;i++)
	{
		if (vis[i]==false) 
		{
			vis[i]=true;
			va+=abs(a[i]-a[st]);
			//cout<<a[i]<<"!!"<<endl;
			fun(i,n+1);
			va-=abs(a[i]-a[st]);
			vis[i]=false;
		
		}
	}
}

int main()
{
//freopen("A - Task Scheduling Problem.txt","r",stdin);
	while(scanf("%d",&a[k])!=EOF)k++;
	
//	for(int j=0; j<k ; j++) cout<<a[j]<<" ";
//	cout<<endl; 
	
	for(int i=0; i<k ;i++)
	{
		fill(vis,vis+k,false);
		vis[i]=true;	
		va=0;
		fun(i,1);
	}
	
	printf("%d",ans);
//fclose(stdin);	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
    char e;
  	string s;
  	cin>>a>>b;
	if(b<a)  
    cout<<a-1<<endl;
    else
      cout<<a<<endl;
  
 return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigDecimal a = new BigDecimal(sc.next());
    BigDecimal b = new BigDecimal(sc.next());
    System.out.println(a.multiply(b).toBigInteger());
  }
}


Measured memory_bytes: 27256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int IN[100001],type[21];
int rui[21][100001];
int dp[1<<20];
int main(){
	int N,M;
	cin>>N>>M;
	rep(i,N){
		cin>>IN[i];
		IN[i]--;
		type[IN[i]]++;
		rui[IN[i]][i]++;
	}
	vector<int>v;
	rep(i,M){
		rep(j,N-1){
			rui[i][j+1]+=rui[i][j];
		}
		v.push_back(i);
	}
	//cout<<rui[0][6]<<endl;
/*int ans=INF;
	do{
		int tmp=0,now=0;
		rep(i,M){
			if(now-1>=0)
				tmp+=(rui[v[i]][now-1]);
	//		cout<<tmp<<" ";
			tmp+=(rui[v[i]][N-1]-rui[v[i]][now+type[v[i]]-1]);
	//		cout<<tmp<<" ";
			now+=type[v[i]];
	//		cout<<endl;
		}
	//	cout<<endl;
		ans=min(tmp,ans);
	}while(next_permutation(v.begin(),v.end())); //??¨?????? O(M!*M) ??????;;??????bitDP???*/
	rep(i,1<<M)dp[i]=99999999;
	dp[0]=0;
	rep(i,1<<M){
		int now=0,used[21];
		rep(j,M){
			used[j]=(i>>j)&1;
			if(used[j])now+=type[j];
		}
		rep(j,M){
			if(used[j])continue;
			int tmp=dp[i];
			if(now-1>=0)
				tmp+=rui[j][now-1];
			tmp+=(rui[j][N-1]-rui[j][now+type[j]-1]);
			dp[i+(1<<j)]=min(dp[i+(1<<j)],tmp);
		}
	}
	cout<<dp[(1<<M)-1]<<endl;
	return 0;
}

Measured memory_bytes: 15272
n = int(input())
l = [input()]

flag = True

for i in range(n-1):
    s = input()
    if s not in l and s[0] == l[-1][-1]:
        l.append(s)
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    string s;
    cin>>s;
    int ans=0;
    int cnt=0;
    REP(i,SZ(s)){
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
            cnt++;
            ans=max(ans,cnt);
        }else cnt=0;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
#170624B
N = int(input())
flag = 0
X = []
ans = 0
for i in range(N):
    a = int(input())
    X.append(a)
    if a == 2:
        flag = 1
b = X[0]
count = 1

#print(X)
if flag == 0:
    ans = -1

else:
    for i in range(N):
        c = X[b-1]
        b = c
        #print(c)
        count += 1
        if c == 2:
            ans = count
            break
if ans == 0:
    ans = -1
    
if X[0] == 2:
    print(1)
else:
    print(ans)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
map<string,int>f,g;
int F(string); 
int G(string s) 
{
    if(g[s]) 
		return g[s];
	int n=s.size(); 
	if(n==1) 
		return g[s]=s[0]-'0'+1;
    int sum=0;
	for(int i=1;i<=n-1;i++) 
	{
		if(n%i==0) 
		{
	        string t=""; 
			for(int j=1;j<=i;j++) 
			{
	            int cur=1; 
	        	for(int k=j-1;k<=n-1;k+=i)
					cur&=s[k]-'0';
	            t+=cur+'0';
	        }
	        sum=(sum+F(t))%mod;
	    }
	}
    return g[s]=sum;
}
int F(string s) 
{
    if(f[s]) 
		return f[s]; 
	int n=s.size(); 
	if(!n) 
		return f[s]=1;
    int sum=0;
	for(int i=1;i<=n;i++)
        sum=(sum+1ll*G(s.substr(0,i))*F(s.substr(i,n))%mod)%mod;
    return f[s]=sum;
}
int main() 
{
	ios::sync_with_stdio(false);
    string s; 
	cin>>s; 
	cout<<F(s)<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

int main() {
	string s;
	cin >> s;

	string buf;
	int ans = 1000;

	rep(i, s.size() - 2){
		rep(j, 3){
			buf[j] = s[i + j];
		}
		ans = min(ans, abs(atoi(buf.c_str()) - 753));
	}

	cout << ans << endl;


    return 0;
}



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

void fnLinkedListSet(list<int>& rltnNum)
{
  list<int>::iterator itltn;
  list<int>::iterator itltEND = rltnNum.end();
  string sCmd;
  int nMaxCmd, nNum;
 
  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> sCmd;
    if (sCmd == "insert")
    {
      cin >> nNum;
      rltnNum.push_front(nNum);
    }
    else if (sCmd == "deleteFirst")
      rltnNum.pop_front();
    else if (sCmd == "deleteLast")
      rltnNum.pop_back();
    else if (sCmd == "delete")
    {
      cin >> nNum;
      for (itltn = rltnNum.begin(); itltn != itltEND; ++itltn)
        if (*itltn == nNum)
        {
          rltnNum.erase(itltn);
          break;
        }
    }
  }
}

void fnLinkedListGet(const list<int>& cnrltnNum)
{
  list<int>::const_iterator itltn;
  list<int>::const_iterator itltEND = cnrltnNum.end();

  for (itltn = cnrltnNum.begin(); itltn != itltEND; ++itltn)
  {
    if (itltn != cnrltnNum.begin()) cout << " ";
    cout << *itltn;
  }
  cout << endl;
}

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

  list<int> ltnNum;
  fnLinkedListSet(ltnNum);
  fnLinkedListGet(ltnNum);

  return 0;
}

Measured memory_bytes: 34376
#include <stdio.h>

int main(){
    int n;
    scanf("%d\n",&n);
    int S[13]={0};
    int H[13]={0};
    int C[13]={0};
    int D[13]={0};
    int i;
    for(i=0;i<n;i++){
        char category;
        int num;
        if(i!=n-1){
            scanf("%c %d\n",&category,&num);
        }else{
            scanf("%c %d",&category,&num);
        }
        if(category=='S'){
            S[num-1]=1;
        }
        else if(category=='H'){
            H[num-1]=1;
        }
        else if(category=='C'){
            C[num-1]=1;
        }
        else if(category=='D'){
            D[num-1]=1;
        }
    }
    int j;
    for(j=0;j<13;j++){
        if(S[j]==0){
            printf("S %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(H[j]==0){
            printf("H %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(C[j]==0){
            printf("C %d\n",j+1);
        }
    }
    for(j=0;j<13;j++){
        if(D[j]==0){
            printf("D %d\n",j+1);
        }
    }
    return 0;
}





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

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

	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x.at(i);
		if (x.at(i) <= (k - x.at(i)))
		{
			distance += x.at(i) * 2;
		}
		else
		{
			distance += (k - x.at(i)) * 2;
		}
	}

	cout << distance << endl;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "sort"
)


func main(){
    var monsterNum int
    fmt.Scan(&monsterNum)
    
    monsterLives := make([]int, monsterNum)
    var hissatsuNum int
    fmt.Scan(&hissatsuNum)
    for i := 0; i < monsterNum; i++ {
        fmt.Scan(&monsterLives[i])
    }
    sort.Sort(sort.Reverse(sort.IntSlice(monsterLives)))

    sum := 0
    for i := hissatsuNum; i < monsterNum; i++ {
        sum = sum + monsterLives[i]
    }
    fmt.Println(sum)
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

template<typename T> struct comb {
	T n,k;
	LL numerator = 1;   //分子
	LL denominator = 1; //分母
	LL ans = 1;
	comb(T a, T b) : n(a), k(b) {set_nd();}

	// function
	/// 分子分母の設定
	void set_nd() {
		for (T i = 0, j = n; i < k; i++,j--) {
			numerator *= j;
			numerator %= MOD;
		}
		for (T i = 1; i < k + 1; i++) {
			denominator *= i;
			denominator %= MOD;
		}
	}
	/// a^b%pの計算
	LL calcInv(LL a,LL b,LL p) {
		if (b == 0) {
			return 1;
		}
		if (b % 2 == 0) {
			LL d = calcInv(a,b/2,p);
			return (d*d)%p;
		}
		return (a * calcInv(a,b-1,p)) % p;
	}

	LL getans() {
		denominator = calcInv(denominator,MOD-2,MOD);
		return (numerator * denominator) % MOD;
	}

};

int main(int argc, char const* argv[])
{
	LL n,m;
	cin >> n >> m;
	map<LL,LL> so;
	for (int i = 2; i < m + 1; i++) {
		if (m % i == 0) {
			so[i]++;
			m /= i;
			i--;
		}
	}
	LL ans = 1;
	for (auto&& var : so) {
		comb<LL> c(n+var.second-1,var.second);
		ans *= c.getans();
		ans %= MOD;
	}

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


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

int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  
  vector<int>A(n);
  rep(i,n)cin>>A[i];
  A.push_back(x);
  sort(A.rbegin(),A.rend());
  int AMax=A[0];
  
  vector<int>B(m);
  rep(i,m)cin>>B[i];
  B.push_back(y);
  sort(B.begin(),B.end());
  int BMin=B[0];
  
  if (AMax<BMin)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];

            string[] op = new String[2] { "+", "-" };
            string[] ansString = new String[8] { $"{a}", "+", $"{b}", "+", $"{c}", "+", $"{d}", "=7" };
            int ansA = a;

            bool notAnswered = true;

            for (int i = 0; i < 2 && notAnswered; i++)
            {
                int ansAB = ansA;
                ansString[1] = op[i];
                if (i == 0) ansAB +=b;
                else ansAB -= b;

                for (int j = 0; j < 2 && notAnswered; j++)
                {
                    int ansABC = ansAB;
                    ansString[3] = op[j];
                    if (j == 0) ansABC += c;
                    else ansABC -= c;

                    for (int k = 0; k < 2 && notAnswered; k++)
                    {
                        int ans = ansABC;
                        ansString[5] = op[k];
                        if (k == 0) ans += d;
                        else ans -= d;

                        if (ans == 7)
                        {
                            foreach (var x in ansString) Console.Write(x);
                            notAnswered = false;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13396
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		sc.close();

		double ans = ((N + 1) / 2) / (double) N;

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 22356
# AOJ DSL_1 A Set - Disjoint Set: Union Find Tree
# Python3 2017.6.23 bal4u

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

n, q = map(int, input().split())
u = UnionSet(n)
for i in range(q):
	cmd, x, y = map(int, input().split())
	if cmd == 0: u.unite(x, y)
	else: print(1 if u.connected(x, y) else 0)


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


int main(){
 ll a,b,k; cin >> a >> b >> k;
  if( a >= k ){ cout << a-k << " " << b << endl;}
  else{ cout << 0 << " "<< max(0LL,a+b-k) << endl;}
  
  return 0;
} 

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

using namespace std;

int main()
{
    int n,x,cnt1=0,cnt2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x%4==0)
            cnt1++;
        else if(x%2==0)
            cnt2++;
    }
    cout<<(cnt1+cnt2/2>=(n/2)?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main()
{
int len;
int i;
char s[10010];
scanf("%s",s);
  
len = strlen(s);

if(s[len-1]!='s'){  
for(i=0;i<len;i++){
printf("%c",s[i]);
}
  printf("s");
}else{
for(i=0;i<len;i++){
printf("%c",s[i]);

}
printf("es");
}
 

return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
string s;
int cnt[26];
vector<char>v;
int main(){
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    if(s.size()!=26){
        for(int i=0;i<s.size();i++)cnt[s[i]-'a']=1;
        for(int i=0;i<26;i++){
            if(cnt[i]!=1){
                cout<<s<<(char)('a'+i)<<endl;
                return 0;
            }
        }
    }
    v.push_back(s[25]);
    for(int i=24;i>=0;i--){
        sort(v.begin(),v.end());
        if(s[i]<s[i+1]){
            if(i==0){
                cout<<(char)(s[0]+1)<<endl;
                return 0;
            }
            cout<<s.substr(0,i);
            for(int j=0;j<v.size();j++){
                if(s[i]<v[j]){
                    cout<<v[j]<<endl;
                    return 0;
                }
            }
        }
        v.push_back(s[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<climits>
#include<cassert>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX (1<<20)

using namespace std;

typedef long long ll;

ll dp[MAX][2],ans;
int N,H,W,r[20][20],CNT=1;

int main(){
  cin >> N;
  while(N--){
    ans = 0;
    cin >> W >> H;
    rep(i,H)rep(j,W)cin >> r[i][j];
    rep(i,MAX)rep(j,2)dp[i][j] = 0;
    rep(i,(1<<W)){
      ll cost = 0;
      bool out = false;
      rep(j,W){
	if( ( (i>>j)&1 ) && ( j-1>=0 && ((i>>(j-1))&1) ) ){
	  out = true;
	  break;
	}
	if( (i>>j)&1 )cost += r[0][j];
      }
      if(out)continue;
      dp[i][0] = cost;
      ans = max(ans,cost);
    }
    int bitmask = (1<<W)-1;
    bool phase = 0;
    REP(y,1,H){
      rep(x,W){
	rep(state,(1<<W)){
	  // not use
	  int nstate = (state>>1)&bitmask;
	  dp[nstate][!phase] = max(dp[nstate][!phase],dp[state][phase]);
	  ans = max(ans,dp[nstate][!phase]);

	  // use y                      x
	  if( (state&1) || ( ( (state>>(W-1))&1 ) && x-1>=0  ) )continue;
	  nstate |= (1<<(W-1));
	  dp[nstate][!phase] = max(dp[nstate][!phase],dp[state][phase]+r[y][x]);
	  ans = max(ans,dp[nstate][!phase]);
	}
	rep(i,(1<<W))dp[i][phase] = 0;
	phase = !phase;
      }
    }

    cout << "Case " << CNT++ << ": " << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 17548
#include<bits/stdc++.h>
using namespace std;
string ppap;
char ch;
int it[2];
int main(){
  cin>>ppap;
  it[0]++;
  for(int i=1;i<4;i++)if(ppap[i]!=ppap[0]){ch=ppap[i];break;}
  for(int i=1;i<4;i++){
    if(ppap[i]==ppap[0])it[0]++;
    else if(ppap[i]==ch)it[1]++;
  }
  if(it[0]==2&&it[1]==2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    int sl = s.length();
    vector<vector<ll>> dp(sl, vector<ll>(2, 0));
    rep(i, sl) {
        if (s[i] == '0') {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1] * 3 % mod;
        }
        else {
            if (i == 0) {
                dp[i][0] = 2;
                dp[i][1] = 1;
            }
            else {
                dp[i][0] = dp[i - 1][0] * 2 % mod;
                dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod;
            }
        }
    }
    cout << (dp[sl - 1][0] + dp[sl - 1][1]) % mod << endl;
    return 0;
}


Measured memory_bytes: 5840
#include <cstdio>
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
#define FOREVER for (;;)
#define FOR(i,a,b) \
for (int (i)=(a);(i)<(b);(i)++)
#define REP(i,a,b) \
for (int (i)=(a);(i)<=(b);(i)++)
#define log(exp) \
printf(#exp" = %d\n", exp)
#define INF 100000000
using namespace std;

const int maxn = 10+3;
int graph[maxn][maxn];
set<int> Set;

int main(void) {
    int N;
    while (cin>>N && N) {
        FOR(i,0, maxn) FOR(j, 0, maxn) graph[i][j] = INF;
        //?????´??°??? fill
        FOR(i,0,10) graph[i][i] = 0;
        
        REP(i,1,N) {//rep N ??????6
            int u,v,d;
            cin>>u>>v>>d;
            graph[u][v] = graph[v][u] = d;
            Set.insert(u);
            Set.insert(v);
        }
        
        FOR(k,0,10)
            FOR(i,0,10)
                FOR(j,0,10)
        graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
        
        int ans = INF, ansNode = 0;
        set<int>::iterator it;
        for (it = Set.begin(); it!=Set.end(); it++) {
            int node = *it;
            int res = 0;
            set<int>::iterator anotherIt;
            for (anotherIt = Set.begin(); anotherIt!=Set.end(); anotherIt++)
                res+=graph[node][*anotherIt];
            if (res<ans) ans = res, ansNode = node;
        }
        
        printf("%d %d\n", ansNode, ans);
        //clear
        Set.clear();
    }
    
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>

int main()
{
        char str[200][300];
        char tmp1[300] = { 0 };
        char tmp2[300] = { 0 };
        int input_number = 0, str_number = 0, str_len = 0;
        int shuffle_number = 0, shuffle_NO = 0, count = 0;

        while ( 1 )
        {
                scanf("%s", str[str_number]);
                if ( str[str_number][0] == '-' )
                {
                        break;
                }

                scanf("%d", &shuffle_number);
                str_len = strlen(str[str_number]);

                while ( shuffle_number > 0 )
                {
                        scanf("%d", &shuffle_NO);
                        strcpy(tmp1, str[str_number]);
                        strcpy(tmp2, tmp1);
                        strcpy(tmp1, tmp2+shuffle_NO);
                        strncat(tmp1, tmp2, shuffle_NO );
                        strcpy(str[str_number], tmp1);

                        shuffle_number = shuffle_number - 1;
                }

                str_number = str_number + 1;

        }

        while ( count < str_number )
        {
                printf("%s\n", str[count]);
                count++;
        }

        return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=998244353;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    if(n<0|k<0||k>n)return 0;
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*inv[n-k]%mod;
}



signed main(){
    int H,W;
    cin>>H>>W;
    if(H>W)swap(H,W);



    int ans=0;
    add(ans,(W-H)*nCk(H+W,W)%mod);

    int ei=nCk(2*H-1,H-1);
    for(int i=0;i<H;i++){
        add(ans,ei);
        int tmp=nCk(W-H+i+1+i,i);
        tmp=tmp*nCk(H-1-i+H-2-i,H-1-i)%mod;
        add(ei,mod-tmp);

        tmp=nCk(W-H+i+i+1,i+1);
        tmp=tmp*nCk(H-2-i+H-1-i,H-1-i)%mod;
        add(ei,tmp);
    }

    ei=nCk(H+W,W);
    for(int i=0;i<H;i++){
        add(ans,ei);
        int tmp=nCk(W-H+i+i,i);
        tmp=tmp*nCk(H-i+H-2-i,H-2-i)%mod;
        add(ei,mod-tmp);

        tmp=nCk(W-H+1+i+i-1,i-1);
        tmp=tmp*nCk(H-1-i+H-1-i,H-1-i)%mod;
        add(ei,tmp);
    }

    ans=ans*mpow(nCk(W+H,W),mod-2)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 17664
class UF:
    def __init__(self, n):
        self.N = n;
        self.d = [-1]*n
    
    def size(self, a):
        x = self.root(a)
        return -self.d[x]

    def root(self, a):
        if self.d[a] < 0:
            return a
        else:
            self.d[a] = self.root(self.d[a])
            return self.d[a]

    def unite(self, a, b):
        x = self.root(a)
        y = self.root(b)
        if self.size(x) < self.size(y):
            x, y = y, x
        self.d[y] = x
    
    def same(self, a, b):
        return self.root(a) == self.root(b)

class Edge:
    def __init__(self, f, t, w):
        self.f = f
        self.t = t
        self.w = w
    def __lt__(self, other):
        return self.w < other.w


def kruskal(edges, n):
    uf = UF(n)
    sum = 0
    for e in sorted(edges):
        if not uf.same(e.f, e.t):
            uf.unite(e.f, e.t)
            sum += e.w
    return sum


n, m = map(int, input().split())
es = []
for i in range(m):
    s, t, w = map(int, input().split())
    es.append(Edge(s, t, w))
print(kruskal(es, n))

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(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, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110;
int n, k, d, cnt[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    ms(cnt, 0);
    cin >> n >> k;
    forn(i, k) {
        cin >> d;
        forn(j, d) {
            int x;
            cin >> x;
            ++cnt[x];
        }
    }
    int ans = 0;
    for1(i, n) {
        if (!cnt[i]) ++ans;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
using namespace std; 

int n,m,a[30][50001];
vector<int> c;

int solve(int i,int sum){
    if(sum<0){
        //cout<<i<<" "<<sum<<" "<<ans;
        return 50001;
    }
    if(a[i][sum]!=0)return a[i][sum];
    if(i==m&&sum==0)return 0;
    if(i==m)return 50001;
    else{
        a[i][sum]=min(solve(i+1,sum),solve(i+1,sum-c[i])+1);
        a[i][sum]=min(solve(i,sum-c[i])+1,a[i][sum]);
        return a[i][sum];
    }
}

int main(void){
    cin>>n>>m;
    c.resize(m,0);
    for(int i=0;i<m;i++){
        cin>>c[i];
    }
    cout<<solve(0,n)<<endl;
    return 0;
}

Measured memory_bytes: 10132
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    String[] s = new String[h];

    for (int i = 0; i < h; i++) {
      s[i] = sc.next();
    }

    char[][] c = new char[h][w];

    int ans = 0;

    // while (true) {
      for (int i = 0; i < Math.pow(2,h+w); i++) {

        for (int j = 0; j < h; j++) {
          c[j] = s[j].toCharArray();
        }

        for (int j = 0; j < h+w; j++) {
          if ((1&i >> j) == 1) {
            if (j < h) {
              for (int l = 0; l < w; l++) {
                // System.out.println(c[j]);
                c[j][l] = 'r';
              }
            } else {
              for (int l = 0; l < h; l++) {
                // System.out.println(c[l][j-h]);
                c[l][j-h] = 'r';
              }
            }
          }
        }

        // System.out.println();

        int count = 0;

        for (int j = 0; j < h; j++) {
          for (int l = 0; l < w; l++) {
            if (c[j][l] == '#') {
              count++;
            }
          }
        }
        if (count == k) {
          ans++;
        }
      }
    // }

    System.out.println(ans);

  }

}


Measured memory_bytes: 37720
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long[] dp = new long[2001];
        for(int i=0;i<=1000;i++)for(int j=0;j<=1000;j++)dp[i+j]++;
		while(sc.hasNext()){
			int n=sc.nextInt();
			n=n>2000?4000-n:n;
			int a=1;
			int b=3;
			int c=3;
			for(int i=0;i<n;i++){
				a+=b;
				b+=c;
				if(i<998){
					c++;
				}else{
					c-=3;
				}
			}
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 19932
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//Union-Find
//複数のカテゴリーに属する配列を、カテゴリーごとに管理することができる。
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n,m;
    cin>>n>>m;
    UnionFind tree(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        tree.unite(a,b);
    }
    set<int>st;
    for(int i=0;i<n;i++){
        st.insert(tree.root(i));
    }
    cout<<st.size()<<endl;

    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n,q,i,j,sum=0,b,c;
  ll num, arr[100001]={0};
  cin>>n;
  for(i=0;i<n;i++){
    cin>>num; sum = sum+num;
    arr[num]++;
  }
  cin>>q;
  for(i=0;i<q;i++){
    cin>>b>>c;
    sum = sum - arr[b]*b + c*arr[b];
    arr[c] = arr[c] + arr[b]; arr[b]=0;
    cout<<sum<<"\n";
  }
}
    
    
  
  

Measured memory_bytes: 4412
#include<stdio.h>

int main(void)

{
	int a, b, n, d;
	scanf("%d %d %d", &n, &a, &b);

	if (a*n < b) {
		printf("%d\n", a*n);
	}

	else {
		printf("%d\n", b);

	}
	return 0;

}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long X){
    cout << ((X-A)<=B && X-A>=0 ? YES : NO) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long X;
    scanf("%lld",&X);
    solve(A, B, X);
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
value, weight = [0], [0]
for _ in range(N):
  v, w = map(int, input().split())
  value.append(v)
  weight.append(w)
record = [[-1] * (W+1) for _ in range(N+1)]
record[0][0] = 0

for i in range(1, N+1): # たて
  for j in range(W+1): # よこ
    if record[i-1][j] != -1:
      if record[i][j] < record[i-1][j]:
        record[i][j] = record[i-1][j]
      if j + weight[i] < W + 1:
        record[i][j + weight[i]] = record[i-1][j] + value[i]
print(max(record[N]))


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        int number = scan.nextInt();
        int bstart = scan.nextInt();
        int ball = 0;
        
        int count;
        int ans = 0;
        for(count = 0 ; count < number ; count++){
            
            ball = scan.nextInt();
            
            if(ball < bstart - ball){
                ans += ball * 2;
            }else{
                ans += (bstart - ball) * 2;
            }
        }
 
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22996
#include<stdio.h>

#define INF 1000000010

int binary_search(int x, int l, int r, int *array){
  while(l < r){
    int m = (r + l) / 2;
    if(array[m] < x) r = m;
    else l = m + 1;
  }
  return l;
}

int main(){
  int n;
  scanf("%d", &n);
  
  int a[n];
  int dp[n];
  
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    dp[i] = -1;
  }
  
  int right = 1;
  dp[0] = a[0];
  for(int i = 1; i < n; i++){
    if(dp[right - 1] >= a[i]){
      dp[right] = a[i];
      right++;
    }else{
      int index = binary_search(a[i], 0, right, dp);
      if(index < right) dp[index] = a[i];
      else dp[right] = a[i], right++;
    }
  }
  
  int len;
  for(len = 0; len < n; len++) if(dp[len] == -1) break;
  
  printf("%d", len);
  
  return 0;
}

Measured memory_bytes: 896
// 2015/06/02 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

class Stack{
private:
	int sp;			// スタックポインタ
	int S[100];		// スタックの配列
public:
	Stack()			{  sp = 0;  }
	bool isFull() const	{  return (sp==100);  }
	bool isEmpty() const	{  return (sp==0);  }
	void push(int d);
	int top();
	void pop();
};

void Stack::push(int d)
{
	if(isFull())
		return;		// 満杯

	S[sp++] = d;		// スタックにデータを追加する
}

int Stack::top()
{
	if(isEmpty())
		return -1;	// 異常終了（空）

	return S[sp-1];		// 頂上のデータ
}

void Stack::pop()
{
	if(isEmpty())
		return;		// 空

	sp--;			// スタックからデータを取り出す
}


int main()
{
	Stack s;

	string expr;
	getline(cin, expr);	// 1行読み込み

	istringstream is(expr);	// 文字列ストリーム

	while(!is.eof()){
		string op;
		is >> op;

		int tmp1, tmp2;

		switch(op[0]){
		case '+':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2+tmp1);
			break;
		case '-':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2-tmp1);
			break;
		case '*':
			tmp1 = s.top();  s.pop();
			tmp2 = s.top();  s.pop();
			s.push(tmp2*tmp1);
			break;
		default:
			istringstream is2(op);
			is2 >> tmp1;
			s.push(tmp1);
			break;
		}
	}

	cout << s.top() << endl;

	return 0;
}

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

using ll = long long;
int main() {
  ll N;
  cin >> N;
    map<ll,ll>A;
    ll ans =0;
    for(ll i=0;i<N;i++){
        ll sub;
        cin >> sub;
        A[sub]=++A[sub];
        ans += sub;
    }
   
    
    ll Q;
    cin >> Q;
    while(Q){
        ll B,C;
        cin >> B >> C;
        
        
        if(A.count(B)){
            ll dis = (C-B)*A[B];
            ans+=dis;
        A[C]+=A.at(B);
        A.erase(B);
        }
        cout << ans << endl;
        
        Q--;
    }
    
}

Measured memory_bytes: 7516
from collections import defaultdict
from bisect import *

s,t = input(),input()
before,count = len(s),0
idx = defaultdict(list)

if not set(t) <= set(s):
  print("-1")
  exit()

for i,l in enumerate(s):
  idx[l] += [i]
  
for c in t:
  N = idx[c]
  index = bisect_left(N, before)
  if index > len(N) - 1:
    before = N[0] + 1
    count += 1
  else:
    before = N[index] + 1
    
print((count - 1) * len(s) + before)

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

int main(){
	int W, H, x, y, r;
	int x_lim, y_lim, y_low, x_low;
	cin >> W >> H >> x >> y >> r;
	x_lim = x + r;
	x_low = x - r;
	y_lim = y + r;
	y_low = y - r;
	
	if (x_lim > W || x_low < 0 || y_lim > H || y_low< 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 3100
import itertools
import numpy as np


def judge(li, T):
    answer = 0
    for i in range(Q):
        a, b, c, d = T[i]
        if li[b - 1] - li[a - 1] == c:
            answer += d
            # print(d)
    return answer


N, M, Q = map(int, input().split())
ans = 0
T = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    T.append([a, b, c, d])


num = list(np.arange(M) + 1)
# print(num)

for tup in itertools.combinations_with_replacement(num, N):
    # num(配列)内のN個分タプルを返す
    # print(df)

    li = list(tup)
    f = judge(li, T)
    ans = max(ans, f)
print(ans)


Measured memory_bytes: 27244
from itertools import product, zip_longest

S = input()
cmb = list(product(["", "+"], repeat=(len(S) - 1)))

formulas = []
for c in cmb:
    formulas.append("".join(x + y for x, y in zip_longest(S, c, fillvalue="")))

ans = 0
for f in formulas:
    ans += eval(f)
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int H, N;
	scanf("%d %d", &H, &N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int a;
		scanf("%d", &a);
		sum += a;
	}
	printf(sum < H ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;
int main(){
	string p,s;
	cin>>p>>s;
	bool f=false;
	p=p+p;
	for (int i=0;i<p.size()-s.size()+1;i++){
		string r=p.substr(i,s.size());
		if(r==s){
			f=true;
			break;
		}
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3212
public class Main{
  public void run(java.io.InputStream in,java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);

    int a, b, i, j, dig;
    for(;sc.hasNextInt();){
/*Input*/
      a = sc.nextInt();
      b = sc.nextInt();

/*answer*/
      dig = caldig(a + b);
      System.out.println(dig);
    }
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in,System.out);
  }

  private static int caldig(int n){
    int i;
    for(i = 1;i < 10;i++){
      if(n / 10 == 0)return i;
      n = n / 10;
    }
    return 0;
  }
}

Measured memory_bytes: 20372
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

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

constexpr int MAXN = 5 + 200000;

vector<int> t[MAXN], nbc[MAXN];
int st[MAXN], en[MAXN], d[MAXN], c[MAXN], p[MAXN];

namespace bit {
  int bit[MAXN];
  void update(int x, int add) {
    for (; x < MAXN; x += x&-x) bit[x] += add;
  }
  int query(int x) {
    int ans = 0;
    for (; x; x -= x&-x) ans += bit[x];
    return ans;
  }
  int query(int l, int r) {
    return query(r) - query(l-1);
  }
  void mod(int x, int newv) {
    update(x, newv - query(x, x));
  }
}

void setsub(int x) {
  if (st[x] == en[x]) {
    bit::mod(st[x], 0);
  } else {
    bit::mod(st[x], -bit::query(1+st[x], en[x]));
  }
}

ll solve(const vector<int>& nodes) {
  vector<int> v = nodes;
  sort(v.begin(), v.end(), [&](const int& a, const int& b)->bool{
    return d[a] > d[b];
    });
  ll ans = 0;
  for (auto u : v) {
    for (auto x : t[u]) {
      if (x != p[u]) {
        ans += (bit::query(st[1], en[1]) - bit::query(st[x], en[x])) * 1LL * bit::query(st[x], en[x]);
        setsub(x);
      }
    }
    if (p[u] != -1) {
      ans += (bit::query(st[1], en[1]) - bit::query(st[u], en[u])) * 1LL * bit::query(st[u], en[u]);
      setsub(u);
    }
  }
  for (int u : v) {
    for (auto x : t[u]) {
      if (x != p[u]) {
        bit::mod(st[x], 1);
      }
    }
    bit::mod(st[u], 1);
  }
  return ans + (int)nodes.size();
}

int tim = 1;
void dfs(int u, int pa, int dep) {
  st[u] = tim++;
  d[u] = dep;
  p[u] = pa;
  bit::update(st[u], 1);

  for (int v : t[u]) {
    if (v == pa) continue;
    dfs(v,u,1+dep);
  }

  en[u] = tim - 1;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n; cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    nbc[c[i]].push_back(i);
  }
  foi (i,1,n) {
    int a,b; cin >> a >> b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  dfs(1,-1,0);
  for (int i = 1; i <= n; ++i) {
    cout << solve(nbc[i]) << '\n';
  }
  return 0;
}


Measured memory_bytes: 40324
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	int t_h, t_s, a_h, a_s;
	
	cin >> t_h >> t_s >> a_h >> a_s;
	
	int i = 0;
	while(a_h > 0 && t_h > 0) {
		if(i % 2 == 0) a_h -= t_s;
		else t_h -= a_s;
		i++;
	}
	
	cout << (t_h > a_h ? "Yes" : "No") << endl;
	
	return 0;
	
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),t=nxtl();
    ll test=0;
    vector <ll> v(n);
    generate(all(v),nxtl);
    bool on=0;
    ll prev=0,next=0;
    for(int i=0;i<n;i++)
    {
        if(on==0)
        {
            on=1;
            prev=v[i];
            next=v[i]+t;
        }
        else
        {
            if(next<v[i])
            {
                test+=next-prev;

            }
            else
                test+=v[i]-prev;
            prev=v[i];
            next=v[i]+t;
        }
    }
    cout<<test+t<<endl;
    
    return 0;   
}




 
 


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int main(){
  int s;
  cin >> s;

  int mem[1000000] = {};

  mem[0] = s;
  int inum = -1;
  bool iFlg = false;
  for(int i=0;i<1000000-1;i++){
    if(mem[i]%2==0){
      mem[i+1]=mem[i]/2;
    } else {
      mem[i+1]=3*mem[i]+1;
    }
    for(int j=0;j<i;j++){
      if(mem[j]==mem[i]){
        iFlg = true;
        inum = i+1;
        break;
      }
    }
    if(iFlg)break;
  }

  cout << inum << endl;

  return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  

}



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

vector<ll> factor(ll a){
    vector<ll> v;
    for(ll i=2; i*i <= a; i++){
        if(a%i != 0) continue;
        while(a % i== 0) a /= i;
        v.push_back(i);
    }
    if(a > 1) v.push_back(a);
    return v;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    map<ll, int> m;
    for(auto e: factor(a)) m[e]++;
    for(auto e: factor(b)) m[e]++;
    int ans = 0;
    for(auto& e: m)  if(e.second == 2) ans++;
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256