akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  int N = 10;
  int d[N][N];  //隣接行列

  REP(i, N) REP(j, N) { cin >> d[i][j]; }

  REP(k, N) REP(i, N) REP(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  int A[H][W];
  REP(i, H) REP(j, W) { cin >> A[i][j]; }

  int ans = 0;
  REP(i, H) REP(j, W) {
    if(A[i][j] != -1) {
      ans += d[A[i][j]][1];
    }
  }
  cout << ans << endl;
}


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

struct st
{
  int t;
  bool sta;
  st(int _t, bool _sta) : t(_t), sta(_sta) {}
};

int main()
{
  int n, t;
  cin >> n >> t;
  vector<st> v;
  v.reserve(n+n);
  for(int i = 0; i < n; ++i){
    int tmp;
    cin >> tmp;
    v.push_back(st(tmp, true));
    v.push_back(st(tmp+t, false));
  }
  sort(v.begin(), v.end(), [](st a, st b){return a.t < b.t;});
  int stack = 0, sum = 0, pre = 0;
  for(int i = 0; i < v.size(); ++i){
    if (v[i].sta){
      if (stack == 0){
        pre = v[i].t;
      }
      ++stack;
    }else{
      --stack;
      if (stack == 0){
        sum += v[i].t - pre;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))
#define bs(n) ((ull)1<<(ull)n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

int main() {
    ull n;
    ll k, l, r;
    cin >> n >> k >> l >> r;
    auto a = new ll[n];
    rep(i, n)cin >> a[i];
    ull s1 = bs(n / 2), s2 = bs((n + 1) / 2);
    vector<pair<ll, ll>> u(s1), v(s2);
    for (ull i = 0; i < s1; i++) {
        int c = 0;
        for (unsigned j = 0; j < n / 2; j++) {
            if (i & (1u << j)) {
                c++;
                u[i].second += a[j];
            }
        }
        u[i].first = c;
    }
    for (ull i = 0; i < s2; i++) {
        int c = 0;
        for (unsigned j = 0; j < (n + 1) / 2; j++) {
            if (i & (1u << j)) {
                c++;
                v[i].second += a[j + n / 2];
            }
        }
        v[i].first = c;
    }
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    ll ret = 0;
    for (auto &e:u) {
        auto p = lower_bound(v.begin(), v.end(), mp(k - e.first, l - e.second));
        auto q = upper_bound(v.begin(), v.end(), mp(k - e.first, r - e.second));
        ret += q - p;
    }
    cout << ret << endl;
}



Measured memory_bytes: 35492
#include <bits/stdc++.h>
using namespace std;
 
int top, S[1000]; 
 
void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main () 
{
    int a, b;
    top = 0;
    char s[100];
    
    while (std::cin >> s)
    {
        if (s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a * b);
        }
        else
        {
            push(atoi(s));
        }
    }
    
    std::cout << pop() << std::endl;
    
    return 0;
}


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

int N;
int d[10001];
int ans[100][2];

int main(){
	int i,j;
	for(i = 0;cin >> N;i++){
		if(N == 0)
			break;
		for(j = 0;j < 10001;j++){
			d[j] = 0;
		}
		for(j = 0;j < N;j++){
			int p,d1,d2;
			cin >> p >> d1 >> d2;
			d[p] = d1 + d2;
		}
		for(j = 0;j < 10001;j++){
			if(d[j] > ans[i][1] ){
				ans[i][1] = d[j];
				ans[i][0] = j;
			}
		}
	}
	for(j = 0;j < i;j++){
		cout << ans[j][0] << " " << ans[j][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import itertools


def average_distance(N, points):
    order = list(itertools.permutations(points))
    distance = []
    for ord in order:
        d = 0
        for i in range(len(ord) - 1):
            d += ((ord[i][0] - ord[i + 1][0]) ** 2 + (ord[i][1] - ord[i + 1][1]) ** 2) ** (1 / 2)
        distance.append(d)
    return sum(distance) / len(distance)


N = int(input())
town = []
for i in range(N):
    town.append(list(map(int, input().split())))
res = average_distance(N, town)
print(res)

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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 1000000000000000000
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 5
#define N 8
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    ll temp = vpow(a, b / 2, p);
    temp *= temp;
    temp %= p;
    if (b % 2 == 0)
        return temp;
    temp = temp * a;
    temp %= p;
    return temp;
}

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


ll inverseMod(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    ll temp = vpow(b, p - 2, p);
    ll ans = temp * a;
    ans %= p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

void factorial() {
    fact[0] = 1;
    fact[1] = 1;
    rep(i, 2, MAX) {
        fact[i] = (fact[i - 1] * i);
        // fact[i]%=M;
    }
}
void solve(ll ttt) {
    ll s;
    cin>>s;
    // if(s<)
    ll dp[s+5];
    rep(i,0,s+1)
        dp[i]=-1;
    dp[0]=1;
    dp[1]=dp[2]=0;
    dp[3]=dp[4]=1;
    if(s<=4){
    	cout<<dp[s]<<endl;
    	return ;
    }
    rep(ss,5,s+1){
    	dp[ss]=0;
    	rep(i,3,ss+1){
    		dp[ss]+=dp[ss-i];
    		dp[ss]%=M;
    	}
    }
    ll ans=dp[s];
    cout<<ans<<endl;
}

int main() {
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    // freopen("output1.txt","w",stdout);
#endif

    ll t = 1;
    //cin >> t;
    fix(12);
    rep(q, 1, t + 1) {
        // cout<<"Test case : "<<q<<endl;
        solve(q);
        //solve2();
    }
    return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
	
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i, mn, mx) for(int i = (mn); i < (mx); i++)

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << endl;

using namespace std;

int n, k, x, y, f;
vector<ii> v;

int main(){
	cin >> n >> k;

	if(n == 1 && k == 1){
		printf("YES\n");
		return 0;

	}
	
	if(k >= n) {
		printf("NO\n");
		return 0;
	}

	if(n%2 && k > n/2+1){
		printf("NO\n");
		return 0;
	}

	if(!(n%2) && k > n/2){
		printf("NO\n");
		return 0;
	}

	printf("YES\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
    using namespace std;
    char c,ans;
    int i;
    string s;
    getline(cin, s);
    int size = s.size();
    for(i=0;i<size;i++){
        c = s[i];
        if(isupper(c)!=0&&islower(c)==0){
            ans = tolower(c);
        }else if(islower(c)!=0&&isupper(c)==0){
            ans = toupper(c);
        }else{
            ans = c;
        }
        cout << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string t=s.substr(0,s.size()/2);
	string m=s.substr(s.size()/2+1);
	if(t!=m)
	{
		cout<<"No\n";
		return 0; 
	}
	for(int i=0;i<t.size();i++)
	{
		if(t[i]!=t[t.size()-1-i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int n = N, div = 0;
  while (n > 0) {
    div += n % 10;
    n /= 10;
  }
  cout << (N % div == 0 ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(true) {
		int a, b;
		char op;
		cin >> a >> op >> b;
		int res;
		switch(op) {
			case '+': res = a + b; break;
			case '-': res = a - b; break;
			case '*': res = a * b; break;
			case '/': res = a / b; break;
			default: return 0;
		}
		cout << res << endl;
	}
}


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

struct s{
	int index;
	int sum;
	bool operator<(const s& rhs) const{
		return sum < rhs.sum;
	}
};

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll  n;
    cin >> n;
    vector <ll> a(n);
    vector <ll> b(n);
    vector 
 sum(n);
    for (int z=0;z<n;z++){
    	cin >> a[z] >> b[z];
    	sum[z].sum = a[z]+b[z];
    	sum[z].index = z;
    }
    sort(sum.rbegin(),sum.rend());
    ll answer=0;
    for (int z=0;z<n;z++){
    	if (z%2 == 0) answer += a[sum[z].index];
    	else answer -= b[sum[z].index];
    }
    cout << answer << endl;
    cin >> n;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
a = ['*']*n


for i in range(m):

  s, c = map(int, input().split())
  if a[s-1] == '*':
    a[s-1] = c
  else:
    if a[s-1] == c:
      continue
    else:
      print(-1)
      exit()
  
if n >1 and a[0] == 0:
  print(-1)
  exit()
elif n >1 and a[0]=='*':
  a[0] = 1

  
b = [str(x) for x in a]
ans= ''.join(b)
print(ans.replace('*', '0'))

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int t;
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> t;
    if(t < A || t >= B) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string str;
void solve()
{
    int i,len=str.length(),tag=0;
    for (i=1;i<len;i++)
        if (str[i-1]=='A'&&str[i]=='C') {tag=1;break;}
    if (tag) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>str)
        solve();
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    int N; cin>>N;
    map<ll, int> mp;
    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        mp[tmp]++;
    }

    ll fst = 0, snd = 0;
    for (auto i : mp){
        if(i.second>=2){
            if(i.first>fst){
                swap(fst, snd);
                fst = i.first;
                if(i.second>=4) snd = i.first;
            }else if(i.first>snd){
                snd = i.first;
            }
        }
    }
    ll ans = fst * snd;
    cout<< ans <<endl;

}

Measured memory_bytes: 6528
import sys

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

for line in sys.stdin:
    a, b = list(map(int, line.split()))
    print("{0} {1}".format(gcd(a, b), int((a * b) / gcd(a, b))))

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  int one=0;
  rep(i,N){
    if(A[i]==1)one+=1;
  }
  if(one==0){
    cout<<-1<<endl;
    return 0;
  }
  int co=0,K=1;
  rep(i,N){
    if(A[i]!=K)co+=1;
    if(A[i]==K)K+=1;
  }
  cout<<co<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int ans = 0;
    if (Math.abs(a-c) <= d){
      ans++;
    }else if (Math.abs(a-b) <= d && Math.abs(b-c)<= d){
      ans++;
    }
    System.out.println(ans == 0 ? "No" : "Yes");
  }
}


Measured memory_bytes: 35580
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> L >> R;
	if (N == L)cout << 0 << endl;
	else cout << 1 << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<vector<int> > ans(n, vector<int>(n, 0));

  for(int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for(int j = 0; j < k; j++) {
      int adj;
      cin >> adj;
      ans[u-1][adj-1] = 1;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n-1; j++){
      cout << ans[i][j] << ' ';
    }
    cout << ans[i][n-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 3144
# -*- coding: utf-8 -*-
from sys import stdin

class Dice:

    def __init__(self,dicelist):
        self.dice_list = dicelist
        self.all_pattern = 'NNNNWNNNWNNNENNNENNNWNNN'

    def roll(self, direction):
        work = list(self.dice_list)
        if (direction == 'N'):
            self.dice_list[0] = work[1]
            self.dice_list[1] = work[5]
            self.dice_list[2] = work[2]
            self.dice_list[3] = work[3]
            self.dice_list[4] = work[0]
            self.dice_list[5] = work[4]
        elif (direction == 'E'):
            self.dice_list[0] = work[3]
            self.dice_list[1] = work[1]
            self.dice_list[2] = work[0]
            self.dice_list[3] = work[5]
            self.dice_list[4] = work[4]
            self.dice_list[5] = work[2]
        elif (direction == 'S'):
            self.dice_list[0] = work[4]
            self.dice_list[1] = work[0]
            self.dice_list[2] = work[2]
            self.dice_list[3] = work[3]
            self.dice_list[4] = work[5]
            self.dice_list[5] = work[1]
        elif (direction == 'W'):
            self.dice_list[0] = work[2]
            self.dice_list[1] = work[1]
            self.dice_list[2] = work[5]
            self.dice_list[3] = work[0]
            self.dice_list[4] = work[4]
            self.dice_list[5] = work[3]

    def equals(self, another):
        for p in self.all_pattern:
            another.roll(p)
            if self.dice_list == another.dice_list:
                return True
        else:
            return False


dice_list1 = list(map(int, stdin.readline().rstrip().split()))
dice_list2 = list(map(int, stdin.readline().rstrip().split()))

dice1 = Dice(dice_list1)
dice2 = Dice(dice_list2)

if dice1.equals(dice2):
    print("Yes")
else:
    print("No")


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

int main() {
    int n, k;
    cin >> n >> k;

    int counter = 0;
    for (int i = 0; i < n; i++) {
        int h_i;
        cin >> h_i;
        if (h_i >= k)
            counter++;
    }

    cout << counter;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  string s,t; cin >> s >> t;
  if(s.size() >= t.size()){
    rep(i,s.size()-t.size()+1){
      bool frag = true;
      rep(j,t.size()){
        if(s.at(i+j) != t.at(j) ) frag = false;
      }
      if(frag) cout << i << "\n";
    }
  }
}


Measured memory_bytes: 3208
import math
def serch(l, r):
    min_x = (l*l + l) % 2019
    for i in range(l+2, r+1):
        a = (l * i) % 2019
        #print("ll", l, "ii", i, "rr", r, "aa", a)
        if(a  < min_x):
            min_x = a
    return min_x

def solve():
    l, r = map(int, input().split())
    l_div = l // 2019
    r_div = r // 2019
    if(l_div != r_div):
        print(0)
    else:
        a = r % 2019
        b = a - 1
        if(a*b < 2019):
            print((l*l + l) % 2019)
        else:
            min_x = 2020
            for i in range(l, r):
                a  = serch(i, r)
               # print("i", i, "r", r, "a", a)
                if(a < min_x):
                    min_x = a
            print(min_x)



if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
n, k = map(int, input().split())
x =[]
y =[]
for i in range(n):
    x1, y1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

d = {}
for i in range(n):
    if x[i] not in d:
        d[x[i]] = y[i]
    else:
        d[x[i]] += y[i]

d_sort = sorted(d)

sum = 0
for i in d_sort:
    if sum+d[i] >= k:
        print(i)
        break
    else:
        sum += d[i]

Measured memory_bytes: 15972
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int height;
	long int n;
	long int flg = 0;
	long int h[100000] = {0};
	
	scanf("%ld", &n);
	
	if(n >= 100000) {
		printf("%ld\n", 9 + 900 + 90000);//100000-100000
	} else if(n >= 10000) {
		printf("%ld\n", 9 + 900 + n - 9999);//10000-99999
	} else if(n >= 1000) {
		printf("%ld\n", 9 + 900);//1000-9999
	} else if(n >= 100) {
		printf("%ld\n", 9 + n - 99);//100-999
	} else if(n >= 10) {
		printf("%ld\n", 9);//10-99
	} else if(n >= 1) {
		printf("%ld\n", n);//1-9
	}
	
	
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m;
    cin>>n>>m;
    cout<<(m*2)-n<<NL;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;
 
 int main(){
	int N, K, a;
	cin >> N >> K;
	int ans = 0;
	rep(i, N){
		cin >> a;
		if(a > abs(a-K)) ans += abs(a-K)*2;
		else ans += a*2;
	}
	cout << ans;
	return 0;
 }

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

int main(){
    int N, H, W;
    cin >> N >> H >> W;
    int A[10000], B[10000];
    for (int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        if (A[i] >= H && B[i] >= W){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int mod = 998244353;

int main(){
	ios_base::sync_with_stdio(false);
	int x;
	cin >> x;
	cout << 360 / gcd(x, 360) << endl;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

a = getN()
s = input().strip()

if a >= 3200:
    print(s)
else:
    print("red")

Measured memory_bytes: 3060
s=input()
t=input()

l=len(s)
ll=len(t)
count=10000
for i in range(l-ll+1):
    v=0
    for j in range(ll):
        
        if s[i+j]!=t[j]:
            v=v+1

        if j==ll-1:
            count=min(count,v)
print(count)

Measured memory_bytes: 9052
#include<iostream>
using namespace std;
int main()
{
	int a[4],x=0,y=0;
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
		if(a[i]==5)
		    x++;
		if(a[i]==7)
		    y++;
	}
	if(x==2 && y==1)
	    cout<<"YES"<<endl;
	else
	    cout<<"NO"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin >> r;
	if (r < 1200)
	{
		cout << "ABC";
	}
	else if (r >= 2800) {
		cout << "AGC";
	}
	else {
		cout << "ARC";
	}
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
int powing(int now, int hoge) {
	int ans = 1;
	while (hoge) {
		if (hoge % 2) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		hoge /= 2LL;
	}
	return ans;
}

int inv(int now) {
	return powing(now, MAX_MOD - 2LL);
}

int going[1000];

vector<int> mult(vector<int> a, vector<int> b) {
	vector<int> ans;
	REP(i, 2) {
		REP(q, 2) {
			ans.push_back(0);
			REP(j, 2) {
				ans.back() += (a[i*2 + j] * b[q + 2 * j]) % MAX_MOD;
				ans.back() %= MAX_MOD;
			}
			ans.back() %= MAX_MOD;
		}
	}
	return ans;
}

int solve(int a, int b,int c) {
	vector<int> inputs;
	inputs.push_back(a);
	inputs.push_back(b);
	inputs.push_back(1);
	inputs.push_back(0);
	vector<int> gogo{ 1,0,0,1 };
	while (c) {
		if (c % 2) {
			gogo = mult(gogo, inputs);
		}
		inputs = mult(inputs, inputs);
		c /= 2;
	}
	return (gogo[0]) % MAX_MOD;
}

void solve() {
	while (true) {
		int n, k, s;
		cin >> n >> k >> s;
		if (n == 0) return;
		int dp[20][200] = {};
		dp[0][0] = 1;
		for (int i = 1; i <= n; ++i) {
			for (int q = k - 1; q >= 0; --q) {
				for (int j = 0; j <= s; ++j) {
					dp[q + 1][j + i] += dp[q][j];
				}
			}
		}
		cout << dp[k][s] << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


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

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

    while (true) {
        string s = to_string(n);
        if (s[0] == s[1] && s[1] == s[2]) break;
        n++;
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=0;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e=0;
  rep1(i,a)rep1(j,b)rep1(k,c){
  if(500*i+100*j+50*k==d)
    e++;
  }
  out(e);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef array <int, 2> pii;
typedef vector <int> vi;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e6 + 3;
int q, fact[MOD], rev[MOD], inv[MOD];

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = (ll)res * x % MOD;
		}
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	fact[0] = rev[0] = inv[1] = 1;
	for (int i = 1; i < MOD; i++) {
		fact[i] = (ll)fact[i - 1] * i % MOD;
		if (i > 1) {
			int x = i - MOD % i;
			inv[i] = (ll)inv[x] * ((MOD + x) / i) % MOD;
		}
		rev[i] = (ll)rev[i - 1] * inv[i] % MOD;
	}
	cin >> q;
	while (q--) {
		int x, d, n;
		cin >> x >> d >> n;
		if (d == 0) {
			cout << bp(x, n) << '\n';
		}	else {
			int a = (ll)x * bp(d, MOD - 2) % MOD;
			if (a + n - 1 >= MOD) {
				cout << 0 << '\n';
			}	else {
				int res = (ll)fact[a + n - 1] * bp(d, n) % MOD;
				if (a > 0) {
					res = (ll)res * rev[a - 1] % MOD;
				}
				cout << res << '\n';
			}
		}
	}
}


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

int main() {
    int d, g;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    vector<int> x(d);
    rep(i,d){
        cin >> p[i] >> c[i];
        x[i]=100*(i+1)*p[i]+c[i];
    }
    int ans=1000000000, pr=0, cur=0;
    for (int bit = 0; bit < (1<<d); ++bit) {
        for (int i = 0; i < d; ++i) {
            if (bit & (1<<i)) {
                cur+=x[i];
                pr+=p[i];
            }
        }
        if(cur>=g){
            ans=min(ans,pr);
        }else{
            int y=g-cur;
            for(int j=d-1; j>=0; --j){
                if(bit & (1<<j)) continue;
                for(int k=0; k < p[j]-1; ++k){
                    ++pr;
                    y-=100*(j+1);
                    if(y<=0) {
                        ans=min(ans,pr);
                        break;
                    }
                }
                break;
            }
        }
        cur=0; pr=0;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc097/tasks/arc097_b

# 重要な性質
# swapできるidxは必ず任意に並び替えられる
# swapできるidxのグループがわかれば、そのなかでなるべく合うように並び替えられる
# union findか
# グループに分けてからidxの集合と、idxが指す要素の集合の積のサイズの合計が答え


N, M = read_ints()
P = read_ints()
uf = UnionFind(N)
for _ in range(M):
    x, y = read_ints()
    uf.unite(x - 1, y - 1)

group = defaultdict(lambda: set())
for i in range(N):
    group[uf.root(i)].add(i)

ans = 0
for g in group.values():
    tmp = set()
    for idx in g:
        tmp.add(P[idx] - 1)
    ans += len(tmp & g)
    # print(tmp, g)
print(ans)


Measured memory_bytes: 98716
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,d;
    cin >> n >> d;
    int ans = 0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <string>
#define max(a,b) a>b ? a:b

using namespace std;
vector<string>s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int  i=0; i<n; i++)
    {
        string temp;
        cin>>temp;
        sort(temp.begin(),temp.end());
        //cout<<temp<<endl;
        s.push_back(temp);
    }
    //cout<<s.size()<<endl;
    sort(s.begin(),s.end());
    long long count=0;
    int i=0;
    while(i<n)
    {
        int j=i+1;
        long long sum=1;
        while(j<n && s[i]==s[j])
        {
            sum++;
            j++;
        }
        count+=sum*(sum-1)/2;
        i=j;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    bitset<10010> dp;
    dp[0]=1;

    int N; cin>>N;
    REP(i,N){
        int s; cin>>s;
        dp|=dp<<s;
    }
    
    int ans=0;
    REP(i,10000){
        if(dp[i] and i%10!=0) ans=i;
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a,ll mod) { return modpow(a,mod-2,mod); } 
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  ll dp[5010][5010]={0};
  string s;
  
  cin >> n;
  cin >> s;
  
  dp[0][0]=1;
  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
      k = dp[i][j];
      dp[i+1][max(j-1,0)] += k;
      dp[i+1][max(j-1,0)] %= MOD1;
      dp[i+1][j+1] += 2*k;
      dp[i+1][j+1] %= MOD1;
    }
  }
  m = s.size();
  result = dp[n][m];
  result *= modinv(modpow(2,m,MOD1),MOD1);
  result %= MOD1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 199700
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 305
using namespace std;
typedef long long ll;
int n;
int dis[maxn][maxn];
int can[maxn][maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&dis[i][j]);

	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			if(i!=j && j!=k && k!=i)
			{
				if(dis[i][j]>dis[i][k]+dis[k][j])
					return printf("-1\n"),0;
				else if(dis[i][j]==dis[i][k]+dis[k][j])
				can[i][j]=1;
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		if(!can[i][j])
			ans+=dis[i][j];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
    int x,t;
    cin>>x>>t;
    cout<<(x-t>=0?x-t:0)<<endl;

  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int64 N;
string s;

int64 sum(vector<int64>& a, int32 l, int32 r){
	if(l == r) return 0;
	int64 rr = a[r-1];
	int64 ll = l != 0 ? a[l-1] : 0;
	return ((rr-ll)%mod+mod)%mod;
}

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

	vector<int64> dp(N+1, 1);
	REP(i, N-1){
		vector<int64> dp2(N+1, 0);
		REP(j, i+2){
			if(s[i] == '>'){
				dp2[j] += sum(dp, 0, j);
			}else{
				dp2[j] += sum(dp, j, N+1);
			}
			dp2[j] %= mod;
		}
		swap(dp, dp2);
		REP(j, N) dp[j+1] = (dp[j+1] + dp[j])%mod;
	}
	cout << dp[N] << endl;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  
  const n = input[0];
  
  let ACn = 0;
  let WAn = 0;
  let TLEn = 0;
  let REn = 0;
  
  for (let i=1 ; i<(n+1) ; i++) {
    if (input[i] === 'AC') {
      ACn++;
    } else if (input[i] === 'WA') {
      WAn++;
    } else if (input[i] === 'TLE') {
      TLEn++;
    } else if (input[i] === 'RE') {
      REn++;
    }
  }
  
  console.log( 'AC x %d', ACn);
  console.log( 'WA x %d', WAn);
  console.log( 'TLE x %d', TLEn);
  console.log( 'RE x %d', REn);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	int N;
	cin >> N;

	ll ans = 0;
	REP(i,N){
		ll now = i+1;
		if(now % 3 != 0 && now % 5 != 0){
			ans += now;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int table[101][101];
  int r, c; cin >> r >> c;

  for (int i = 0; i < r; i++) {
    table[i][c] = 0;
    for (int j = 0; j < c; j++) {
      cin >> table[i][j];
      table[i][c] += table[i][j];
      if (i == 0) table[r][j] = table[i][j];
      else table[r][j] += table[i][j];
    }
  }
  
  for (int i = 0; i < r+1; i++) {
    int last = 0;
    for (int j = 0; j < c+1; j++) {
      if (i == r) {
	if (j < c) last += table[i][j];
      }
      if (i == r && j == c) {
	cout << last;
      } else {
	cout << table[i][j];
	if (j < c) cout << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

N,M = input_multiple_number()

shilve = [-1]*(N+1)
michi = [[] for _i in range(N+1)]

for i in range(M):
	a,b = input_multiple_number()
	michi[a].append(b)
	michi[b].append(a)

que = [1]

while len(que) > 0:
	now_heya = que.pop(0)
	for nexthop in michi[now_heya]:
		if shilve[nexthop] == -1:
			shilve[nexthop] = now_heya
			que.append(nexthop)


print("Yes")
for i in shilve[2:]:
	print(i)



Measured memory_bytes: 34356
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  double t,x;
  cin>>t>>x;

  cout << (double)(t/x) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
const ld pi = 3.14159265358979323846;
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
}


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

int main(void) {
    string S,T;
    cin >> S;
    cin >> T;
    
    long long int i = 0;
    long long int counter = 0;
    while (S[i]) {
        if (S[i] != T[i])
            counter++;
        i++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>

using namespace std;

int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	int sum = 0;

	for (i = 1; i <= 999; i++) {
		sum += i;
		if (b - a == i) {
			cout << sum - b << endl;
				break;
		}
	}










	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

void solve(long long N){
    vector<long long> a =  enum_divisors(N-1);
    int ans = a.size()-1;
    vector<long long> b =  enum_divisors(N);
    for (int i=1;i<b.size();i++){
        long long k = N;
        while(k %b[i] ==0 ){
            k  = k/b[i];
        }
        if (k%b[i] == 1) ans++;
    }
    printf("%lld\n",ans);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    REP(i,m) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m, 0));
    REP(i,n) REP(j,m) cin >> a[i][j];
    int cnt = 0;
    REP(i,n) {
        int asum = 0;
        REP(j,m) {
            asum += a[i][j]*b[j];
        }
        if (asum+c > 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

typedef long long int ll;

ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    cin >> n;
    string t = to_string(n);
    t.pop_back();
    ll a = 0;
    for(ll i = 0;i < t.size();i++){
        a += (t[i] - '0') * powk(10,t.size() - i - 1);
    }
    if(n % 2 == 0){
        ll ans = 0;
        for(ll i = 1;i <= n;i *= 5){
            ans += a / i;
        }
        cout << ans;
    }
    else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256