akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int n, m;
vector <int> g[(int)1e5+10];
vector <int> topsort;
bool used[(int)1e5+10];
int dp[(int)1e5+10];
void dfs(int v) {
	used[v] = 1;
	for(int i = 0; i < g[v].sz; ++i) if(!used[g[v][i]]) dfs(g[v][i]);
	topsort.pb(v);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
	}
	dfs(1);
	for(int i = 1; i <= n; ++i) used[i] = 0;
	topsort.clear();
	for(int i = 1; i <= n; ++i) if(!used[i]) dfs(i);
	reverse(topsort.begin(), topsort.end());
	for(int i = 0; i < topsort.sz; ++i) {
		int v = topsort[i];
		for(int j = 0; j < g[v].sz; ++j) {
			int to = g[v][j];
			dp[to] = max(dp[to], dp[v] + 1);
		}
	}
	int ans = -1e9;
	for(int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 8056
n=int(input())
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])
import bisect
ans=0
for i in range(n):
  b=B[i]
  ans+=bisect.bisect_left(A,b)*(n-bisect.bisect_right(C,b))
print(ans)

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

using namespace std;

const int NS = (int)2e5+4;
int H, W, N;
int X, Y;
char arr[NS], brr[NS];

int main(){
    scanf("%d %d %d", &H, &W, &N);
    scanf("%d %d", &X, &Y);
    scanf("%s %s", arr+1, brr+1);
    int a = X, b = X, c = Y, d = Y;
    for(int i = 1; i <= N; ++i){
        if(arr[i]=='U'){
            --a; if(!a){
                puts("NO"); return 0;
            }
        }
        else if(arr[i]=='D'){
            ++b; if(b>H){
                puts("NO"); return 0;
            }
        }
        if(arr[i]=='L'){
            --c; if(!c){
                puts("NO"); return 0;
            }
        }
        else if(arr[i]=='R'){
            ++d; if(d>W){
                puts("NO"); return 0;
            }
        }
        if(brr[i]=='U'){
            --b; if(!b){
                ++b;
            }
        }
        else if(brr[i]=='D'){
            ++a; if(a>H){
                --a;
            }
        }
        if(brr[i]=='L'){
            --d; if(!d){
                ++d;
            }
        }
        else if(brr[i]=='R'){
            ++c; if(c>W){
                --c;
            }
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int n, k;
int l[50];

int int_sort( const void *a, const void *b )
{
	if ( *(int *)a > *(int *)b ) return -1;
	if ( *(int *)a < *(int *)b ) return 1;
	return 0;
}

int main(void)
{
	int i, ans;
	
	scanf( "%d %d", &n, &k );
	
	for( i=0; i<n; i++ ) {
		scanf( " %d", &l[i] );
	}
	
	qsort( l, n, sizeof(l[0]), int_sort );
	
	ans = 0;
	for( i=0; i<k; i++ ) {
		ans += l[i];
	}
	
	printf( "%d\n", ans );
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {

    int n;
    cin >> n;
    vector<vector<int> > v(2, vector<int>(100005));
    vector<int> mode(2);
    vector<int> maxi(2);
    rep(i, n / 2) {
        int x, y;
        cin >> x >> y;
        v[0][x]++;
        v[1][y]++;

        if (mode[0] < v[0][x]) {
            mode[0] = v[0][x];
            maxi[0] = x;
        }
        if (mode[1] < v[1][y]) {
            mode[1] = v[1][y];
            maxi[1] = y;
        }
    }
    sort(v[0].begin(), v[0].end(), greater<int>());
    sort(v[1].begin(), v[1].end(), greater<int>());

    int ans = 0;
    if (maxi[0] != maxi[1]) {
        ans = n - mode[0] - mode[1];
    } else {
        ans = min(n - mode[0] - v[1][1], n - mode[1] - v[0][1]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,ans;
  cin >> N;
  vector<int> T(N);
  for(int i = 0;i < N;i++){
    cin >> T.at(i);
  }
  for(int i = 0;i < N-1;i++){
    for(int j = i + 1;j < N;j++){
      ans += T.at(i) * T.at(j);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = list(input())
holder = set()
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.add(i+1)

# 累積和でどうぞ
prefix = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if i-1 in holder:
        prefix[i] = prefix[i-1] + 1
    else:
        prefix[i] = prefix[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(prefix[r] - prefix[l])


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ld A,B,H,M;		cin>>A>>B>>H>>M;
	ld s=abs(5.5*M-30*H);
	ld d=A*A+B*B-2*A*B*cos(s*3.141592653589793238/180);
	cout<< fixed << setprecision(15)<<sqrt(d)<<endl;

    return 0;
}




Measured memory_bytes: 4148
takahashi, aoki, kaisu = [int(x) for x in input().split()]
taka_amari = takahashi - kaisu
ao_amari = aoki
if taka_amari<0:
    ao_amari = aoki+taka_amari
 
if taka_amari<0:
    taka_amari = 0
if ao_amari<0:
    ao_amari = 0
print(str(taka_amari) + " " + str(ao_amari))

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  string s; cin >> s;
  if(SZ(s) % 2) {
    cout << "No" << endl;
    return 0;
  }

  bool ok = true;
  for(int i=0;i<SZ(s);++i) {
    if(i%2) {
      if(s[i] != 'i') {
        ok = false;
        break;
      }
    } else {
      if(s[i] != 'h') {
        ok = false;
        break;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        String id = scanner.nextLine();
        StringBuilder addOneId = new StringBuilder(scanner.nextLine());
        StringBuilder aoi = new StringBuilder(addOneId.deleteCharAt(addOneId.length()-1));
        
        if(id.equals(aoi.toString())) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
const ll INF = 1LL << 60;
ll itr_M = 0; ll itr_m = 0;

void chmax(ll &a, ll b, ll c){ if( a < b){ swap(a,b); itr_M = c;} return ;}

void chmin(ll &a, ll b, ll c){ if( a > b){ swap(a,b); itr_m = c;} return ;}

int main(){
  ll N; cin >> N;
  vector<ll> A(N); 
  ll max_A = -INF; ll min_A = INF;

  for(ll i = 0; i < N; i++){ 
    cin >> A[i]; chmax(max_A,A[i],i); chmin(min_A,A[i],i);}
  
  if( max_A == min_A){ cout << 0 << endl; return 0;}
  
  if( abs(max_A) >= abs(min_A)){
    cout << 2*N-2 << endl;
    for(ll i = 0; i < N; i++){
      if( i == itr_M){ continue;}
      cout << itr_M+1 << " " << i+1 << endl;}
    for(ll i = 0; i < N-1; i++){
      cout << i+1 << " " << i+2 << endl;}
    
  }
  
  else{
    cout << 2*N-2 << endl;
    for(ll i = 0; i < N; i++){
      if( i == itr_m){ continue;}
      cout << itr_m+1 << " "<< i+1 << endl;}
    for(ll i = N-1; i >= 1; i--){
      cout << i+1 << " " << i << endl;}
    
  }
  
  return 0;}
    
  
   

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	int N, u, v;
	cin >> N;
	vector<vector<int> > neighb(N);
	forn(i, N - 1)
	{
		cin >> u >> v;
		--u, --v;
		neighb[u].push_back(v);
		neighb[v].push_back(u);
	}
	vector<int> c(N);
	forn(i, N)
		cin >> c[i];
	sort(all(c));
	uint32_t resv = 0;
	forn(i, N-1)
		resv += c[i];
	vector<int> q;
	vector<int> d(N), res(N);
	forn(i, N)
	{
		d[i] = neighb[i].size();
		if (d[i] == 1)
		{
			q.push_back(i);
		}
	}
	forn(i, N)
	{
		int act = q[i];
		res[act] = c[i];
		forn(j, neighb[act].size())
		{
			int cand = neighb[act][j];
			d[cand]--;
			if (d[cand] == 1)
			{
				q.push_back(cand);
			}
		}
	}
	cout << resv << endl;
	forn(i, N)
	{
		cout << res[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] ary = sc.next().toCharArray();
		for (char c : ary) {
			if(c == '1') System.out.print(9);
			else System.out.print(1);
		}
		System.out.println();
	}
}

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


int main()
{
  ll MOD = 1000000007;
  string K;
  int D;
  cin >> K >> D;
  vector<vector<vector<ll>>> dp(K.length() + 1, vector<vector<ll>>(2, vector<ll>(D)));
  dp[0][1][0] = 1;
  rep(i, K.length())
  {
    int d = K[i] - '0';
    rep(j, D)
      rep(k, 10)
        dp[i+1][0][(j+k)%D] = (dp[i+1][0][(j+k)%D] + dp[i][0][j]) % MOD;
    rep(j, D)
    {
      dp[i+1][1][(j+d)%D] = (dp[i+1][1][(j+d)%D] + dp[i][1][j]) % MOD;
      rep(k, d)
        dp[i+1][0][(j+k)%D] = (dp[i+1][0][(j+k)%D] + dp[i][1][j]) % MOD;
    }
  }
  ll ans = (dp[K.length()][1][0] + dp[K.length()][0][0] - 1) % MOD;
  if (ans < 0)
    ans += MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string a="AKIHABARA",b;
bool used[10];
int main(){
	cin>>b;
	int nxt = 0;
	for(int i=0;i<b.size();i++){
		while(nxt<a.size() && a[nxt] != b[i]) nxt++;
		if(nxt == a.size()){
			puts("NO");return 0;
		}
		used[nxt] = 1;
		nxt++;
	}
	for(int i=0;i<9;i++){
		if(!used[i] && a[i]!='A'){
			puts("NO");return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a.back() - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

# すべて鶴だと仮定する
turu = X

asi = turu * 2

if asi > Y or (Y % 2) != 0 or X * 4 < Y:
    print("No")
else:
    husoku = Y - asi

    kame = husoku // 2

    turu = turu - kame

    if turu * 2 + kame * 4 == Y:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9180
function permutation(n,k){
    var ret=[[]];
    var next;
    for(var i=0;i<k;i++){
        next=[];
        ret.forEach(e=>{
            for(var k=1;k<=n;k++){
                if(!e.includes(k)){
                    next.push(e.concat([k]));
                }
            }
        });
        ret=next.concat([]);
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const A=input[0].split(' ')[0]-0;
  const B=input[0].split(' ')[1]-0;
  const K=input[0].split(' ')[2]-0;
  if(K>A){
    console.log('0',Math.max(0,A+B-K));
  }else{
    console.log(A-K,B);
  }
}


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



  


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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

void mat_mul(int n, vvl &a, vvl &b){
	vvl r(n, vl(n, 0)); 
	rep(i,0,n) rep(j,0,n) 
		rep(k,0,n) r[i][j]=(r[i][j]+a[i][k]*b[k][j])%mod;
	a=r;
}

ll bpow(int n, vvl &a, ll b){
	vvl r(n, vl(n, 0)); rep(i,0,n) r[i][i]=1;
	for(;b>0;mat_mul(n, a, a), b>>=1)
		if(b&1) mat_mul(n, r, a);
	
	ll ans=0; rep(i,0,n) rep(j,0,n) ans+=r[i][j];
	return ans%mod;
}

int main(){
	flash; QuickSilver;
	ll n,k; cin>>n>>k;
	vvl a(n, vl(n)); rep(i,0,n) rep(j,0,n) cin>>a[i][j]; 
	cout<<bpow(n, a, k)<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(){
  char A[4][10]={"Sunny","Cloudy","Rainy"};
  char S[10];
  scanf("%s",S);
  int i=0;
  while(strcmp(S,A[i])!=0) i++;
  printf("%s\n",A[(i+1)%3]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll K, X; cin >> K >> X;
  cout << (K*500 >= X ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const ll mod = 1000000000 + 7;


int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll r = 0;
  ll b = 0;
  REP(i, n){
  	if (s[i] == 'R') r += 1;
  	else b += 1;
  }
  if (r>b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  int cnt = 0;
  rep(i,n){
    int d1,d2;
    cin >> d1 >> d2;
    if(d1 == d2) cnt++;
    else cnt = 0;

    if(cnt == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No"<<endl;
}


Measured memory_bytes: 3636
// AtCoder ABC103: C - Modulo Summation
// 2019.10.17 bal4u

#include <stdio.h>
#include <ctype.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
    while (isspace(c)) c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int n, ans;

    n = in(), ans = 0;
    while (n--) ans += in()-1;
    printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define __TRUE "yes"
#define __FALSE "no"

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h+2);
  for(int i=1;i<=w+2;i++) a[0] += "#";
  for(int i=1;i<=h;i++) {
    string temp;
    cin >> temp;
    a[i] = "#"+temp+"#";
  }
  for(int i=1;i<=w+2;i++) a[h+1] += "#";

  for(int i=0;i<a.size();i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[200000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		
		
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(a[i]==a[i-1]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	
	
	return 0;
} 

Measured memory_bytes: 1024
#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;
  int K=N,har=0;
  while(K>0){
    har+=K%10,K/=10;
  }
  if(N%har==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

typedef long long int ll;

int main () {
    int n; cin >> n;
    vector<ll> as(n);
    map<ll, ll> m;

    for (int i = 0; i < n; i++) {
        cin >> as[i];
        int index = i + 1;
        ll key = index - as[i];
        if (m.find(key) == m.end()) {
            m[key] = 0;
        }
        m[key]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int index = i + 1;
        ll key = index - as[i];
        m[key]--;
        ll target = as[i] + index;
        if (m.find(target) == m.end()) {
            continue;
        }
        ans += m[target];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15920
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;cin>>n;
  vector<int> c(n-1),s(n-1),t(n-1);
  for(int i=0;i<n-1;i++){
    cin>>c[i]>>s[i]>>t[i];
  }
  for(int i=0;i<n;i++){
    k=0;
    for(int j=i;j<n-1;j++){
      if(k<s[j]){k=s[j];}
      else if(k%t[j]==0);
      else{k+=t[j]-k%t[j];}
      k+=c[j];
    }
    cout<<k<<endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            var a = PrimeFactorsImpl(n);

            long result = 0;
            if (!a.Any())
            {
                result = 0;
            }
            else
            {
                foreach (var item in a.GroupBy(x => x))
                {
                    var cnt = item.Count();
                    if (cnt == 1)
                    {
                        result++;
                    }
                    else
                    {
                        for (long i = 2; i <= cnt; i++)
                        {
                            result++;
                            if (cnt < test(i)) break;
                        }
                    }
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }

        /// <summary>
        /// 素因数分解。
        /// 出展：https://qiita.com/y_miyoshi/items/da814d96e8890224aad3
        /// </summary>
        public static IEnumerable<long> PrimeFactorsImpl(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
        public static long test(long n)
        {
            return n * (n + 1) / 2;
        }
    }
}


Measured memory_bytes: 28264
val P = 1000000007L

data class Edge(val from: Int, val to: Int)

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val graph = Array(n, { mutableListOf<Edge>() })
    repeat(n - 1) {
        val (aRaw, bRaw) = readLine()!!.split(" ").map { it.toInt() }
        val a = aRaw - 1
        val b = bRaw - 1
        graph[a].add(Edge(a, b))
        graph[b].add(Edge(b, a))
    }

    fun solve(v: Int, parent: Int, depth: Int): Long {
        if (graph[v].size == 0) return 1L
        val numChildren = graph[v].size - if (depth > 0) 1 else 0
        val numColors = k - 1 - if (depth > 0) 1 else 0
        if (numColors < numChildren) return 0L
        var ans = 1L
        for (i in 0 until numChildren) {
            ans *= numColors - i
            ans %= P
        }
        for (e in graph[v]) {
            if (e.to == parent) continue
            ans *= solve(e.to, v, depth + 1)
            ans %= P
        }
        return ans
    }
    println(solve(0, -1, 0) * k % P)
}

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

string s, t, h, a, b;
bool booln;
long long k, l;
string x, y;
int main(){
	s = ",1,3,5,7,8,10,12,";
	t = ",4,6,9,11,";
	h = ",2,";
	x = ",";
	y = ",";
	cin >> a >> b;
	x += a;
	y += b;
	x += ',';
	y += ',';
	k = -1; l = -1;
	k = s.find(x);
	l = s.find(y);
	if ((k >= 0) && (l >= 0)){
		cout << "Yes" << endl;
		booln = true;
	}
	k = -1; l = -1;
	k = t.find(x);
	l = t.find(y);
	if ((k >= 0) && (l >= 0)){
		cout << "Yes" << endl;
		booln = true;
	}
	k = -1; l = -1;
	k = h.find(x);
	l = h.find(y);
	if ((k >= 0) && (l >= 0)){
		cout << "Yes" << endl;
	}
	if (not booln){
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int INF = 100000;
const int MAX_N = 1001001001;

int n,m;
vector<P> ran; 

bool comp(P a,P b){
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    cin >> n  >> m;
    int a,b ;
    rep(i,m){
        cin >> a >>b;
        ran.push_back(make_pair(a,b));
    }

    sort(ran.begin(),ran.end(),comp);

    int ans = 1;
    int cur = ran[0].second;

    rep(i,m){
        if(ran[i].first < cur) continue;
        ans++;
        cur = ran[i].second;
    }


    cout << ans << endl;



}


Measured memory_bytes: 4296
n, m = map(int, input().split())
ac_list = [0]*n
wa_list = [0]*n
AC = 0
WA = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac_list[p] == 0:
        if s == "WA":
            wa_list[p] += 1
        else:
            ac_list[p] = 1
            AC += ac_list[p]
            WA += wa_list[p]


print(AC, WA)

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

struct BinaryIndexedTree {
  BinaryIndexedTree(size_t n) : n(n), v(n + 1, 0) {}

  size_t n;
  vector<int> v;

  int sum(int k) {
    int ret = 0;
    for (; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, int x) {
    for (; k <= n; k += k & -k) v[k] += x;
  }
};

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

  M++;

  vector<pair<int, pair<int, int>>> v(N);
  for (int i = 0; i < N; ++i) {
    int l, r;
    cin >> l >> r;
    v[i].first = r - l + 1;
    v[i].second.first = l;
    v[i].second.second = r;
  }

  sort(v.begin(), v.end());

  int idx = 0;
  BinaryIndexedTree bit(M + 1);
  for (int d = 1; d < M; ++d) {
    while (idx < N && v[idx].first < d) {
      pair<int, int> r = v[idx].second;
      bit.add(r.first, 1);
      bit.add(r.second + 1, -1);
      idx++;
    }

    int ans = N - idx;
    for (int i = d; i < M; i += d) {
      ans += bit.sum(i);
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long INF = 1_000_000_000_000_000_000L;
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        ArrayList<ArrayList<int[]>> edge = new ArrayList<ArrayList<int[]>>();
        for (int i=0;i<V;i++) {
            ArrayList<int[]> add = new ArrayList<int[]>();
            edge.add(add);
        }
        for (int i=0;i<E;i++) {
            int s = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            int d = Integer.parseInt(sc.next());
            int[] add = {t, d};
            edge.get(s).add(add);
        }

        long[] dist = new long[V];
        for (int i=0;i<V;i++) {
            dist[i] = INF;
        }

        PriorityQueue<long[]> q = new PriorityQueue<long[]>((o1, o2)->Long.compare(o1[1], o2[1]));
        long[] first = {r, 0};
        q.add(first);
        while (!q.isEmpty()) {
            long[] rem = q.poll();
            int index = (int)rem[0];
            long d = rem[1];

            dist[index] = Math.min(dist[index], d);
            for (int[] tmp : edge.get(index)) {
                long[] add = {tmp[0], tmp[1]+d};
                if (dist[tmp[0]]==INF) q.add(add);
            }
        }

        for (int i=0;i<V;i++) {
            if (dist[i]==INF) System.out.println("INF");
            else System.out.println(dist[i]);
        }
    }
}


Measured memory_bytes: 200576
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for(T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));

    int ans = 0;

    rep(i, ret.size()){
        int j = 1;
        //cout << ret[i].first << " " << ret[i].second << " " << j << endl;
        while(1){
            if(ret[i].second >= j){
                ret[i].second -= j;
                j++;
                ans++;
            }else{
                break;
            }
        }
        //cout << ret[i].first << " " << ret[i].second << " " << j << endl;
    }
    cout << ans << endl;
    return ret;
}

void Main()
{
    ll n;
    cin >> n;
    prime_factor(n);
    
    //cout << ans << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

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

int main(){
    char a[10010];
    char b[10010];

    cin >> a >> b;
    sort(a, a+strlen(a));
    sort(b, b+strlen(b), greater<char>());

    string s, t;

    for(int i = 0;i < strlen(a);i++){
        s.push_back(a[i]);
    }

    for(int i = 0;i < strlen(b);i++){
        t.push_back(b[i]);
    }

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    ll res = 0LL;
    rep(i, 1, n){
        res += i;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int X = in.nextInt();
		while (!isPrime(X)) {
			X++;
		}
		System.out.println(X);
		in.close();
	}

	static boolean isPrime(int n) {
		if (n == 1)
			return false;
		for (int i = 2; i * i <= n; ++i) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <string>

using namespace std;

struct Dice {
    int face[6];
    const int dir[5][6]={
        {1, 5, 2, 3, 0, 4},
        {3, 1, 0, 5, 4, 2},
        {4, 0, 2, 3, 5, 1},
        {2, 1, 5, 0, 4, 3},
        {0, 2, 4, 1, 3, 5}
    };
    const char dchars[6]="NESWY";
    int encode[256]={};
    Dice(int f[6]) {
        for (size_t i=0; i<6; ++i)
            face[i] = f[i];

        for (size_t i=0; i<5; ++i)
            encode[dchars[i]+0] = i;
    }
    void roll(char d) {
        int tmp[6]={};
        for (size_t i=0; i<6; ++i)
            tmp[i] = face[i];

        for (size_t i=0; i<6; ++i)
            face[i] = tmp[dir[encode[d+0]][i]];
    }
    void yaw() {
        roll('Y');
    }
    void flip() {
        roll('N'), roll('N');
    }
    int top() {
        return face[0];
    }
    int front() {
        return face[1];
    }
    int right() {
        return face[2];
    }
    int back() {
        return face[3];
    }
    int left() {
        return face[4];
    }
    int bottom() {
        return face[5];
    }
};

int main() {
    int f[6];
    for (size_t i=0; i<6; ++i)
        scanf("%d", &f[i]);

    Dice d(f);

    size_t q;
    scanf("%zu", &q);

    for (size_t i=0; i<q; ++i) {
        int t, f;
        scanf("%d %d", &t, &f);

        // fix top face
        if (d.bottom() == t) {
            d.flip();
        } else if (d.top() != t) {
            while (d.front() != t) d.yaw();
            d.roll('N');
        }

        // fix front face
        while (d.front() != f)
            d.yaw();

        printf("%d\n", d.right());
    }

    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")
// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<queue<int>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].front(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].front();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 368752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int ans[20010]={}, dp[20010];

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	--X; --Y;
	for(int i=0; i<N; ++i){
		for(int j=0; j<N; ++j) dp[j]=1e6;
		dp[i]=0;
		deque<int> dq{i};
		while(!dq.empty()){
			int f=dq.front();
			dq.pop_front();
			if(f>0){
				if(dp[f-1]>dp[f]+1){
					dp[f-1]=dp[f]+1;
					dq.emplace_back(f-1);
				}
			}
			if(f<N-1){
				if(dp[f+1]>dp[f]+1){
					dp[f+1]=dp[f]+1;
					dq.emplace_back(f+1);
				}
			}
			if(f==X || f==Y){
				if(dp[X+Y-f]>dp[f]+1){
					dp[X+Y-f]=dp[f]+1;
					dq.emplace_back(X+Y-f);
				}
			}
		}
		for(int j=0; j<N; ++j) ++ans[dp[j]];
	}
	for(int i=1; i<N; ++i) cout << ans[i]/2 << endl;
	return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h,n = get_nums_l()
aaa = get_nums_l()
s = sum(aaa)

if s >= h:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 53364
#include <stdio.h>
#include <string.h>

int main(void){
  int i,f1;
  char s[101];
  long long int k;
  scanf("%s",s);
  scanf("%lld",&k);
  
  /*最初に1が何個あるか調べる*/
  for(f1=0,i=0;i<strlen(s);i++){
    if(s[i] == '1') f1++;
    else break;
  }
  
  //printf("%d\n",f1);
  
  if(strlen(s)==1 || k==1) printf("%c\n",s[0]);
  else if( k <= f1 )       printf("%c\n",s[0]);
  else                     printf("%c\n",s[f1]);   
  
  return 0;
}


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

int main() {
  string S[51] ;
  char ans[51][51] = {0};
  int H = 0, W = 0, i = 0, j = 0;
  cin >> H >> W;
  for (i = 0; i < H; i++ ) {
    cin >> S[i];
  }
  for (i = 0; i < H; i++ ) {
    for (j = 0; j < W; j++ ) {
      if (S[i].at(j) == '#') {
        ans[i][j] = '#';
        continue;
      } else {
        ans[i][j] = '0';
      }
      // migi
      //cout << i << " " << j << endl;
      if (j == (W-1)) {
      } else if (S[i].at(j+1) == '#') {
        ans[i][j]++;
      }
      // ue
      if (i == (H-1)) {
      } else if (S[i+1].at(j) == '#') {
        ans[i][j]++;
      }
      // shita
      if (i == 0) {
      } else if (S[i-1].at(j) == '#') {
        ans[i][j]++;
      }
      // hidari
      if (j == 0) {
      } else if (S[i].at(j-1) == '#') {
        ans[i][j]++;
      }
      // hidari-shita
      if ((j == 0) || (i == 0)) {
      } else if (S[i-1].at(j-1) == '#') {
        ans[i][j]++;
      }
      // hidari-ue
      if ((j == 0) || (i == (H-1))) {
      } else if (S[i+1].at(j-1) == '#') {
        ans[i][j]++;
      }
      // migi-shita
      if ((j == (W-1)) || (i == 0)) {
      } else if (S[i-1].at(j+1) == '#') {
        ans[i][j]++;
      }
      // migi-ue
      if ((j == (W-1)) || (i == (H-1))) {
      } else if (S[i+1].at(j+1) == '#') {
        ans[i][j]++;
      }
    }
  }
  for (i = 0; i < H; i++) {
    printf("%s\n", ans[i]);
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void) {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if ((~a & 1) || (~b & 1) || (~c & 1)) {
    puts("0");
  } else {
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    printf("%lld\n", (long long)a * b);
  }
}


Measured memory_bytes: 128
x,n=map(int,input().split())
if n==0:exit(print(x))
p=list(map(int,input().split()))
ans=-1
tmp=float("inf")
for i in range(0,102):
    if i in p:
        continue
    k=abs(i-x)
    if k<tmp:
        ans=i
        tmp=k
print(ans)


Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

bool kai(string s){
  string sr = s;
  reverse(sr.begin(), sr.end());
  int n = s.size();
  for(int i=0; i<n; ++i) if(s[i] != sr[i]) return false;
  return true;
}


int main(){
  string s; cin >> s;
  int n= s.size();
  if(kai(s.substr(0,n/2)) && kai(s.substr(n/2+1,n/2)) && kai(s) ) cout << "Yes";
  else cout << "No";
}

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

int main()
{
    int K, S;
    cin >> K >> S;

    int cnt = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            int t = S - i - j;
            if (0 <= t && t <= K)
            {
                cnt++;
            }
        }
    }

    cout << cnt;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int n, x, s;
bitset<2002001> f;
int main() {
	scanf("%d", &n);
	f[0] = 1;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		f |= f << x;
		s += x;
	}
	for (int i = (s + 1) / 2; i <= s; i++) {
		if (f[i]) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
a, b = [], []
for i in range(n):
    s = input()
    assert len(s) == n
    a.append(s)
for j in range(m):
    s = input()
    assert len(s) == m
    b.append(s)


def scan(i1, j1):
    for i2 in range(m):
        if a[i1+i2][j1:j1+m] != b[i2]:
            return False
    return True


def solve():
    for i1 in range(n-m+1):
        for j1 in range(n-m+1):
            if scan(i1, j1):
                return True
    return False


print('Yes' if solve() else 'No')


Measured memory_bytes: 38256
N=int(input())
D=[[] for i in range(N)]
F,S=[-1]*N,[-1]*N
F[0]=0
S[N-1]=0
for i in range(N-1):
  a,b=map(int, input().split())
  a-=1
  b-=1
  D[a].append(b)
  D[b].append(a)
 
from collections import deque
import sys
sys.setrecursionlimit(10**7) 
dis=0

def bfs(n):
  t=0
  q=deque()
  q.append(n)
  while len(q):
    x=q.popleft()
    for i in D[x]:
      if F[i]==-1 and i!=x: 
        F[i]=F[x]+1
        q.append(i)

def bfs2(n):
  t=0
  q=deque()
  q.append(n)
  while len(q):
    x=q.popleft()
    for i in D[x]:
      if S[i]==-1 and i!=x:
        S[i]=S[x]+1
        q.append(i)
bfs(0)
bfs2(N-1)
f,s=0,0
for i in range(N):
  if F[i]<=S[i]:
    f+=1
  else:
    s+=1
#print(F,S,f,s)
if f<=s:
  print('Snuke')
else:
  print('Fennec')

Measured memory_bytes: 29360
a, b = map(int, input().split())

maxf = 1
minf = a

for i in range(b):
    c, d = map(int, input().split())
    if(maxf < c):
        maxf = c
    if(minf > d):
        minf = d

if(minf-maxf < 0):
    print(0)
else:
    print(minf -maxf + 1)

Measured memory_bytes: 3060
/*
      author  : nishi5451
      created : 12.08.2020 23:47:42
*/

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


int main(){
    string o,e;
    cin >> o >> e;
    rep(i,int(e.size())){
        cout << o[i] << e[i];
    }
    if(o.size() > e.size())
        cout << o.back();
    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func ParseInt(str string) int {
	i, _ := strconv.ParseInt(str, 10, 64)
	return int(i)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	inputs := strings.Split(sc.Text(), " ")

	a := ParseInt(inputs[0])
	b := ParseInt(inputs[1])
	c := ParseInt(inputs[2])

	ans := 0

	if a <= c {
		ans += a
	} else {
		ans += c
	}
	c -= a

	if c > 0 {
		if b > c {
			ans += c * 2
			ans += b - c
		} else {
			ans += b * 2
		}
	} else {
		ans += b
	}
	c -= b

	if c > 0 {
		ans += 1
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<algorithm>

#define fst first
#define snd second

using namespace std;

typedef pair<int,int> pp;
typedef long long int lli;

multiset<pp> tr;
set<lli> xa, ya;
vector<lli> xv, yv;
int field[6000][6000];

int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);
    int ix=0, iy=0;
    xa.insert(-2000000000);
    xa.insert(+2000000000);
    ya.insert(-2000000000);
    ya.insert(+2000000000);
    for(int i=0; i<n; i++) {
        lli x,y;
        scanf("%lld%lld",&x,&y);
        xa.insert(x);
        ya.insert(y);
        tr.insert(pp(x,y));
    }

    for(lli x : xa)
        xv.push_back(x);
    for(lli y : ya)
        yv.push_back(y);

    field[0][0] = tr.count(pp(xv[0],yv[0]));
    auto itx = ++xv.begin(), ity = ++yv.begin();
    for(int i=1; i<xv.size(); i++,itx++)
        field[i][0] = field[i-1][0] + tr.count(pp(*itx,yv[0]));
    for(int i=1; i<yv.size(); i++,ity++)
        field[0][i] = field[0][i-1] + tr.count(pp(xv[0],*ity));

    itx = ++xv.begin();
    for(int i=1; i<xv.size(); i++,itx++) {
        ity = ++yv.begin();
        for(int j=1; j<yv.size(); j++,ity++)
            field[i][j] = -field[i-1][j-1] + field[i-1][j] + field[i][j-1] + tr.count(pp(*itx,*ity));
    }

    for(int i=0; i<m; i++) {
        lli x1,y1,x2,y2;
        scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);

        int sx,sy,tx,ty;
        sx = lower_bound(begin(xv), end(xv), x1)-begin(xv);
        sy = lower_bound(begin(yv), end(yv), y1)-begin(yv);
        tx = upper_bound(begin(xv), end(xv), x2)-begin(xv)-1;
        ty = upper_bound(begin(yv), end(yv), y2)-begin(yv)-1;
        //printf("%d - %d - %d + %d\n",field[tx][ty] , field[sx-1][ty] , field[tx][sy-1] , field[sx-1][sy-1]);
        printf("%d\n",field[tx][ty] - field[sx-1][ty] - field[tx][sy-1] + field[sx-1][sy-1]);
    }

    return 0;
}

Measured memory_bytes: 120860
#include <cstdio>
#define maxn 100005
using namespace std;

int fa[maxn], dis[maxn];

int find(int x)
{
	if(fa[x] == x) return x;
	int t = fa[x];
	fa[x] = find(fa[x]);
	dis[x] += dis[t];
	return fa[x];
}

int main(int argc, char** argv)
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0; i<n; i++) fa[i] = i;
	for(int i=0; i<m; i++)
	{
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		int x = find(--l), y = find(--r);
		if(x == y && dis[l] - dis[r] != d)
		{
			puts("No");
			return 0;
		}
		if(x != y)
			fa[x] = y, dis[x] = d + dis[r] - dis[l];
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
int main() {
	int n, ans = 1; read(n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
		ans = 1ll * ans * i % P;
	int r = 0, g = 0, b = 0, rg = 0, rb = 0, gb = 0;
	for (int i = 1; i <= 3 * n; i++) {
		if (s[i] == 'R') {
			if (gb) {
				ans = 1ll * ans * gb % P;
				gb--;
			} else if (g) {
				ans = 1ll * ans * g % P;
				g--; rg++;
			} else if (b) {
				ans = 1ll * ans * b % P;
				b--; rb++;
			} else r++;
		}
		if (s[i] == 'B') {
			if (rg) {
				ans = 1ll * ans * rg % P;
				rg--;
			} else if (g) {
				ans = 1ll * ans * g % P;
				g--; gb++;
			} else if (r) {
				ans = 1ll * ans * r % P;
				r--; rb++;
			} else b++;
		}
		if (s[i] == 'G') {
			if (rb) {
				ans = 1ll * ans * rb % P;
				rb--;
			} else if (b) {
				ans = 1ll * ans * b % P;
				b--; gb++;
			} else if (r) {
				ans = 1ll * ans * r % P;
				r--; rg++;
			} else g++;
		}
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 512