akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, 0, H) cin >> S[i];

    vector<vector<int>> sum(H + 1, vector<int>(W + 1, 0));
    REP(i, 0, H) {
        REP(j, 0, W) {
            sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + (S[i][j] == '1');
        }
    }

    int ans = 1 << 30;
    for (int bit = 0; bit < (1 << (H - 1)); bit++) {
        vector<int> partition;
        partition.push_back(0);
        REP(i, 0, H - 1) if (bit & (1 << i)) partition.push_back(i + 1);
        partition.push_back(H);

        int prev = 0, cnt = 0; bool possible = true;
        REP(i, 1, W + 1) {
            bool ok = true;
            REP(j, 1, partition.size()) {
                int choco = sum[partition[j]][i] - sum[partition[j - 1]][i] - sum[partition[j]][prev] + sum[partition[j - 1]][prev];
                if (choco > K) {
                    ok = false;
                    break;
                }
            }
            if (!ok) {
                if (prev == i - 1) {
                    possible = false;
                    break;
                }
                prev = i - 1;
                cnt++;
            }
        }
        if (possible) ans = min(ans, cnt + (int)partition.size() - 2);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
const int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
char c[8][9];
int place(int x, int y, char t, bool m) {
	int ret = 0;
	for (int i = 0; i < 8; i++) {
		int px = x + dx[i], py = y + dy[i];
		bool flag = false;
		while (0 <= px && px < 8 && 0 <= py && py < 8) {
			if (c[py][px] == '.') break;
			if (c[py][px] == t) {
				flag = true; break;
			}
			px += dx[i];
			py += dy[i];
		}
		if (flag) {
			ret += max(abs(x - px) - 1, abs(y - py) - 1);
			if (m) {
				int qx = x, qy = y;
				while (qx != px || qy != py) {
					c[qy][qx] = t;
					qx += dx[i];
					qy += dy[i];
				}
			}
		}
	}
	return ret;
}
int main() {
	for (int i = 0; i < 8; i++) scanf("%s", &c[i]);
	int t = 0, v = 0;
	while (true) {
		int x = -1, y = -1, r = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '.') {
					int p = place(j, i, t % 2 == 0 ? 'o' : 'x', false);
					if (t % 2 == 1) {
						if (p >= r && p >= 1) {
							x = j; y = i; r = p;
						}
					}
					else {
						if (p > r && p >= 1) {
							x = j; y = i; r = p;
						}
					}
				}
			}
		}
		if (r == 0) {
			if (v == 0) {
				v = 1; t++; continue;
			}
			else {
				break;
			}
		}
		else {
			place(x, y, t++ % 2 == 0 ? 'o' : 'x', true); v = 0;
		}
	}
	for (int i = 0; i < 8; i++) printf("%s\n", c[i]);
	return 0;
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
// #define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////
void dfs(int i,int vis[],vector<int> gr[])
{
	if(vis[i]==1)
		return ;
	vis[i]=1;
	for(auto r:gr[i])
	{
		dfs(r,vis,gr);
	}
}
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	vector<int> gr[n+1];
	for(int i=0;i<m;++i)
	{
		int x,y,w;
		cin>>x>>y>>w;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	int ans=0;
	int vis[n+1]={};
	for(int i=1;i<=n;++i)
	{
		if(vis[i]==0)
		{
			++ans;
			dfs(i,vis,gr);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n,m,p,Q;
int head[N],col[N],V[N],D[N],C[N];
bool vis[N][11];
struct Edge {
  int to,last;
  Edge () {}
  Edge (int a,int b) :to(a),last(b) {}
}edge[N<<1];
void ADD(int a,int b) {
  edge[++p]=Edge(b,head[a]); head[a]=p;
  edge[++p]=Edge(a,head[b]); head[b]=p;
}
void DFS(int u,int d,int c) {
  if(!col[u]) col[u]=c;
  if(vis[u][d]||!d) return;
  int t=d;
  while(t&&!vis[u][t]) vis[u][t--]=true;
  for(int i=head[u];i;i=edge[i].last) {
    int v=edge[i].to;
    DFS(v,d-1,c);
  }
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=m;++i) {
    int u,v; read(u,v);
    ADD(u,v);
  }
  read(Q);
  for(int i=1;i<=Q;++i) read(V[i],D[i],C[i]);
  for(int i=Q;~i;--i) DFS(V[i],D[i],C[i]);
  for(int i=1;i<=n;++i) printf("%d\n",col[i]);
  return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

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

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        int cnt = 0;

        for (; i < N - 1 && H[i + 1] <= H[i]; i++)
            cnt++;

        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long 
vector<int> num;
ll DP[10004][103][2][2],d;

ll call(int pos, int sum, int small, int startHere)
{
    if(pos==(int)num.size())
    {
        return sum%d==0;
    }

    if(~DP[pos][sum][small][startHere]) return DP[pos][sum][small][startHere];

    ll res = 0;
    int LMT = small? 9 : num[pos];

    if(startHere)
    {
        res+=call(pos+1, 0, 1, 1);
    }
    for(int dgt=startHere; dgt<=LMT; dgt++)
    {
        res=(res+call(pos+1, (sum+dgt)%d, small|(dgt<num[pos]), 0)%MOD)%MOD;
    }

    return DP[pos][sum][small][startHere] = res;
}
ll solve(string& s)
{
    for(int i=0; i<s.size(); i++)
        num.push_back(s[i]-'0');
    memset(DP, -1, sizeof(DP));
    return (call(0, 0, 0, 1)-1+MOD)%MOD;
}

int main ()
{
    string s;
    cin>>s>>d;
    cout<<solve(s)<<endl;
    return 0;
}


Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n;
    cin >> n;
    ll sum=0;
    ll mx=0;
    rep(i,n){
        ll a;
        cin >> a;
        mx = max(mx,a);
        sum += a;
    }
    ll ans = sum - mx/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();
	int ans = 0;
	if(13<=a) {
		ans = b;
	}
	else if(6<=a&&a<=12) {
		ans = b/2;
	}
	else {ans =0;
	}
	System.out.println(ans);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename H, typename ...T> void qqbx(const char *s, const H &h, T&&...a) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr<<*s;
    std::cerr<<" = "<<h<<(sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, a...);
}
#else
#define debug(...) ((void)0)
#endif // local
#define pb emplace_back
#define all(v) begin(v),end(v)

using namespace std;
const int MOD = 1000000007, N = 2025;
int dp[N][N], pre[N];
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    dp[0][0] = 1;
    int ans = 0;
    for(int i = 1; i < N; i++) {
        pre[0] = dp[i-1][0];
        for(int w = 1; w <= n; w++) pre[w] = (pre[w-1] + dp[i-1][w]) % MOD;
        for(int w = 3; w <= n; w++) dp[i][w] = pre[w-3];
        ans = (ans + dp[i][n]) % MOD;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 19640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  long double L;
  cin >> L;

  long double l_p3 = L / 3;
  long double ans = l_p3 * l_p3 * l_p3;

  printf("%Lf\n", ans);

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


Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    cout << ((360*n)/gcd(360, n))/n << "\n";
}

int main() {
    io;
    int t = 1;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3612
n, m = map(int, input().split())


a = [[],[],[]]
for i in range(m):
    s, c = map(int, input().split())
    if not c in a[s-1]:
        a[s-1].append(c)
    
ans = 0
if m==0:
    if n==3:
        print(100)
    elif n==2:
        print(10)
    else :
        print(0)
elif (len(a[0]) > 1) or (len(a[1]) > 1) or (len(a[2]) > 1):
    print(-1)
else:
    if (n==3 or n==2) and len(a[0]) == 0:
        a[0].append(1)
    if (n==3 or n==2) and a[0][0] == 0:
        print(-1)
    else:
        for i in range(n):
            if len(a[i]) == 1:
                ans += a[i][0] * (10**(n-1-i))
        print(ans)








Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long
struct IoSetup {
	IoSetup() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
		cerr << fixed << setprecision(10);
	}
}IoSetup;
typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}



signed main() {
   
   string s;

	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;

  return 0;
}


Measured memory_bytes: 3584
def solve(r, s, p, t) -> int:
    R, S, P = 0, 1, 2

    n = len(t)
    dp = [[0] * 3 for _ in range(n + 1)]

    for i, c in enumerate(t, 1):
        dp[i][R] = max(dp[i - 1][S], dp[i - 1][P]) + (r if c == 's' else 0)
        dp[i][S] = max(dp[i - 1][P], dp[i - 1][R]) + (s if c == 'p' else 0)
        dp[i][P] = max(dp[i - 1][R], dp[i - 1][S]) + (p if c == 'r' else 0)

    return max(dp[n])


def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()

    ret = 0
    for i in range(k):
        ti = t[i::k]
        ret += solve(r, s, p, ti)

    print(ret)


if __name__ == '__main__':
    main()

# mod Kで小問題に分割して、
# 独立なk個の問題を解く


Measured memory_bytes: 22604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N ;
  vector<long> vec(5);
  for(int i=0; i<5; i++) {
    cin >> vec.at(i);
    }
  sort(vec.begin(), vec.end());
  if(N<=vec.at(0)) cout << 5 << endl;
  else if (N%vec.at(0)==0) cout << (N/vec.at(0))+4 << endl;
  else cout << (N/vec.at(0))+5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


int main()
{
	int n;
	cin >> n;
	multimap<long long, long long> memo;
	for(int i=0;i<n;i++){
		long long a,b;
		cin >> a >> b;
		memo.insert(make_pair(b, a));
	}

	long long t = 0;
	bool ans = true;
	for(multimap<long long, long long>::iterator it=memo.begin(); it!=memo.end(); it++){
		t += it->second;
		if(it->first < t){
			ans = false;
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
using namespace std;


int main(){
  int n; cin >> n;
  string s; cin >> s;
  int c = 0;
  for (int i=0;i<1000;i++){
    string p;
    int flag = 0;
    if (i < 10) p = "00" + to_string(i);
    else if (i < 100) p = "0" + to_string(i);
    else p = to_string(i);
    for (int j=0;j<s.size();j++){
        if (s[j] == p[0] && flag == 0) flag++;
        else if (s[j] == p[1] && flag == 1) flag++;
        else if (s[j] == p[2] && flag == 2) {
            c++;
            break;
        }
    }
  }
    cout << c;
}



Measured memory_bytes: 384
n = int(input())
temp, targettemp = map(int, input().split())
loc=list(map(int, input().split()))
anstemp = 10000000

for i in range(len(loc)):
    loctemp = temp - (loc[i]*0.006)
    loctemp = abs(targettemp-loctemp)

    if loctemp < anstemp:
        anstemp = loctemp
        ans = i+1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>
 
#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int main()
{
	int n;
	ll ans = 0;
	cin >> n;
	
	REP(i,n)
	{
		int a,b;
		cin >> a >> b;
		ans += b - a + 1;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[]) {

	string dummy,s;

	cin >> dummy >> s >> dummy;

	cout << "A" << s[0] << "C" << endl;

	return 0;

}

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

struct node
{
    int a,b;
}quest[100010];

bool cmp(node aa,node bb)
{
    return aa.b<bb.b;
}
int main()
{
    int n,m;
    cin>> n >> m;
    for(int i=0;i<m;i++)
        cin>>quest[i].a>>quest[i].b;
    sort(quest,quest+m,cmp);
    int r=quest[0].b;
    int cnt=1;
    for(int i=0;i<m;i++)
    {
        if(quest[i].a>=r)
        {
            cnt++;
            r=quest[i].b;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
def solver(d,num,A):
    A.append(num)
    if d == 10:
        return
    
    for x in range(-1,2):
        add = num%10 + x
        if add >=0 and add <=9:
            solver(d+1,(num*10+add),A)
A =[]
K = int(input())
if K <=9:
    print(K)
else:
    for t in range(1,10):
        solver(1,t,A)
    A.sort()
    print(A[K-1])


Measured memory_bytes: 61648
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;
int d,n,m,p;
int amida(int x, vs &A){
	for(int i=0;i<d;i++)
		if(A[i][x]-'0')x++;
		else if(A[i][x-1]-'0')x--;
	return x;
}
int f(vs &A){
	for(int i=0;i<d;i++)
		for(int j=1;j<n;j++)
			if (A[i][j-1]=='0'&&A[i][j]=='0'&&A[i][j+1]=='0'){
				A[i][j]='1';
				if (amida(m,A)==p){
					cout<<i+1<<" "<<j<<endl;
					return 0;
				}
				A[i][j]='0';
			}
	cout<<1<<endl;
	return 0;
}
int main(){
	while (1){
		string s;
		cin>>n;
		if (n==0)break;
		vs A;
		cin>>m>>p>>d;
		getline(cin,s);
		for(int i=0;i<d;i++){
			getline(cin,s);
			A.push_back('0'+s+'0');
		}
		if (amida(m,A)==p)cout<<0<<endl;
		else f(A);
		A.clear();
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
typedef long double ld;
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int MAX = 20;
    vector<vector<long>> c(MAX, vector<long>(MAX));
    for (int i = 0; i < n; i++) {
        ld x;
        cin >> x;
        long xx = (long)(x * 1e9 + .1);
        int p2 = 0;
        while (xx % 2 == 0) {
            xx /= 2;
            p2++;
            if (p2 == MAX - 1) break;
        }
        int p5 = 0;
        while (xx % 5 == 0) {
            xx /= 5;
            p5++;
            if (p5 == MAX - 1) break;
        }
        c[p2][p5]++;
    }
    long res = 0;
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            for (int ii = 0; ii < MAX; ii++) {
                for (int jj = 0; jj < MAX; jj++) {
                    if (i + ii >= 18 && j + jj >= 18) {
                        if (i == ii && j == jj) {
                            res += c[i][j] * (c[i][j] - 1) / 2;
                        } if (ii > i || ii == i && jj > j) {
                            res += c[i][j] * c[ii][jj];
                        }
                    }
                }
            }
        }
    }
    cout << res << "\n";

    return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int> > ans(h, vector<int>(w));
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];

    int cur = 1;
    for(int i = 0; i < h; i++){
        if(i % 2){
            for(int j = 0; j < w; j++){
                if(a[cur] == 0) cur++;
                ans[i][j] = cur;
                a[cur]--;
            }
        }else{
            for(int j = w-1; j >= 0; j--){
                if(a[cur] == 0) cur++;
                ans[i][j] = cur;
                a[cur]--;
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << ans[i][j];
            if(j < w-1) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main ()
{
	int a,b,c,o;
	scanf("%i%i%i",&a,&b,&c);
	if (a>=b+c)
	{
		printf("0");
	}
	else
	{
		o=c-(a-b);
		printf("%i",o);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << -1 << endl;
  exit(0);
}
void dfs (int crr, int dpt, vector<vector<int>>& grh, long long& cnt) {
  cnt += dpt;
  for (int nxt : grh[crr]) {
    dfs(nxt, dpt + 1, grh, cnt);
  }
}
int main() {
  int n;
  cin >> n;
  vector<long long> d(n);
  map<long long, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    mp[d[i]] = i;
  }
  sort(d.begin(), d.end());
  vector<long long> sz(n, 1);
  vector<vector<int>> grh(n);
  vector<pair<int, int>> edg;
  for (auto it = d.rbegin(); next(it) != d.rend(); it++) {
    auto i = mp.rbegin()->second;
    long long wnt = *it - n + 2 * sz[i];
    if (mp.find(wnt) == mp.end()) err();
    auto p = mp[wnt];
    sz[p] += sz[i];
    grh[p].push_back(i);
    edg.emplace_back(i, p);
    mp.erase(--mp.end());
  }
  int rt = mp.begin()->second;
  long long cnt = 0;
  dfs(rt, 0, grh, cnt);
  if (d[0] != cnt) err();
  for (auto const& e : edg) {
    cout << e.first + 1 << ' ' << e.second + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 14840
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());


        String[] D  = new String[K];
        for(int i=0;i<K;i++){
            D[i] =  sc.next();
        }
        int ans=0;
        int f = 0;
        for(int i = N  ; i < 100000 ; i++ ){
            String s = String.valueOf(i);
           //  System.out.println(s);
            for(int k=0; k<K; k++){
            
            
              if( s.contains( D[k]) )
                f++;
            }
            ans = i;
            if(f==0)break;
            f=0;
        }


        System.out.println(ans);
    }

}

Measured memory_bytes: 14804
#include <stdio.h>

#include <string.h>

int main() {

    char s[4];

    gets(s);

  

    if(strcmp(s,"RRS") == 0 || strcmp(s,"SRR") == 0)

        printf("2");

    else if(strcmp(s, "RRR") == 0)

        printf("3");

    else if(strcmp(s, "SSS") == 0)

        printf("0");

    else

        printf("1");

    

    return 0;

}

Measured memory_bytes: 1528
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n, m;
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    int res = 0, tmp;
    vector<int> points, points2;
    for(int i = 0;i < n;i++){
      scanf("%d", &tmp);
      if(tmp < m)points.push_back(tmp);
    }
    vector<int>::iterator it1,it2;
    for(it1 = points.begin();it1 != points.end();it1++){
      points2.push_back(*it1);
      for(it2 = points.begin();it2 != points.end();it2++){
	if(*it1 + *it2 <= m)points2.push_back(*it1 + *it2);
      }
    }
    sort(points2.begin(),points2.end());
    for(it1 = points2.begin();it1 != points2.end();it1++){
      it2 = upper_bound(points2.begin(), points2.end(), m - *it1);
      res = max(res, *it1);
      if(it2 == points2.begin())continue;
      it2--;
      res = max(res, *it1 + *it2);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 100100;
int a[N], b[N], c[N];
ll db[N], sdb[N], dc[N];

int main() {
	int n;
	scanf("%d", &n);
	FOR(i,n) scanf("%d", &a[i]);
	FOR(i,n) scanf("%d", &b[i]);
	FOR(i,n) scanf("%d", &c[i]);
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	int j = 0;
	FOR(i,n) {
		while (j < n && a[j] < b[i]) j++;
		db[i] = j;
		sdb[i] = db[i] + (i ? sdb[i-1] : 0);
	}
	j = 0;
	ll res = 0;
	FOR(i,n) {
		while (j < n && b[j] < c[i]) j++;
		dc[i] = j ? sdb[j-1] : 0;
		res += dc[i];
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include <list>
#include <unordered_map>
using namespace std;

class graph {
public:
	int v;
	int e;
	unordered_map<int, list<int> > gp;
	int dp[100005] = {0};

	graph(int n, int m) {
		v = n;
		e = m;
	}

	void addEdge(int x, int y) {
		gp[x].push_back(y);
	}

	int pathLength(int x, int ans) {
		ans = 0;
		for (int y : gp[x]) {
			if (dp[y] == 0) {
				dp[y] += pathLength(y, 0);
			}
			dp[x] = max(dp[x], dp[y] + 1);
		}
		return ans;
	}
	int maxPath() {

		for (auto p : gp) {
			pathLength(p.first, 0);
		}
		int ans = 0;
		for (int i = 0; i <= v; i++) {
			// cout << i << " --> " << dp[i] << endl;
			ans = max(ans, dp[i]);
		}
		return ans;
	}

};

int main() {
	int n, m;
	cin >> n >> m;
	graph g(n, m);
	while (m--) {
		int x, y;
		cin >> x >> y;
		g.addEdge(x, y);
	}
	cout << g.maxPath() << endl;
}

Measured memory_bytes: 16824
n,m,c=map(int,input().split())
*b,=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
cnt=0
for j in range(n):
    sum=0
    for k in range(m):
        sum+=a[j][k]*b[k]
    if sum>-c:
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }
    ll ans = 0, d;
    rep(i, 10000) {
        double theta = M_PI * 2 * i / 10000.0;
        ll X = 0, Y = 0;
        rep(j, N) {
            if (cos(theta) * x[j] + sin(theta) * y[j] >= 0) {
                X += x[j];
                Y += y[j];
            }
        }
        //cout << X << " " << Y << endl;
        d = X * X + Y * Y;
        ans = max(ans, d);
    }
    cout << setprecision(20) << sqrt(1.0 * ans) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  set<string> s;
  REP(c, 'a', 'z' + 1) {
    REP(i, 0, S.length()) {
      if (S[i] == c) {
        REP(j, i, min((int)i + K, (int)S.length())) {
          string sub = S.substr(i, j - i + 1);
          s.insert(sub);
        }
      }
    }
    if (s.size() >= K) break;
  }

  int i = 1;
  for (auto v : s) {
    if (i == K) {
      cout << v << endl;
      break;
    }
    ++i;
  }
}

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

int main()
{

//
//# ifndef ONLINE_JUDGE
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
//#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
//  cin >> t;
  while (t--) {
    int d,t,s;
    cin >> d >> t >> s;
    if(double(1.0*d/s)<=t){
        cout << "Yes"<< endl;
    }
    else cout <<  "No"<< endl;
    }
}






Measured memory_bytes: 3632
from collections import deque

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

def bfs(s):
    dist = [-1] * (N + 1)
    dist[s] = 0
    Q = deque([s])
    while Q:
        v = Q.popleft()
        d = dist[v] + 1
        for u in E[v]:
            if dist[u] >= 0:
                continue
            dist[u] = d
            Q.append(u)

    ma = max(dist)
    return dist.index(ma), ma

i, _ = bfs(1)
_, L = bfs(i)

if L % 3 != 1:
    print("First")
else:
    print("Second")

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

int num(char a) {
    return (int)a - 48;
}

int pow(int a, int n) {
    if ( n==0 ) {
        return 1;
    } else {
        return a* pow(a, n-1);
    }
}

int main() {
    string str;
    cin >> str;
    long long int res = 0;
    for (int n=0; n<str.length(); n++) {
        if ( str.length() > 4 ) {
            long long int tmp = pow(2, str.length()-4);
            tmp = tmp * (9*pow(5, n) - 1);
            tmp = tmp * num(str[str.length() - n - 1]);
            res += tmp;
        } else {
            res += pow(2, str.length()) * (9*pow(5, n) - 1) / 16 * num(str[str.length() - n - 1]);
        }
    }
    cout << res << endl;
}

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

int main() {
	cin>>a>>b;
	cout<<"100 100\n";
	char graph[104][104];
	for(int i = 1;i<=100;i++)
		for(int j = 1;j<=100;j++)
			graph[i][j] = i<=50 ? '#' : '.';
	a--;
	b--;
	for(int i = 2;i<50;i += 2)
		for(int j = 2;j<=100; j+= 2)
			if(a){
			graph[i][j] = '.';
			a--;
			}
	for(int i = 52;i<100;i += 2)
		for(int j = 2;j<=100; j+= 2)
			if(b){
			graph[i][j] = '#';
			b--;
			}
	for(int i = 1;i<=100;i++){
		for(int j = 1; j<=100;j++)
			cout<<graph[i][j];
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  n=lines[0];s=lines[1];
  d=0;t=0;
  for(i=0;i<n;i++){
      if(s.charAt(i)=="(")d++
      else d--;
      if(d<0){
          d++;t++;
      }
  }
  console.log("(".repeat(t)+s+")".repeat(d));
});

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 1), b(n);
  for (auto& e : a) cin >> e;
  for (auto& e : b) cin >> e;
  b.push_back(0);
  ll r = 0;
  for (ll i = 0, t = 0; i < n + 1; i++) {
    ll m = min(t + b[i], a[i]);
    r += m;
    t = min(t + b[i] - m, b[i]);
  }
  cout << r << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5+7;
ll f[N];
deque<int> ans;
map<ll, ll> c[2];
int main()
{
    ll n;
    f[0] = 1;
    scanf("%lld", &n);
    for(int i = 1; i <= 32; i++)
    {
        f[i] = f[i-1]*-2;
    }
    for(int i = 0; i < (1<<16); i++)
    {
        ll s1 = 0, s2 = 0;
        for(int j = 0; j < 16; j++)
        {
            if(i&(1<<j))
            {
                s1 += f[j];
                s2 += f[j+16];
            }
        }
        c[0][s1] = i+1;
        c[1][s2] = i+1;
    }
    int res = 0;
    for(map<ll, ll>::iterator it = c[0].begin(); it != c[0].end(); it++)
    {
        ll a = it->second-1;
        if(c[1][n-it->first])
        {
            ll b = c[1][n-it->first]-1;
            for(int i = 15; i >= 0; i--)
            {
                if(a&(1<<i))
                {
                    res |= (1<<i);
                }
                if(b&(1<<i))
                {
                    res |= (1<<i+16);
                }
            }
            break;
        }
    }
    for(int i = 0; i <= 31; i++)
    {
        if(res&(1<<i))
        {
            ans.push_front(1);
        }
        else
        {
            ans.push_front(0);
        }
    }
    while(ans.size()>1&&ans.front()==0)
    {
        ans.pop_front();
    }
    /*ll cnt = 0, cur = 1;
    while(!ans.empty())
    {
        if(ans.back()==1)
        {
            cnt += cur;
        }
        ans.pop_back();
        cur *= -2;
    }
    printf("%lld\n", cnt);*/
    while(!ans.empty())
    {
        printf("%d", ans.front());
        ans.pop_front();
    }
    puts("");
    return 0;
}


Measured memory_bytes: 12416
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q

ans = []

Adic = {}
sum = 0
for n in range(N):
	sum += A[n]
	if not A[n] in Adic:
		Adic[A[n]] = 1
	else:
		Adic[A[n]] +=1

for i in range(Q):
	B,C = map(int,input().split())
	if B in Adic:
		sum = sum - B * Adic[B] + C * Adic[B]
		
		if C in Adic :
			Adic[C] += Adic[B]
		else:
			Adic[C] = Adic[B]
		Adic.pop(B)

	ans.append(sum)

for a in ans:
	print(a)

Measured memory_bytes: 21432
using System;

class _0054 {
    public static void Main() {
        string str;
        double[] ns;
        int pp, sum;
        while((str = Console.ReadLine()) != null) {
            ns = Array.ConvertAll(str.Split(), s => double.Parse(s));
            str = (ns[0] / ns[1]).ToString();
            pp = str.IndexOf('.');
            if (pp != -1) {
                str = str.Substring(pp + 1);
                sum = 0;
                for (int i = 0; i < str.Length && i < ns[2]; i++)
                    sum += str[i] - '0';
                Console.WriteLine(sum);
            } else
                Console.WriteLine(0);
        }
    }
}

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

bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    int a[100005];
    int b[100005];
    int c[100005];
    int ans[100005];
    memset(ans, 0, sizeof(ans));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i]-1;
        c[i]=a[i]+1;
    }
    int sum =0;

    for(int i =0 ;i<n; i++)
    {
        ans[a[i]]++ ;
        ans[b[i]]++ ;
        ans[c[i]]++ ;
    }
    sort(ans,ans+100005,cmp);
    printf("%d",ans[0]);
    return 0;
}


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

int main(void){

  int n;
  int s[1000];
  int max,min,sum,ave;

  while(1){

    max=0;
    min=1000;
    sum=0;
    ave=0;

    cin >> n;

    if( n == 0 ) break;

    for( int i = 0 ; i < n ; i++ ){

      cin >> s[i];

    }

    for( int i = 0 ; i < n ; i++ ){

      if( max < s[i] ) max = s[i];

      if( min > s[i] ) min = s[i];

      sum+= s[i];

    }

    sum = sum - max - min;
    ave = sum / (n-2);

    cout << ave << endl;

  }

  return 0;

}

Measured memory_bytes: 1164
#include<cstdio>
#define ll long long
#define P 1000000007
int a[100005],in[100005],col[100005],cnt[100005],n,foot[100005];bool cir[100005];long long dp[100005],ans=1;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]),++in[a[i]];
    for (int i=1;i<=n;++i)
	{
        if (col[i]) continue;int x=i;
        for(;!col[x];x=a[x]) col[x]=i;
        if (col[x]!=i) continue;
        for (;!cir[x];x=a[x]) cir[x]=1; 
    }
    for (int i=1;i<=n;++i) if ((cir[i]&&in[i]>2)||(!cir[i]&&in[i]>1)) {printf("0");return 0;}
    for (int i=1;i<=n;++i)
	{
        if (in[i]) continue;int x=i,tmp=0;
        while(!cir[x]) x=a[x],tmp++;foot[x]=tmp;
    } 
    for (int i=1;i<=n;++i)
	{
        if (!cir[i]) continue;int x=i,st=0,first=0,id=0,len=0;
        while (cir[x])
		{
            ++id;cir[x]=0;
            if (foot[x])
			{
                if (!first){st=first=id;len=foot[x];x=a[x];continue;}
				else
				{
                    int numm=(foot[x]<(id-st))+(foot[x]<=(id-st));
					(ans*=numm)%=P;if (!ans) {printf("0");return 0;}st=id;x=a[x];continue;
                }
            }
			x=a[x];
        }
		if (first)
		{
            int numm=(len<(id+first-st))+(len<=(id+first-st));
            (ans*=numm)%=P;if (!ans) {printf("0");return 0;}
        }
		else cnt[id]++;
    }
    for (int i=1;i<=n;++i)
	{
        dp[0]=1;if (!cnt[i]) continue;
        if (i>1&&(i%2)) for (int j=1;j<=cnt[i];++j) {dp[j]=dp[j-1]*2%P;if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%P)%=P;}
		else for (int j=1;j<=cnt[i];++j){dp[j]=dp[j-1];if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%P)%=P;}   
        (ans*=dp[cnt[i]])%=P;if (!ans){printf("0");return 0;}
    }
	printf("%lld",ans);
}

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

int main(void){
  int x[5];
  for(int i = 0; i < 5; i++)
    cin >> x[i];
  for(int i = 0; i < 5; i++){
    if(x[i] == 0){
      cout << i + 1 << "\n";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

////////////////////////////////////////////////////////

vector<vector<ll>> tree;
ll ans[200010];
ll seen[200010];

void bfs(){
    queue<ll> qu;
    qu.push(1);
    while(!qu.empty()){
        ll p = qu.front(); qu.pop();
        seen[p] = 1;
        rep(j, 0, tree[p].size()){
            if(seen[tree[p][j]]==1) continue;
            ans[tree[p][j]] += ans[p];
            qu.push(tree[p][j]);
        }
    }
}

int main() {
    ll n, q; cin >> n >> q;
    tree.resize(n+1);
    rep(i, 1, n){
        ll a, b; cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    rep(i, 0, q){
        ll p, x; cin >> p >> x;
        ans[p] += x;
    }
    bfs();
    Rep(i, 1, n){
        if(i>1) cout << " ";
        cout << ans[i];
    }
    coel;

    return 0;
}


Measured memory_bytes: 19440
#include <iostream>
#include <algorithm>

int main(int argc, char *argv[]) {  
	int n;
	int ans = 100000000;
	int t;
	int cnt = 0;
	int tot = 0;
	std::cin >> n;
	for(int i = 0; i < n; i++) {
		std::cin >> t;
		tot = 0;
		while(t%2 == 0) {
			t/=2;
			tot++;
		}
		ans = std::min(ans, tot);
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main() {

        int n;

        std::cin >> n;

        int result = 0;
        int max = 0;

        for (int i = 0; i < n; ++i) {
                int n;
                std::cin >> n;
                result += n;

                if (max <= n) {
                        max = n;
                }
        }

        std::cout << result - (max / 2) << std::endl;

        return 0;
}

Measured memory_bytes: 256
N=int(input())

V = list(map(int,input().split()))
C = list(map(int,input().split()))

ans=0


for i in range(N):
    #for文の中では三項演算子ダメ？
     if  V[i] - C[i] > 0:
        ans += V[i]-C[i]  

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
	int i, j, p, N;
	scanf("%d", &N);
	printf("%d\n", (N - 1) * (N - 1) / 2);
	for (i = 1, p = 1 - N % 2; i < N; i++) {
		for (j = i + 1; j <= N; j++) if (j != N - i + p) printf("%d %d\n", i, j);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
y1=min(Y)
x1=max(X)
if x<y1 and x1<y:
    if x1<y1:
        print('No War')
    else:
        print('War')
else:
    print('War')

Measured memory_bytes: 3064
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        for (int i = 1; i <= 5; i++) {
            if (scanInt() == 0) {
                System.out.println(i);
                break;
            }
        }
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 32528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,t;cin>>n>>t;
    vint a(n);
   rep(i,n) cin>>a[i];

   int res=t;
   rep(i,n-1){
       if(a[i]+t<a[i+1]) res+=t;
       else res+=a[i+1]-a[i];
   }
   cout<<res<<endl;
}

Measured memory_bytes: 4724
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> abc = new HashSet<>();

		for (int i=0; i<3; i++) {
			int num = sc.nextInt();
			abc.add(num);
		}
		if (abc.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> v(n);
  for (ll i = 0; i < n; ++i) {
    cin >> v[i];
  }

  ll ans = 0;
  ll len = min(n, k);
  for (ll l = 0; l <= len; ++l) {
    for (ll r = 0; r <= len-l; ++r) {
      //cout << l << ", " << r << endl;
      vector<ll> tmp;
      ll value = 0;
      for (ll i = 0; i < l; ++i) {
        //cout << "l[" << i << "] : " << v[i] << endl;
        value += v[i];
        tmp.push_back(v[i]);
      }
      for (ll i = n-r; i < n; ++i) {
        //cout << "r[" << i << "] : " << v[i] << endl;
        value += v[i];
        tmp.push_back(v[i]);
      }
      
      ll d = k-l-r;
      //cout << "d : " << d << endl;
      sort(tmp.begin(), tmp.end());
      for (ll i = 0; i < d; ++i) {
        if (tmp.size() <= i) break;
        if (tmp[i] >= 0) break;
        value -= tmp[i];
      }
      ans = max(ans, value);
    }
  }

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

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

int main() {
    long long N, K, min1, min2;

    cin >> N >> K;

    min1 = N % K;
    min2 = K - min1;
    if(min1 < min2){
        cout << min1 << endl;
    }else{
        cout << min2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    map<ll, ll> mp;
    rep(i, n) mp[a[i]]++;
    ll ans = 0;
    rep(i, n)
    {
        if (mp[a[i]] == 0)
            continue;
        mp[a[i]]--;
        repr(j, 31)
        {
            ll tmp = 1LL << j;
            if (tmp <= a[i])
                continue;
            if (mp[tmp - a[i]] > 0)
            {
                mp[tmp - a[i]]--;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 52736
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

int alph[30];

int main(){
	char w[101];
	scanf("%s", w);
	for(int i=0; w[i] != '\0'; i++) alph[w[i] - 'a']++;
	for(int i=0; i < 26; i++) if( alph[i] % 2 != 0) goto No;
	
	printf("Yes\n");
	return 0;
No: printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>> n;
  while(n--){
    int x,y,b,p;
    cin>> x>> y>> b>> p;
    cout<< min(((double)(x*b+y*p)),((double)(max(b,5)*x+max(p,2)*y)*0.8))<< endl;
  }
}

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

int main() {

  int N;
  cin >> N;

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

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

  cout << a[N - 1] - a[0] << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, T = map(int, input().split())

    ans = float('inf')
    for _ in range(N):
        c, t = map(int, input().split())
        if c<ans and t<=T:
            ans = c
    
    if ans==float('inf'):
        print('TLE')
    else:
        print(ans)
    

 
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940