akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
vector<int> adj[100005];
int vis[100005];
int dp[100005];
stack<int> st;
void dfs(int ele) {
    vis[ele] = 1;
    for(int i=0;i<adj[ele].size();i++) {
        if(!vis[adj[ele][i]]) {
            dfs(adj[ele][i]);
        }
    }
    st.push(ele);
}
int main() {
    int n, m;
    cin>>n>>m;
    for(int i=0;i<m;i++) {
        int x, y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    for(int i=1;i<=n;i++) {
        if(!vis[i]) {
            dfs(i);
        }
    }
    while(!st.empty()) {
        int nd = st.top();
        st.pop();
        for(int j=0;j<adj[nd].size();j++) {
            dp[adj[nd][j]] = max(dp[adj[nd][j]], dp[nd] + 1);
        }
    }
    int mx = 1;
    for(int i=n;i>=1;i--) {
        mx = max(mx, dp[i]);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main(){
    int k,s; cin>>k>>s;
    int rst = 0;
    rep(0,x,k+1){
        rep(0,y,k+1){
            if(x+y>=s-k && x+y <= s)
                rst++;
        }
    }

    cout << rst << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b;
	while (scanf("%d%d",&a,&b)!= EOF)
	{
		int i = 0;
		a = a + b;
		while (a>0)
		{
			a = a / 10;
			i++;

		}
		printf("%d\n", i);
	}
}

Measured memory_bytes: 2552
n, t = gets.split(' ')

arr = []

n.to_i.times.with_index do |i|
  cost, time = gets.split(' ')
  hash = {cost: cost.to_i, time: time.to_i}
  arr.push hash
end

arr.reject! do |h|
  h[:time] > t.to_i
end

result = arr.min {|a, b| a[:cost] <=> b[:cost] }&.[](:cost)

puts result ? result : 'TLE'

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

int main(){
    string s;
    cin>>s;
    bool go=false;
    while(s!="-"){
        int a,cnt=0; cin>>a;
        int n=s.size();
        for(int i=0; i<a; ++i){
            int h; cin>>h;
            cnt+=h;
        }
        string sa=s.substr(0,cnt%n);
        string sb=s.substr(cnt%n);
        cout<<sb+sa<<endl;
        cin>>s;
    }
    return 0;
}


Measured memory_bytes: 3184
io = STDIN
str=io.gets.chomp
chunk=str.split(//).chunk_while{|a,b|a==b}.map{|a|[a[0],a.size]}.to_a
st=0
ar=[]
chunk.each do |a|
  if a[0]=="<"
    a[1].times do |i|
      ar<<i
    end
    st =ar[-1]+1
  elsif a[0]==">"
    init=[st,a[1]].max
    ar<<init
    (a[1]-1).times do |i|
      ar<<a[1]-i-1
    end
    st=ar[-1]-1
  end
end
ar << st
p ar.inject(:+)


Measured memory_bytes: 76296
#include<stdio.h>
int main()
{
    long int a,b,ans;
    char op;
    scanf("%ld %c %ld",&a,&op,&b);
    if(op == '+'){
        ans = a+b;
    }
    else{
        ans = a-b;
    }
    printf("%ld\n",ans);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < 3; ++i) {
        for (int j = i; j < 3; ++j) {
            if (s[i] == 'S') continue;
            bool flag = true;
            for (int k = i; k < j; ++k) {
                if (s[k] != s[k+1]) flag = false;
            }
            if (flag) res = max(res, j-i+1);
        }
    }

    cout << res << endl;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

void solve(vector<string>& W, int k, vector<vector<int>>& A) {
    int n = W.size();
    int m = W[0].size();
    vector<int> B;
    A.resize(n);
    for (int i = 0; i < n; i++)
        A[i].assign(m, -1);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        B.clear();
        for (int j = 0; j < m; j++) {
            if (W[i][j] == '#') {
                B.push_back(j);
            }
        }
        if (!B.empty()) {
            for (int k = 0; k < B.size(); k++) {
                cur++;
                if (k == 0) {
                    for (int j = 0; j <= B[k]; j++) {
                        A[i][j] = cur;
                    }
                } else {
                    for (int j = B[k-1] + 1; j <= B[k]; j++) {
                        A[i][j] = cur;
                    }
                }
                if (k == B.size() - 1) {
                    for (int j = B[k] + 1; j < m; j++) {
                        A[i][j] = A[i][j-1];
                    }
                }
            }
        }
    }
    for (int i = n - 2; i >= 0; i--) {
        if (A[i][0] == -1 && A[i+1][0] != -1) {
            copy(A[i+1].begin(), A[i+1].end(), A[i].begin());
        }
    }
    for (int i = 1; i < n; i++) {
        if (A[i][0] == -1 && A[i-1][0] != -1) {
            copy(A[i-1].begin(), A[i-1].end(), A[i].begin());
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, k;
    vector<string> W;
    vector<vector<int>> A;
    cin >> n >> m >> k;
    W.resize(n);
    for (int i = 0; i < n; i++)
        cin >> W[i];
    solve(W, k, A);
    for (int i = 0; i < n; i++) {
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
def main():
    N, K = map(int, input().split())
    S = input()
    lz = []
    lo = []
    o = 0
    z = 0
    for i in S:
        if i == '1':
            o += 1
            if z > 0:
                lz.append(z)
                z = 0
        if i == '0':
            z += 1
            if o > 0:
                lo.append(o)
                o = 0
    if o > 0:
        lo.append(o)
    if z > 0:
        lz.append(z)
    if len(lz) <= K:
        return N
    if S[0] == '0':
        m = t = sum(lz[:K]) + sum(lo[:K])
        for i in range(len(lz) - K):
            if i == 0:
                t -= lz[i]
            else:
                t -= (lz[i] + lo[i-1])
            if len(lo) == (i + K):
                t += lz[i + K]
            else:
                t += (lz[i + K] + lo[i + K])
            m = max(m, t)
        return m
    if S[0] == '1':
        m = t = sum(lz[:K]) + sum(lo[:K+1])
        for i in range(len(lz) - K):
            t -= (lz[i] + lo[i])
            if len(lo) == (i + K + 1):
                t += lz[i + K]
            else:
                t += (lz[i + K] + lo[i + K + 1])
            m = max(m, t)
        return m
print(main())


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

int main()
{
    string s;
    cin >> s;
    string r = s;
    reverse(r.begin(), r.end());

    int ans = 0;
    rep(i, (int)s.size() / 2) if (s[i] != r[i])
        ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3580
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int K = Integer.parseInt(s[1]);
		
		s=br.readLine().split(" ");
		int R = Integer.parseInt(s[0]);
		int S = Integer.parseInt(s[1]);
		int P = Integer.parseInt(s[2]);
		
		String st=br.readLine();
		char t[]=st.toCharArray();
		char moves[]=new char[N];
		
		long ans=0;
		
		/*logic: if I can play winning move then I play it, if not then I play a move 
		which doesn't obstruct the (i+K)th move, since be it is a loss or draw, 
		there are no poins associated with it.*/
		
		
		for(int i=0;i<N;i++)
		{
			if(i<K)
			{
				if(t[i]=='r')
				{
					ans+=P;
					moves[i]='p';
				}	
				else if(t[i]=='p')
				{
					ans+=S;
					moves[i]='s';
				}	
				else if(t[i]=='s')
				{
					ans+=R;
					moves[i]='r';
				}
			}
			
			else //i>K
			{
				if(t[i]=='r' && moves[i-K]!='p')
				{
					ans+=P;
					moves[i]='p';
				}	
				else if(t[i]=='p' && moves[i-K]!='s')
				{
					ans+=S;
					moves[i]='s';
				}	
				else if(t[i]=='s' && moves[i-K]!='r')
				{
					ans+=R;
					moves[i]='r';
				}
				
				else
					moves[i]='X';//dummy value, means I play a move that doesnt obstruct (i+K)th move
			}	
		}
		
		out.println(ans);
	
	}
}




Measured memory_bytes: 25172
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 300005
#define INF 1000000000

using namespace std;

int n,ans=INF;
int l[MAX_N];
int r[MAX_N];
char s[MAX_N];

int sec(int l,int r,int *a)
{
	if(l>r) return 0;
	return a[r]-a[l-1];
}

int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
	{
		l[i]+=l[i-1]+(s[i]=='W');
		r[i]+=r[i-1]+(s[i]=='E');
	}
	for(int i=1;i<=n;i++)
	{
		int now=sec(1,i-1,l)+sec(i+1,n,r);
		ans=min(ans,now);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	vector<int>A(N), B(N), C;
	int asum = 0, bsum = 0, minussum = 0, cnt = 0;
	rep(i, N) {
		cin >> A[i];
		asum += A[i];
	}
	rep(i, N) {
		cin >> B[i];
		if (A[i] < B[i]) {
			minussum += B[i] - A[i];
			cnt++;
		}
		else if (A[i] > B[i]) {
			C.push_back(A[i] - B[i]);
		}
		bsum += B[i];
	}
	if (asum < bsum) {
		cout << -1;
		return 0;
	}
	sort(C.begin(), C.end());
	int i = C.size() - 1;
	while (1) {
		if (minussum <= 0) {
			cout << cnt;
			return 0;
		}
		minussum -= C[i];
		cnt++;
		i--;
	}
}

Measured memory_bytes: 2428
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    if(W>=S) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


Measured memory_bytes: 3764
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

N = int(input())
A = list(map(int, input().split()))

L = [0]
for i in A:
    L.append(gcd(L[-1], i))

R = [0]
for i in range(N-1, -1, -1):
    R.append(gcd(R[-1], A[i]))
R.reverse()
M = []
for i in range(N):
    M.append(gcd(L[i], R[i+1]))

print(max(M))


Measured memory_bytes: 14076
import random
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]

t=[random.randint(1,26) for i in range(D)]
#print(t) 
    
M=22*10000
day=[random.randint(1,5) for i in range(M)]
q=[random.randint(1,26) for i in range(M)]
    
m=[0]*D
 
a=[[0 for i in range(26)] for j in range(D)]
R=[[0 for i in range(26)] for j in range(D)]
for u in range(D):
    i=t[u]
    for y in range(u,D):
        a[y][i-1]=u+1
    if u==0:
        m[u]=s[u][i-1]
    else:
        m[u]=m[u-1]+s[u][i-1]
mm=[0]*D
for d  in range(D):
    for i in range(26):
        mm[d]+=c[i]*(d+1-a[d][i])
    if not d==0:
        mm[d]+=mm[d-1]
for d in range(D):
    m[d]-=mm[d]
mmm=m[D-1]

#for i in range(D):
 #   print(a[i])
 
 
for p in range(M):
    new_type=q[p]
    old_type=t[day[p]-1]
    #print(new_type,old_type)
    A=0
    B=0
    C=0
    C=s[day[p]-1][old_type-1]-s[day[p]-1][new_type-1]
    for d in range(D):
        A+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    xday=day[p]
    R=a
    if xday>1:
        before_new=a[xday-2][new_type-1]
        before_old=a[xday-2][old_type-1]
        now_new=a[day[p]-1][new_type-1]
        now_old=a[day[p]-1][old_type-1]
        for d in range(day[p]-1,D):
            if a[d][new_type-1]==now_new:
                a[d][new_type-1]=xday
            if a[d][old_type-1]==now_old:
                a[d][old_type-1]=before_old
    else:
        for d in range(day[p]-1,D):
            if a[d][old_type-1]==1:
                a[d][old_type-1]=0
            if a[d][new_type-1]==0:
                a[d][new_type-1]=1   
    t[day[p]-1]=new_type
    for d in range(D):
        B+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    T=mmm-(B-A+C)
    if T>mmm:
        mmm=T
        #for i in range(D):
         #   print(a[i])
        #print(mmm)
    else:
        a=R
    #print(mmm)
for i in range(len(t)):
    print(t[i])

Measured memory_bytes: 103772
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    ll n,t=0,h=0;
    cin>>n;
    while(n--)
    {
        string tt,hh;
        cin>>tt>>hh;
        if(tt.compare(hh)==0)
        {
            t++;
            h++;
        }
        else if(tt.compare(hh)>0)
            t+=3;
        else
            h+=3;
    }
    cout<<t<<" "<<h<<endl;
    return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> b = a;
	rep(i,n) b.at(i) -= i + 1;
	sort(b.begin(),b.end());
	ll k = b.at(n / 2);
	ll ans = 0;
	rep(i,n){
		ans += abs(a.at(i) - (k + (i + 1)));
	}
	cout << ans << endl;
}


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


int main()
{
    long long int n;
    while(cin>>n)
    {
        long long int x=sqrt((double)n);
        double i;
        double y;
        for(i=x;i>0;i--)
        {
            y=n/i;
            if(y-(long long int)y==0)
            break;
        }
        cout<<(long long int)i+(long long int)y-2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Data.Array.IO
import Data.IORef
import Data.List
import Control.Monad

main = do
  (n:k:_) <- getLine >>= return . map read . words :: IO [Int]
  a <- getLine >>= return . map read . words :: IO [Int]

  arr <- newArray (1, n) 0 :: IO (IOArray Int Int)
  cnt <- newIORef 0

  forM_ a $ \x -> do
    r <- readArray arr x
    writeArray arr x (r+1)
    when (r==0) (modifyIORef cnt (+1))

  c <- readIORef cnt

  print =<< return . sum . take (c-k) . sort . (filter (/=0)) =<< getElems arr


Measured memory_bytes: 61820
#include <stdio.h>
int main(){
  int n,N;
  scanf("%d",&N);
  n = N%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9) printf("hon\n");
  if(n==0 || n==1 || n==6 || n==8 ) printf("pon\n");
  if(n==3) printf("bon\n");
  return 0;
}

Measured memory_bytes: 3172
from bisect import bisect, bisect_left

n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(n):
	b.append(b[-1] + a[i])

ans = float("inf")
for j in range(2, n-1):
	c = []
	f = bisect(b, b[j]/2)
	f -= 1
	if f == 0 or j == 2:
		c += [b[1]-b[0], b[j]-b[1]]
	elif f == j-1:
		c += [b[j-1]-b[0], b[j]-b[j-1]]
	else:
		if abs(b[f]-b[0] - (b[j]-b[f])) <= abs(b[f+1]-b[0] - (b[j]-b[f+1])):
			c += [b[f]-b[0], b[j]-b[f]]
		else:
			c += [b[f+1]-b[0], b[j]-b[f+1]]

	l = bisect(b, b[j]+((b[n]-b[j])/2))
	l -= 1
	#print(l)
	if l == j or j == n-2:
		c += [b[j+1]-b[j], b[n]-b[j+1]]
	elif l == n-1:
		c += [b[n-1]-b[j], b[n]-b[n-1]]
	else:
		if abs(b[l]-b[j] - (b[n]-b[l])) <= abs(b[l+1]-b[j] - (b[n]-b[l+1])):
			c += [b[l]-b[j], b[n]-b[l]]
		else:
			c += [b[l+1]-b[j], b[n]-b[l+1]]

	ans = min(ans, max(c)-min(c))

print(ans)

Measured memory_bytes: 25544
#include <cstdio>
typedef long long ll;
using namespace std;
int main(){
		ll a,b,k;scanf("%lld %lld %lld",&a,&b,&k);
		if(k<=a){
				printf("%lld %lld",a-k,b);
			}	
		else if(k<=a+b){
				printf("0 %lld",b-(k-a));
			}	
		else{
				printf("0 0");
			}	
		return 0;	
	}


Measured memory_bytes: 1728
def solve(n, x):
    layers = 2 ** (n + 1) - 3  # レベルn-1バーガーの層の数
    patties = 2 ** n - 1    # レベルn-1バーガーのパティの数
    if x == 0:
        ans = 0
    elif x <= layers + 1:
        ans = solve(n - 1, x - 1)
    elif x <= 2 * layers + 2:
        ans = patties + 1 + solve(n - 1, x - layers - 2)
    else:
        ans = 2 * patties + 1

    return ans

N, X = [int(x) for x in input().split()]
print(solve(N, X))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			System.out.println((n > k) ? k * x + (n - k) * y : n * x);
		}
	}
}


Measured memory_bytes: 22228
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,M = I()
C = [[] for _ in range(N+1)]
for i in range(M):
    p,y = I()
    C[p].append([y,i])
ans = ['a']*M
for i in range(1,len(C)):
    c = C[i]
    if c:
        c.sort()
        for j in range(len(c)):
            y,b = c[j]
            ans[b] = str(i).zfill(6)+str(j+1).zfill(6)
for a in ans:
    print(a)

Measured memory_bytes: 41020
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int an=b;
	if(a!=1){
	   for(int i=2;i<=a;i++){
		  an=(b-1)*an;
	   }
    }
	cout<<an<<endl;
	return 0;
}


Measured memory_bytes: 256
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;
	vi dp(W+1); dp[1] = 1;
	char a[1001];
	for(int h=1; h<=H; h++){
		scanf("%s",a);
		for(int w=1; w<=W; w++) dp[w] = a[w-1]=='.'? (dp[w] + dp[w-1]) % MOD: 0;
	}
	printf("%d\n",dp[W]);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <vector>

using namespace std;



int H, W;
string map[101];


void saiki(int h, int w)
{
	
	//cout << "h = " << h << " : w = " << w << endl;
	
	if (map[h][w] == '.')
	{
		cout << w << " " << h << endl;
	} else if (map[h][w] == '1') {
		cout << "LOOP" << endl;
	} else if (map[h][w] == '>') {
		map[h][w] = '1';
		saiki(h, w + 1);
	} else if (map[h][w] == 'v') {
		map[h][w] = '1';
		saiki(h + 1, w);
	} else if (map[h][w] == '<') {
		map[h][w] = '1';
		saiki(h, w - 1);
	} else if (map[h][w] == '^') {
		map[h][w] = '1';
		saiki(h - 1, w);
	}
}


int main()
{
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		
		for (int i=0; i<H; i++)
		{
			cin >> map[i];
		}
		/*
		for (int i=0; i<H; i++)
		{
			cout << map[i] << endl;
		}
		*/
		saiki(0, 0);
	}
	
	return 0;
}

Measured memory_bytes: 1228
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c; cin >>a >> b >> c;
  cout << min(b/a, c)<< endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n,ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	ll z = 0;
	ll ans = max(a - k, z);
	ll ans2 = max(a + b - k, z);
	if (ans > 0) {
		cout << ans << " " << b << endl;
	}
	else {
		cout << ans << " " << ans2 << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n;
    cin >> n;
    vector<vector<pair<int,int> > > gg(n);
    for (int i = 0;i < n;i++) {
        int q;
        cin >> q;
        gg[i].resize(q);
        cin >> gg[i];
        for (auto &x : gg[i]) {
            x.X--;
        }
    }

    vector<int> is_honest(n, 0);

    int ans = 0;

    for (int i = 0;i < (1 << n);i++) {
        for (int j = 0;j < n;j++) {
            if (i&(1 << j)) {
                is_honest[j] = 1;
            }else {
                is_honest[j] = 0;
            }
        }

        bool f = true;

        for (int j = 0;j < n;j++) {
            if (is_honest[j]) {
                for (auto x : gg[j]) {
                    if (x.Y) {
                        if (!is_honest[x.X]) {
                            f = false;
                        }
                    }else {
                        if (is_honest[x.X]) {
                            f = false;
                        }
                    }
                }
            }
        }

        if (f) {
            chkmax(ans, __builtin_popcount(i));
        }
    }

    cout << ans;

    return 0;
}


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

int main(){
  int D, N;
  cin >> D >> N;
  int A=1;

  for (int i = 0; i < D; i++) {
    A*=100;
  }
  if(N<=99) cout << A*N << endl;
  else cout << A*101 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 vector<int>x(N);
 vector<int>y(N);
 for(int i=0;i<N;i++){
   cin>>x[i]>>y[i];
 }
 vector<int>a(N);
 for(int i=0;i<N;i++){
   a[i]=i;
 }
 double d=1;
 for(int i=1;i<=N;i++){
  d*=i;
 }
 double sum=0;
 do{
  for(int i=0;i<N;i++){
    int X=abs(x[a[i+1]]-x[a[i]]);
    int Y=abs(y[a[i+1]]-y[a[i]]);
    if(i<N-1){sum=sum+sqrt(X*X+Y*Y);}
  }
 }while(next_permutation(a.begin(),a.end()));

cout<<fixed<<setprecision(10)<<sum/d<<endl;
 return 0;
}

Measured memory_bytes: 3796
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedMultiSet = tree < T, null_type, less_equal < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int main() {
    fast_io();
    ll n, m;
    cin >> n >> m;
    vector < string > v[n + 5];
    string s;
    for (ll i = 0, x; i < m; i++) {
        cin >> x >> s;
        v[x].eb(s);
    }
    ll ans = 0, pen = 0;
    for (ll i = 1; i <= n; i++) {
        ll cur = 0;
        for (auto s : v[i]) {
            if (s == "WA") {
                cur++;
            } else {
                pen += cur;
                ans++;
                break;
            }
        }
    }
    cout << ans << " " << pen << "\n";
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll N; cin >> N;
  ll d = ll(ceil(log10(N)));

  map<pair<int, int>, ll> table;

  REP(head, 1, 10) {
    REP(tail, 1, 10) {
      ll cnt = 0;

      // 1ケタのとき
      if (head == tail && head <= N) cnt++;

      // 2ケタ以上のとき
      REP(m, 1, d) {
        ll body_max = ll(pow(10, m - 1)) - 1;
        ll A_max = head * ll(pow(10, m)) + tail + body_max * 10;
        ll A_min = head * ll(pow(10, m)) + tail;

        if (A_min > N) break;

        if (A_max > N) {
          body_max = (N - head * ll(pow(10, m)) - tail) / 10;
        }

        cnt += body_max + 1;
      }

      table.emplace(make_pair(head, tail), cnt);

#ifdef DEBUG
      printf("%d ... %d: %lld\n", head, tail, cnt);
#endif
    }
  }

  ll cnt = 0;

  REP(head, 1, 10) {
    REP(tail, 1, 10) {
      ll n_ht = table.at(make_pair(head, tail));
      ll n_th = table.at(make_pair(tail, head));
      cnt += n_ht * n_th;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n;ll ans;
string s[200005];
int son[1000005][27],tag[1000005];
char typ[1000005];
int ex[1000005][27],suf1[1000005],suf2[1000005][27];/*ex 是无用数组*/
int num;
//root is 0
void ins(string s){
    int cur = 0;
    rap(i,0,s.size()){
        if(!son[cur][s[i] - 'a']) {
            son[cur][s[i] - 'a'] = ++num;
            typ[num] = s[i];
            cur = num;
        }
        else cur = son[cur][s[i] - 'a'];
    }
    tag[cur]++;
}
void dfs(int x){
    ex[x][typ[x] - 'a'] ++;//无用语句
    suf1[x] += tag[x];
    rep(i,0,25){
        if(son[x][i]) {
            dfs(son[x][i]);
            suf1[x] += suf1[son[x][i]];
            rep(j,0,25) {ex[x][j] += ex[son[x][i]][j]; suf2[x][j] += suf2[son[x][i]][j];}
        }
    }
    rep(ch,0,25) {
        if(typ[x] == ch + 'a') suf2[x][ch] = suf1[x];
    }
    //cout<<x<<' '<<typ[x]<<' '<<suf2[x][2]<<'\n';
}
int main()
{
    fastio;
    cin>>n;
    rep(i,1,n) {cin>>s[i];reverse(s[i].begin(),s[i].end());}
    rep(i,1,n) ins(s[i]);
    dfs(0);
    rep(i,1,n) {
        //walk
        int nwlen = (int)s[i].size() - 1;
        int cur = 0;
        bool flg = 0;
        rap(j,0,nwlen){
            int to = son[cur][s[i][j] - 'a'];
            if(!to) {flg = 1;break;}
            cur = to;
        }
        if(flg) continue;
        //cout<<i<<' '<<cur<<'\n';
        char lst = s[i][(int)s[i].size() - 1];
        rep(ch,0,25) if(son[cur][ch]) ans += suf2[son[cur][ch]][lst - 'a'];
        //cout<<lst<<' '<<suf2[cur][lst - 'a']<<'\n';
    }
    ans -= n;
    cout<<ans<<'\n';
    return 0;
}

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

int main() {
  ll n, ans = 0;
  cin >> n;
  map<int, int> mp;

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

  for (int k = 0; k < n; k++) cout << ans - (mp[a[k]] - 1) << endl;
}

Measured memory_bytes: 8320
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	Integer[][][] mem;
	char[][] arr;
	int row, col;
	int[] dir_row = new int[]{0, 1};
	int[] dir_col = new int[]{1, 0};
	int inf = (int)1e9;
	private void run_case() {
		row = reader.ni();
		col = reader.ni();

		mem = new Integer[row][col][2];

		arr = new char[row][col];
		for (int i=0; i<row; i++) arr[i] = reader.ns().toCharArray();

		int res = dfs(0, 0, 0);

		out.println(res);

		return;
	}

	private int dfs(int r, int c, int pv) {
		if (r == row-1 && c == col-1) {
			if (arr[r][c] == '#' && pv == 0) return 1;
			else return 0;
		}
		if (mem[r][c][pv] != null) return mem[r][c][pv];
		int res = inf;
		int cost = 0;
		if (arr[r][c] == '#' && pv == 0) cost = 1;
		for (int i=0; i<dir_row.length; i++) {
			int tr = r + dir_row[i];
			int tc = c + dir_col[i];
			if (tr >= row || tc >= col) continue;
			res = Math.min(res, cost + dfs(tr, tc, arr[r][c] == '#' ? 1 : 0));
		}
		return mem[r][c][pv] = res;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


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

const int maxn=2*1e5+6;
int n, a[maxn], b[maxn];
int l=-1, r=-2, c;

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=0;i<n;i++) cin >> b[i];
	reverse(b,b+n);
	for (int i=0;i<n;i++){
		if (a[i]==b[i]){
			if (l==-1) l=i;
			r=i;
			c=a[i];
		}
	}
	int idx=0;
	for (int i=l;i<=r;i++){
		while (idx<n && (b[idx]==c || a[idx]==c)) idx++;
		if (idx==n) break;
		swap(b[i],b[idx]);
		idx++;
	}
	for (int i=0;i<n;i++){
		if (a[i]==b[i]){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i=0;i<n;i++) cout << b[i] << " ";
	cout << "\n";
}

Measured memory_bytes: 5200
# _*_ coding: utf-8 _*_

a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a < b:
    ab_min = a
else:
    ab_min = b
if c < d:
    cd_min = c
else:
    cd_min = d

print(ab_min + cd_min)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200001], s[200001];
map<int, int> mp;
signed main(){
	int n, ans = 0;
	scanf("%lld", &n);
	rrep(i,n)scanf("%lld", &a[i]);
	rrep(i,n)s[i] = s[i-1]+a[i];
	drep(i,n,0)mp[s[i]] = i;
	rrep(i,n){
		chmax(ans, i-mp[s[i]]);
	}
	printf("%lld\n", ans);
	return 0;
}








Measured memory_bytes: 18800
#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
int main()
{
   ios;
   string a, b;
   cin >> a >> b;
   sort(all(a));
   sort(All(b));
   cout << (a < b ? "Yes" : "No") << '\n';
   return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

template <typename T>
struct segtree{
	//元データx[i]はv[n+i]
	//v[i]の親はv[i/2],子はv[i*2]とv[i*2+1]
	vector<T> v;
	int n;
	
	const T init_value = {Inf,-Inf};
	
	segtree(vector<T> &x){
		n=1;
		while(true){
			if(n>=x.size())break;
			n*=2;
		}
		v.resize(2*n,init_value);
		
		for(int i=0;i<x.size();i++){
			v[n+i]=x[i];
		}
		for(int i=n-1;i>=0;i--){
			v[i]=func(v[i*2],v[i*2+1]);
		}
	}

	void update(int x,T val){
		x+=n;
		v[x]=val;
		while(true){
			x=(x)/2;
			v[x]=func(v[x*2],v[x*2+1]);
			if(x<=0)break;
		}
	}
	
	//区間[l,r)におけるクエリ処理
	T query(int l,int r){
		T res = init_value;
		if(l>=r)return res;
		l+=n;r+=n;
		while(true){
			if(l%2==1){
				res=func(v[l],res);
				l++;
			}
			if(r%2==1){
				res=func(v[r-1],res);
				r--;
			}
			if(l>=r)break;
			l/=2;r/=2;
		}
		return res;
	}
	T func(T a,T b){
		return {min(a.first,b.first),max(a.second,b.second)};
	}
	
	void show(){
		int n = 1;
		for(int i=1;i<v.size();i++){
			for(int j=0;j<n;j++){
				if(j!=0)cout<<' ';
				cout<<v[i+j];
			}
			cout<<endl;
			i+=n-1;
			n*=2;
		}
	}
	
};

int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<pair<int,int>> P(N);
	for(int i=0;i<N;i++){
		cin>>P[i].first;
		P[i].second = P[i].first;
	}
	
	segtree<pair<int,int>> seg(P);
	
	vector<pair<int,int>> range(0);
	
	for(int i=0;i<N;i++){
		int ind = i;
		while(ind!=N-1&&P[ind+1]>P[ind]){
			ind++;
			
		}
		range.push_back({i,ind});
		i=ind;
	}
	/*
	for(int i=0;i<range.size();i++){
		cout<<range[i].first<<','<<range[i].second<<endl;
	}*/
	
	int T = 0,F = 0;
	
	for(int i=0;i<N;i++){
		int fin = i+K-1;
		if(fin>=N)break;
		
		auto it = lower_bound(range.begin(),range.end(),make_pair(i,0));
		pair<int,int> PP = *it;
		//if(it!=range.begin()){
			//PP = *(it--);
			if(PP.second>=fin && PP.first<=i){
				F=1;
				continue;
			}
		//}
		
		if(i==0){
			T++;
			continue;
		}
		
		PP = seg.query(i,fin);
		
		if(PP.first<=P[i-1].first||PP.second>=P[fin].first){
			T++;
		}
	}
	//cout<<T<<','<<F<<endl;
	
	cout<<T+F<<endl;
		
		
		
	
	
	return 0;
}



Measured memory_bytes: 7032
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

vector<long long int> W;
vector<long long int> V;
int N;

int main() {
    long long int maxW;
    cin >> N >> maxW;
    
    W.resize(N+1);
    V.resize(N+1);
    for(int n=1; n<N+1; n++) {
        cin >> W[n] >> V[n];
    }

    long long int dpnum=N;
    long long int cycle=dpnum*3+1;
    dpnum = cycle*dpnum;
    vector<vector<long long int> > dp(2, vector<long long int>(dpnum+1, -1));
    dp[0][0]=0;
    
    for(int n=0; n<N; n++) {
        for(int w=0; w<dpnum+1; w++) {
            if(n%2==0) {
                if(dp[0][w]!=-1) {
                    dp[1][w] = max(dp[1][w], dp[0][w]);
                    
                    if(w==0) {
                        dp[1][W[n+1]-W[1]+1] = max(dp[1][W[n+1]-W[1]], dp[0][w]+V[n+1]);
                    } else {
                        dp[1][w+cycle+W[n+1]-W[1]] = max(dp[1][w+cycle+W[n+1]-W[1]], dp[0][w]+V[n+1]);
                    }
                }
            } else {
                if(dp[1][w]!=-1) {
                    dp[0][w] = max(dp[0][w], dp[1][w]);
                    
                    if(w==0) {
                        dp[0][W[n+1]-W[1]+1] = max(dp[0][W[n+1]-W[1]], dp[1][w]+V[n+1]);
                    } else {
                        dp[0][w+cycle+W[n+1]-W[1]] = max(dp[0][w+cycle+W[n+1]-W[1]], dp[1][w]+V[n+1]);
                    }
                }
            }
        }
    }
    
    // cout << endl;
    long long int ans=0;
    for(int w=1; w<dpnum+1; w++) {
        // cout << ((w-1)/cycle+1)*W[1]+(w-1)%cycle << endl;
        if(((w-1)/cycle+1)*W[1]+(w-1)%cycle<=maxW) {
            if((N-1)%2==0) {
                ans = max(ans, dp[1][w]);
            } else {
                ans = max(ans, dp[0][w]);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
    
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

    std::map<ll, ll> map;
    map[0] = 1;
    ll ans = 0;
    ll sum = 0;
    REP(i, N)
    {
        ll a;
        cin >> a;
        a %= M;
        sum = (sum + a) % M;
        ans += map[sum]++;
    }

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

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    vector<vector<int>> x(N, vector<int>(D));
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            float sum = 0;
            for(int k=0; k<D; k++){
                sum += pow(x[i][k]-x[j][k],2);
            }
            sum = sqrt(sum);
            int intSum = sum;
            if(intSum == sum){
                cnt++;
            }
        }
    }

    cout << cnt <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    vector<int> alpha(26, 0);
    for (int i = 0; i < s.size(); i++) alpha[s[i]-'a']++;

    bool is_dup = false;
    for (int i = 0; i < 26; i++) {
        if (alpha[i] > 1) {
            is_dup = true;
            break;
        }
    }

    cout << (is_dup ? "no" : "yes") << endl;
}

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

const int maxn=105;
int n;
int a[maxn];

void solve()
{
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans+=a[i+1]-a[i];
    }
    printf("%d\n",ans);
}

int main()
{
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        solve();
    }
}


Measured memory_bytes: 128
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = InputNumList();
            var h = nums[0];
            var a = nums[1];

            int cnt = 0;
            while (true)
            {
                h = h - a;
                cnt++;
                if (h <= 0) break;
            }

            WriteLine(cnt);

        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
P = tuple(map(float,input().split()))
dp = [[0]*(n+1) for i in range(n+1)]
#dp[i][j] i枚投げてj枚表の確率 
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(i+1):
        if j == 0:
            dp[i][j] = dp[i-1][j]*(1-P[i-1])
        else:
            dp[i][j] = dp[i-1][j-1]*P[i-1] + dp[i-1][j]*(1-P[i-1])
res = 0
for i in range(n//2 + 1, n+1):
    res += dp[n][i]
print(res)

Measured memory_bytes: 262280
#include<ios>
int parseN(int a){
    int b = 0;
    while( a){
        b += (a % 10);
        a /= 10;
    }
    return b;
}
int main(){
    int iN,iAns;
    scanf("%d",&iN);
    iAns = iN;
    for( int i=1;i <= iN/2;i++){
        int iD ;
        iD = parseN(i) + parseN(iN-i);
        if (iD < iAns){
            iAns = iD;
        }
    }
    printf("%d\n",iAns);
    return 0;
}


Measured memory_bytes: 128
X, Y = [int(v) for v in input().split()]

ans = "No"
for c in range(X + 1):
    t = X - c
    if 2 * c + 4 * t == Y:
        ans = "Yes"
        break
# if ans == "No":
#     for t in range(X + 1):
#         c = X - t
#         if 2 * c + 3 * t == Y:
#             ans = "Yes"
#             break

print(ans)

Measured memory_bytes: 9064
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int x=0;
	string n;
	cin >> n;
	rep(i, 4) {
		if (n[i] == '2')
			x++;
	}
	cout << x<<endl;
}

Measured memory_bytes: 256
X = int(input())
# m = 0
# n = -1
# while X >= m**5-n**5:
#     m += 1
#     n += 1
# hazimete = 0
# while X >= hazimete ** 5:
#     hazimete += 1

for i in range(-500, 500):
    for j in range(-500, 500):
        if X == i**5 - j**5:
            print(i, j)
            exit()


Measured memory_bytes: 64624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  char c;
  while(1){
    scanf("%d %c %d",&a,&c,&b);
    if(c=='?') break;
    else if(c=='+') printf("%d\n",a+b);
    else if(c=='-') printf("%d\n",a-b);
    else if(c=='*') printf("%d\n",a*b);
    else if(c=='/') printf("%d\n",a/b);
  }
  return 0;
}



Measured memory_bytes: 3164
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();
    int k = sc.nextInt();

    os.println(n - k + 1);
  }
}

Measured memory_bytes: 23636