akhauriyash/Code-Regression huggingface dataset:
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
inline ll add(ll a,ll b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline ll sub(ll a,ll b){a-=b;if(a<0)a+=MOD;return a;}
inline ll mul(ll a,ll b){return (a*1ll*b)%MOD;}
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll a,b,c,k;
     cin>>a>>b>>c>>k;
     if(a>=k) return cout<<k,0;
     else if(a+b>=k) return cout<<a,0;
     else
     {
        ll x=a+b;
        ll y=k-x;
        x=a-y;
        cout<<x;
     }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3768
s=input()
ans=0
s=[i for i in s]
for i in range(len(s)):
  del s[-1]
  if len(s)%2==0:
    if s[:len(s)//2]==s[len(s)//2:] and len(s)>0:
      ans=len(s)
      break
print(ans)

Measured memory_bytes: 3060
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    N = i2n()
    keys = ['AC', 'WA', 'TLE', 'RE']
    d = {}
    for k in keys:
        d[k] = 0
    for _ in range(N):
        s = i2s()
        d[s] += 1
    for k in keys:
        print('%s x %d' % (k, d[k]))

main()


Measured memory_bytes: 9492
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int x;

int main() {
	cin >> x;
	int sum = 0;
	for (int i = 1;; i++) {
		sum += i;
		if (sum >= x) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
using namespace std;
 
int main() {
    int n, y;
    cin >> n >> y;
    int t = (y / 1000) - n;
    if(t < 0) {
        cout << "-1 -1 -1" <<endl;
        return 0;
    }
    for(int i = t / 4; i >= 0; i--) {
        if((t - (i * 4)) % 9 == 0) {
            int m = (t - (i * 4)) / 9;
            if(m < 0 || n - m - i < 0) continue;
            cout << m << " " << i << " " << n - m - i << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,check;

int main(){
    cin>>N;
    check=1;
    while(check<=N){
        check*=2;
    }
    out(check/2);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"



int32_t main()
{
	boost;
	
	int a,b,n;
	cin>>a>>b>>n;
	if(a<b)
		swap(a,b);
	int ans=0;
	while(ans*a<n)
		ans++;
	cout<<ans<<endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string o,e;
    cin >> o >> e;
    if(o.size() > e.size()){
        for(int i = 0; i < e.size(); i++){
            cout << o.at(i) << e.at(i);
        }
        cout << o.at(o.size()-1);
    }
    else {
        for(int i = 0; i < e.size(); i++){
            cout << o.at(i) << e.at(i);
        }
    }
    cout << endl;

}

Measured memory_bytes: 3632
INF=10**18
def calc(a,b,xor):
  if (a,b,xor) in memo:
    return memo[(a,b,xor)]
  if (a&1)^(b&1)!=(xor&1):
    return INF
  if xor==0:
    if a<b:
      return INF
    else:
      return (a-b)//2
  x=2*calc(a//2,b//2,xor//2)
  y=2*calc((a-1)//2,(b+1)//2,xor//2)+1
  memo[(a,b,xor)]=min(x,y)
  return memo[(a,b,xor)]

n=int(input())
arr=list(map(int,input().split()))
a,b=arr[0],arr[1]
xor=0
for i in range(2,n):
  xor^=arr[i]
memo={}
ans=calc(a,b,xor)
if ans>=a:
  print(-1)
else:
  print(ans)

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

#define N 1123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n, match, a, days = 0, mdays[N], currdays;
    bool find, vis[N];
    queue<int> qu[N];
    cin >> n;
    match = (n*(n-1))/2;
    for(int i = 1 ; i <= n ; i++){
    	mdays[i] = 0;
    	for(int j = 1 ; j < n ; j++){
    		cin >> a;
    		qu[i].push(a);
    	}
    }
    while(match != 0){
    	find = false;
    	fill(vis, vis+N, false);
    	for(int i = 1 ; i <= n ; i++){
    		if(qu[qu[i].front()].front() == i){
				currdays = max(mdays[i], mdays[qu[i].front()])+1;
				mdays[i] = mdays[qu[i].front()] = currdays;
				days = max(days, currdays);
	    		match--;
	    		find = true;
				qu[qu[i].front()].pop();
				qu[i].pop();
    		}	
    	}
    	if(!find){
    		days = -1;
    		break;
    	}
    }
    cout << days << endl;
    return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int main(void){
	int a[100000];
	int b[100000];
	int c;
	int d;
	int k;
	int n;
	int p;
	int q;
	long long s;
	int x;
	int y;
	int z;
	for (int i = 0; i < 100000; i++){
		a[i] = 0;
		b[i] = 0;
	}
	z = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		b[a[i]]++;
	}
	if (n % 2 == 0){
		for (int i = 0; i < n / 2; i++){
			if (b[2 * i + 1] != 2)z++;
		}
	}
	else{
		if (b[0] != 1)z++;
		for (int i = 0; i < n / 2; i++){
			if (b[2 * i + 2] != 2)z++;
		}
	}
	if (z != 0)printf("0\n");
	else{
		s = 1;
		n =n / 2;
		for (int i = 0; i < n; i++){
			s = s * 2;
			s = s % 1000000007;
		}
	printf("%lld\n",s);
	}
	return 0;
}


Measured memory_bytes: 896
#include<iostream> 
using namespace std;
int main(){
	string s;
	cin>>s;
	int temp=0;
	if(s[0]==s[s.length()-1]){
		temp++;
	}
	if(s.length()%2==1){
		temp++;
	}
	if(temp%2==1){
		cout<<"First"<<endl;
	}else{
		cout<<"Second"<<endl;
	}
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] num = new int[n];
        int sum = 0;
        double now = 0;
        for (int i = 0; i < n; i++){
            num[i] = input.nextInt();
            sum += num[i];
            now = Math.max(now,num[i]);
        }
        double ave = (double)sum / (double)num.length;
        int ans = 0;
        for (int i = 0; i < n; i++){
            if (now > Math.abs(num[i] - ave)){
                now = Math.abs(num[i] - ave);
                ans = i;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

int main(void) {
  int a[4], b[2];
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < 2; i++) {
    cin >> b[i];
  }
  sort(a, a + 4);
  sort(b, b + 2);

  cout << a[1] + a[2] + a[3] + b[1] << endl;

  return 0;
}


Measured memory_bytes: 3156
n, k = map(int, input().split())
a = list(map(int, input().split()))
cum = [0]
for i in range(n):
    cum.append(min(a[i], 0) + cum[-1])
cum2 = [0]
for i in range(n):
    cum2.append(max(a[i], 0) + cum2[-1])
SUM = sum(max(a[i], 0) for i in range(n))
l = []
for i in range(n - k + 1):
    l.append(SUM + cum[i + k] - cum[i])
    l.append(SUM - cum2[i + k] + cum2[i])
print(max(l))

Measured memory_bytes: 35044
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

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

	vector<vector<bool>> edges(N, vector<bool>(N, false));
	rep(i, M)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		edges[a][b] = true;
		edges[b][a] = true;
	}

	vector<int> indices;
	for (int i = 1; i < N; ++i)
	{
		indices.push_back(i);
	}

	int ans = 0;
	do {
		int index = 0;
		bool isSatisfied = true;
		rep(i, indices.size())
		{
			if (!edges[index][indices[i]])
			{
				isSatisfied = false;
				break;
			}

			index = indices[i];
		}

		if (isSatisfied) ++ans;
	} while (next_permutation(indices.begin(), indices.end()));

	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc097/tasks/abc097_b

vector<bool> expo(1005);

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

    expo[1] = true;
    for (int b = 2; b <= X; b++) {
        int v = b * b;
        while(v <= X) {
            expo[v] = true;
            v *= b;
        }
    }

    for (int i = X; i >= 1; i--) if(expo[i]) {
        cout << i << "\n";
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int s[500000],n;
long long count;

void Merge(int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1],R[n2 + 1];
    for(int i = 0;i < n1;i++)
        L[i] = s[left + i];
    for(int i = 0;i < n2;i++)
        R[i] = s[mid + i];
    L[n1] = 2000000000;
    R[n2] = 2000000000;
    int i = 0;
    int j = 0;
    for(int k = left;k < right;k++){
        if(L[i] <= R[j])
            s[k] = L[i++];
        else{
            s[k] = R[j++];
            count += n1 - i;
        }
    }
}

void MergeSort(int left,int right){
    if(left + 1< right){
        int mid = (left + right)/2;
        MergeSort(left,mid);
        MergeSort(mid,right);
        Merge(left,mid,right);
    }
}

int main(void){
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&s[i]);
    }

    MergeSort(0,n);
    printf("%lld\n",count);
    return 0;
}

Measured memory_bytes: 4248
#include <stdio.h>
int main(){
    int h, w;
    int i = 0;
    int j, k;
    while(i<1000){
      scanf("%d %d", &h, &w);
      if(h == 0 && w == 0){
        break;
      }else{
        for(j=0; j<h; j++){
          for(k=0; k<w; k++){
            printf("#");
          }
          printf("\n");
        }
        printf("\n");
      }
      i++;
    }
    return 0;
  }


Measured memory_bytes: 2032
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, Q[201000], head, tail, Deg[201000], v[201000], D[201000], E[201000];
vector<int> F[201000];
bool Pos(int a, int d) {
	D[a] = d;
	int x = a, i;
	while (1) {
		x = E[x];
		for (i = 0; i < F[x].size(); i++) {
			v[D[F[x][i]]] = -x;
		}
		for (i = 0;; i++)if (v[i] != -x)break;
		if (x == a && i != d)return false;
		D[x] = i;
		if (x == a)return true;
	}
}
int main() {
	int i, x;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &x);
		E[i] = x;
		F[x].push_back(i);
		Deg[x]++;
	}
	for (i = 1; i <= n; i++) {
		if (!Deg[i])Q[++tail] = i;
	}
	while (head < tail) {
		x = Q[++head];
		for (i = 0; i < F[x].size(); i++) {
			v[D[F[x][i]]] = x;
		}
		for (i = 0;; i++)if (v[i] != x)break;
		D[x] = i;
		int y = E[x];
		Deg[y]--;
		if (!Deg[y]) Q[++tail] = y;
	}
	for (i = 1; i <= n; i++)if (Deg[i])break;
	x = i;
	for (i = 0; i < F[x].size(); i++)if(!Deg[F[x][i]])v[D[F[x][i]]] = x;
	for (i = 0;; i++)if (v[i] != x)break;
	int r1 = i;
	for (i = i + 1;; i++)if (v[i] != x)break;
	int r2 = i;
	if (Pos(x, r1))puts("POSSIBLE");
	else {
		if (Pos(x, r2))puts("POSSIBLE");
		else puts("IMPOSSIBLE");
	}
}

Measured memory_bytes: 13696
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  long long L[N];
  for(int i = 0; i < N; i++) scanf("%lld", L + i);
  
  int t = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      for(int k = j + 1; k < N; k++){
        if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
        if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]){
          ++t;
        }
      }
    }
  }
  
  printf("%d\n", t);
  
  return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <limits.h>
#define MAX 10000
typedef struct {
	int w;
	int u;
	int v;
} HEN;

HEN all[MAX] = {0};
int n;
int num = 0;
int DS[MAX] = {0};
int rank[MAX] = {0};

void inithen() {
	int i;
	for (i = 0; i < MAX; ++i) {
		all[i].w = INT_MAX;
	}
	return;
}

void add(int weight, int a, int b) {
	int i, j;
	HEN tmp;

	if (num == 0) {
		all[0].w = weight;
		all[0].u = a;
		all[0].v = b;
		num++;
		return;
	}

	for (i = 0; ((all[i].w < weight) && (i < num)) ; ++i);
	
	for (j = num; j > i ; --j) {
		all[j] = all[j-1];
	}
	all[i].w = weight;
	all[i].u = a;
	all[i].v = b;

	num++;
}

void initDS() {
	int i;
	for (i = 0; i < MAX; ++i) {
		DS[i] = i;
		rank[i] = 0;
	}
	return;
}

int find(int x) {
	if (x != DS[x]) {
		DS[x] = find(DS[x]);
	}
	return DS[x];
}

int isSame(int x, int y) {
	return find(x) == find(y);
}

void link(int x, int y) {
	if (rank[x] > rank[y]) {
		DS[y] = x;
	} else {
		DS[x] = y;
		if (rank[x] == rank[y]) {
			rank[y]++;
		}
	}
}

void unite(int x, int y) {
	link(find(x), find(y));
	return;
}




int main() {
	int i, j, tmp;
	inithen();
	initDS();
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			scanf("%d", &tmp);
			if (i < j && tmp != -1) {
				add(tmp, i, j);
			}
		}
	}
//	printf("test\n");
	tmp = 0;
	for (i = 0; i < num; ++i) {
		if (find(all[i].u) != find(all[i].v)) {
//			printf("u = %d, v = %d, w = %d\n", all[i].u, all[i].v, all[i].w);
			tmp += all[i].w;
			unite(all[i].u, all[i].v);
		}
	}
	printf("%d\n", tmp);
	return 0;
}

Measured memory_bytes: 792
#include <iostream>

using namespace std;

int main() {
    int n, x;

    cin >> n >> x;

    int a[100010];

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

    long long d, ans = 0;

    for (int i = 0; i < n-1; i++) {
        d = a[i] + a[i+1] - x;

        if (d > 0) {
            ans += d;
            a[i+1] = max(a[i+1] - d, 0LL);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
def resolve():
    a, b, x = map(int, input().split())
    if a ** 2 * b / 2 < x:
        t = 2 * (a ** 2 * b - x) / (a ** 3)
    else:
        t = a * b ** 2 / x / 2
    import math
    d = math.degrees(math.atan(t))
    print(d)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int number = sc.nextInt();
			int count = 0;

			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					for(int k=0;k<10;k++){
						for(int l=0;l<10;l++){
							if(i+j+k+l == number) count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17024
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

constexpr double PI = acos(-1);

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 1), y(n + 1);
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
  vector<int> p(n);
  iota(begin(p), end(p), 0);
  double ans = 1e100;
  do{
    double sum = 0;
    double now = atan2(0, 1);
    ll X = 0, Y = 0;
    p.push_back(n);
    for(auto i : p) {
      double t = atan2(y[i] - Y, x[i] - X);
      sum += min({abs(now - t), abs(t - now), abs(now - t + 2 * PI), abs(t - now + 2 * PI), abs(now - t - 2 * PI), abs(t - now - 2 * PI)});
      now = t;
      X = x[i], Y = y[i];
    }
    p.pop_back();
    ans = min(ans, sum);
  } while(next_permutation(begin(p), end(p)));
  cout << fixed << setprecision(20);
  cout << ans / 2 / PI * 360 << endl;
  return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1005;
const ll INF=1e15;
 
struct edge{int from, to; ll cost;};
int N,M;
vector<edge> es;
ll d[MAX];
 
void add_edge(int u, int v, ll cost){
	edge e = {u, v, cost};
	es.push_back(e);
}

//負閉路のないケース
void BF(int s){
	rep(i,N)d[i]=INF;//1-indexedならrep1に変更;
	d[s]=0;
	while(true){
		bool update=false;
		rep(i,M){
			edge e=es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update=true;
			}
		}
	if(!update) break;
	}
}

//負閉路もある場合
//始点s, 終点tの場合の最小、無限に小さくなるならtrue
bool BF_nloop(int s, int t){
	rep(i,N)d[i]=INF;//1-indexedならrep1に変更;
	d[s]=0;
	rep(i,N){
		rep(j,M){
			edge e=es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i == N-1 && e.to == t) return true;
			}
		}
	}
	return false;
}

//sから到達できる負閉路の検出
bool BF_nloop_from(int s){
	rep(i,N)d[i]=INF;//1-indexedならrep1に変更;
	d[s]=0;
	rep(i,N){
		rep(j,M){
			edge e=es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i == N-1 && e.to == N-1) return true;
			}
		}
	}
	return false;
}

//全ての負閉路の検出
bool BF_nloop(){
	rep(i,N)d[i]=0;
	rep(i,N){
		rep(j,M){
			edge e=es[j];
			if(d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i == N-1) return true;
			}
		}
	}
	return false;
}

int main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		a--;b--;
		add_edge(a,b,-c);
	}
	
	if(BF_nloop(0,N-1)){
		cout<<"inf"<<endl;
		return 0;
	}
	cout<<-d[N-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int a; cin >> a;
	int b; cin >> b;
	string s; cin >> s;
	for (unsigned int i = 0; i < s.length(); ++i) {
		if (i == a) continue;
		if (s[i] < '0' || s[i] > '9') {
			cout << "No" << endl;
			return;
		}
	}
	if (s[a] != '-') {
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
    return;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll d,g;
  cin>>d>>g;
  vll p(d),c(d);
  rep(i,d) cin>>p[i]>>c[i];
  ll ans=INF;
  for(int bit=0;bit<(1<<d);bit++){
    ll cu=0;
    ll cc=0;
    ll k=0;
    for(int i=0;i<d;i++){
      if(bit&(1<<i)){
        cu+=100*(i+1)*p[i]+c[i];
        cc+=p[i];
      }
      else{
        k=i;
      }
    }
    if(cu<g){
      ll j=(g-cu+100*(k+1)-1)/(100*(k+1));
      if(j<p[k]){
        cc+=j;
        ans=min(cc,ans);
      }
    }
    else{
      ans=min(cc,ans);
    }
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char str[150];
  int N,i,Rcount=0,Bcount=0;
  scanf("%d",&N);
  scanf("%s",str);
  for(i=0;i<N;i++){
    if(str[i] == 'R') Rcount++;
    else Bcount++;
  }
  if(Rcount > Bcount) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
cnt = {
  p: 0,
  g: 0
}
point = 0

gets.chomp.each_char do |c|
  if c == "g"
    if cnt[:p] < cnt[:g]
      hand = :p
      point += 1
    else
      hand = :g
    end
  else
    if cnt[:p] < cnt[:g]
      hand = :p
    else
      hand = :g
      point -= 1
    end
  end

  cnt[hand] += 1
end

puts point

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

int main() {
  char x, y;
  cin >> x >> y;
  if (x < y) {
    cout << "<" << endl;
  } else if (x > y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int i,j,k,n;
    string s;
    bool f=1;
    cin>>n;
    cin>>s;
    if(n&1)
        f=0;
    else
        for(i=0; i<n/2; i++)
        {
            if(s[i]!=s[i+n/2])
            {
                f=0;
                break;
            }
        }
    if(f)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# def combinations(n, r):
# 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# def gcd(a, b):
# 	if b == 0:
# 		return a
# 	else:
# 		return gcd(b, a%b)
 
# def lcm(a, b):
# 	return a // gcd(a, b) * b

# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


K = II()
S = input()

if len(S)>K:
	print(S[:K]+'...')
else:
	print(S)






















Measured memory_bytes: 9632
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

const int MAX_N = 110;
const int MAX_V = 100100;
const ll INF = 1LL<<62;
ll dp[MAX_N][MAX_V];

int main() {
  int N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      dp[i][j] = INF;
    }
  }
  
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      if (j - v[i] >= 0) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
      }
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }
  }
  
  ll res = 0;
  for (int i = 0; i < MAX_V; i++) {
    if (dp[N][i] <= W) {
      res = i;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    vector<long long> acc(n + 1, 0);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + p[i];
    long long ans = 0;
    for (int i = k; i <= n; i++) ans = max(ans, acc[i] - acc[i - k]);
    cout << setprecision(15) << (double)(ans + k) / 2 << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


void dividenum(int n, VI&a) {
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			n /= i;
			a[i]++;
		}
	}
	if (n > 1)a[n]++;
}
LL N;

LL ans = 0LL;

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

	cin >> N;
	ans = 1;
	VI a(1001,0);
	FOR(i, 2, N + 1) {
		dividenum(i, a);
	}
	FOR(i, 2, N + 1) {
		if (a[i])
			ans *= (a[i] + 1);
		ans %= MOD;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 1000; i++) {
		int a, b, c;
		a = i / 100;
		c = i % 10;
		b = (i - a * 100) / 10;
		bool a_b = false;
		bool b_b = false;
		bool c_b = false;
		for (int j = 0; j < s.size(); j++) {
			int d = s.at(j) - '0';
			if (a_b == false && d == a) {
				a_b = true;
			}
			else if (a_b == true && b_b == false && d == b) {
				b_b = true;
			}
			else if (a_b == true && b_b == true && c_b == false && d == c) {
				c_b = true;
				ans++;
				break;
			}
			else {}
		}
	}
	cout << ans << endl;
}

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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n;

/*funcs*/


/*main*/
int main(){
    cin>>n;
    cout<<180*(n-2);
}

Measured memory_bytes: 256
N = input().split()
count = [0] * int(int(N[0])+1)
P = []
ans = []
for i in range(int(N[1])):
	p,y = map(int, input().split())
	P.append((y,p,i))
# print(P)
K = sorted(P)
# print(K)
for y,p,i in K:
	count[p] += 1
	ans.append((i,p,count[p]))

ans.sort()
for i,p,count in ans:
	print("{:0=6}".format(int(p))+"{:0=6}".format(count))

Measured memory_bytes: 34040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int[] array = new int[x];

		for(int i=0;i<x;i++) {
			array[i] = sc.nextInt();
		}

		show(array, x);
		insertionSort(array, x);

		sc.close();
	}

	public static void show(int[] array, int x) {
		for(int i=0;i<x;i++) {
			System.out.print(array[i]);
			if(i!=x-1) {
				System.out.print(" ");
			}
		}
		System.out.println();
	}

	public static void insertionSort(int[] array, int x) {
		int j,i,v;
		for(i=1;i<x;i++) {
			v=array[i];
			j=i-1;
			while(j>=0 && array[j]>v) {
				array[j+1] = array[j];
				j--;
			}
			array[j+1]=v;
			show(array,x);
		}
	}
}


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

int N;
int A[100005];
int flag=0; //-1 descending, 0 neutral, 1 ascending
int counter=1;

int main()
{
    cin>>N;

    for (int i=1; i<=N; i++)
    {
        cin>>A[i];
    }

    for (int i=2; i<=N; i++)
    {


        if (A[i]>A[i-1] && flag==-1)
        {
            flag=0;
            counter++;
        }
        
        else if (A[i]<A[i-1] && flag==1)
        {
            flag=0;
            counter++;
        }

        else if (flag==0 && A[i]>A[i-1])
        {
            flag=1;
        }

        else if (flag==0 && A[i]<A[i-1])
        {
            flag=-1;
        }

    }

    cout<<counter<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

//??§?¬??????§?§£??????
int main(void){
	int n, a, b;
	double kizi;
	cin >> n >> a >> b >> kizi;
	vector<int> debu(n + 1);//?????????????????\????????????
	rep(i, n) cin >> debu[i];
	sort(debu.begin(), debu.end());
	reverse(debu.begin(), debu.end());//??§???????????????????????????
	vector<double> ans(n + 1);
	//?????????????????????????????????????????????????????§??????
	rep(i, n + 1){//i????????????????????°????????¶??¨???
		double nedan = (double)a + (double)i * (double)b;//??????????¨????
		double karori = kizi;//?????°?????????????????????????????¨??????
		rep(j, i) karori += debu[j];//i????????????????????°????????????????????????????????????????????????i???????????§??????
		ans[i] = karori / nedan;
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	printf("%d\n", (int)floor(ans[0]));
	/*
	double max; max = ans[0];
	rep(i, n){
		if(max == ans[i]) printf("%d\n", int(floor(max)));
		else break;
	}
	*/
	return 0;
}

Measured memory_bytes: 3300
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        # return (1 + limit) / 2
        return sum(range(limit + 1)) / limit

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99264
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let d: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = (n + (2 * d)) / (2 * d + 1);
    println!("{}", ans);
}


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

const int N=210;
int bel[N],a[N],b[N],n;
bool G[N][N],vis[N];
std::map<int,int> M;
 
bool isprime(int n) {
	if(n==1) return 0;
	for(int i=2;i*i<=n;i++)
		if(n%i==0) return 0;
	return 1;
}
 
bool DFS(int i) {
	for(int j=1;j<=n;j++)
		if(!vis[j]&&G[i][j]) {
			vis[j]=1;
			if(!bel[j]||DFS(bel[j])) { bel[j]=i;return 1; }
		}
	return 0;
}
 
int main() {
	std::cin>>n;
	for(int i=1,x;i<=n;i++) std::cin>>x,M[x]^=1,M[x+1]^=1;
	for(auto x:M)
		if(x.second) (x.first&1?a[++*a]:b[++*b])=x.first;
	int ans=0;
	for(int i=1;i<=*a;i++)
		for(int j=1;j<=*b;j++)
			if(isprime(std::abs(a[i]-b[j]))) G[i][j]=1;
	for(int i=1;i<=*a;i++) {
		memset(vis,0,sizeof(vis));
		ans+=DFS(i);
	}
	std::cout<<ans+(*a-ans)/2*2+(*b-ans)/2*2+(*a-ans)%2*3<<std::endl;
	return 0;
}

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

#define fi first
#define se second

const int N = 1001;
const int Q = 10000010;

using namespace std;

int n;
int a[N];
int p[N];
bitset < Q > d;
vector < int > v[N];
bool used[N];

bool dfs(int x)
{
        if(used[x]){
                return false;
        }
        used[x] = true;
        for(int y: v[x]){
                if(p[y] == -1 || dfs(p[y])){
                        p[y] = x;
                        return true;
                }
        }
        return false;
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        for(int i = 2; i * i < Q; i++){
                if(d[i]){
                        continue;
                }
                for(int j = i * i; j < Q; j += i){
                        d[j] = 1;
                }
        }
        d[0] = d[1] = d[2] = 1;

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        vector < int > b;
        b.push_back(a[1]);
        for(int i = 2; i <= n; i++){
                if(a[i - 1] + 1 < a[i]){
                        b.push_back(a[i - 1] + 1);
                        b.push_back(a[i]);
                }
        }
        b.push_back(a[n] + 1);

        n = b.size();
        vector < int > A;
        vector < int > B;
        for(int i = 0; i < n; i++){
                p[i] = -1;
                if(b[i] % 2){
                        A.push_back(i);
                } else{
                        B.push_back(i);
                }
                for(int j = 0; j < n; j++){
                        if(d[abs(b[i] - b[j])] == 0){
                                v[i].push_back(j);
                        }
                }
        }
        int cnt = 0;
        for(int x: A){
                for(int i = 0; i < n; i++){
                        used[i] = 0;
                }
                cnt += dfs(x);
        }
        int res = cnt;
        res += (A.size() - cnt) / 2 * 2;
        res += (B.size() - cnt) / 2 * 2;
        if((A.size() - cnt) % 2 || (B.size() - cnt) % 2){
                res += 3;
        }
        cout << res << "\n";
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll x, k, q;
ll r[maxn];
ll t[maxn], a[maxn];

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

    cin>>x;
    cin>>k;
    for (int i=0; i<k; i++) {
	cin>>r[i];
    }

    cin>>q;
    for (int i=0; i<q; i++) {
	cin>>t[i]>>a[i];
    }

    auto bound = [&](ll val, ll l, ll r) {
	val = min(val, r);
	val = max(l, val);
	return val;
    };


    int ri=0;
    ll sgn = -1;
    ll lo = 0;
    ll hi = x;
    ll dx = 0;
    ll last = 0;
    
    for (int qi=0; qi<q; ) {
	if (ri==k || t[qi] < r[ri]) {
	    ll res = bound(dx+a[qi], lo, hi);
	    res += sgn*(t[qi]-last);
	    res = bound(res, 0, x);
	    cout<<res<<"\n";
	    qi++;
	    
	} else {
	    ll dr = sgn*(r[ri]-last);

	    lo = bound(lo+dr, 0, x);
	    hi = bound(hi+dr, 0, x);
	    dx += dr;

	    last = r[ri];
	    ri++;
	    sgn = -sgn;	    
	}
    }
    
    
    return 0;
}


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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

ll dp[100001]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n,w;
	cin>>n>>w;

	for(ll i=0;i<=100000;i++){
		dp[i]=LLONG_MAX/2;
	}

	for(int i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		for(int j=100000;j>=0;j--){
			if(dp[j]+a<=w){
				dp[j+b]=min(dp[j+b],dp[j]+a);
			}
		}
		dp[b]=min(dp[b],a);
	}
	ll maxi=0;
	for(int i=0;i<=100000;i++){
		if(dp[i]!=LLONG_MAX/2){
			maxi=i;
		}
	}

	cout<<maxi<<endl;


	return 0;
}

Measured memory_bytes: 1024
my@e;
$/=[*] 2..get;
map {(@e[$_]++;$//=$_)while $/%%$_},2..99;
$_={+@e.grep: *>$_-2};
say .(75)+.(25)*+^-.(3)+.(15)*+^-.(5)+.(5)*+^-.(5)*(.(3)-2)/2

Measured memory_bytes: 77196
import java.io.*;
import java.util.*;
public class Main{
    public static Scanner scn=new Scanner(System.in);
    public static void main(String args[]){
        ans();
    }
    public static void ans(){
        int n=scn.nextInt();
        boolean flag=false;
        while(n>0){
            int a=n%10;
            if(a==7){
                System.out.print("Yes");
                flag=true;
                break;
            }
            n/=10;
        }
        if(flag==false)
        System.out.print("No");
    }
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

const int MAXV = 202;
class FordFulkerson {
	private:
	struct edge {int to, cap, rev;};
	vector<edge> g[MAXV];
	bool used[MAXV];
	public:
	// fromからtoへ向かう要領capの辺をグラフに追加する
	void add_edge(int from, int to, int cap) {
		g[from].pb((edge){to,cap,g[to].size()});
		g[to].pb((edge){from,0,g[from].size()-1});
	}
	// 増加パスをdfsで探す
	int dfs(int v, int t, int f) {
		if (v==t) return f;
		used[v] = true;
		rep(i,g[v].size()) {
			edge &e = g[v][i];
			if (!used[e.to] && e.cap>0) {
				int d = dfs(e.to,t,min(f,e.cap));
				if (d>0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	// sからtへの最大流を求める
	int getflow(int s, int t) {
		int flow = 0;
		while (true) {
			memset(used,0,sizeof(used));
			int f = dfs(s,t,inf);
			if (f==0) return flow;
			flow += f;
		}
	}
};

int n, a[100], b[100], c[100], d[100];
FordFulkerson f;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i] >> b[i];
		f.add_edge(n*2,i,1);
	}
	rep(i,n) {
		cin >> c[i] >> d[i];
		f.add_edge(i+n,n*2+1,1);
		rep(j,n) if (a[j]<c[i] && b[j]<d[i]) f.add_edge(j,i+n,1);
	}
	cout << f.getflow(n*2,n*2+1) << ln;
}

Measured memory_bytes: 384
using System;

namespace v0_0006
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            for (int i = line.Length - 1; i >= 0; i--)
            {
                Console.Write(line[i]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8760
# include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  int divs = 0;
  for(int i = a; i <= b; i++){
    if(c % i == 0){
      divs++;
    }
  }
  cout << divs << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

void solve() {
	ll n; string s; cin >> n >> s;
	vector<int> p;
	rep(i,0,n) {
		if (s[i]=='W') p.push_back(i);
	}
	if (p.size()==0) {
		cout << "0\n";
		return;
	}
	ll cnt = 0;
	per(i,n-1,-1) {
		if(s[i]=='R') {
			if (p[cnt] < i+1) {
				cnt++;
			} else {
				break;
			}
		}
	}
	cout << cnt << '\n';
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 4468
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

dic = defaultdict(int)
for i in range(N):
    dic[A[i]] += 1

ans = 0
for k in dic.keys():
    if dic[k] >= k:
        ans += dic[k] - k
    else:
        ans += dic[k]

print(ans)

Measured memory_bytes: 18676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average, variance;

                double sum = 0;
                for (int i = 0; i < scores.length; i++) {
                    sum += scores[i];
                }
                average = sum / n;

                double sum_variance = 0;
                double a = 0;
                for (int i = 0; i < scores.length; i++) {
                    a = (scores[i] - average) * (scores[i] - average);
                    sum_variance += a;
                }
                variance = sum_variance / n;
                System.out.println(Math.sqrt(variance));

            }
        }
    }
}


Measured memory_bytes: 31824
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,M,HH,MM,K;
  cin>>H>>M>>HH>>MM>>K;
  
  co(HH*60+MM-H*60-M-K);
}

Measured memory_bytes: 3640