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

typedef long long int ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	ll n;
	cin >> n;
	cout << n * (n + 1) / 2;
	
	return 0;
}


Measured memory_bytes: 256
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 3005;
int arr[N][N], dp[N][N];
char c1[N], c2[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> c1 + 1 >> c2 + 1;
    int i = 0, j = 0;
    while (c1[++i] != '\0')
    {
        j = 0;
        while (c2[++j] != '\0')
        {
            if (c1[i] == c2[j])
            {
                if (dp[i][j] < dp[i - 1][j - 1] + 1)
                {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    arr[i][j] = 1;
                }
            }
            if (dp[i - 1][j] > dp[i][j])
            {
                dp[i][j] = dp[i - 1][j];
                arr[i][j] = 2;
            }
            if (dp[i][j - 1] >= dp[i][j])
            {
                dp[i][j] = dp[i][j - 1];
                arr[i][j] = 3;
            }
        }
    }
    i--;
    j--;
    // cout << dp[i][j] << '\n';
    string s = "";
    while (i > 0 && j > 0)
    {
        if (arr[i][j] == 1)
        {
            s += c1[i];
            i--;
            j--;
        }
        else if (arr[i][j] == 2)
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}


Measured memory_bytes: 70784
import java.util.*;

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

        for(int i=1;i<=n;i++){
            int x = i;
            int c = 0;
            while(x>0){
                c += x%10;
                x /= 10;
            }
            if(a<=c&&c<=b){
                ans += i;
            }
        }

        System.out.println(ans);
    }
}


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

const int N = 500001;

namespace SEG {
int st[1 << 20], m;

void init(int n) {
    for (m = 1; n + 2 > m; m <<= 1);
}

void modify(int x, int v) {
    for (x += m; x; x >>= 1) st[x] += v;
}

int query(int l, int r) {
    int ans = 0;
    for (l += m - 1, r += m + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
        if (~l & 1) ans += st[l ^ 1];
        if (r & 1) ans += st[r ^ 1];
    }
    return ans;
}

}

struct query { int l, r, i; };

int a[N], l[N], ans[N];

int main(void) {
    int n, q; scanf("%d %d", &n, &q);
    SEG::init(n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    vector<query> v(q);
    for (int i = 0; i < q; ++i)
        scanf("%d %d", &v[i].l, &v[i].r), v[i].i = i + 1;
    sort(v.begin(), v.end(), [](query q1, query q2) { return q1.r < q2.r; });
    for (int i = 1, p = 0; i <= n; ++i) {
        if (l[a[i]]) SEG::modify(l[a[i]], -1);
        l[a[i]] = i;
        SEG::modify(i, 1);
        while (p < q && v[p].r == i) {
            ans[v[p].i] = SEG::query(v[p].l, v[p].r);
            p++;
        }
    }
    for (int i = 1; i <= q; ++i)
        printf("%d\n", ans[i]);
    return 0;
}

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

string divide[4] = { "dream", "dreamer" , "erase", "eraser" };

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

	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

	bool can = true;
	for (int i = 0; i < S.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; ++j) {
			string d = divide[j];
			if (S.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
}



Measured memory_bytes: 512
N, W = map(int, input().split())
dp = [-1]*(W+1)
dp[0] = 0

# 品物の数ループ
for _ in range(N):
    value, weight = map(int, input().split())
    for i in range(weight, W+1):
        if dp[i-weight] != -1:
            dp[i] = max(dp[i], dp[i-weight]+value)

ans = 0
for i in range(W+1):
    ans = max(ans, dp[i])
print(ans)



Measured memory_bytes: 5920
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int n;
vi x,y;
double ans = 0;

int main(){
  cin >> n;
  rep0(i,n){
    int a,b;  cin >> a >> b;
    x.push_back(a);
    y.push_back(b);
  }
  rep0(i,n){
    for(int j = i+1; j < n; j++){
      ans += sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))*2/n;
    }
  }
  cout << setprecision(10) <<ans;
}


Measured memory_bytes: 256
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1
            

Measured memory_bytes: 3064
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val nCount = s.count { it == 'N' }
    val sCount = s.count { it == 'S' }
    val wCount = s.count { it == 'W' }
    val eCount = s.count { it == 'E' }

    val ans = if (((nCount > 0 && sCount > 0) || (nCount == 0 && sCount == 0))
        && ((wCount > 0 && eCount > 0) || (wCount == 0 && eCount == 0))) "Yes" else "No"
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 34236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).rbegin(), (v).rend())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define DESC(v) sort((v).rbegin(), (v).rend())
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while(Y >= X) {
        ans++;
        X *= 2;
    }
    cout << ans << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

const ll MOD = 998244353;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> left(k), right(k);
  rep (i, k) cin >> left[i] >> right[i];
  vector<ll> dp(n+1);
  vector<ll> dpSum(n+1);
  dp[1] = 1;
  dpSum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    rep (j, k) {
      int l = i - right[j], r = i - left[j];
      if (r < 1) continue;
      l = max(l, 1);
      ll sum = (dpSum[r] + MOD - dpSum[l-1]) % MOD;
      dp[i] += sum;
      dp[i] = dp[i] % MOD;
    }
    dpSum[i] = (dpSum[i-1] + dp[i]) % MOD;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
string S;
cin>>S;
 if (S.compare("SUN")==0){
     cout<<7;}
 else if(S.compare("MON")==0){

     cout<<6;}
 else if(S.compare("TUE")==0){
     cout<<5;}
else if(S.compare("WED")==0){
     cout<<4;}
 else if(S.compare("THU")==0){
     cout<<3;}
 else if(S.compare("FRI")==0){
     cout<<2;}
 else if(S.compare("SAT")==0){
     cout<<1;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    int ans=1, _max=h[0];
    for (int i = 1; i < n; i++)
    {
        if(_max<=h[i]){
            ans++;
            _max = h[i];
        }
    }
    cout << ans << endl;
}

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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int32_t main()
{



	FASTIO;

	int n; cin >> n;

	if (n % 1000 == 0)
	{
		cout << 0;
	}
	else {
		int x = n / 1000;
		cout << 1000 * (x + 1) - n;
	}

}

Measured memory_bytes: 3648
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			String temp = reader.readLine();
			int x = Integer.parseInt(temp);
			System.out.println(x*x*x);
		}catch( IOException e ){
			System.out.println(e);
		}catch( NumberFormatException e ){
			System.out.println("Input only 1data");
		}
		return;
	}
}

Measured memory_bytes: 17056
import java.util.*;
 
class Main {
  
   public static int findSumOfDigits (int n){
     int sum = 0;
     while(n>0){
       sum += n%10;
       n = n/10;
     } 
     return sum;
   }
  
  
    public static void main(String[] args) {
      
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int total = 0;
      
      for(int i = 1;i<=N;i++){
        int sum = findSumOfDigits(i);
        if(A<=sum&&sum<=B){
          total = total + i;
        }
      }
		System.out.print(total);
    }
}

Measured memory_bytes: 23764
#include <cstdio>
double P[102][101];
char L[101],B[101];
int main(){
	int N,T,l,b,x,t,n,k;
	for(;scanf("%d%d%d%d",&N,&T,&l,&b),N;){
		for(n=0;n<=N;n++)for(L[n]=B[n]=t=0;t<=T;t++)P[t][n]=0;
		for(;l--;)scanf("%d",&x),L[x]=1;
		for(;b--;)scanf("%d",&x),B[x]=1;
		for(P[t=0][0]=1;t<T;P[t+1][N]+=P[t][N],t++)for(n=0;n<N;n++){
			for(k=1;k<=6;k++){
				x=n+k;
				if(x>N)x=2*N-x;
				if(B[x])x=0;
				P[t+1+L[x]][x]+=P[t][n]/6;
			}
		}
		printf("%f\n",P[T][N]);
	}
}

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

int main(){
vector<char> data(4);
int i;

for(i=0;i<=3;i++){
  cin >>data.at(i);
}


for(i=0;i<3;i++){
  if(data.at(i)==data.at(i+1)){
    cout<<"Bad"<<endl;
    break;
  }
  if(i==2){
    cout<<"Good"<<endl;
  }
}

return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int b[n+1];
    for (int i = n; i >= 1; i--) {
        b[i] = a[i];
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                a[j] ^= b[i];
                if (j * j != i && j != i) {
                    a[i/j] ^= b[i];
                }
            }
        }
    }

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        cnt += b[i];
    }

    cout << cnt << endl;
    bool f = false;
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            cout << (f ? " " : "") << i;
            f = true;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200];
long long w[110],v[110];



int main() {
   long long a;
   cin>>a;
   dp[0]=0;
   for(long long i=1;i<100200;i++){
       dp[i]=1;
   }
   rep(i,100000){
       if(dp[i]==0){
           dp[i+100]=0;
           dp[i+101]=0;
           dp[i+102]=0;
           dp[i+103]=0;
           dp[i+104]=0;
           dp[i+105]=0;
       }
   }
   if(dp[a]==0){
       cout<<1<<endl;
   }
   else{
       cout<<0<<endl;
   }
}


Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double r = sc.nextDouble();
		double s = r * r * Math.PI;
		double l = 2 * r * Math.PI;

		BigDecimal src_s = BigDecimal.valueOf(s);
		BigDecimal src_l = BigDecimal.valueOf(l);
		src_s = src_s.setScale(6, BigDecimal.ROUND_DOWN);
		src_l = src_l.setScale(6, BigDecimal.ROUND_DOWN);

		System.out.println(src_s + " " + src_l);

	}

}



Measured memory_bytes: 28356
#include <stdio.h>
#include <stdlib.h>
//#include <limits.h>
//#include <math.h>

//昇順
int acs(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n], s[n+1]; long cnt = 1, ans = 0;
  s[n] = 0;
  for (int i=0; i<n; i++) scanf("%d", a+i);
  for (int i=0; i<n; i++) a[i] %= m;
  s[0] = a[0];
  for (int i=1; i<n; i++) s[i] = (s[i-1] + a[i]) % m;
  qsort(s, n+1, sizeof(int), acs);
  for (int i=1; i<n+1; i++) {
    if (s[i] == s[i-1]) {
      ans += cnt;
      cnt++;
    } else cnt = 1;
  }
  printf("%ld\n", ans);
  return 0;
}


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

int main() {
    int n;
    string result;
    vector<int> a;
    vector<int>::reverse_iterator begin,end;
    cin >> n;
    for (int c = 0; c < n; c++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    begin = a.rbegin();
    end = a.rend();

    for (;begin != end; begin++) {
        result += to_string(*begin) + " ";
    }
    result.erase(result.size() - 1);
    cout << result << endl;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int res = -1;
    rep(i, 1, 1001)
        if ((int) (i * 0.08) == a && (int)(i * 0.1) == b)
        {
            res = i;
            break;
        }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int root;
  root = sqrt(N) + 1;
  int p = 0;
  int count = 0;
  bool frag = true;
  for(int i = 0; i < N; i++){
    count = 0;
    for(int j = 1; j < root; j++){
      for(int k = 1; k < root; k++){
        for(int l = 1; l < root; l++){
          p = j * j + k * k + l * l + j * k + k * l + l * j;
          if(p == (i + 1)){
            count++;
            //cout << i << " " << p << " "<<j<<" "<<k<<" "<<l<<endl;
          }
          if(p > (i + 1)) break;
          if(p < (i+1)) continue;
        }
      }
    }
    cout << count << endl;
    count = 0;
  }
}


Measured memory_bytes: 3620
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a<b && b <c) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 26180
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long

#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

ll n,m;

int main()
{
	ll a;
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		cin>>a;
		n-=a;
	}
	if(n<0)
		cout<<-1<<endl;
	else
		cout<<n<<endl;
	return 0;
}

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

#define PI acos(-1)
#define pi 3.14159265359
#define ar array
#define ll long long
#define el "\n"

int main() {
    int total, n, sum = 0;
    cin >> total >> n;
    int ar[n];

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

        sum = sum + ar[i];
    }

    if(sum>total) cout << -1 << el;
    else cout << total - sum << el;

    return 0;
}


Measured memory_bytes: 3672
from collections import deque
N = int(input())
c = deque(input())
ans = 0
while c:
    a = c.popleft()
    if a == "R":
        continue
    else:
        if c:
            while c:
                b = c.pop()
                if b == "W":
                    continue
                else:
                    ans += 1
                    break
        else:
            break
print(ans)

Measured memory_bytes: 11048
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, c;
  int b[25];
  int a[25][25];
  int sum[25] = {};
  int ans = 0;
  
  cin >> n >> m >> c;
  for(int i = 0;i < m;i++){
    cin >> b[i];
  }

  for(int i = 0;i < n;i++){
    for(int j = 0;j < m;j++){
      cin >> a[i][j];
      sum[i] += (a[i][j] * b[j]);
    }
    sum[i] += c;
  }
  
  for(int i = 0;i < n;i++){
    if(sum[i] > 0){
      ans ++;
    }
  }

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



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;

int a[200005];

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

ll factorial(ll n)
{
    if (n == 0)
        return 1;
    return n * factorial(n - 1);
}
ll combination(ll n, ll k)
{
    return (factorial(n)) / (factorial(k) * factorial(n - k));
}

int main()
{
    ll N;
    cin >> N;
    vll A(N);
    vll S(N);
    map<ll, ll> cnt;
    cnt[0] = 1;
    rep(i, N)
    {
        cin >> A[i];
        if (i == 0)
        {
            S[i] = A[i];
            cnt[S[i]]++;
        }
        else
        {
            S[i] = S[i - 1] + A[i];
            cnt[S[i]]++;
        }
    }
    ll ans = 0;
    for (auto num : cnt)
    {
        ans += ((num.second - 1) * num.second) / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());

    rep(i, x) r.push_back(p[i]);
    rep(i, y) r.push_back(q[i]);
    sort(r.begin(), r.end(), greater<int>());
    ll ret = 0;
    rep(i, x+y) ret += r[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2552
using System;
public class Program
{
    public static void Main()
    {
        string[]array=Console.ReadLine().Split(' ');
        var num1=int.Parse(array[0]);
        var num2=int.Parse(array[1]);
        var num3=int.Parse(array[2]);
        
        if(num3>num1&&num3<num2)Console.WriteLine("Yes");
        else if(num3<num1&&num2<num3)Console.WriteLine("Yes");
        else Console.WriteLine("No");
        
    }
}

Measured memory_bytes: 11092
#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)

int main()
{
  int n, k,st=0,ans=0;
  cin >> k >> n;
  vector<int> a(n);
  REP(i, n)
  {
    cin >> a.at(i);
  }

  int m=0,pre=0;
  REP(i, n)
  {
    if(i<n-1){
    pre = a.at(i + 1) - a.at(i);
  }else{
    pre = k - (a.at(n-1)- a.at(0));
  }
    if(pre>=m){
      m = pre;
      st = i;
    }
  }

  REP(i,n-1){
    ans += a.at(i + 1) - a.at(i);
  }
  ans += k - (a.at(n - 1) - a.at(0));
  if(st+1<n){
    ans -= a.at(st+1) - a.at(st);
  }else{
    ans -= k - (a.at(n - 1) - a.at(0));
  }

  cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] m = new int[N];
        int min = 1000;
        int sum = 0;
        
        for(int i=0; i<N; i++){
            m[i] = sc.nextInt();
            sum += m[i];
            if(min > m[i]){
                min = m[i];
            }
        }
        //System.out.println(sum);
        X = X - sum;
        //System.out.println(X);
        X /= min;
        
        System.out.println(N+X);
    }
}


Measured memory_bytes: 36144
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

vector<vector<mint>> succ(10, vector<mint>(200001));
vector<mint> ten(200001);

struct S{
	mint v;
	int size;
};

S op(S x, S y) {
	return {
		x.v * ten[y.size] + y.v,
		x.size + y.size
	};
}

S e() {
	return S{0, 0}; // editted here
}

struct F {
	int v;
	bool id;
};

S mapping(F f, S x) {
	if (f.id) return x;
	else return {
		succ[f.v][x.size],
		x.size
	};
}

F composition(F f, F g) {
	if (f.id) return g;
	else return f;
}

F id() {
	return F{1, true};
}

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	for (int i = 1; i < 10; ++i) {
		mint x = i;
		for (int j = 1; j < 200001; ++j) {
			succ[i][j] = x;
			x = x * 10 + i;
		}
	}
	mint t = 1;
	for (int i = 0; i < 200001; ++i) {
		ten[i] = t;
		t *= 10;
	}
	int n, q; cin >> n >> q;
  vector<S> v(n, {1, 1}); // editted here
	lazy_segtree<S, op, e, F, mapping, composition, id> st(v); // editted here
	for (int i = 0; i < q; ++i) {
		int l, r, d; cin >> l >> r >> d;
		st.apply(l-1, r, F{d, false});
		cout << st.all_prod().v.val() << "\n";
	}
	return 0;
}


Measured memory_bytes: 19612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

string maxs(string l,string r){
    if(l.size()<r.size()) return r;
    else if(l.size()==r.size()){
        if(l<=r) return r;
        else return l;
    }else return l;
}

int H,W;
char C[100][100];

string dp[100][100];

void solve(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>C[i][j];
            dp[i][j]="";
        }
    }

    string ma="";
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(C[i][j]<'0'||C[i][j]>'9') dp[i][j]="";
            else{
                string up="",le="";
                if(i-1>=0) up=dp[i-1][j];
                if(j-1>=0) le=dp[i][j-1];

                string res=maxs(up,le);
                if(res==""&&C[i][j]!='0') res=C[i][j];
                else if(res==""&&C[i][j]=='0') res="";
                else res=res+C[i][j];

                dp[i][j]=res;
            }
            ma=maxs(ma,dp[i][j]);
        }
    }

    cout<<ma<<endl;
}

int main(){
  while(1){
      cin>>W>>H;
      if(W==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PAIR;
const int N = 1e3+5;
const int INF = 0x3f3f3f3f;

int main(){
	ll n,k;
	cin >> n >> k;
	if(n > k) n = (n-1)%k+1;
	printf("%lld\n",min(n,k-n));
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N = S.size();
    for(int i=0; i<N; i+=2) if(S.substr(i, 2) != "hi"){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,l,s,minn=2000;
int main()
{
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
	{
		int a=i+l-1;
		if(fabs(a)<fabs(minn))
			minn=a;
		s+=a;
	}
	printf("%d",s-minn);
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] a = new int[n];
		a[0] = in.nextInt()%m;
		int zero = 0;
		if(a[0]==0) zero++;
		for(int i=1;i<n;i++) {
			a[i] = (a[i-1]+in.nextInt())%m;
			if(a[i]==0) zero++;
		}
		Arrays.sort(a);
		long sum = zero;
		int num = a[0];
		long count = 1;
		for(int i=1;i<n;i++) {
			if(num==a[i]) {
				count++;
			}else {
				sum += (count*(count-1))/2;
				count = 1;
				num = a[i];
			}
		}
		sum += (count*(count-1))/2;
		System.out.println(sum);
		in.close();
	}

}


Measured memory_bytes: 50564
<?php
$input = explode(' ', trim(fgets(STDIN)));
$rectanglePosWidth = $input[0];
$rectanglePosHeight = $input[1];
$circlePosWidth = $input[2];
$circlePosHeight = $input[3];
$circleRadius = $input[4];
  
if (judgeCircleIncludInRectangleForWidth($circlePosWidth, $circleRadius, $rectanglePosWidth) && judgeCircleIncludInRectangleForHeight($circlePosHeight, $circleRadius, $rectanglePosHeight)) {
    echo 'Yes', PHP_EOL;
} else {
    echo 'No', PHP_EOL;
}
  
function judgeCircleIncludInRectangleForWidth($circlePosWidth, $circleRadius, $rectanglePosWidth)
{
    return 0 <= ($circlePosWidth - $circleRadius) && ($circlePosWidth + $circleRadius) <= $rectanglePosWidth;
}
  
function judgeCircleIncludInRectangleForHeight($circlePosHeight, $circleRadius, $rectanglePosHeight)
{
    return  0 <= ($circlePosHeight - $circleRadius) && ($circlePosHeight + $circleRadius) <= $rectanglePosHeight;
}

Measured memory_bytes: 15396
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

k, x = readmi()

index = x - k + 1
s = defaultdict(int)
for i in range(k):
    for j in range(k):
        s[j + index] = 1
    index += 1
for i in sorted(s):
    print(i, end=" ")

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

using namespace std;

typedef long long ll;

const int MX = 300003;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, len;
int x[MX], t[MX], l[MX], r[MX];

void input()
{
	read(n), read(len), len *= 2;
	for(int i=1; i<=n; i++) read(x[i]);
	for(int i=1; i<=n; i++) read(t[i]);
}

void work()
{
	ll ans = len;
	for(int i=1; i<=n; i++)
	{
		if(t[i]%len == 0) ans += t[i];
		else
		{
			ans += 1ll*((t[i]-1)/len+1)*len;
			if(t[i]%len <= x[i]*2) r[i] = 1;
			if(t[i]%len <= len-x[i]*2) l[i] = 1;
		}
	}
	int lft = 0, rgt = 0, tmp = 0;
	for(int i=1; i<n; i++)
	{
		if(!(t[i]%len)) continue;
		else if(r[i]) tmp += l[i], rgt++;
		else lft += l[i];
		while(rgt-lft < 2*tmp)
		{
			if(tmp) tmp--;
			else lft--;
		}
	}
	ans -= 1ll*l[n]*len;
	printf("%lld\n", ans - 1ll*lft*len - 1ll*tmp*len);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )
static const double PI = acos(-1);
 
class Point{
    public:
    double x, y;
     
    Point ( double x = 0, double y = 0): x(x), y(y){}
     
    Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
    Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
    Point operator * ( double a ){ return Point(x*a, y*a); }
    Point operator / ( double a ){ return Point(x/a, y/a); }
 
    double abs() { return sqrt(norm());}
    double norm() { return x*x + y*y; }
 
    bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
    }
 
    bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};
 
typedef Point Vector;
 
double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);}
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }
 
bool isOrthogonal( Vector a, Vector b ){
     return equals( dot(a, b), 0.0 );
}
 
bool isOrthogonal( Point a1, Point a2, Point b1, Point b2 ){
    return isOrthogonal( a1 - a2, b1 - b2 );
}
 
bool isParallel( Vector a, Vector b ){
    return equals( cross(a, b), 0.0 );
}
 
bool isParallel( Point a1, Point a2, Point b1, Point b2){
    return isParallel( a1 - a2, b1 - b2 );
}
 
int main(){
    Point P[4];
    while( cin >> P[0].x >> P[0].y ){
    for ( int i = 1; i < 4; i++ ) cin >> P[i].x >> P[i].y;
    if ( isOrthogonal(P[0], P[1], P[2], P[3] )) cout << "YES" << endl;
    else cout << "NO" << endl;
    }
     
 
    return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[2010][2010];
int A[2010];
pair<int,int> p[2010];
int N; 
int calc(int x = 0, int L = 0, int R = N - 1) {
    
    if (x == N) return 0;
    if(dp[L][R] != -INF) return dp[L][R];
    dp[L][R] = max(dp[L][R], calc(x + 1, L + 1, R) + p[x].first * abs(p[x].second - L));
    dp[L][R] = max(dp[L][R], calc(x + 1, L, R - 1) + p[x].first * abs(p[x].second - R));
    //cout << x << " " << L << " " << R << " " << " " << dp[L][R] << endl;
    return dp[L][R];
} 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    
    rep(i, N) cin >> A[i];
    
    rep(i, N) p[i] = {A[i], i};
    rep(i, N) rep(j, N) dp[i][j] = -INF;
    sort(p, p + N, greater<pair<int, int>>());
    //rep(i, N) cout << p[i].first << " " << p[i].second << endl;
    cout << calc() << endl;
    // rep(i, N) {
    //     rep(j, N) cout << dp[i][j] << " ";
    //     cout << endl; 
    // }
    

    return 0;
}


Measured memory_bytes: 35220
#include <cstdio>
#include <iostream>

int main()
{
	int n, a, b;
	while(1){
		std::cin >> n;
		if(n == 0) break;
		int max = -1, min = 1001, sum = 0;
		for(int i = 0; i < n; i++){
			std::cin >> a;
			if(a > max) max = a;
			if(a < min) min = a;
			sum += a;
		}
		b = (sum - max - min) / (n - 2);
		std::cout << b << std::endl;
	}
	return 0;
}

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

int gcd (int x, int y){
    if (y == 0) return x;
    return gcd (y, x % y);
}
int main(){
    long long w, h, x, y;
    cin >> w >> h >> x >> y;
    if (x * 2 == w && y * 2 == h) cout << setprecision(15) << (double)1.0 * w * h / 2 << " " << 1 << endl;
    else cout << setprecision(15) << (double)1.0 * w * h / 2 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int bt=0,bd=0;
    for(int i = 0; i < n; i++){
        int t,x,y;
        cin >> t >> x >> y;
        bt = t-bt;
        bd = abs(x+y-bd);
        if(bd > bt || bd%2 != bt%2){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

typedef long long ll;

std::vector<std::vector<ll> > Graph;

void dfs(ll now, ll root, std::vector<ll> &resa){
  for(int i = 0 ; i < (int)Graph[now].size() ; i++){
    if(Graph[now][i] != root){
      resa[Graph[now][i]] += resa[now];
      dfs(Graph[now][i], now, resa);
    }
  }

}

int main(){
  ll N, Q;
  std::cin >> N >> Q;
  Graph.assign(N, std::vector<ll>() );
  for(int i = 0 ; i < N - 1 ; i++){
    ll a, b;
    std::cin >> a >> b;
    Graph[a - 1].push_back(b - 1);
    Graph[b - 1].push_back(a - 1);
  }
  std::vector<ll> counter(N);
  for(int i = 0 ; i < Q ; i++){
    ll p, x;
    std::cin >> p >> x;
    counter[p - 1] += x;
  }
  
  dfs(0, -1, counter);

  for(auto && r : counter){
    std::cout << r << " ";
  }
  std::cout << std::endl;
  
  return 0;
}



Measured memory_bytes: 31444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int>A(M);
  vector<int>B(M);
  vector<int>a(N,0);
  vector<int>b(N,0);
  
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    if (A.at(i) == 1){
      a.at(B.at(i)-1)++;
    }
    else if (A.at(i) == N){
      b.at(B.at(i)-1)++;
    }
    else if (B.at(i) == N){
      b.at(A.at(i)-1)++;
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (a.at(i) == 1 && b.at(i) == 1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}
  

Measured memory_bytes: 6328
#include <stdio.h>

int n,A[50];

int solve(int i,int m)
{
   if(m==0) return 1;
   if(i>=n) return 0;
   int res=solve(i+1,m)||solve(i+1,m-A[i]);
   return res;
}

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


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e9+7;
ll dp[3010][3010];
ll sum[3010];
int main(){
    int n;cin>>n;
    string s;cin>>s;
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+1;    
    for(int i=0;i<n-1;i++){
        for(int j=1;j<=n-i-1;j++){
            if(s[i]=='<'){
                dp[i][j]=sum[j];  
            }else{
                dp[i][j]=sum[n]-sum[j]+MOD;
            }
        }
        for(int j=0;j<=n;j++)sum[j]=0;
        for(int j=1;j<=n;j++){
            sum[j]+=sum[j-1]+dp[i][j];
            sum[j]%=MOD;
        }
    }
    cout<<sum[n]<<endl;
}   


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
	int n;cin>>n;
	string line;cin>>line;
	string ans = "";
	fore(i,0,line.size()){
		int cur = line[i]-'A';
		int sum = cur+n;
		if(sum>25)ans+=(sum-26)+'A';
		else ans+=sum+'A';
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	set<int>s;
	set<int>t;
	t.insert(1);
	t.insert(9);
	t.insert(7);
	t.insert(4);
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	s.insert(d);
	
	if(s==t)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<int(s.size());i++){
        if(s[i]=='A')
        a++;
        else
        b++;
    }
    if(a>0 & b>0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CINS(int, C1, 3);
    CINS(int, C2, 3);
    CINS(int, C3, 3);

    int X = 0, Y = 0, Z = 0;
    for (int i = 0; i < 3; i++) {
        X += C1[i];
        Y += C2[i];
        Z += C3[i];
    }
    int A = C1[0] + C2[0] + C3[0];
    int B = C1[1] + C2[1] + C3[1];
    int C = C1[2] + C2[2] + C3[2];

    string ans = "Yes";
    if ( (Y - X) % 3 != 0 || (Z - X) % 3 != 0 || (B - A) % 3 != 0 || (C - A) % 3 != 0 ) {
        ans = "No";
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int solve(int K) {
   vector<bool> seen(K);
   int rem = 0;
   for (int n = 1; ; ++n) {
      rem = (rem * 10 + 7) % K;
      if (rem == 0)
         return n;
      if (seen[n])
         break;
      seen[n] = true;
   }
   return -1;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int K;
   cin >> K;
   
   int res = solve(K);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3768
/* 
	solution by :
		Beksultan Almazbekov
		;
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll w[3546],v[3546],q[123123];
int main(){
	ll mx=0,n,m,i,j;
	cin>>n>>m;
	for (i=0;i<n;++i){
		cin>>w[i]>>v[i];
	}
	for (i=0;i<n;++i){
		for (j=m;j>=w[i];--j){
			mx=max(mx,q[j]=max(q[j],q[j-w[i]]+v[i]));
		}
	}
	cout <<mx;
	
}

Measured memory_bytes: 1024
N = int(input())
l = list(map(int,input().split()))

upper_ave = int(sum(l)/len(l)) + 1
lower_ave = int(sum(l)/len(l))

ans_1, ans_2 = 0, 0

for i in l:
    ans_1 += (i - upper_ave) ** 2
    ans_2 += (i - lower_ave) ** 2

print(min(ans_1,ans_2))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
 string n;
 cin >> n;
 int sum = 0;
 for(int i=0;i<n.size();i++){
       sum +=n[i]-'0';
 }
 if(sum%9==0){
 cout << "Yes" << endl;
 }else{
       cout << "No" << endl;
 }
 return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (c - (a - b) < 0) {
    cout << 0 << endl;
  } else {
    cout << c - (a - b) << endl;
  } 
}


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

int main(){
    // a = XXXXX 10000 ~ 99999
    // b = XXXXX 10000 ~ 99999
    // a <= b
    int a,b;
    // n1 n2 X n3 n4
    int n1,n2,n3,n4;
    int count = 0;
    cin >> a >> b;
    
    while(a <= b) {
        n1 = a/10000;
        n2 = a/1000 % 10;
        n3 = a/10 % 1000 % 100 % 10;
        n4 = a % 10000 % 1000 % 100 % 10;
        if (n1 == n4 && n2 == n3) {
            count++;
        }
        a++;
    }

    cout << count << endl;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

const int MOD=1e9+7;


ull fast_mi(int a,int p)
{
	if(p==0)
		return 1LL;
	ull tmp=fast_mi(a,p>>1);
	tmp*=tmp;
	tmp%=MOD;
	if(p&1)
		tmp*=(ull)a;
	tmp%=MOD;
	return tmp;
}

ull C(int x,int y)
{
	ull res=1;
	y=min(y,x-y);
	for(ull i=x;i>=x-y+1;i--)
	{
		res*=i;
		res%=MOD;
	}
	for(ull i=2;i<=y;i++)
	{
		res*=fast_mi(i,MOD-2);
		res%=MOD;
	}
	return res; 
}


int n,a,b;

int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>a>>b;
    ull ans=fast_mi(2,n);
    ans=(ans-C(n,a)+MOD)%MOD;
	ans=(ans-C(n,b)+MOD)%MOD;
	ans=(ans-1LL+MOD)%MOD;
	cout<<ans<<endl; 
    /* end code */
	return 0;
}

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

char tolower(char);

int main(){
  char w[100];
  char t[100];
  char eof[100]="END_OF_TEXT";
  scanf("%s", w);
  int counter=0;
  while(true){
    scanf("%s", t);
    if(strcmp(t, eof)==0) break;
    for(int i=0; t[i]!='\0'; i++){
      t[i] = tolower(t[i]);
    }
    if(strcmp(t, w)==0) counter++;
  }
  cout << counter << endl;
}

char tolower(char c){
  if(c>='A'&&c<='Z')c+=32;//大文字を小文字に
  return c;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    vector<ll> fl{0};
    char now{'('};
    for (auto&& c: S){
        if (c == now){
            fl.back()++;
        } else {
            fl.emplace_back(1);
            now = now=='(' ? ')' : '(';
        }
    }
    if (fl.size() % 2 == 1){
        fl.emplace_back(0);
    }
//    for (auto &&i: fl){
//        cout << i << endl;
//    }
//    cout << endl;
    ll l_lack{};
    for (auto &&i: boost::irange(0LL, (ll)fl.size())){
        if (i % 2 == 0){
            l_lack += fl.at(i);
        } else {
            l_lack = max(0LL, l_lack - fl.at(i));
        }
    }
    fl.back() += l_lack;

    ll f_lack{};
    for (auto &&i: boost::irange(0LL, (ll)fl.size()) | reversed){
        if (i % 2 == 0){
            f_lack = max(0LL, f_lack - fl.at(i));
        } else {
            f_lack += fl.at(i);
        }
    }
    fl.front() += f_lack;
    for (auto &&i: boost::irange(0LL, (ll)fl.size())){
        char c;
        c = (i%2 == 0) ? '(' : ')';
        for (auto &&j: boost::irange(0LL, fl.at(i))){
            cout << c;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ls = [[] for _ in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    ls[a].append((b,i))
ans = [None]*m
for i,l in enumerate(ls):
    l.sort()
    for j,(a,b) in enumerate(l):
        ans[b]= "{:06d}{:06d}".format(i,j+1)
for i in range(m):
    print(ans[i])

Measured memory_bytes: 74272