akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//組み合わせの数
//1 <= x の値を3つ使ってnを作成

//1,6,2
//1,5,3

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int n,m,l;
    cin >> n >> m >> l;

	int a[n][m];
	int b[m][l];
	ll c[n][l];

	REP(i,n)
	{
		REP(j,l)
		{
			c[i][j] = 0;
		}
	}

	REP(i,n)
	{
		REP(j,m)
		{
			cin >> a[i][j];
		}
	}

	REP(i,m)
	{
		REP(j,l)
		{
			cin >> b[i][j];
		}
	}

	REP(i,n)
	{
		REP(j,l)
		{
			//cの設定
			REP(k,m)
			{
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	REP(i,n)
	{
		REP(j,l)
		{
			cout << c[i][j];
			if(j != l-1)
			{
				cout << " ";
			}
		}
		cout << endl;
	}

    return 0;    
}




Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
		    int H=scan.nextInt();
		    int W=scan.nextInt();
		    if(H==0 && W==0)break;
			
			for(int i=0;i<H;i++){
				
				if(i%2==0){//偶数行は#.#.
					for(int j=0;j<W;j++){
						if(j%2==0)System.out.print("#");
						else System.out.print(".");
					}
				}
				else {//奇数は.#.#
					for(int j=0;j<W;j++){
						if(j%2==0)System.out.print(".");
						else System.out.print("#");
					}
				}
				System.out.println();
				
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 35240
INF = -1 * 10 ** 1000
n = gets.to_i
nums = gets.split.map(&:to_i)
length = nums.length
# dp[i 個目の num まで][i 個目の数字を選んだか][ぴったり採用 - 1, ぴったり採用, ぴったり採用 + 1]の最大値
dp = (length + 1).times.map { 2.times.map { Array.new(3, INF) } }
# 初期化
# dp[0 個目の num まで][i 個目の数字を選んでいない][ぴったり採用]の最大値は 0
dp[0][0][1] = 0

# num 数分ループする（i は遷移元の num）
length.times do |i|
  # 最適化のため、事前に 1 行分だけ参照渡しをする
  dp_current = dp[i]
  dp_next = dp[i + 1]
  # dp_current の数字を選んでいない場合(0)と、選んだ場合(1)を順に確認
  2.times do |selected|
    dp_current_selected = dp_current[selected]
    # dp_current までの累計採用数が ぴったり - 1, ぴったり, ぴったり + 1 の場合を順に確認
    3.times do |count|
      current_sum = dp_current_selected[count]
      next if current_sum == INF
      # dp_current が偶数個目（dp_next が奇数個目）の num の時、必要採用が 1 つ増える
      count -= 1 if i.odd?
      # dp_next の数字を選ばない場合(0)と、選ぶ場合(1)を順に確認
      2.times do |next_selected|
        # 連続では選べない
        next if selected == 1 && next_selected == 1
        tmp_count = count
        if next_selected == 1
          current_sum += nums[i]
          tmp_count += 1
        end
        next if tmp_count > 2 || tmp_count < 0
        dp_next[next_selected][tmp_count] = current_sum if dp_next[next_selected][tmp_count] < current_sum
      end
    end
  end
end

# dp[n 個目の num まで][n 個目を採用][ぴったり採用]
# dp[n 個目の num まで][n 個目を不採用][ぴったり採用] のうち、値が大きい方を出力
puts [dp[n][0][1], dp[n][1][1]].max


Measured memory_bytes: 57832
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, x; cin >> n >> x;
    vector<ll> v1(n), v2(n);
    REP(i, n){
        ll a;
        cin >> a;
        v1[i] = a;
        v2[i] = a;
    }

    ll res1 = 0, res2 = 0;
    REP(i, n-1){
        ll sum1 = v1[i] + v1[i+1];
        ll sumdif1 = sum1 - x;
        if(sumdif1 > 0){
            v1[i+1] -= sumdif1;
            if(v1[i+1] <0){
                v1[i] += v1[i+1];
                v1[i+1] = 0;
            }
            res1 += sumdif1;
        }  

        ll sum2 = v2[i] + v2[i+1];
        ll sumdif2 = sum2 - x;
        if(sumdif2 > 0){
            v2[i] -= sumdif2;
            if(v2[i] <0){
                v2[i+1] += v2[i];
                v2[i] = 0;
            }
            res2 += sumdif2;
        } 
    }
    cout << min(res1, res2) << endl;
}

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

Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))
if N == 1:
  print("Yes")
  exit(0)
for i in range(1, N):
  if H[-(i+1)] <= H[-i]:
    continue
  if H[-(i+1)] - H[-i] == 1:
    H[-(i+1)] -= 1
  if H[-(i+1)] - H[-i] >= 2:
    print("No")
    exit(0)
print("Yes")

Measured memory_bytes: 14396
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    long long N,a,b,c,d,e;
    long long ans;

    cin >>N>>a>>b>>c>>d>>e;
    
   ans=5+(N-1)/min(a,min(b,min(c,min(d,e))));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string n;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
if (n[0]==n[1] and n[1]==n[2]) cout << "No";
else cout << "Yes";
return 0;
}


Measured memory_bytes: 256
#encoding:utf-8 No.0060 2014.12.11
while gets
  cards = $_.chomp.split.map{|item| item.to_i}
  stack = (1..10).to_a - cards

  under20 = 0
  stack.each do |item|
    if cards[0] + cards[1] + item <= 20
      under20 += 1
    end
  end

  if under20 >= 4
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 6104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int str = line.length();
		int end = 0;

		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == 'A') {
				str = Math.min(str, i);
			} else if (line.charAt(i) == 'Z') {
				end = Math.max(end, i);

			}

		}
		System.out.println(end - str + 1);
	}

}


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

int main() {
    int x[6], i;
    cin >> x[1] >> x[2] >> x[3] >> x[4] >> x[5];
    for (i = 1; i < 6; i++) {
        if (x[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3648
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n;
char buf[40];

int main()
{
    scanf("%d",&n);
    scanf("%s",buf);
    map<string,map<string,int>> mp;
    ll ans=0;
    for (int i=0;i<(1<<n);i++) {
        string a,b;
        for (int j=0;j<n;j++) {
            if (i>>j&1) a+=buf[j];
            else b+=buf[j];
        }
        mp[a][b]++;
    }
    for (int i=0;i<(1<<n);i++) {
        string a,b;
        for (int j=n-1;j>=0;j--) {
            if (i>>j&1) a+=buf[j+n];
            else b+=buf[j+n];
        }
        if (mp.find(b)!=mp.end()) {
            ans+=mp[b][a];
        }
    }
    printf("%lld\n",ans);
}


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

using namespace std;

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

    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            if (s - x - y >= 0 && s - x - y <= k) ans++;
        }
    }

    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<ll> v,w;
  UnionFind(int n) : v(n, -1), w(n,0) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    w[x] += w[y];
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
  ll weight(int x) { return w[find(x)]; }
};

struct edge{
  ll a,b,w;
};

ll n,m;
vector<edge> es;
ll x[200010];
bool used[200010];
bool dame[200010];
vector<ll> g[200010];
ll pre[200010],ew[200010],sw[200010],idx[200010];
ll V;

void dfs(int v){
  if(v<n)return ;
  if(sw[v]<ew[v]){
    dame[idx[v]]=true;
    for(int nv : g[v])dfs(nv);
  }
}

int main(){
  cin>>n>>m;
  rep(i,n)cin>>x[i];
  rep(i,m){
    ll a,b,w;
    cin>>a>>b>>w;
    a--;b--;
    es.push_back((edge){a,b,w});
  }
  sort(all(es),[=](const edge& a,const edge& b){ return a.w < b.w; });

  UnionFind uf(n);
  rep(i,n)uf.w[i]=x[i];
  V=n;
  rep(i,n)pre[i]=i;
  rep(i,m){
    if(!uf.same(es[i].a,es[i].b)){
      used[i]=true;
      ew[V]=es[i].w; sw[V]=uf.weight(es[i].a)+uf.weight(es[i].b);
      g[V].push_back(pre[uf.find(es[i].a)]);
      g[V].push_back(pre[uf.find(es[i].b)]);
      idx[V]=i;
      uf.unite(es[i].a,es[i].b);
      pre[uf.find(es[i].a)]=V;
      V++;
    }
  }
  dfs(V-1);
  uf.init();
  rep(i,n)uf.w[i]=x[i];
  rep(i,m)if(used[i]&&!dame[i])uf.unite(es[i].a,es[i].b);
  ll res=0;
  rep(i,m){
    if(uf.same(es[i].a,es[i].b)&&uf.weight(es[i].a)>=es[i].w)continue;
    res++;
  }
  cout<<res<<endl;

  return 0;
}


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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007








int main()
{	
	
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n=Int,k=Int;
    cout<<n/(k*2+1)+(bool)(n%(k*2+1))<<endl;
    
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ll N;

ll F(vl vec){
    ll count=0;
    for(ll i=1;i<N;i++){
        if(vec[i-1]==0&&vec[i])count++;
    }
    if(vec[0])count++;
    if(count==0)return 0;
    for(ll i=0;i<N;i++)vec[i]=max(vec[i]-1,0LL);
    return count+F(vec);

}

int main(){
    cin >> N;
    vector<ll> H(N,0);
    vector<ll> M(N,0);
    for(ll i=0;i<N;i++)cin>>H[i];
    print(F(H))
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))

int a[100005];
int even[100005],odd[100005];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    int n,x=0,y=0,Maxe=-1,Maxo=-1,ei=-1,oi=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(i&1){
            even[a[i]]++;
            if(Maxe<even[a[i]]){
                Maxe=max(Maxe,even[a[i]]);
                ei=i;
            }
        }
        else{
            odd[a[i]]++;
            if(Maxo<odd[a[i]]){
                Maxo=max(Maxo,odd[a[i]]);
                oi=i;
            }
        }
    }
    if(a[oi]!=a[ei]) printf("%d\n",n-odd[a[oi]]-even[a[ei]]);
    else{
        sort(odd,odd+100001,cmp);
        sort(even,even+100001,cmp);
        printf("%d\n",min(n-odd[0]-even[1],n-odd[1]-even[0]));
    }
    return 0;
}

Measured memory_bytes: 1536
x, k, d = map(int, input().split())
if (x - k*d > 0 and x > 0) or (x + k*d < 0 and x < 0):
    print(abs(x) - k*d )
else:
    if x % d == 0:
        if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
    else:
        y = abs(x)
        if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d))

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;




int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if (u==s)
        a--;
    else if (u==t)
        b--;
    cout<<a<<endl<<b;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char R[100000],G[100000],B[100000],A[100000],n;
int r,g,a,b,p;

int main()
{
	for(;gets(R),R[0]!='-';)
	{
		memset(A,0,sizeof(A));
		gets(G);gets(B);
		for(r=a=b=0,n=G[0],g=1;R[r]||G[g];)
		{
			if(n==B[b])
			{
				b++;
				n=R[r++];
			}
			else
			{
				A[a++]=n;
				n=G[g++];
			}
		}
		A[a++]=n;
		puts(A);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;

int main() {
	string a[100];
	int b;
	while (cin >> b, b) {
		for (int c = 0; c < b; c++)cin >> a[c];
		int s = 0;
		for (int d = 0; d < b - 1; d++) { if (a[d][1] == a[d + 1][1])s++; }
		cout << s << endl;
	}
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,k,ans=0;
  string s,t="Yes";
  cin >>a>>b>>c>>k;
  while(a>=b){
    b*=2;
    ans++;
  }
    while(b>=c){
    c*=2;
    ans++;
  }
  if(ans>k) t="No";
  cout <<t;
}

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

int main(){
    vector<int> days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int x, y;
    cin >> x >> y;

    x -= 1;
    y -= 1;
    if(days[x] == days[y]) cout << "Yes" << endl;
    if(days[x] != days[y]) cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]){

    	Scanner scan = new Scanner(System.in);
    	
    	//ベルの値段
    	int a = Integer.parseInt(scan.next());
    	int b = Integer.parseInt(scan.next());
    	int c = Integer.parseInt(scan.next());
    	
    	//合計金額
    	int sum = a + b;
    	int sum2 = a + c;
    	int sum3 = b + c;
    	
    	//sumが最安の場合
    	if((sum <= sum2)&&(sum <= sum3)){
    		System.out.println(sum);
    	}
    	//sum2が最安の場合
    	else if((sum2 <= sum)&&(sum2 <= sum3)){
    		System.out.println(sum2);
    	}
    	//sum3が最安の場合
    	else{
    		System.out.println(sum3);
    	}
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e18
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
        cin>>n;
        ll ans=INF;
        forn(i,5){
            ll tmp;
            cin>>tmp;
            ans=min(ans,tmp);
        }
        cout<<n/ans+(n%ans?1:0)+4<<endl;
	return 0;
}


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


int main(){
    long N,K;
    std::cin >> N >> K;
    long sum=0;
    long plus=1;
    long MOD=1000000000+7;
    for(long i=0; i<=N+1; i++){
        if(K<=i){
            sum+=plus;
            sum%=MOD;
        }
        plus+=(N-i*2);
        plus%=MOD;
        if(plus<0){
            plus+=MOD;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  if( h < b*2 || w < a*2 ){
    cout << "No" << "\n";
    return 0;
  }
  char board[h][w];
  rep(i,h) rep(j,w) board[i][j] = '1';

  rep(i,b) rep(j,a){
    board[i][j] = '0';
  }

  FOR(i,b,h) FOR(j,a,w){
    board[i][j] = '0';
  }

  rep(i,h){
    rep(j,w){
      cout << board[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto N = readln.chomp.to!int;
    int ret;
    foreach (_; 0..N) {
        auto lr = readln.split.to!(int[]);
        ret += lr[1] - lr[0] + 1;
    }
    writeln(ret);
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll p[2200],a[100005],k[100005];
int cnt=0;
map<ll,int>x;
map<ll,bool>vis;
ll M(ll t,ll h)
{
    ll ans1=1,ans2=1;
    for(int i=0;i<cnt;i++)
    {
        int cot=0;
        while(t%p[i]==0) cot++,t/=p[i];
        cot%=3;
        if(cot==0) continue;
        if(cot==1)
        {
            ans1*=p[i],ans2*=p[i];
            if(ans2>1e10) ans2=0;
            ans2*=p[i];
        }
        else ans1*=p[i]*p[i],ans2*=p[i];
        if(ans2>1e10) ans2=0;
    }
    ans1*=t;
    ll w=(ll)sqrt(t);
    if(w*w==t)
        ans2*=w;
    else
    {
        ans2*=t;
        if(ans2>1e10) ans2=0;
        ans2*=t;
    }
    if(ans2>1e10) ans2=0;
    x[ans1]++;
    k[h]=ans2;
    return ans1;
}
int main()
{
    for(int i=2;i<=2200;i++)
    {
        bool flag=true;
        for(int j=2;j*j<=i;j++)
        if(i%j==0) {flag=false;break;}
        if(flag) p[cnt++]=i;
    }
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        ll m;
        scanf("%lld",&m);
        a[i]=M(m,i);
    }
    int ans=0;
    vis[1]=true;
    for(int i=1;i<=n;i++)
        if(!vis[a[i]]) ans+=max(x[a[i]],x[k[i]]),vis[a[i]]=vis[k[i]]=true;
    if(x[1]>=1) ans++;
    printf("%d\n",ans);
}


Measured memory_bytes: 22400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int h, r;
	cin >> h >> r;
	int pos = h + r;

	if (pos > 0)
	{
		cout << 1 << endl;
	}
	else if (pos < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
mod = 1000000007
def power(x, y):
    if   y == 0     : 
        return 1
    elif y == 1     : 
        return x % mod
    elif y % 2 == 0 : 
        return power(x, y//2)**2 % mod
    else            : 
        return power(x, y//2)**2 * x % mod
X,Y = (int(i) for i in input().split())

Z = X + Y
A = max(X,Y)
B = min(X,Y)
C = A - B

if Z % 3 != 0:
    print(0)
elif A > 2*B :
    print(0)
else:
    N = Z // 3
    if (N - C) % 2 != 0:
        print(0)
    else:
        M = (N - C) // 2


        a = 1
        b = 1
        for i in range(M):
            a = (a * (i + 1)) % mod
            b = (b * (N-i)) % mod
        c = power(a, mod-2)
        ans = b * c % mod

        print(ans)

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

int main() {
  int m, D;
  cin>>m>>D;
  int cnt = 0;
  for (int i=1; i<=m; i++) {
    for (int d=22; d<=D; ++d) {
      if (d % 10 < 2) {
        continue;
      }
      int d1 = d / 10;
      int d2 = d % 10;
      if (d1 * d2 == i) {
        ++cnt;
      }
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,B;
  cin >> N >> B;
  vector<int> costs (N,999999999);
  vector<int> times (N,0);
  int X = 999999999;
  for ( int i = 0; i<N ; i++) {
    int P,Q;
    cin >> P >> Q;
    if ( Q <= B ) {
      costs[i] = P;
    }
  }
  for ( int i = 0; i <N ; i++) {
    if ( costs[i] <= X ) {
      X = costs[i];
    }
  }
  if ( X != 999999999 ) {
    cout << X << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll pow(ll base, int ex) {
	if (ex == 0) {
		return 1;
	} else {
		return base * pow(base, ex - 1);
	}
}

int main() {
	ll N;
	cin >> N;
	N--;
	int name_length = 1;
	while (N >= pow(26, name_length)) {
		N -= pow(26, name_length);
		name_length++;
	}
	vector<char> name(name_length, 'a');
	for (int i = name_length - 1; N > 0; i--) {
		name.at(i) = (char) ('a' + N % 26);
		N /= 26;
	}
	for (auto c : name) {
		cout << c;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3576
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
ll a[N];
vector<int> v[N];
int T = 1;
int pos[N];
bool vis[N];
int sz[N];
void dfs(int s){
    vis[s] = 1;
    pos[s] = T++;
    sz[s] = 1;
    for(auto i : v[s]){
        if(!vis[i]){
            dfs(i);
            sz[s] += sz[i];
        }
    }
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x  >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        a[pos[p]] += x;
        a[pos[p] + sz[p]] -= x;
    }
    for(int i = 1; i < N; i++) a[i] += a[i - 1];
    for(int i = 1; i <= n; i++){
        cout << a[pos[i]] << " ";
    }
return 0;
}


Measured memory_bytes: 25984
S=input()
T=input()

from collections import Counter
sd = Counter(S)
td = Counter(T)

sdd = Counter(list(sd.values()))
tdd = Counter(list(td.values()))

for k,v in sdd.items():
  if k not in tdd or tdd[k] != sdd[k]:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3772
# -*- coding: utf-8 -*-
#ABC089C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
h = hoge[0]
w = hoge[1]

list = [[0 for i in range(w+2)] for j in range(h+2)]

for i in range(0,h):
	fuga = input()
	for j in range(0,w):
		if(fuga[j]=="."):
			list[i+1][j+1]=0
		else:
			list[i+1][j+1]=1

flg=0
for i in range(1,h+1):
	for j in range(1,w+1):
		if(list[i+1][j+1] == 1):
			if(list[i][j+1] == 0)and(list[i+1][j] == 0)and(list[i+1][j+2] == 0)and(list[i+2][j+1] == 0):
				flg=1
if(flg):
	print("No")
else:
	print("Yes")

#print(list)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<LP> w;

ll dp[5010][5010];

void solve(){
    cin >> n;
    rep(i,n){
        int h,p;
        cin >> h >> p;
        w.push_back(LP(h,p));
    }
    sort(w.begin(),w.end(),[](const LP& a,const LP& b){return a.first+a.second<b.first+b.second;});

    // rep(i,n){
    //     cout << w[i].first << " " << w[i].second << endl;
    // }

    rep(i,n+1){
        rep(j,n+1) dp[i][j]=INF;
    }

    dp[0][0]=0;
    rep(i,n){
        rep(j,i+2){
            dp[i+1][j]=dp[i][j];
            if (dp[i][j-1]<=w[i].first) dp[i+1][j]=min(dp[i+1][j],dp[i][j-1]+w[i].second);
        }
    }

    // rep(i,n+1){
    //     rep(j,n+1) cout << i << " " << j << " " << dp[i][j] << endl;;
    // }

    per(i,n+1){
        if (dp[n][i]!=INF) {
            cout << i << endl;
            return;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 196352
class UFT(object):
    def __init__(self):
        self.par={i:i for i in range(10001)}
        self.rank={i:0 for i in range(10001)}
    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def unite_chk(self,a,b):
        return self.find(a)==self.find(b)
        
obj=UFT()
n,q=map(int,input().split())
for _ in range(q):
    c,x,y=map(int,input().split())
    if c:
        print(int(obj.unite_chk(x,y)))
    else:
        obj.unite(x,y)



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

int main()
{
	int n, m;
	cin >> n >> m;
	
	if (n == m)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


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

int main(){
        vector<int>x(5);
        vector<int>n= {0, 1, 2, 3, 4};
        int ans = 0,ans2 = 999999999;
        cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

        for(int i =0;i < 5;i++){
              while(ans % 10 != 0)ans += 1;
              ans +=x[n[i]];
        }
        ans2 = min(ans2,ans);

        while(next_permutation(n.begin(),n.end())){
            int ans = 0;
            for(int i =0;i < 5;i++){
                    while(ans % 10 != 0)ans += 1;
                    ans +=x[n[i]];
            }
            ans2 = min(ans2,ans);
        }
        cout << ans2 << endl;
}


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

#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

using namespace std;

void clear(int ar[]){
	for(int i=0;i<10;i++){
		ar[i]=0;
	}
}

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

	int n;
	string s;
	cin >> n >> s;
	int ava[n][10];
	int total[10];clear(total);
	for(int i=0;i<n;i++){
		total[s[i]-'0']++;
	}
	for(int i=0;i<n;i++){
		total[s[i]-'0']--;
		copy(total,total+10,ava[i]);
	}
	int t=0;
	int aa[10];clear(aa);
	int ab[10];clear(ab);
	for(int i=0;i<n;i++){
		if(aa[s[i]-'0']==0){
			aa[s[i]-'0']++;
			clear(ab);
			for(int j=i+1;j<n;j++){
				if(ab[s[j]-'0']==0){
					ab[s[j]-'0']++;
					for(int k=0;k<10;k++){
						t += ava[j][k]>0;
					}
				}
			}
		}
	}


	cout << t << "\n";
}

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

#define ll long long
#define maxn 5000
#define mod 1000000007
ll ans[maxn],n;
void task()
{
    for(int i = 0; i <= 2; i++)
    {
        ans[i] = 0;
    }
    ans[3] = 1;
    for(int i = 4; i <= 2005; i++)
    {
        ans[i] = (ans[i-1] + ans[i-3]) % mod;
    }
}
int main()
{
    cin >> n;
    task();
    cout << ans[n];
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<pair<int,int>> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i).second>>a.at(i).first;
  sort(a.begin(),a.end());
  
  int sum=0,flag=0;
  
  for(int i=0;i<N;i++){
    sum+=a.at(i).second;
    if(sum>a.at(i).first){
      flag++;
      break;
    }
  }
  
  if(flag==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> A(n);
  rep_i(i, n){
    cin >> A[i];
  }
  int m;cin >> m;
  vector<int> B(m);
  rep_i(i, m){
    cin >> B[i];
  }
  vector<int> C;

  set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(C, end(C)));
  rep_i(i, C.size()){
    say(C[i]);
  }
}


Measured memory_bytes: 6460
N, M = map(int, input().split())
L = [[] for i in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
    
import itertools
count = 0
for p in itertools.permutations(range(N)):
    if p[0] == 0:
#         print("p",p)
        flag = True
        for i in range(N-1):
#             print(p[i+1], L[p[i]])
            if not p[i+1] in L[p[i]]:
                flag = False
#             print(flag)
        if flag:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
char s[10];
int a,w,t,r;
int main(){
	int n,i;
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		if(s[0]=='A')a++;//统计首字母数量
		else if(s[0]=='W')w++;
		else if(s[0]=='T')t++;
		else if(s[0]=='R')r++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",w);
	printf("TLE x %d\n",t);
	printf("RE x %d\n",r);
	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

ll gettugibaisu(ll from, ll k) {

	ll ret = ((from + k - 1) / k) * k;

	return ret;
}

ll getmaebaisu(ll to, ll k) {

	ll ret = (to / k) * k;

	return ret;
}


signed main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<pii> b(n);
	int x = 0;
	REP(i, n) {
		cin >> a[i];
		x ^= a[i];
		REP(j, 31) {
			if (bitcheck(a[i], j)) {
				b[i] = { j, a[i] };
				break;
			}
		}
	}
	sort(ALL(b), greater<pii>());
	int cou = 0;

	REP(i, n) {
		if (bitcheck(x, b[i].first)) {
			x ^= b[i].second ^ (b[i].second - 1);
			cou++;
		}
	}
	if (x == 0) {
		cout << cou << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <random>
#include <vector>
#include <array>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ull powmod(ull  a,ull b, ull mod) {
  ull res=1;
  for(; b; b >>= 1){
    if(b & 1){
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c[3];
  vector<string> str;
  for (int i = 0; i < 3; i ++){
    string s;
    cin >> s;
    str.push_back(s);
  }

  for (int i = 0; i < 3; i ++){
    for (int j = 0; j < 3; j ++){
      if (i == j){
        c[i] = str[i][j];
      }
    }
  }

  string res(c, end(c));
  cout << res << "\n";

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
    int a, b, t;
    cin >> a >> b >> t;

    int tmp = (t + 0.5) / a;

    cout << tmp * b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>



template<class T>
struct FenwickTree {
  using size_t = std::size_t;
  T e; size_t n; std::vector<T> dat;
  FenwickTree() {}
  FenwickTree(T e, size_t n_=0) : e(e), n(n_), dat(n_+1, e) {}
  void add(size_t k, T v) { for(++k;k<dat.size();k+=k&-k) dat[k] += v; }
  T sum(size_t k) { T r=e; for(;k>0;k-=k&-k) r += dat[k]; return r; } // [0, k)
};
template<class T> auto make_bit(T e, std::size_t n=0) { return FenwickTree<T>(e, n); }



#include <iostream>

void DSL_2_B() { // RSQ
  std::cin.tie(nullptr); std::cout.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  using namespace std;
  int n, q; cin >> n >> q;
  vector<int> c(q), x(q), y(q);
  for(int i=0;i<q;++i) cin >> c[i] >> x[i] >> y[i];
  auto bit = make_bit(0, n);
  for(int i=0;i<q;++i) {
      if(c[i] == 0) bit.add(x[i]-1, y[i]);
      else cout << bit.sum(y[i]) - bit.sum(x[i]-1) << '\n';
  }
}

signed main() {

  DSL_2_B();

  return 0;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	for(int i=A; i<=10000; i+=A)
    {
        if(i%B==C)
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
	return 0;
}


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

int main(){
	double r;
	double pi = 3.14159265358979;
	cin >> r;
	
	cout << fixed;
	cout << setprecision(5);
	cout << r * r * pi;
	cout << " ";
	cout << r * 2 * pi;
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#pragma warning(disable : 4996)
 
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
 
int main(){
	int a, b, c;
	
	cin >> a >> b >> c;

        if (a <= c && c <= b) cout << "Yes"<< endl;
        else cout << "No" << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#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: 3564
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  double a, b, c;
  cin >> a >> b >> c;
  double s = (a + b + c) / 2;
  cout << sqrt(s * (s - a) * (s - b) * (s - c)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	}
	
	private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	}
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000009
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  string q;
  int l=1,r=1;
  vector<LL> hash(n+1),ruijo(n+1);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> random(0, MOD-1);
  LL base=random(mt);
  // cout << base << endl;
  hash[0]=0,ruijo[0]=1;
  char c;
  for(int i=0;i<n;i++){
    cin >> c;
    hash[i+1]=(hash[i]*base%MOD+(c-'a'+1))%MOD;
    ruijo[i+1]=ruijo[i]*base%MOD;
    // cout << c SP hash[i+1] << endl;
  }
  vector<set<LL>> part(n);
  for(int i=0;i<m;i++){
    cin >> q;
    if(q=="L++") l++;
    else if(q=="L--") l--;
    else if(q=="R++") r++;
    else if(q=="R--") r--;
    part[r-l].insert(((hash[r]-ruijo[r-l+1]*hash[l-1])%MOD+MOD)%MOD);
    // cout << l SP r << endl;
    // cout << ((hash[r]-ruijo[r-l+1]*hash[l-1])%MOD+MOD)%MOD << endl;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=part[i].size();
  }
  cout << ans << endl;
  return 0;
}



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

int main(int argc, char const *argv[])
{
	int n;
	long long m;
	cin>>n>>m;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	long long s[n+5]={};
	for (int i = 0; i < n; ++i)
	{
		s[i+1]=(s[i]+a[i])%m;
	}
	map<int,long long> mp;
	for (int i = 0; i <= n; ++i)
	{
		++mp[s[i]];
	}
	long long ans=0LL;
	for (auto i = mp.begin(); i != mp.end(); ++i)
	{
		ans+=(i->second-1LL)*i->second/2LL;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;

using namespace std;

int solve(int arr[],int n,int k)
{
	int i,j,ans;
    int dp[n];
    for(i=0;i<n;i++)dp[i]=2147483647;
    

    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
         
        }
        
    }
    
   
    return dp[n-1];
}

int main()
{
	FIO
	
		int n,k;
		cin>>n>>k;
        int arr[n];
        for(int i=0;i<n;i++)cin>>arr[i];
		cout<<solve(arr,n,k);
	

}

Measured memory_bytes: 4356
//SkGeN
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve() {
	ll n;
	cin>>n;
	ll sum = 0;
	for(int i = 1 ; i < n ; i++) {
		sum += i;
	}
	cout<<sum<<"\n";
}
int main()
{
	DANGER;
	ll t = 1;
	//cin>>t;
	while(t--) {
		solve();
	}
return 0;
}
//---->O ,,

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  cin>>S;
  S.erase(0, 5);
  if((S[0] - 48 ) * 10 + (S[1] - 48) <= 4){
		cout<<"Heisei"<<endl;
		return 0;
  }
  cout<<"TBD"<<endl;
  //cout<<S[0];
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;
 
signed main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int sum = 0;
        vector<int> p(n), j(n - 1);
        rep(i, 0, n){
            cin >> p[i];
            sum += p[i];
        }
        rep(i, 0, n - 1){
            cin >> j[i];
            sum += j[i];
        }
        sort(all(j));
        int ans = sum;
        rep(i, 0, n - 1){
            sum -= j[i];
            ans = max(sum * (i + 2), ans);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3872
#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 flag = true;
    for (int i=0; i<S.size();) {
        bool flag2 = false;
        for (int j=0; j<4; ++j) {
            string s = divide[j];
            if (S.substr(i, s.size()) == s) {
                flag2 = true;
                i += s.size();
                break;
            }
        }
        if (!flag2) {
            flag = false;
            break;
        }
    }

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

Measured memory_bytes: 512
object Main extends App {
  val a =  scala.io.StdIn.readLine()
  val aArray = a.split(" ").map(_.toLong).toSeq
  val aPos = aArray(0)
  val aHayasa = aArray(1)

  val b =  scala.io.StdIn.readLine()
  val bArray = b.split(" ").map(_.toLong).toSeq
  val bPos = bArray(0)
  val bHayasa = bArray(1)

  val t = scala.io.StdIn.readLong()

  val max = 1000000000
  var sabun = 0L
  var maxSabun = 0L

  if (aPos < 0L && bPos >= 0L) {
    sabun = bPos - aPos
    maxSabun = max - aPos
  } else if (aPos >= 0L && bPos < 0L) {
    sabun = aPos - bPos
    maxSabun = max + aPos
  } else {
    sabun = Math.abs(bPos - aPos)
    maxSabun = max - Math.abs(aPos)
  }

  if (sabun - (aHayasa * t - bHayasa * t) <= 0L) {
    println("YES")
  } else {
    //if (maxSabun - aHayasa * t <= 0L) {
    //  println("YES")
    //} else {
    //  println("NO")
    //}
    println("NO")
  }
}

Measured memory_bytes: 54740
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 100005



// Driver code to tes above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int n;
    cin >> n;
    int ans = MAXI;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans = min(ans, i+n/i -2);
        }
    }

    cout << ans;

    return 0;
    
} 

Measured memory_bytes: 256