akhauriyash/Code-Regression huggingface dataset:
#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 ll;
#define all(x) (x).begin(),(x).end()
int INF = 100000000;

int main() {
  int N; cin >> N;
  map<string, int> mp;
  vector<string> s(N);
  rep(i, N) {
    cin >> s[i];
    mp[s[i]]++;
  }
  int M; cin >> M;
  vector<string> t(M);
  rep(i, M) {
    cin >> t[i];
    mp[t[i]]--;
  }
  int ans = 0;
  rep(i, s.size()) {
    int cnt = mp[s[i]];
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int n, q; 
	 cin >> n;
	 ll sum = 0;
	 vector<int> cnt(100008, 0);
	 for(int i = 0; i < n; ++i) {
		 int x;
		 cin >> x;
		 cnt[x]++;
		 sum += x;
		 }
	 cin >> q;
	 for(int i = 0; i < q; ++i) {
		 int x, y; 
		 cin >> x >> y;
		 sum += (y - x) * cnt[x];
		 cnt[y] += cnt[x];
		 cnt[x] = 0;
		 cout << sum << endl;
		 }
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
		solve();
	return 0;
}
 















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

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

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


int main(){

ll a,b;
  
cin >> a >> b;
  
  cout << lcm(a,b) << endl;
  
  
  
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a,b;
	cin>>a>>b;
	string k = b.substr(0,(int) a.size());
	if(k == a)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3532
def main():
    N = int(input())
    A = list(map(int, input().split()))
    all_val = sum(A)
    A = A[::-1]

    sum_val = 0
    for i in range(len(A)):
        all_val -= A[i]
        sum_val += all_val * A[i] % (10**9 + 7)
    return sum_val % (10**9 + 7)

if __name__ == '__main__':
    print(main())

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

int main()
{
    int n,i;
    cin >> n;
    int a[n+1];
    int cost[n+1];
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    
    cost[1] = 0;
    cost[2] = abs(a[1] - a[2]);
    for(i=3;i<=n;i++)
    {
        cost[i] = min(cost[i-2] + abs(a[i-2] - a[i]), cost[i-1] + abs(a[i-1] - a[i]));
    }
    
    cout << cost[n];
    
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  long long sol = 0;
  sol = n * (n - 1) / 2;
  sol += m * (m - 1) / 2;
  cout << sol << "\n";
  
  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
      	String[] l2 = br.readLine().split(" ");
      
      	int N = Integer.parseInt(l2[0]);
      	int K = Integer.parseInt(l2[1]);
        
        String[] l1 = br.readLine().split(" ");
 
        int[] arr = new int[N];
 
        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }
 
        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
 
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + K && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);
 
    }
}

Measured memory_bytes: 35036
#include<bits/stdc++.h>
#define int long long
using namespace std;
int INF = 1e10;

signed main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int ret = 0;
    for(int i = 0;i < N - 1;i++) {
        for(int j = i + 1;j < N;j++) {
            ret += vec.at(i) * vec.at(j);
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll sum;
ll x;
vector<pair<ll,ll>> ans[100000];
ll iseven[100000];
ll visited[100000];
vector<ll> vec[100000];
vector<ll> alr[100000];
vector<pair<ll,ll>> pres;
void adddp(ll n);
void samedp(ll n);
void samedp(ll n){
  if(visited[n]){return;}
  visited[n] = 1;
  for(auto itr:vec[n]){
    samedp(itr);
  }
  for(auto itr:vec[n]){
    if(count(alr[n].begin(),alr[n].end(), itr) > 0){continue;}
    alr[itr].push_back(n);
    if(iseven[n] % 2 == 0){
      iseven[itr]++;
      pres.push_back(make_pair(n,itr));
    }else{
      iseven[n]++;
      pres.push_back(make_pair(itr,n));
    }
  }
}
int main(){
  ll n,m,x,y;
  cin >> n >> m;
  rep(i,m){
    cin >> x >> y;
    x--;y--;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  memset(iseven,0,sizeof(iseven));
  memset(visited,0,sizeof(visited));
  samedp(0);
  bool can = true;
  rep(i,n){
    if(iseven[i] % 2 != 0){
      can = false;
      break;
    }
    //cout << iseven[i];
  }
  if(can){
    rep(i,m){
        cout << pres[i].second+1 << " " << pres[i].first+1 << endl;
    }
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 24048
#include <iostream>
#include <stdio.h>

using namespace std;

int n,k;

int findTrackMax(int stackWeight[]){
	int max = 0;
	for(int i = 0; i < k; i++){
		if(max < stackWeight[i]){
			max = stackWeight[i];
		}
	}
	return max;
}

bool pileW(int w[],int p){

	int trial[k],index_w=0,index_track=0,tmp=0;

	for(int i = 0; i < k; i++){
		trial[i] = 0;
	}

	while(true){
		if(tmp + w[index_w] <= p){
			tmp += w[index_w++];
		}else{
			trial[index_track++] += tmp;
			tmp = 0;
		}

		if(index_track == k-1){
			for(int i = index_w; i < n; i++){
				trial[index_track] += w[i];
			}
			return (trial[index_track] <= p);
		}else if(index_w == n-1){
			return (w[index_w] <= p);
		}
	}
}

int main(){

	scanf("%d %d",&n,&k);
	int w[n],guessPMax[k];

	for(int i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	for(int i = 0; i < k; i++){
		guessPMax[i] = 0;
	}

	if(k == 1){
		int onetrack;
		for(int i = 0; i < n; i++){
			onetrack += w[i];
		}
		printf("%d\n",onetrack);
	}else{

		int p_trial_number;
		if(n >= k){
			if(n%2 == 0 && k%2 == 0){
				p_trial_number = n/k;
			}else{
				p_trial_number = n/k + 1;
			}
		}else{
			p_trial_number = 1;
		}

		int k_trial = 0,n_trial = 0;
		while(true){
			for(int i = 0; (i < p_trial_number && n_trial < n-1);i++){
				guessPMax[k_trial] += w[n_trial++];
			}
			k_trial++;
			if(k_trial == k-1){
				for(int i = n_trial;i < n;i++){
					guessPMax[k_trial] += w[i];
				}
				break;
			}else if(n_trial == n-1){
				guessPMax[k-1] += w[n_trial];
				break;
			}
		}

		int right = findTrackMax(guessPMax),left = w[0],m;

		if(right - left == 1){
			if(pileW(w,left)){
				right = left;
			}
		}else{
			while(right - left > 1){
				m = (left + right)/2;
				if(pileW(w,m)){
					right = m;
				}else{
					left = m;
				}
			}
		}
		printf("%d\n",right);
	}
}

Measured memory_bytes: 1964
#include<stdio.h>

int N=100;
 
int main(){
  int M[N][N];
  int i,j,n,u,k,v;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){ 
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){ 
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){ 
    for(j=0;j<n;j++){
      if(j){
	printf(" ");
      }
      printf("%d",M[i][j]);   
    }
    printf("\n"); 
  }
 
  return 0;
}
 

Measured memory_bytes: 640
#include <bits/stdc++.h> // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repto(i, n) for (int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

__attribute__((constructor)) void initial()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int N, X, Y;
int L[2001][2001];

void bfs(int start, int current, int l)
{
    queue<int> q;
    q.push(current);
    queue<int> nextQ;

    do
    {

        while (!q.empty())
        {
            int cur = q.front();
            q.pop();
            if (L[start][cur] != -1)
            { // 既に値があるパターンはパス
                continue;
            }
            L[start][cur] = l; // 最初のポジション埋め

            // 左へ
            if (cur > 1 && L[start][cur - 1] == -1)
            {
                nextQ.push(cur - 1);
            }

            // 右へ
            if (cur < N && L[start][cur + 1] == -1)
            {
                nextQ.push(cur + 1);
            }

            // X → Y へ
            if (cur == X && L[start][Y] == -1)
            {
                nextQ.push(Y);
            }

            // Y → X へ
            if (cur == Y && L[start][X] == -1)
            {
                nextQ.push(X);
            }
        }

        l++;
        q = nextQ;
        queue<int>().swap(nextQ);
    } while (!q.empty());
}

int main()
{
    // 配列初期化
    Fill(L, -1);
    // 全ての点から全ての点への最短距離を計算
    cin >> N >> X >> Y;

    // 全最短距離埋め
    for (int i = 1; i <= N; i++)
    {
        bfs(i, i, 0);
    }

    int cnt[2001] = {0};

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {

            cnt[L[i][j]]++;
        }
    }

    for (int i = 1; i <= N - 1; i++)
    {
        cout << (cnt[i] / 2) << endl;
    }
}


Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    ans = 0
    for i in range(N):
        ans += (i + 1)*(N - i)
    for _ in range(N - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        if a > b:
            a,b = b,a
        ans -= (N - b) * (a + 1)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5, MAX = 1e18;
int n, a[N], l1[N], r1[N], l2[N], r2[N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	n++;
	fw (i, 0, n) cin >> a[i];
	l1[0] = r1[0] = 1;
	fw (i, 1, n) {
		l1[i] = max(0ll, l1[i - 1] - a[i - 1]);
		r1[i] = min(MAX, 2 * (r1[i - 1] - a[i - 1]));
	}
	
	l2[n - 1] = r2[n - 1] = a[n - 1];
	bw (i, n - 1, 0) {
		l2[i] = ((l2[i + 1] + 1) / 2) + a[i];
		r2[i] = r2[i + 1] + a[i];
	}
	int ans = 0;
	fw (i, 0, n) {
		if (r1[i] < l2[i] || r2[i] < l1[i]) {
			cout << "-1\n";
			return 0;
		} else {
//			cout << max(l1[i], l2[i]) << " " << min(r1[i], r2[i]) << "\n";
			ans += min(r1[i], r2[i]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
//#pragma comment(linker, ”/STACK:36777216“)

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 1)
	cout << b - a;
 else cout << a - b;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(input())

first = s[0]
second = 'R' if first=='L' else 'L'

i = 0
while k > 0 and i < n:
    if s[i] ==second:
        while i < n and  s[i] == second:
            s[i] = first
            i += 1
        k -= 1
    else:
        i += 1

# print(s)

ans = 0

def happy_check(i):
    global ans
    if i < n-1 and s[i] == 'R' and s[i+1] == 'R':
        ans += 1
    elif 0 < i and s[i] == 'L' and s[i-1] == 'L':
        ans += 1

for i in range(n):
    happy_check(i)

print(ans)

Measured memory_bytes: 77352
import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        int x = sc.nextInt();
        int y = sc.nextInt();
        double s = w*h/2.0;
        int e;
        if(x == w/2 && y ==h/2 && w % 2 ==0 && h % 2==0){
            e =1;
        }else{
            e = 0;
        }



        System.out.println(s);
        System.out.println(e);

    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    vector<int> vec(5);
    rep(i, 5)  cin >> vec[i];

    vector<pair<int, int>> p;
    rep(i, 5) {
        p.push_back(make_pair(vec[i]%10, vec[i]));
    }
    sort(p.begin(), p.end());
    int ans = 0;
    bool flag = true;
    rep(i, 5) {
        if (p[i].first != 0 && flag) {
            ans += p[i].second;
            flag = false;
        } else {
            if (p[i].second % 10 != 0) {
                ans += ((p[i].second / 10) + 1) * 10;
            } else {
                ans += p[i].second;
            }
        }
    }

    print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, K;
	cin >> N >> K;

	vector<ll> H(N);
	for (ll i = 0; i < N; ++i) cin >> H[i];

	sort(H.begin(), H.end());
	reverse(H.begin(), H.end());

	ll ans = 0;

	for (ll i = 0; i < N; ++i)
	{
		if (K > 0)
		{
			--K;
			continue;
		}

		ans += H[i];
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = []
for i in range(N-1):
  if A[i+1] - A[i] == 1:
    D.append(C[A[i]-1])
for j in range(N):
  D.append(B[j])
print(sum(D))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,K;cin >> N >> K;
  vector<ll> v(N);
  rep(i,N)cin >> v[i];
  sort(all(v));

  auto f = [&](ll x){
    ll total = 0;
    
    rep(i,N){
      if(v[i] < 0){
        int l = -1, r = N;
        while(r-l>1){
          int c = (l+r)/2;
          if(v[c]*v[i] < x) r = c;
          else l = c;
        }
        total += N-r;
      }else{
        int l = -1, r = N;
        while(r-l>1){
          int c = (l+r)/2;
          if(v[c]*v[i] < x) l = c;
          else r = c;
        }
        total += r;
      }
      if(v[i]*v[i] < x) --total;
    }
    total/=2;
    return total < K;

  };

  ll l = -1e18-1, r = 1e18+1;
  while(r-l>1){
    ll m = (l+r)/2;
    if(f(m)) l = m;
    else r = m;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

#define f first
#define s second

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<pair<int,int>> D;
	
	cin>>N;
	
	D.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>D[i].f>>D[i].s;
	}
	
	for(int i = 2; i < N; i++){
		int con = 0;
		
		if(D[i].f == D[i].s) con++;
		if(D[i-1].f == D[i-1].s) con++;
		if(D[i-2].f == D[i-2].s) con++;
		
		if(con == 3) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] candy = new int[3];
    candy[0] = sc.nextInt();
    candy[1] = sc.nextInt();
    candy[2] = sc.nextInt();
    Arrays.sort(candy);
    String ans = "No";
    if(candy[2] == (candy[0] + candy[1])) ans = "Yes";
    System.out.println(ans);
  }
}

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var n = cin.ReadInt();
            Console.WriteLine(n * (n + 1) / 2);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine()   { return Console.ReadLine(); }
        public int    ReadInt()    { return int.Parse(Read()); }
        public long   ReadLong()   { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
    }

    public class MyUtility
    {
        /// <summary>2値を入れ替える</summary>
        public static void Swap<T>(ref T m, ref T n)
        {
            T tmp = m;
            m = n;
            n = tmp;
        }

        public static void PutYN(bool f)
        {
        	Console.WriteLine(f ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13268
# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))

# 各頂点の次数をカウント
dp = [0 for _ in range(N + 1)]
for a, b in zip(A, B):
    dp[a] += 1
    dp[b] += 1

# 全ての頂点の次数が偶数ならば解はYES
ans = 'YES' if all(dp[i] % 2 == 0 for i in range(1, N + 1)) else 'NO'

# 出力
print(ans)


Measured memory_bytes: 57468
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll dp[3010][3010][2]= {};
ll N;
ll a[3010];

ll dfs(ll lv=0, ll rv=N-1, ll turn=0){
    ll &res = dp[lv][rv][turn];
    if(~res) return res;
    res = 0;
    if(lv == rv){
        res = a[lv];
        return res;
    }
    res = -INF;
    if(turn == 0){
        res = max(a[lv] - dfs(lv+1, rv, 1), a[rv] - dfs(lv, rv-1, 1));
    }else{
        res = max(a[lv] - dfs(lv+1, rv, 0), a[rv] - dfs(lv, rv-1, 0));
    }
    return res;

}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    memset(dp,-1, sizeof(dp));
    ll ans = dfs();
    print(ans);

}


Measured memory_bytes: 141952
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------
sys.setrecursionlimit(100005)
mod = 1000000007
N=int(2*1e5+100)
sz = [0]*N
dp = [0]*N
gr = defaultdict(list)
def modPow(a,b):
    ans=1
    while (b):
        if (b&1): ans=(ans*a)%mod
        b>>=1
        a=(a*a)%mod
    return ans

def modInv(x):
    return modPow(x,mod-2)

def dfs(x, par):
    sz[x]=1
    for item in gr[x]:
        if item==par: continue
        dfs(item,x)
        sz[x]+=sz[item]

def dfs1(x, par):
    for item in gr[x]:
        if item==par: continue
        dp[item]=(dp[x]*(n-sz[item]))%mod
        dp[item]=(dp[item]*modInv(sz[item]))%mod
        dfs1(item,x)

n = int(input())
for i in range(n-1):
    x,y = mapi()
    gr[x].append(y)
    gr[y].append(x)
dfs(1,0)
dp[1]=1
for i in range(1,n+1):
    dp[1]=(dp[1]*sz[i])%mod
dfs1(1,0)
res = 1
for i in range(1,n+1):
    res = (res*i)%mod
for i in range(1,n+1):
    dp[i]=(res*modInv(dp[i]))%mod
for i in range(1,n+1):
    print(dp[i])


Measured memory_bytes: 133340
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
}
int main() {
	int n;
	cin >> n;
	string s; int k;
	cin >> s >> k;
	rip(i, n) {
		if (s[i] != s[k - 1])s[i] = '*';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const double eps = 1e-11;
const int inf = 1ll << 62;

signed main(){
	int n;cin>>n;
	string s;
	while(n){
		if(n&1){
			s.push_back('1');
			n--;
			}
		else{
			s.push_back('0');
			}	
		n/=-2;	
		}
		if(s.empty())s.push_back('0');
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n;
  int m=0;
  int d[101];
  int i;
  int max=0;
  int num[101];
  scanf("%d",&n);
  for(i=0;i<101;i++){
    num[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    if(d[i]>max) max=d[i];
    num[d[i]]++;
  }
  for(i=0;i<=max;i++){
    if(num[i]>=1){
      m++;
    }
  }
  printf("%d",m);
  return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
int main(int argc, char const *argv[]){
	int n,m,a[1000],i,max,tmp,j;
	scanf("%d %d",&n,&m);
	while(n>=2&&m>=2){
		max=0;
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n;i++)
			for(j=i+1;j<n;j++){
				tmp=a[i]+a[j];
				if(tmp<=m&&tmp>max)
					max=tmp;
			}
		if(max==0)printf("NONE\n");
		else printf("%d\n",max);
		scanf("%d %d",&n,&m);
	}
		return 0;
}


Measured memory_bytes: 2104
z[9][101][101];n,m,t,c,b;main(a){for(;scanf("%d%d",&n,&m)*n;){for(memset(z,9,9e4);n--;z[0][a][b]=z[0][b][a]=c)scanf("%d%d%d%d",&a,&b,&c,&t),z[1][a][b]=z[1][b][a]=t;for(t=m;t;--t)for(c=m;c;--c)for(b=m;b;--b)for(a=2;a--;)z[a][b][c]=fmin(z[a][b][c],z[a][b][t]+z[a][t][c]);for(scanf("%d",&n);n--;printf("%d\n",z[a][b][c]))scanf("%d%d%d",&c,&b,&a);}}

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

int parse(const vector<string>& subgrid)
{
  unsigned s = 0;
  s |= ((subgrid[1][3] == '-') << 6);
  s |= ((subgrid[2][2] == '|') << 5);
  s |= ((subgrid[2][4] == '|') << 4);
  s |= ((subgrid[3][3] == '-') << 3);
  s |= ((subgrid[4][2] == '|') << 2);
  s |= ((subgrid[4][4] == '|') << 1);
  s |= ((subgrid[5][3] == '-') << 0);
  switch (s) {
    case 19:  return 1;
    case 93:  return 2;
    case 91:  return 3;
    case 58:  return 4;
    case 107: return 5;
    case 111: return 6;
    case 82:  return 7;
    case 127: return 8;
    case 123: return 9;
    default:  throw "unrecognized char";
  }
}

void lr(vector<string>& subgrid)
{
  for (vector<string>::iterator it = subgrid.begin(); it != subgrid.end(); ++it) {
    reverse(it->begin(), it->end());
  }
}

void ud(vector<string>& subgrid)
{
  reverse(subgrid.begin(), subgrid.end());
}

void rot(vector<string>& subgrid)
{
  const vector<string> src(subgrid);
  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 7; j++) {
      if (src[i][j] == '|') {
        subgrid[6-j][i] = '-';
      } else if (src[i][j] == '-') {
        subgrid[6-j][i] = '|';
      } else {
        subgrid[6-j][i] = src[i][j];
      }
    }
  }
}

int main()
{
  string line;
  while (cin >> line && line != "0") {
    vector<string> lines(1, line);
    for (int i = 1; i < 21; i++) {
      cin >> line;
      lines.push_back(line);
    }
    int d[2][6];
    for (int k = 0; k < 2; k++) {
      static const int tbl[][2] = {{0,7},{7,0},{7,7},{7,14},{7,21},{14,7}};
      for (int i = 0; i < 6; i++) {
        vector<string> grid;
        for (int j = 0; j < 7; j++) {
          grid.push_back(lines[tbl[i][0]+j].substr(tbl[i][1]+29*k, 7));
        }
        switch (i) {
          case 0:
          case 2:
          case 4:
            lr(grid);
            break;
          case 1:
            rot(grid);
            rot(grid);
            rot(grid);
            lr(grid);
            break;
          case 3:
            rot(grid);
            lr(grid);
            break;
          case 5:
            lr(grid);
            ud(grid);
            break;
        }
        d[k][i] = parse(grid);
      }
    }
    int w[2] = {0, 0};
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 6; j++) {
        if (d[0][i] > d[1][j]) {
          ++w[0];
        } else if (d[0][i] < d[1][j]) {
          ++w[1];
        }
      }
    }
    cout << (w[0] < w[1] ? "LOW" : "HIGH") << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
mint choose(int n,int a){
  mint x = 1,y=1;
  rep(i,a){
    x*= n-i;
    y*= i+1;
  }
  return x/y;
}
int main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]%=mod;}
  sort(been(a));
  combination c(n+5);
  mint ans =0;
  rep(_,2){
    rep(i,n){
      mint  sum =c(n-i-1,k-1);
      if(_==0)ans -=(mint)a[i]*sum;
      else ans+=(mint)a[i]*sum;
    }
    reverse(been(a));
  }
  cout<<ans.x<<endl;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

struct edge {
  int v1;
  int v2;
  int c;
};

int main() {
  int l; std::cin >> l;
  int n = int(log2(l))+1;

  std::vector<edge> es;
  for (int i = 1; i < n; i++) {
    es.push_back(edge{i-1, i, 0});
    es.push_back(edge{i-1, i, int(pow(2, i-1))});
  }
  for (int m = n-1; m > 0; m--) {
    int sub = l - pow(2, m-1);
    if (sub >= pow(2, n-1)) {
      l -= pow(2, m-1);
      es.push_back(edge{m-1, n-1, sub});
    }
  }

  std::cout << n << " " << es.size() << std::endl;
  for(auto e : es) {
    std::cout << e.v1+1 << " " << e.v2+1 << " " << e.c << std::endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define kragar ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	kragar

   int n;
   cin>>n;
   int x=n%10;
   if(x==2||x==4||x==5||x==7||x==9)
   	cout<<"hon";
   else if(x==0||x==1||x==6||x==8)
   	cout<<"pon";
   else
   	cout<<"bon";
}


Measured memory_bytes: 3612
#include<iostream>
#include<queue>
#include<map>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int w,h,ans,swn[256],nsw;
char f[31][31];
bool V[30][30][256];
int main(){
	while(cin>>w>>h,w){
		rep(i,256)swn[i]=-1;nsw=0;
		int sy,sx;
		rep(i,h)cin>>f[i];
		rep(i,h)rep(j,w){
			if(f[i][j]=='@')sy=i,sx=j,f[i][j]='.';
			if('a'<=f[i][j]&&f[i][j]<='z'&&swn[f[i][j]]<0)swn[f[i][j]]=nsw++;
			rep(k,256)V[i][j][k]=0;
		}
		ans=-1;V[sy][sx][0]=1;
		queue<pair<pair<int,int>,pair<int,int> > > Q;Q.push(make_pair(make_pair(sy,sx),make_pair(0,0)));
		while(!Q.empty()){
			int y=Q.front().first.first,x=Q.front().first.second,
			s=Q.front().second.first,c=Q.front().second.second;
			Q.pop();
			if(f[y][x]=='>'||f[y][x]=='<'){
				ans=c;break;
			}
			rep(d,4){
				int ny=y+dy[d],nx=x+dx[d],ns=s;
				if(f[ny][nx]=='#'||'A'<=f[ny][nx]&&f[ny][nx]<='Z'&&!(s&1<<swn[f[ny][nx]-'A'+'a']))continue;
				if('a'<=f[ny][nx]&&f[ny][nx]<='z')ns^=1<<swn[f[ny][nx]];
				if(!V[ny][nx][ns])V[ny][nx][ns]=1,Q.push(make_pair(make_pair(ny,nx),make_pair(ns,c+1)));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
using System;
class program
{
	static void Main()
	{
    string number=Console.ReadLine();
    int count=1;
    char lastnumber='a';
    for(int i=0;i<4;i++)
    {
     // Console.WriteLine(number[i]);
      if(lastnumber==number[i])
        count++;
      else
      {
        count=1;
        lastnumber=number[i];
      }
       if(count>=3)
       {
      Console.WriteLine("Yes");
      break;
       }
    }
    if(count<3)
      Console.WriteLine("No");
      
    }
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    cout << min(n % k, k - (n % k)) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< pair<int, int> > R(N);
	for(int i = 0; i < N; i++) cin >> R[i].ff >> R[i].ss;
	sort(begin(R), end(R));
	vector<int> st = {0};
	for(int i = 1; i < N; i++) {
		while(!st.empty() && R[st.back()].ff+R[st.back()].ss >= R[i].ff+R[i].ss)
			st.pop_back();
		if(!st.empty() && R[st.back()].ff+R[st.back()].ss > R[i].ff-R[i].ss)
			continue;
		st.push_back(i);
	}
	cout << st.size() << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll K; cin >> K;
  ll n = 50;
  ll a = K / n;
  ll b = K % n;

  cout << n << endl;
  rep(i, n) {
    ll ans = a + i;
    if (i >= n-b) ans++;
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(abs(a-c)<=d) cout<<"Yes"<<endl;
  else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char S = '#';
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i,h) cin >> s[i];

    vector<vector<int>> ans(h,vector<int>(w));

    vector<pii> st;
    int c = 1;
    REP(i,h) REP(j,w) {
        if (s[i][j] == S) {
            ans[i][j] = c;
            c++;
            st.push_back({i,j});
        }
    }

    for(auto t:st) {
        //cerr << "t" << t.first << " " << t.second << endl;
        int xs = t.second, xe = t.second;
        int ys = t.first, ye = t.first;
        while(xs > 0 && ans[ys][xs-1] == 0) xs--;
        while(xe < w && ans[ys][xe+1] == 0) xe++;
        bool b = true;
        while(b) {
            if (ys-1 < 0) {
                b = false; break;
            }
            FOR(i,xs,xe+1) {
                if (ans[ys-1][i] != 0) {
                    b = false; break;
                }
            }
            if (b) ys--;
        }
        b = true;
        while(b) {
            //cerr << ye << endl;
            if (ye+1 >= h) {
                b = false; break;
            }
            FOR(i,xs,xe+1) {
                if (ans[ye+1][i] != 0) {
                    b = false; break;
                }
            }
            if (b) ye++;
        }
        FOR(y,ys,ye+1) FOR(x,xs,xe+1) {
            //cerr << y << " " << x << endl;
            ans[y][x] = ans[t.first][t.second];
        }
        
    }


    for(auto v:ans) {
        REP(i,v.size()-1) cout << v[i] << " ";
        cout << v.back() << endl;
    }

    return 0;
}


Measured memory_bytes: 2040
n, x = map(int,input().split())
l = list(map(int,input().split()))
a = [0]
for i in range(n):
    tmp = a[i] + l[i]
    a.append(tmp)
ans = 0
for i in range(n + 1):
    if (a[i] <= x):
        ans = ans + 1

print(ans)


Measured memory_bytes: 9084
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef long long ll;

using namespace std;

int main(){
  int n,m,ta,tb;
  std::cin >> n >> m;
  int a[m],b[m],c[m];
  int d[n+1][n+1];
  fill(d[0],d[n+1],INF);
  int ans=0,temp=1;

  rep(i,m){
    std::cin >> ta >> tb >> c[i];
    a[i]=ta-1,b[i]=tb-1;
    d[a[i]][b[i]]=c[i];
    d[b[i]][a[i]]=c[i];
  }
  rep(i,n){
    d[i][i]=0;
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        d[i][j]=min(d[i][j],d[i][k]+d[j][k]);
        d[j][i]=d[i][j];
      }
    }
  }
  rep(k,m){
    temp=1;
    rep(i,n){
      if(d[i][a[k]]+c[k]==d[i][b[k]]){
        temp*=0;
        break;
      }
    }
    ans+=temp;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<set>
using namespace std;
#define pb push_back
#define fi first
#define sc second

int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if((a%2)*(b%2)*(c%2)==0){
		cout<<0<<endl;
	}else{
		cout<<min(min(a*b,b*c),c*a)<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll X, Y;
  cin >> X >> Y;
  // (i + 1, j + 2) -> m
  // (i + 2, j + 1) -> n
  // m + 2n = X
  // 2m + n = Y
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  for (ll m = 0; m <= 1000000; m++) {
    if ((X - m) % 2 != 0) {
      continue;
    }
    // n = (X - m)/2
    // n = Y - 2m;
    if (X - m < 0) {
      continue;
    }

    if ((X - m) / 2 == Y - 2 * m) {
      ll n = Y - 2 * m;
      ans += modCombination(n + m, n, MOD);
    }
  }

  cout << ans % MOD << endl;

  return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l, r;
  l = 0;
  r = n - 1;
  int cnt = 0;
  while (l < r) {
    while (s[l] == 'R') l++;
    while (s[r] == 'W') r--;
    if (r <= l) break;
    swap(s[l], s[r]);
    cnt++;
    dump(s);
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

console.log(main());
function main(){
  var n = o.a();
  var a = o.a();
  n %= 500;
  return n > a ? "No" : "Yes";
}

Measured memory_bytes: 7372
import java.io.*;

import static java.lang.Integer.*;

public class Main {
    static PrintWriter prnt = new PrintWriter(System.out);
    static BufferedReader read;

    public static void main(String[] args) throws IOException {
        read = new BufferedReader(new InputStreamReader(System.in));

        int x = parseInt(read.readLine());

        if (x >= 30){
            prnt.println("Yes");
        } else {
            prnt.println("No");
        }
        prnt.close();
    }
}


Measured memory_bytes: 32532
#include "bits/stdc++.h"

using namespace std;
using int64 = long long int;

constexpr int MaxN = 1000 + 10;
string S[20];
int sum[20][MaxN];

int BitCount(long bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int main()
{
	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
	{
		cin >> S[i];

		for (int j = 0; j < w; j++)
		{
			sum[i][j + 1] += sum[i][j] + (S[i][j] == '1' ? 1 : 0);
		}
	}

	int ans = 1 << 30;

	for (int bit = 0; bit < (1 << (h - 1)); bit++)
	{
		int left = 0, right = 1;
		int thisAns = BitCount(bit);
		while (left < w)
		{
			int currentSum = 0;
			for (int x = 0; x < h; x++)
			{
				currentSum += sum[x][right] - sum[x][left];

				if (x == h - 1 || ((1 << (x)) & bit) != 0)
				{
					if (currentSum > k)
					{
						if (right - left == 1)
						{
							thisAns = 1 << 30;
							break;
						}

						thisAns++;
						left = right - 1;
						//right++;
						//goto MoveNext;
						break;
					}

					currentSum = 0;
				}
			}

			right++;
			if (right == w + 1)
			{
				break;
			}
			//MoveNext:
		}

		ans = min(ans, thisAns);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	char code[n + k + 1];
	scanf("%s", code);
	int temp = 0;
	for (int i = 0; i < n + k + 1; i++){
		if (i != n){
			if (code[i] >= '0' && code[i] <= '9'){
				temp++;	
			}
		}
		else if (code[i] == '-'){
			temp++;
		}
	}
	if (temp == n + k + 1){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 1664