akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    long[][] DP, SUM;
    DP.length = N+1;
    SUM.length = N+1;
    foreach (i; 0..N+1) {
        DP[i].length = M+1;
        SUM[i].length = M+1;
    }
    auto SS = readln.split.to!(long[]);
    auto TS = readln.split.to!(long[]);

    DP[0][0] = 1;
    foreach (i; 0..N+1) {
        foreach (j; 0..M+1) {
            if (i > 0 && j > 0 && SS[i-1] == TS[j-1]) {
                DP[i][j] = SUM[i-1][j-1];
            }
            SUM[i][j] = DP[i][j];
            if (i > 0) SUM[i][j] += SUM[i-1][j];
            if (j > 0) SUM[i][j] += SUM[i][j-1];
            if (i > 0 && j > 0) SUM[i][j] += P - SUM[i-1][j-1];
            SUM[i][j] %= P;
        }
    }

    writeln(SUM[N][M]);
}

Measured memory_bytes: 66556
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] vect1 = new int[n];
		int[] vect2 = new int[n];
		double keisan = 0.0;
		double inf = Double.POSITIVE_INFINITY;
		for(int i=0;i<n; i++){
			vect1[i] = scan.nextInt();
//				System.out.println(vect1[i]);
		}
		for(int i=0;i<n; i++){
			vect2[i] = scan.nextInt();
		}

		for(int i=0;i<n; i++){
			double zet = 0;
			zet = vect1[i] - vect2[i];
			zet = Math.abs(zet);
			zet = Math.pow(zet,1);
			keisan += zet;
		}
		keisan = Math.pow(keisan, (1.0/1.0));
		System.out.println(keisan);
		keisan = 0.0;

		for(int i=0;i<n; i++){
			double zet = 0;
			zet = vect1[i] - vect2[i];
			zet = Math.abs(zet);
			zet = Math.pow(zet,2);
			keisan += zet;
		}
		keisan = Math.pow(keisan, (1.0/2.0));
		System.out.println(keisan);
		keisan = 0.0;

		for(int i=0;i<n; i++){
			double zet = 0;
			zet = vect1[i] - vect2[i];
			zet = Math.abs(zet);
			zet = Math.pow(zet,3);
			keisan += zet;
		}
		keisan = Math.pow(keisan, (1.0/3.0));
		System.out.println(keisan);
		keisan = 0.0;

		for(int i=0;i<n; i++){
			double zet = 0;
			zet = vect1[i] - vect2[i];
			zet = Math.abs(zet);
			if(zet>keisan){
				keisan = zet;
			}
			
		}
		//keisan = Math.pow(keisan, (1.0/inf));
		System.out.println(keisan);
		keisan = 0.0;
	}
}

Measured memory_bytes: 26516
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    a *= 100;
    b *= 10;
    if ((a + b + c) % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#include<cmath>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=5e5+11;
int N,D,Q,f[MAXN],p[MAXN],A[MAXN];
int main(){
    N=read(),D=read();for(int i=1;i<=N;i++) A[i]=read();
    f[N+1]=1;for(int i=N;i>=1;i--) f[i]=(f[i+1]*2<=A[i])?f[i+1]:f[i+1]+A[i];
    p[0]=D;for(int i=1;i<=N;i++) p[i]=min(p[i-1],abs(p[i-1]-A[i]));
    Q=read();while(Q--){int u=read();printf(f[u+1]<=p[u-1]?"YES\n":"NO\n");}
    return 0;
}



Measured memory_bytes: 8940
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
long long r[2001];
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long c(int n, int k) {
	if (n < 0 || k < 0)return 0;
	long long res = 1;
	int s = 1;
	for (int i = n; i > n - k; i--) {
		res *= i;
		res %= mod;
		res *= r[s];
		res %= mod;
		s++;
	}
	return res;
}
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < 2001; i++) {
		r[i] = modpow(i, mod - 2, mod);
	}
	for (int i = 1; i <= K; i++) {
		long long res = c(K - 1, i - 1) * c(N - K + 1, i);
		res %= mod;
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;


int main() {
	int N,i;
	long long A, B, X[100000], ans;
	scanf("%d %lld %lld", &N, &A, &B);
	for (i = 0; i < N; i++) {
		scanf("%lld", &X[i]);
	}

	ans = 0;
	for (i = 1; i < N; i++) {
		if ((X[i] - X[i - 1])*A > B) {
			ans = ans + B;
		}
		else {
			ans = ans + (X[i] - X[i - 1])*A;
		}
	}
	printf("%lld\n", ans);
}


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

using namespace std;

int main (void) {
      string n;
      int cnt;

      cin >> n;

      for (cnt = 0; cnt < 3; cnt++){
            if (n[cnt] == '1'){
                  n[cnt] = '9';
            }else{
                  n[cnt] = '1';
            }
      }

      cout << n << "\n";

      return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

H, W = map(int,input().split())

# 3の倍数の場合、単に切って終わり
if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

def calc(ans, height, width):
    # 高さが偶数の場合、きれいにわれる
    if height % 2 == 0:
        # 1〜width-1まで全探索
        for lw in range(1, width):
            a = lw * height
            b = (width-lw) * (height//2)
            ans = min(ans, abs(a-b))
    else:
        # 高さが奇数の場合、高さ/2 の切り上げと切り下げを比較
        for lw in range(1,width):
            a = lw * height
            b = (width-lw) * (height//2)
            c = (width-lw) * (height//2 + 1)
            tmp = max(a,b,c) - min(a,b,c)
            ans = min(ans, tmp)

    return ans

ans = min(H,W)
ans = min(ans, calc(ans, H, W))

# H/Wを入れ替え
ans = min(ans, calc(ans, W, H))

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <iostream>
#include <cstring>
#include <cmath>
#include <queue>
#define ull unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
void close(){
       std::ios::sync_with_stdio(false);
       std::cin.tie(0);
}
const ll mod=1e9+7;
ll qpow(ll a,ll b){
	ll ret=1;
	while(b) {
		if (b&1) ret=(ret*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ret;
}
const int maxn=1e4+5;
const int N=1e6+5;
int n,a[maxn],num[N],lcm=1,ans=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) {
		int x=a[i];
		for(int j=2;j*j<=x;j++){
			if(x%j==0){
				int cnt=0;
				while(x%j==0){
					x/=j,cnt++;
				}
				num[j]=max(num[j],cnt);
			}
		}
		if(x!=1) num[x]=max(num[x],1);
	}
	for(int i=2;i<N;i++) 
		if(num[i]){
			lcm=1ll*lcm*qpow(i,num[i])%mod;
		}
	for(int i=1;i<=n;i++){
		ans=(ans+1ll*lcm*qpow(a[i],mod-2)%mod)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2816
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var s = o.a(1);
  var x = [o.a(),o.a()];
  var h = [[],[]], l = s.length;
  var T = "T";
  for(var i = 0; i < l; i++){
    if(s[i] === T)break;
    x[0]--;
  }
  var f = 1, u = 0;
  for(i++; i < l; i++){
    if(s[i] === T){if(u)h[f].push(u); f ^= 1; u = 0;}
    else u++;
  }
  if(u)h[f].push(u);
  for(i = 0; i < 2; i++){
    var set = new Set();
    set.add(x[i]);
    while(h[i].length){
      var t = h[i].pop();
      var set2 = new Set();
      for(var j of set){
        set2.add(j-t);
        set2.add(j+t);
      }
      set = set2;
    }
    if(!set.has(0))return "No";
  }
  return "Yes";
}

Measured memory_bytes: 39156
N, M = list(map(int,input().split()))
max = -float('inf')
x = []
y = []
z = []
for i in range(N):
	xx,yy,zz = list(map(int,input().split()))
	x.append(xx)
	y.append(yy)
	z.append(zz)
for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			s = []
			for m in range(N):
				s.append(i*x[m]+j*y[m]+k*z[m])
			s = sorted(s)
			tmp = sum(s[-1*M:])
			if tmp > max:
				max = tmp
if M==0:
	print(0)
else:
	print(max)

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

int main() {
  string str1, str2;
  cin >> str1 >> str2;
  int N=0;
  int M=0;
  M = str1.size();
  
  for (int i=0;i<M;i++){
  if(str1.at(i) == str2.at(i)){
  }
    else{
    N++;
    }
  }
  if (N == 0){
  cout << "Yes"<< endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    string S;
    cin >> S;
    
    int n=0,s=0, e=0,w=0;
    
    for(int i=0; i<S.length();i++){
        if(S[i]=='N')n++;
        if(S[i]=='W')w++;
        if(S[i]=='S')s++;
        if(S[i]=='E')e++;
    }
    
    if(n){
        if(!s){cout<<"No"<<endl; return 0;}
    }
    
    if(e){
        if(!w){cout<<"No"<<endl; return 0;}
    }
    if(s){
        if(!n){cout<<"No"<<endl; return 0;}
    }
    
    if(w){
        if(!e){cout<<"No"<<endl; return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

A = [[x for x in str(input())] for _ in range(n)]
B = [[x for x in str(input())] for _ in range(m)]

#shift回数, 1軸
num = n - m + 1
check = 0

#起点の設定
for i in range(num):
    for j in range(num):
        C = []
        #要素の追加
        for k in range(m):
            C.append(A[i+k][j:j+m])
        if C == B:
            check += 1

if check >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 1; i <= n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
#define MP make_pair
#define FI first
#define SE second
#define VI vector<int>
#define CLR(x) memset(x, 0, sizeof(x))
#define SZ(x) (x.size())
#ifdef QWERTIER
#define err(x) cerr<<x<<endl;
#else
#define err(x)
#endif
typedef long long LL;


#define N 100010
int a[N], v0, v1, v2;
int main() {
#ifdef QWERTIER
  freopen("in.txt", "r", stdin);
#endif
  int n;
  scanf("%d", &n);
  FOR (i, n) {
    scanf("%d", &a[i]);
    if (a[i] % 4 == 0)
      v2++;
    else if (a[i] % 2 == 0)
      v1++;
    else
      v0++;
  }
  if (v1 == 0) {
    puts(v2 >= v0 - 1 ? "Yes" : "No");
  } else {
    puts(v2 >= v0 ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._600problems
{
    class ARC071_E
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            string t = Read();
            int q = ReadInt();
            bool[] res = new bool[q];
            int[] sSums = new int[s.Length];
            int[] tSums = new int[t.Length];

            for(int i=0;i<s.Length; i++)
            {
                sSums[i] = s[i] == 'A' ? 1 : 2;
                if (i > 0) sSums[i] += sSums[i - 1];
            }
            for (int i = 0; i < t.Length; i++)
            {
                tSums[i] = t[i] == 'A' ? 1 : 2;
                if (i > 0) tSums[i] += tSums[i - 1];
            }

            for (int i = 0; i < q; i++)
            {
                int[] abcd = ReadInts();
                int sVal = sSums[abcd[1] - 1];
                if (abcd[0] >= 2) sVal -= sSums[abcd[0] - 2];
                int tVal = tSums[abcd[3] - 1];
                if (abcd[2] >= 2) tVal -= tSums[abcd[2] - 2];
                res[i] = sVal % 3 == tVal % 3;
            }

            for(int i = 0; i < q; i++)
            {
                WriteLine(res[i] ? "YES" : "NO");
            }
        }

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


Measured memory_bytes: 16952
import java.util.*;

/**
 * A
 */
public class Main {

    void run() {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] A = new int[n];
        int[] B = new int[n];

        int max=0;

        for(int i=0; i<n; i++) {
            A[i] = sc.nextInt();
            if(A[i]>max) {
                max = A[i];
            }
        }

        sc.close();

        countingSort(A, B, max);

        /*
        for(int i=1; i<n; i++) {
            if(i == n-1) {
                System.out.println(" "+B[i]);
            } else {
                System.out.print(" "+B[i]);
            }
        }
        */

        StringBuilder br = new StringBuilder();

        for(int i=0; i<n-1; i++) {
            br.append(B[i]+" ");
        }
        System.out.println(br.append(B[n-1]));

    }

    void countingSort(int[] A, int[] B, int k) {

        int[] C = new int[k+1];

        for(int j=0; j<A.length; j++) {
            C[A[j]]++;
        }

        for(int i=1; i<k+1; i++) {
            C[i] = C[i] + C[i-1];
        }

        for(int j=A.length-1; j>=0; j--) {

            B[C[A[j]]-1] = A[j];
            C[A[j]]--;

        }

    } 

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



Measured memory_bytes: 579372
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  ll N,K; cin>>N>>K;
  vector<ll> A(1e5 + 1);
  for(ll i=0; i<N; i++) {
    ll a,b; cin>>a>>b;
    A[a] += b;
  }

  map<ll,ll> dict;
  for(int i=1; i < (int)A.size(); i++) {
    if(A[i] <= 0) continue;
    dict[i] += A[i];
  }

  ll ans = -1;
  ll left = 0;
  ll right = 0;
  for(auto p: dict) {
    right += p.second;
    // cout << "left:" << left << " right:" << right << endl;
    // cout << "K:" << K << endl;
    if(left < K && K <= right) {
      ans = p.first;
    }
    left += p.second;
    // cout << "left:" << left << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  int n;
  char s[100006][5];
  int cnt[5] = {0};
  scanf("%d", &n);

  int i;
  for(i = 0;i < n;i++){
    scanf("%s", s[i]);
    if(s[i][0] == 'A') cnt[0]++;
    else if(s[i][0] == 'W') cnt[1]++;
    else if(s[i][0] == 'T') cnt[2]++;
    else cnt[3]++;
  }

  printf("AC x %d\n", cnt[0]);
  printf("WA x %d\n", cnt[1]);
  printf("TLE x %d\n", cnt[2]);
  printf("RE x %d\n", cnt[3]);  
  return 0;
}


Measured memory_bytes: 4204
#   Battle

class Monster:
    def __init__(self, hp, attack):
        self.hp = hp
        self.attack = attack
        self.death = False


def battle(monster1, monster2):  # attack monster1 -> monster2
    monster2.hp -= monster1.attack
    if monster2.hp <= 0:
        monster2.death = True
    return monster2.death


a, b, c, d = map(int, input().split())

t_monster = Monster(a, b)
a_monster = Monster(c, d)

# print(t_monster.hp)
# print(a_monster.hp)

while True:
    result = battle(t_monster, a_monster)
    if result:
        print("Yes")
        break
    result = battle(a_monster, t_monster)
    if result:
        print("No")
        break


Measured memory_bytes: 8984
package main
import (
  "fmt"
)
 
func main(){
  var n int
  fmt.Scan(&n)
  n = n % 10
  switch n {
  case 3:
    fmt.Print("bon\n")
  case 0, 1, 6, 8:
    fmt.Print("pon\n")
  default:
    fmt.Print("hon\n")
  }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> C(N + 1, 0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    C[a]++;
  }
  sort(C.begin(), C.end(), greater<int>());
  int res = 0;
  for (int i = K; i <= N; i++) {
    res += C[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
# 2020/07/15
# AtCoder Grand Contest 006 - A

# Input
n = int(input())
s = input()
t = input()
ans = n * 2

for i in range(n):
    j = 0
    while i + j < n :
        if s[i+j] != t[j]:
            break
        j = j + 1

    if i + j == n:
        ans = j + i * 2
        break

print(ans)

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b; cin>>n>>a>>b;
	int p=a/n, q=b/n;
	if(a%n==0||b%n==0) cout<<"OK";
	else if(p==q) cout<<"NG";
	else cout<<"OK";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
H,W = map(int,input().split())

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = min(H,W)

for i in range(1,W):
    a = i*H
    if H%2:
        b = (W-i)*(H//2)
        c = (W-i)*(H//2+1)
        tmp = max(a,b,c) - min(a,b,c)
    else:
        b = (W-i)*(H//2)
        tmp = max(a,b) - min(a,b)
    ans = min(ans, tmp)

H,W = W,H

for i in range(1,W):
    a = i*H
    if H%2:
        b = (W-i)*(H//2)
        c = (W-i)*(H//2+1)
        tmp = max(a,b,c) - min(a,b,c)
    else:
        b = (W-i)*(H//2)
        tmp = max(a,b) - min(a,b)
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,a[105];
int32_t main(){
cin>>n>>m;
ll s=0;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    s=s+a[i];
}
ll ans=0;
for(ll i=0;i<n;i++)
{
   if(a[i]*4*m>=s){
    ans++;
   }
}
if(ans>=m){
    cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>
#include<map>

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		map<char,char> dict;
		while(n--){
			getline(cin,str);
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			char a = tmp[0];
			getline(ss,tmp);
			char b = tmp[0];
			dict[a]=b;
		}
		getline(cin,str);
		n = atoi(str.c_str());
		stringstream ss;
		while(n--){
			getline(cin,str);
			map<char,char>::iterator it;
			if((it = dict.find(str[0])) != dict.end()){
				ss<<dict[str[0]];
			}
			else ss<<str[0];
		}
		cout<<ss.str()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[4][3][10] = {0};
	int n;
	cin >> n;
	for (int i=0;i<n;i++){
		int r,b,c,x;
		cin >> r >> b >> c >> x;
		a[r - 1][b - 1][c - 1] += x;
	}
	for (int i=0;i<4;i++){
		for (int j=0;j<3;j++){
			for (int k=0;k<10;k++){
				cout << ' ' << a[i][j][k]; 
			}
			cout << endl;
		}
		if (i != 3) cout << "####################" << endl;
	}
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<ll, ll> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;

struct uf {
private:
	vector<int> par, ran;
public:
	uf(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

#include<cstring>
struct edge {
	int to, cap, rev;
};
const int mn = 3000;
vector<edge> G[mn];
bool used[mn];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to,cap,(int)G[to].size() });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	rep(i, (int)G[v].size()) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

vector<int> vx[1000];
vector<int> vy[1000];
void solve() {
	int n, m; cin >> n >> m;
	int s = n + n; int t = s + 1;
	rep(i, n) {
		add_edge(s, i, 1);
		add_edge(n + i, t, 1);
	}
	rep(i, m) {
		int x, y; cin >> x >> y;
		x--; y--;
		add_edge(x, n + y, 1);
		vx[x].push_back(i);
		vy[y].push_back(i);
	}
	int ans2 = max_flow(s, t);
	//cout << "hello" << endl;
	uf u(m+1);
	rep(i, n) {
		rep(j, (int)vx[i].size() - 1) {
			int le = vx[i][j];
			int ri = vx[i][j + 1];
			u.unite(le, ri);
		}
		rep(j, (int)vy[i].size() - 1) {
			int le = vy[i][j];
			int ri = vy[i][j + 1];
			u.unite(le, ri);
		}
	}
	int ans1 = 0;
	rep(i, m) {
		if (!u.same(m, i)) {
			ans1++; u.unite(m, i);
		}
	}
	cout << m-ans2 << " " << m-ans1 << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//find_prime();
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
int main()
{

  int n,c=0;
   //double s;
   cin>>n;
   for(int i=2;i<=n;i++)
   {

      if(i%2==0)
      {
        c++;
      }
   }
   double t=n-c;
   //cout<<c<<endl;
      printf("%.10f\n",t/n);
      return 0;
   }




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,bo,ans;
string st;
int main()
{
	getline(cin,st);
	i=0;j=st.size()-1;
	while(i<=j)
	{  
		if(st[i]==st[j]) {i++;j--;continue;}
		if(st[i]=='x') {i++;ans++;continue;}
		if(st[j]=='x') {j--;ans++;continue;}
		bo=1;break;
	}
	if(bo!=1) cout<<ans<<"\n";
	  else cout<<-1<<"\n";
	return 0;
 } 

Measured memory_bytes: 512
#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>;
const int mod = 1000000007;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[100005][2];

int main(){
  string s;
  cin >> s;
  int n = int(s.size());
  dp[0][0] = 1;
  rep(i,n){
    //a+b = 0
    if(s[i]=='0'){
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
    }else{
      dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
    }
    //a+b = 1
    if(s[i]=='0'){
      (dp[i+1][1] += dp[i][1]*2%mod) %= mod;
    }else{
      (dp[i+1][0] += dp[i][0]*2%mod) %= mod;
      (dp[i+1][1] += dp[i][1]*2%mod) %= mod;
    }
  }
  cout << (dp[n][0] + dp[n][1]) % mod << endl;
  return 0;
  
}

Measured memory_bytes: 4508
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn gcd(a: i64, b: i64) -> i64 {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut l: Vec<i64> = vec![a[0]; n];
    let mut r: Vec<i64> = vec![a[a.len() - 1]; n];

    for i in 1..n {
        l[i] = gcd(a[i], l[i - 1]);
    }

    for i in (0..n - 1).rev() {
        r[i] = gcd(a[i], r[i + 1]);
    }

    let mut ans = 1;
    for i in 0..n {
        match (l.get(i.wrapping_sub(1)), r.get(i + 1)) {
            (Some(&l), Some(&r)) => ans = std::cmp::max(ans, gcd(l, r)),
            (None, Some(&r)) => ans = std::cmp::max(ans, r),
            (Some(&l), None) => ans = std::cmp::max(ans, l),
            _ => (),
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long Q, H, S, D;
    scan(Q, H, S, D);
    long N = lread();
    N *= 4;
    long solve(long x)
    {
        if (x == 0)
            return 0;
        long ret = long.max;
        if (8 <= x)
            ret = ret.min((x / 8) * D + solve(x % 8));
        if (4 <= x)
            ret = ret.min((x / 4) * S + solve(x % 4));
        if (2 <= x)
            ret = ret.min((x / 2) * H + solve(x % 2));
        if (1 <= x)
            ret = ret.min((x / 1) * Q + solve(x % 1));
        return ret;
    }

    solve(N).writeln();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,m;

ll sum[100001];
ll a[100000];

int main(){
	cin >> n >> m;
	rep(i,n)cin >> a[i];
	rep(i,n){
		sum[i+1] = sum[i] + a[i];
	}
	map<ll,ll> cnt;
	rep(i,n+1)cnt[sum[i]%m]++;
	ll ans = 0;
	for(map<ll,ll>::iterator it = cnt.begin();it != cnt.end();it++){
		ll num = it->second;
		if(num >= 2){
			num *= (num - 1);
			num /= 2;
			ans += num;
		} 
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
def examA():
    S = SI()
    if S=="AAA" or S=="BBB":
        print("No")
    else:
        print("Yes")
    return

def examB():
    N, A, B = LI()
    loop = N//(A+B)
    ans = loop*A + min(A,N%(A+B))
    print(ans)
    return

def examC():
    A, B = LI()
    ans = -1
    for i in range(1,20000):
        if i*8//100==A:
            if i*10//100==B:
                ans = i
                break
    print(ans)
    return

def examD():
    S = SI()
    Q = I()
    rev = 0
    L = ""; R = ""
    for _ in range(Q):
        q = LSI()
        if q[0]=="1":
            rev += 1
        else:
            c = int(q[1])
            if (c+rev)%2==1:
                L += q[2]
            else:
                R += q[2]
    ans = ""
    if rev%2==0:
        ans = L[::-1] + S + R
    else:
        ans = R[::-1] + S[::-1] + L
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 5272
#include <iostream>
#include <vector>
#include <queue>
#define mp make_pair
#define INF 1e+9
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> PP;
typedef pair<int,PP> P;

int main(){
	int n,m,x,t[10000];
	vector<edge> G[10000];
	int d[10000][401];
	cin >> n >> m >> x;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= 400;j++) d[i][j] = INF;
	}
	d[0][(t[0] - 1) * x + 200] = 0;
	for(int i = 0;i < n;i++) cin >> t[i];
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c; a--;b--;
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(mp(0,mp(0,(t[0] - 1) * x)));
	while(!que.empty()){
		P p = que.top();que.pop();
		int cost = p.first,v = p.second.first,nowt = p.second.second;
		if(d[v][nowt + 200] < cost) continue;
		//cout << v << " " << nowt << " " << cost << endl;
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			int next = nowt;
			if(nowt < 0) next = min(0,nowt + e.cost);
			else if(nowt > 0) next = max(0,nowt - e.cost);
			if((next < 0 && t[e.to] == 2) || (next > 0 && t[e.to] == 0)) continue;
			if(t[e.to] == 2) next = x;
			else if(t[e.to] == 0) next = -x;
			if(d[e.to][next + 200] > d[v][nowt + 200] + e.cost){
				d[e.to][next + 200] = d[v][nowt + 200] + e.cost;
				//cout << e.to << " " << d[e.to][next + 200] << endl;
				que.push(mp(d[e.to][next + 200],mp(e.to,next)));
			}
		}
	}
	int mi = INF;
	for(int i = 0;i <= 400;i++) mi = min(mi,d[n - 1][i]);
	cout << mi << endl;
	return 0;
}

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

int main(){
	long long int d;
	int n,m;
	long long int s[300003];
	while(cin >> d,d){
		cin >> n >> m;
		long long int res = 0;
		s[0] = 0ll;
		s[n] = d;
		s[2 * n] = 2 * d;
		for(int i = 1;i < n;i++) {
			cin >> s[i];
			s[i + n] = s[i] + d;
			s[i + 2 * n] = s[i] + 2 * d;
		}
		sort(s,s + 3 * n);
		for(int i = 0;i < m;i++){
			long long int a;
			cin >> a;
			int pos = lower_bound(s,s + 3 * n,a + d) - s;
			res += min(a + d - s[pos - 1],s[pos] - (a + d));
		}
		cout << res << endl;
	}
	return 0;	
}

Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 5e4+10;
int a[maxn];
string str;
bool cmp(int a,int b)
{
    return a > b;
}
int main()
{
    ll cur = 0;
    cin>>str;
    for (int i = 0;i < str.length();i++)
    {
        cur = (cur + str[i] - '0')%9;
    }
    if(cur == 0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<cur<<endl;

}


Measured memory_bytes: 3700
N = input()
if N == "SUN":
    print(7)
elif N == "SAT":
    print(1)
elif N == "FRI":
    print(2)
elif N == "MON":
    print(6)
elif N == "THU":
    print(3)
elif N == "WED":
    print(4)
elif N == "TUE":
    print(5)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <stdint.h>
#include <algorithm>
#include <map>

using namespace std;

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

  map<int, int> P, M;

  for (int n=1; n<=N; ++n) {
    int a;
    cin >> a;

    auto itrP = P.find(n+a);
    if (itrP == P.end())
      P[n+a] = 1;
    else
      ++P[n+a];

    auto itrM = M.find(n-a);
    if (itrM == M.end())
      M[n-a] = 1;
    else
      ++M[n-a];
  }

  int64_t ans = 0;

  for (auto p : P) {
    auto m = M.find(p.first);

    if (m == M.end())
      continue;

    ans += (int64_t)p.second * m->second;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20864
n, a, b, k = map(int, input().split())
mod = 998244353

MAX = 3 * 10 ** 5

fact = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (MAX + 1)
for i in range(2, MAX + 1):
    inv[i] = inv[mod % i] * (mod - mod // i) % mod

fact_inv = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod


def comb(n, k):
    if n < k:
        return 0
    return fact[n] * fact_inv[n-k] * fact_inv[k] % mod


ans = 0
for ea in range(n + 1):
    ebb = k - ea * a
    if ebb % b == 0:
        eb = ebb // b
        if 0 <= eb <= n:
            ans += comb(n, ea) * comb(n, eb)
            ans %= mod

print(ans)


Measured memory_bytes: 38644
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	ll cnt = 0;
	rep(i, N) {
		if(a[i]==(cnt+1)) {
			cnt++;
		}
	}

	if(cnt==0) {
		cout << -1 << endl;
	} else {
		cout << N - cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
import scala.io.StdIn.{readInt,readLine}

object Main {

  def scan(p:Long,q:Long,rList:List[Long],l:List[Long]):(Int,List[Long]) = {
    val n = p/q
    val r = if(p>=q) p%q else p
    if(r==0) (0, (n::l).reverse)
    else if(rList.contains(r)) {
      val i = rList.reverse.indexWhere(_==r)
      (i+1,(n::l).reverse)
    }
    else scan(10*r, q, r::rList, n::l)
  }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>
      val n = s.split(" ").map(_.toInt)
      val (repeat, value) = scan(n(0),n(1),Nil,Nil)
      println(value.drop(1).mkString)
      if(repeat>0) {
        (0 until repeat-1).foreach(_=>print(' '))
        (repeat-1 until value.length-1).foreach(_=>print('^'))
        println()
      }
    }
  }
}

Measured memory_bytes: 45468
#include<bits/stdc++.h>
#define ll long long
#define for(in1,in2,in3) for (int in1 = in2; in1 < in3; in1++)
#define inf 1e9
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;

int mx,x,y,z,t,u,v,ans,n,m,o;
string s1,s2,ans1;

int main() {
	cin >> s1;
	for(a,0,s1.length()) {
		x+=int(s1[a]-48);
	}
	y = stoi(s1);
	if (y%x == 0) cout << "Yes\n"; else cout << "No\n"; 
}

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

#define lld long double

int main(void) {
	int n; cin >> n;
	vector<lld> p(n+1); for (int i = 1; i <= n; i++) cin >> p[i];
	
	vector< vector<lld> > dp(n+1, vector<lld>(n+1, 0));
	dp[1][1] = p[1]; dp[1][0] = 1-p[1];
	for (int i = 2; i <= n; i++) {
		dp[i][0] = dp[i-1][0] * (1-p[i]);
		for (int j = 1; j <= i; j++) {
			dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i];
		}
	}
	
	lld r = 0.0;
	for (int i = ceil(n/2.0); i <= n; i++) r += dp[n][i];
	
	cout.precision(10);
	cout << r;
	
	return 0;
}

Measured memory_bytes: 141184
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

class P
{
    static void Main(string[] _)
    {
        StringBuilder ans = new StringBuilder();
        StringBuilder S = new StringBuilder(Console.ReadLine());
        StringBuilder T = new StringBuilder(Console.ReadLine());
        int q = int.Parse(Console.ReadLine());
        int[] s = new int[S.Length + 1];
        int[] t = new int[T.Length + 1];
        s[0] = 0;
        for (int i = 0; i < S.Length; i++)
        {
            s[i + 1] = 'A' == S[i] ? s[i] + 1 : s[i] + 2;
        }
        t[0] = 0;
        for (int i = 0; i < T.Length; i++)
        {
            t[i + 1] = 'A' == T[i] ? t[i] + 1 : t[i] + 2;
        }
        for (int i = 0; i < q; i++)
        {
            _ = Console.ReadLine().Split(' ');
            int a = int.Parse(_[0]);
            int b = int.Parse(_[1]);
            int c = int.Parse(_[2]);
            int d = int.Parse(_[3]);
            Console.WriteLine((s[b] - s[a - 1]) % 3 == (t[d] - t[c - 1]) % 3 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 17636
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(/\s/)
  .map(Number);

var ret = 0;
for (var i = 1; i <= input[0]; i++) {
  var s = i.toString().split("");
  var sum = s.map(Number).reduce(function (a, b) {
    return a + b;
  });

  if (input[1] <= sum && sum <= input[2]) ret += i;
}

console.log(ret);


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

#define MOD (1000000000+7)

int main() {
	string L;

	cin >> L;

	int n = L.size();
	vector<vector<long long>> dp( n + 1, vector<long long>( 2 ) );
	dp[0][1] = 1;
	for( int i = 0; i < n; i++ ) {
		if( L[i] == '1' ) {
			dp[i + 1][1] = dp[i][1] * 2 % MOD;
			dp[i + 1][0] = dp[i][1];
		}
		else {
			dp[i + 1][1] = dp[i][1];
		}
		dp[i + 1][0] += dp[i][0] * 3 % MOD;
		dp[i + 1][0] %= MOD;
	}
	long long ans = (dp[n][0] + dp[n][1]) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5760
n, m, k = map(int, input().split())
 
 
#
# Union-Find(素集合データ構造)
# uf = UnionFind(n)
# https://note.nkmk.me/python-union-find/
#
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
uf = UnionFind(n)
ans = [-1]*n
for i in range(m):
    a, b = list(map(int, input().split()))
    ans[a-1] -= 1
    ans[b-1] -= 1
    uf.union(a-1, b-1)
 
for i in range(k):
    c, d = list(map(int, input().split()))
    if uf.same(c-1,d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
 
for i in range(n):
    ans[i] += uf.size(i)
print(*ans)

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

using namespace std;

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

#define int long long

const int MOD = 1e9 + 7;
const int N = 504002;

int n, x;
int a[N + 1], b[N + 1];
int c[N + 1], d[N + 1];
map<int, vector<int> > graph;
map<int, int> color;
int ans;

void dfs(int v)
{
    color[v] = 1;
    for (auto u : graph[v])
    {
        if (color[u] == 0)
        {
            dfs(u);
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) a[n] = a[n] ^ a[i];
    for (int i = 0; i < n; i++) b[n] = b[n] ^ b[i];
    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
            ans++;
    }
    if (!ans)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i <= n; i++) c[i] = a[i];
    for (int i = 0; i <= n; i++) d[i] = b[i];
    sort(c, c + n + 1);
    sort(d, d + n + 1);
    for (int i = 0; i <= n; i++)
    {
        if (c[i] != d[i])
        {
            cout << -1;
            return 0;
        }
    }
    for (int i = 0; i <= n; i++)
    {
        if (a[i] != b[i])
        {
            graph[a[i]].push_back(b[i]);
            color[a[i]] = 0, color[b[i]] = 0;
        }
    }
    color[a[n]] = 0, color[b[n]] = 0;
    for (int i = 0, x = c[0]; i <= n; i++, x = c[i])
    {
        if (color.find(x) != color.end() && color[x] == 0)
        {
            dfs(x);
            ans++;
        }
    }
    cout << ans - 1;
}


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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

int R[123][123];

void fill(int l, int d, int r, int u) {
	if (l > r) swap(l, r);
	if (d > u) swap(d, u);
	for (int i = l; i < r; ++i) {
		for (int j = d; j < u; ++j) {
			R[i][j] = 1;
		}
	}
}

void solve() {
	int w, h; scanf("%d %d", &w, &h);
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y, a; scanf("%d %d %d", &x, &y, &a);
		if (a == 1) {
			// x < xi
			fill(0, 0, x, h);
		} else if (a == 2) {
			// x > xi
			fill(x, 0, w, h);
		} else if (a == 3) {
			// y < yi
			fill(0, 0, w, y);
		} else {
			// y > yi
			fill(0, y, w, h);
		}
	}
	int ans = 0;
	for (int i = 0; i < w; ++i) {
		for (int j = 0; j < h; ++j) {
			if (!R[i][j]) ++ans;
		}
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
good_tenboudai = [1] * N
for _ in range(M):
    a, b = map(int, input().split())
    if H[a - 1] < H[b - 1]:
        good_tenboudai[a - 1] = 0
    elif H[a - 1] > H[b - 1]:
        good_tenboudai[b - 1] = 0
    else:
        good_tenboudai[b - 1] = 0
        good_tenboudai[a - 1] = 0
print(sum(good_tenboudai))


Measured memory_bytes: 19988
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;
#define N 100010
long long n,a[N],pre[N];

bool p(int x)
{
	long long tot=pre[x],node=x+1;
	while(node!=n+1)
	{
		if(tot*2>=a[node]) tot+=a[node++];
		else return false;
	}
	return true;
}

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	int L=1,R=n,mid;
	while(L!=R)
	{
		mid=(L+R)>>1;
		if(p(mid))R=mid;
		else L=mid+1;
	}
	printf("%lld\n",n-L+1);
	return 0;
}

Measured memory_bytes: 1664
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

const int INF = 7+(1e+9);
typedef ll Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 Graph:隣接リスト,dist:各頂点から各頂点までの距離が入る,inter:最短路木の親頂点が入る
//戻値 負閉路が存在しない場合:true,そうでないとき:false
bool shortestPath(const Graph &g,vector<vector<Weight> > &dist,vector<vector<int> > &inter) {
  int n = g.size();
  dist.assign(n,vector<Weight>(n,INF));
  for(int i=0;i<n;i++){
    dist[i][i]=0;
  }
  for(int i=0;i<n;i++){
    for(auto f=g[i].begin();f!=g[i].end();f++){
      dist[i][f->dst]=f->weight;
    }
  }
  inter.assign(n, vector<int>(n,-1));
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(dist[i][k]<INF && dist[k][j]<INF && dist[i][j]>dist[i][k]+dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
          inter[i][j] = k;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    if(dist[i][i]<0){
      return false;
    }
  }
  return true;
}

int main(){
  ll n,m,l;
  cin>>n>>m>>l;
  Graph g(n);    //頂点数vの空隣接リストgを生成
  for(ll i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    if(c<=l){
      g[a].push_back(Edge(a,b,c));
      g[b].push_back(Edge(b,a,c));
    }
  }
  vector<vector<Weight> >dist;
  vector<vector<int> > inter;
  shortestPath(g,dist,inter);
  Graph g2(n);
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      if(dist[i][j]<=l){
        g2[i].push_back(Edge(i,j,1));
        g2[j].push_back(Edge(j,i,1));
      }
    }
  }
  vector<vector<Weight> >dist2;
  vector<vector<int> > inter2;
  shortestPath(g2,dist2,inter2);
  ll q;
  cin>>q;
  for(ll i=0;i<q;i++){
    ll s,t;
    cin>>s>>t;
    s--;
    t--;
    ll ans=dist2[s][t]==INF?-1:dist2[s][t]-1;
    cout<<ans<<endl;
  }
}


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

using namespace std;
#define ll long long int
int const mod=1000000007;
//vector<ll>v1[100001];
//vector<ll>v2(100001,0);
//vector<ll>h(100001,0);

int main()
{
    ll t;
    cin>>t;
    cout<<abs(1-t);
}


Measured memory_bytes: 3628