akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int dp[2001];
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    dp[0] = 1;
    for (int i = 3; i <= n; i++)
    {
        for (int j = 3; j <= i; j++)
        {
            dp[i] += dp[i - j];
            dp[i] %= mod;
        }
    }
    // for(int i=0;i<=n;i++) cout<<dp[i]<<' ';
    cout << dp[n];
    return 0;
}

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

int main(){
    int a, h, m, s;
    cin >> a;
    h = a / 3600;
    m = a % 3600 / 60;
    s = a % 3600 % 60;
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

struct Edge {
  int to, id;
  Edge(int to, int id): to(to), id(id) {}
};
vector<vector<Edge>> edges(51);

ll path; // 各制約のパスに存在するedgeに1を立てる
bool dfs(int v, int to, int p=0) {
  if (v==to) {
    path = 0ll;
    return true;
  }
  for(auto edge: edges[v]) {
    if (edge.to==p) continue;
    if (dfs(edge.to, to, v)) {
      // path+=1<<edge.id; //この1はint型になるので32bit以上shiftさせるとoverflowする
      path+=1ll<<edge.id;
      return true;
    }
  }
  return false;
}


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;

  REP(i,n-1) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(Edge(b, i));
    edges[b].push_back(Edge(a, i));
  }

  // // debug
  // for (int i = 0; i < n+1; i++) {
  //   for(auto e: edges[i]) {
  //     cout << "(" << e.to << "," << e.id << ") ";
  //   } cout << endl;
  // }

  int m;
  cin >> m;
  vector<ll> constraints;
  REP(i,m) {
    int u, v;
    cin >> u >> v;
    dfs(u, v);
    constraints.push_back(path);
  }

  // // debug
  // for(auto c: constraints) {
  //   bitset<100> b(c); // edgeの数分
  //   cout << b << endl;
  // }

  // 全白の数を数えて、制約が奇数個なら-, 偶数個なら+
  ll ans = 0;
  for (ll i = 0; i < 1<<m; i++) {
    int pos = 0;
    ll white_edges = 0;
    ll tmp=i;
    while(tmp) {
      if (tmp&1) white_edges |= constraints[pos];
      tmp >>=1; pos++;
    }
    int count = __builtin_popcountll(i);
    int white = __builtin_popcountll(white_edges);
    ll conb = 1ll<<(n-1-white);
    if (count&1) ans-=conb;
    else ans+=conb;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll MOD = 1e9+7;

class UF
{
  public:
  int s;//木の頂点数
  vector<int> par;//親
  vector<int> rank;//木の深さ
  vector<int> size;//木の直径
  //コンストラクタ
  //n要素で初期化
  UF(int n)
  {
    s=n;
    par.resize(s);
    rank.resize(s);
    size.resize(s);
    for(int i=0;i<n;i++)
    {
      par[i]=i;
      rank[i]=0;
      size[i]=1;
    }
  }
  //木の根を求める
  int find(int x)
  {
    if(par[x]==x)
      return x;
    else
      return par[x]=find(par[x]);
  }
  //xとyの属する集合を併合
  void unite(int x,int y)
  {
    x=find(x);
    y=find(y);
    if(x==y)
      return;
  
    if(rank[x]<rank[y])
    {
      par[x]=y;
      size[y]+=size[x];
    }else{
      par[y]=x;
      size[x]+=size[y];
      if(rank[x]==rank[y])
        rank[x]++;
    }
  }
  //xとyが同じ集合に属するか否か
  bool same(int x,int y)
  {
    return find(x)==find(y);
  }
  //xが属する集合の大きさを求める
  int getsize(int x)
  {
    return size[par[x]];
  }
};
double x[100];
double y[100];
double z[100];
double r[100];
double dist[100][100];
priority_queue<pair<double,P>,vector<pair<double,P>>,greater<pair<double,P>>> q;
//中心間の距離の2乗を求める
double jou2(int i,int j)
{
	return (x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])+(z[j]-z[i])*(z[j]-z[i]);
}
int main()
{
	int n;
	double ans;
  while(1)
	{
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
			cin>>x[i]>>y[i]>>z[i]>>r[i];
		UF u=UF(n);
		q=priority_queue<pair<double,P>,vector<pair<double,P>>,greater<pair<double,P>>>();
		ans=0.0;
		fill(dist[0],dist[100],1e14-1);
		//全点間の距離を求め距離0のものをuniteする
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				dist[i][j]=max(0.0,sqrt(jou2(i,j))-r[i]-r[j]);
				if(dist[i][j]==0.0)
					u.unite(i,j);
				else
					q.push(make_pair(dist[i][j],P(i,j)));
			}
		}
		//距離の短いものからuniteしていく
		while(u.getsize(0)!=n)
		{
			if(q.empty())
				break;
			auto p=q.top();q.pop();
			if(!u.same(p.second.first,p.second.second))
			{
				u.unite(p.second.first,p.second.second);
				ans+=p.first;
			}
		}
		cout<<fixed<<setprecision(3)<<ans<<endl;
	}
  return 0;
}


Measured memory_bytes: 3440
def main():

    d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
    N = int(input())
    for _ in range(N):
        S = input()
        d[S] += 1

    for s in ['AC', 'WA', 'TLE', 'RE']:
        print(s + ' x ' + str(d[s]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 69872
main = do
    s <- getLine
    putStrLn $ if "keyence" `elem` cut (length s - 7) s
               then "YES" 
               else "NO"

cut :: Int -> String -> [String]
cut n xs = cut' n (length xs) xs
    where 
        cut' _ (-1) _ = []
        cut' n ns xs = (take ns xs ++ drop (ns + n) xs) : cut' n (ns - 1) xs


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

struct BinaryIndexedTree {
  BinaryIndexedTree(size_t h, size_t w) : h(h), w(w), v(h + 1, vector<int>(w + 1, 0)) {}
  BinaryIndexedTree(size_t n) : h(n), w(n), v(n + 1, vector<int>(n + 1, 0)) {}

  size_t h, w;
  vector<vector<int>> v;

  long long sum(int y, int x) {
    long long ret = 0;
    for (int i = y; i; i -= i & -i)
      for (int j = x; j; j -= j & -j) ret += v[i][j];

    return ret;
  }

  long long sum(int y1, int x1, int y2, int x2) {
    return sum(y1, x1) - sum(y1, x2) - sum(y2, x1) + sum(y2, x2);
  }

  void add(int y, int x, int d) {
    for (int i = y; i <= h; i += i & -i)
      for (int j = x; j <= w; j += j & -j) v[i][j] += d;
  }
};

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

  vector<long long> x, y, a, b;
  map<long long, int> X, Y;
  for (int i = 0; i < n; ++i) {
    int s, t;
    cin >> s >> t;
    x.push_back(s);
    y.push_back(t);
  }

  a = x;
  b = y;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < n; ++i) {
    X[a[i]] = i + 1;
    Y[b[i]] = i + 1;
  }

  BinaryIndexedTree bit(n);
  for (int i = 0; i < n; ++i) {
    bit.add(Y[y[i]], X[x[i]], 1);
  }

  long long ans = 5001001001001001001;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        for (int l = k + 1; l < n; ++l) {
          if (bit.sum(Y[b[l]], X[a[j]], Y[b[k]] - 1, X[a[i]] - 1) >= K) {
            ans = min(ans, (b[l] - b[k]) * (a[j] - a[i]));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    int n;

    for (;;) {
        cin >> n;
        if (!n)
            break;

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int j = i, k = 0;
            for (; k < n; k += j, j++)
                ;
            if (j != i + 1 && k == n) {
                ans++;
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String input = readLine();
        String[] arg = input.split(" ");

        byte A = Byte.parseByte(arg[0]);
        byte B = Byte.parseByte(arg[1]);

        byte Result = (byte)(A - (B*2));
        if (Result < 0) Result = 0;
        Print(Result);

    }

    private static final Scanner __in = new Scanner(System.in);
    private static String readLine() {
        return __in.nextLine();
    }

    private static void Print(byte m) {
        System.out.println(m);
    }
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	long long sum = 0, value = 0;
	int i = 0;
	while (sum < m) {
		value += a[i].first;
		a[i].second--;
		if (!a[i].second)
			i++;
		sum++;
	}
	cout << value << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;

ll n, m, fl, cnt[5], v[100005];
vector<ll> gr[100005];

void f(ll p, ll q) {
	if(v[p]) {
		fl |= (v[p] != q);
		return;
	}
	v[p] = q;
	cnt[q]++;
	for(auto x:gr[p]) f(x, 3-q);
}

int main() {
	ll i, t1, t2;
	cin >> n >> m;
	for(i=0; i<m; i++) {
		scanf("%lld%lld", &t1, &t2);
		gr[t1].push_back(t2);
		gr[t2].push_back(t1);
	}
	f(1, 1);
	if(fl) cout << n * (n-1) / 2 - m;
	else cout << cnt[1] * cnt[2] - m;
	return 0;
}

Measured memory_bytes: 7552
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n,k;
    cin>>k>>n;
    int ans = 0;
    fr(i,0,k)
    {
        fr(j,0,k)
        {
            int z = n - i - j;
            if(z>=0 && z<= k)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;
}



void inorder(Node u){
    if(u->left!=NIL){
        inorder(u->left);
    }
    printf(" %d",u->key);
    
    if(u->right!=NIL){
        inorder(u->right);
    }
}

void preorder(Node u){
    printf(" %d",u->key);
    
    if(u->left!=NIL){
        preorder(u->left);
    }
    if(u->right!=NIL){
        preorder(u->right);
    }
    
}

Node find(Node x, int k){
    
    if(x == NIL || k == x->key)
        return x;
    if(k < x->key)
        return find(x->left, k);
    else
        return find(x->right, k);
    
}


int main(){
    int n, i, x, k;
    char com[20];
    scanf("%d", &n);
    root=NIL;
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if( com[0] == 'f'){
            scanf("%d",&x);
            Node t=find(root,x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        }
    }
    
    return 0;
}

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

int main(){
  int n,m,b,r=0;
  cin >> n;
  m=n;
  while(m!=0){
    b=m%10;
    r+=b;
    m/=10;
  }
  if(n%r==0)
    cout <<"Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    map<int64_t, int64_t>d;
    for (int i=0; i<N; i++) {
        int64_t n;
        cin >> n;
        if(d.count(n) > 0) {
            d[n] = d[n] + 1;
        } else {
            d[n] = 1;
        }
    }

    int64_t M;
    cin >> M;
    bool ok = true;
    for (int i=0; i<M; i++) {
        int n;
        cin >> n;
        if (d.count(n) == 0) {
            ok = false;
            break;
        } else {
            d[n] -= 1;
            if (d[n] < 0) {
                ok = false;
                break;
            }
        }
    }

    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 16068
import sys
import queue

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = tin()
	#s = input()
	mm = [[] for _ in range(n)]
	rrp=[-1]*n
	for _ in range(m):
		a,b = tin()
		mm[a-1].append(b-1)
		mm[b-1].append(a-1)
	
	q = queue.Queue()
	q.put((0,0))
	while not q.empty():
		pos, parent = q.get()
		if rrp[pos] >= 0:
			continue
		rrp[pos] = parent
		
		for v in mm[pos]:
			q.put((v, pos))
	print('Yes')
	for v in rrp[1:]:
		print(v+1)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 110676
X,K,D = map(int,input().split())
div,rem = divmod(abs(X),D)
if abs(div)<=K and (div-K)%2 == 0:
    print(abs(rem))
elif div<=K and (div-K)%2 == 1:
    print(min(abs(rem-D),abs(rem+D)))
else:
    print(abs(abs(X)-K*D))

Measured memory_bytes: 8920
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    N, K = LI()
    x = N % K
    y = abs(x - K)
    print(min(x, y))

main()


Measured memory_bytes: 65728
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int a[MAX];
    int n;

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

    int maxv = -1000000000;
    int minv = a[0];

    for(int i = 1; i<n; i++){
        maxv = max(maxv, a[i]-minv);
        minv = min(minv, a[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3872
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int l = 1, r = n;
        for (int i = 0; i < m; ++i) {
            l = Math.max(l, scanner.nextInt());
            r = Math.min(r, scanner.nextInt());
        }
        writer.println(r - l + 1 > 0 ? r - l + 1 : 0);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 42596
import math


def calc(a, b, theta):
    if a * math.tan(math.radians(theta)) <= b:
        return a * a * b - a * a * a * math.tan(math.radians(theta)) / 2
    else:
        return b * b / math.tan(math.radians(theta)) * a / 2


def solve():
    a, b, x = map(int, input().split())

    ok = 90
    ng = 0
    for _ in range(1000):
        mid = (ok + ng) / 2
        if calc(a, b, mid) < x:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int A, P;
  cin >> A >> P;

  P += A * 3;
  int ans = P / 2;

  cout << ans << endl;
}

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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n;
	cin>>n;
	for(ll i=n;;i++)
	{
		if(prime(i)==true)
		{
			cout<<i;
			return;
		}
	}
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int H, N;
    cin >> H >> N;
    int atk = 0;
    REP(i,N){
        int a;
        cin >> a;
        atk+=a;
    }
    if(atk >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3644
K, N = map(int, input().split())
As = list(map(int, input().split()))
Ds = []
past = 0
for i, a in enumerate(As):
    if not i==0:
        Ds.append(a-past)
    past = a
Ds.append(As[0]+K-As[-1])
print(K-max(Ds))

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

int main() { 
    int A, B;
    cin >> A >> B;
    int price = 10;
    int ans = -1;
    while (price < 1251 && !((price * 8 / 100 == A) && (price * 10 / 100 == B))) {
      price++;
    }
    if (price != 1251) {
        ans = price;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
from math import sqrt


def get_divisors(n):
    """
    約数の個数を数える
    :param n: 自然数
    :return: 約数の個数, 約数の set
    """
    res = {1}
    cnt = 1
    for i in range(2, int(sqrt(n)) + 1):
        if n % i == 0:
            cnt += 1

        while n % i == 0:
            res.add(i)
            n /= i
        if (n <= 1): break

    if n > 1:  # 素数の場合
        res.add(n)
    return cnt, res


A, B = [int(_) for _ in input().split()]
print(len(get_divisors(A)[1] & get_divisors(B)[1]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 100005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;

int main()
{
    int n;
    cin>>n;
    bool flag=0;
    while(n)
    {
        if(n%10==9)
            flag=1;
        n/=10;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iomanip>

int main() {

    int N, X, A, B, C, tmp1, tmp2, i = 0, ans = 0, cnt = 0, W, H;
    double S = 0, x, y;

    std::cin >> N;

    for(i=1; i<=N; i++){
        std::string tmp = std::to_string(i);
        if(tmp.size()%2 == 1){
            ans++;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.c
//  Minor Change
//
//  Created by k19031kk on 2020/06/27.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    
    int ret;
    
    char sentence1[100000000];
    char sentence2[100000000];
    
    scanf("%s",sentence1);
    scanf("%s",sentence2);
    
    int count = 0;
    
    ret=(int)strlen(sentence1);
    
    //printf("%d\n",ret);
//
//    ret = scanf("%s",sentence1);
//
//    if(ret == EOF){
//        return -1;
//    }
//
//    ret1 = scanf("%s",sentence2);
//
//    if(ret1 == EOF){
//        return -1;
//    }
//
//    int len = (int) strlen(sentence1);
//    int len1 = (int) strlen(sentence2);
//    if(len != len1){
//        return -1;
//    }
    
//    for(int i=0;i<len;i++){
//        if(!(sentence1[i]>= 'a') && (sentence1[i]<='z')){
//            return -1;
//        }
//
//        if(!(sentence2[i]>= 'a') && (sentence2[i]<='z')){
//            return -1;
//        }
//    }
//
//
//    for(int i=0;i<len;i++){
//
//        if(sentence1[i] != sentence2[i]){
//            count++;
//        }
//    }
    
    for(int i=0;i<ret;i++){
        if(sentence1[i]!=sentence2[i]){
            count++;
        }
    }
    
    printf("%d\n",count);
    return 0;
}


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

int main()
{
    char S[200002],T[200002];
    int i,j=0,l;

    scanf("%s",S);
    scanf("%s",T);

    l = strlen(S);

    for(i=0;i<l;i++){
        if(S[i] != T[i]){
            j++;
        }
    }

    printf("%d\n",j);

  return 0;
}


Measured memory_bytes: 2116
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,n,m,n1,a,b,c,d,x[100],t[100];
	cin>>n;
	for(i=0;i<n;i++){
		x[i]=0;
		t[i]=1;
	}
	n1=n*(n-1)/2;
	for(i=0;i<n1;i++){
		cin>>a>>b>>c>>d;
		if(c>d) x[a-1]=x[a-1]+3;
		if(c<d) x[b-1]=x[b-1]+3;
		if(c==d){
			x[a-1]=x[a-1]+1;
			x[b-1]=x[b-1]+1;
		}
//		cout<<'1'<<'2'<<'3'<<'4'<<endl;
//		cout<<x[0]<<x[1]<<x[2]<<x[3]<<endl;
	}
/*	for(i=0;i<n;i++) cout<<x[i];
	cout<<endl;*/
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(x[i]<x[j]){
				t[i]=t[i]+1;
			}
		}
	}
	for(i=0;i<n;i++){
		cout<<t[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3116
s = input()
t = 0

for i in range(0, len(s)):
  if(s[i].isupper()):
    t = t + 1
  else:
    pass

try:
  if 2 <= s.index('C') and s.index('C') <= len(s)-2 and s.index('A')==0:
    if t == 2:
      print('AC')
    else:
      print('WA')
  else:
    print('WA')

except ValueError:
  print('WA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b;
    cin >> a >> b;
    int s=1,ans=0;
    while(s<b){
        s+=a-1;
        ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			invite = new boolean[n];
			friend = new boolean[n][n];
			for (int i = 0; i < m; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				friend[a][b] = friend[b][a] = true;
			}
			for (int i = 1; i < n; i++) {
				if (!friend[0][i])
					continue;
				invite[i] = true;
				for (int j = 1; j < n; j++) {
					if (!friend[i][j])
						continue;
					invite[j] = true;
				}
			}
			int count = 0;
			for (int i = 0; i < n; i++)
				if (invite[i])
					count++;
			System.out.println(count);

		}
	}

	int n, m, ans;
	boolean[] invite;
	boolean[][] friend;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    
    int minimum = 1e3, maximum = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      sum += s;
      minimum = min(minimum, s);
      maximum = max(maximum, s);
    }
    
    cout << (sum - minimum - maximum) / (n - 2) << '\n';
  }
}


Measured memory_bytes: 3184
#coding:utf-8

nyu =""
moji =[]
s1 =[]
s2 =[]
n= 0
a= 0
while nyu != "-":
    nyu = input().rstrip()
    if nyu =="-":
#        print("".join(moji))
        break

    n = int(input().rstrip())
    moji = list(nyu)

    for i in range(n):
        a = input().rstrip()
        s1 =moji[:int(a)]
        s2 =moji[int(a):]
        moji= list("".join(s2) + "".join(s1))
#        print(moji)

    print("".join(moji))

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,x,a[100000];
    long long res=0;
    cin >> N >> x;
    for (int i = 0; i < N; i++) {
        cin >>a[i];
        if(a[i]>x){
            res+=a[i]-x;
            a[i]=x;
        }
    }
    for (int i = 1; i < N; i++) {
        if(a[i-1]+a[i]>x){
            res+=a[i-1]+a[i]-x;
            a[i]-=a[i-1]+a[i]-x;
        }
    }
    cout <<res<< endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> k(M, 0);
	vector<vector<int>> s(M);
	vector<int> p(M,0);
	for (int i = 0;i < M;i++) {
		cin >> k[i];
		for (int j = 0;j < k[i];j++) {
			int tmp = 0;
			cin >> tmp;
			s[i].push_back(tmp-1);
		}
	}
	for (int i = 0;i < M;i++) {
		cin >> p[i];
	}

	int count = 0;
	for(int bit = 0;bit < (1 << N);bit++) {
		int count1 = 0;
		for (int i = 0;i < M;i++) {
			int scount = 0;
			for (int j = 0;j < k[i];j++) {
				if (bit & (1 << s[i][j])) {
					scount++;
				}
			}
			if ((scount % 2) == p[i]) {
				count1++;
			}
		}
		if (count1 == M) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
#+++++
import itertools
n=int(input())
aa=list(map(int, input().strip().split()))
am={}
for a in aa:
	t=am.get(a, 0)
	am[a]=t+1

ans=0
for ak, av in am.items():
	if ak <= av:
		ans += av-ak
	else:
		ans += av
print(ans)

Measured memory_bytes: 18156
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int cnt = 0;
  while(a>0&&c>0) {
    if(cnt%2==0) c -= b;
    else a-= d;
    cnt++;
  }
  if(cnt%2==0) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<vector>
#include<iostream>
#include<functional>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

template <typename Monoid=ll> class SegmentTree {
    public:
    using Monoid_func = function<Monoid(Monoid, Monoid)>;
    ll size;
    std::vector<Monoid> segment;  // 1-indexed 葉ノードは size ~ 2*size-1
    Monoid Monoid_unit;
    Monoid_func Monoid_calc;

    SegmentTree(ll N, 
                Monoid Monoid_unit = 0,
                Monoid_func Monoid_calc = [](ll a, ll b){return a+b;}) 
            : size(1), Monoid_unit(Monoid_unit), Monoid_calc(Monoid_calc) {
        while(size < N) size <<= 1;
        segment.assign(size*2, Monoid_unit);
    }

    void set(ll k, Monoid a){
        segment[k+size] = a;
    }
    void build(){  // 全てのノードを再計算
        for(ll k=size-1; k>0; k--) segment[k] = Monoid_calc(segment[k*2], segment[k*2+1]);
    }
    void update(ll k, Monoid a){
        k += size;
        segment[k] = a;
        while(k >>= 1) segment[k] = Monoid_calc(segment[k*2], segment[k*2+1]);
    }
    Monoid query(ll a, ll b){ // [a, b)の演算結果
        Monoid l=Monoid_unit, r=Monoid_unit;
        for(a+=size, b+=size; a<b; a>>=1, b>>=1){
            if(a % 2 == 1) l = Monoid_calc(l, segment[a++]);
            if(b % 2 == 1) r = Monoid_calc(segment[--b], r);
        }
        return Monoid_calc(l,r);
    }

    Monoid operator[](const ll &k) const{
        return segment[k+size];
    }
};

int main(){
    int n,q, com, x, y;

    cin >> n >> q;
    SegmentTree<ll> st(n, 2147483647, [](ll a, ll b){return std::min(a,b);});
    REP(i,q){
        cin >> com >> x >> y;
        if(com==0){
            st.update(x,y);
        }
        else{
            cout << st.query(x,y+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4884
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll p[a], q[b], r[c];
    rp(i, 0, a) cin >> p[i];
    rp(i, 0, b) cin >> q[i];
    rp(i, 0, c) cin >> r[i];
    sort(p, p + a);
    sort(q, q + b);
    sort(r, r + c);
    reverse(p, p + a);
    reverse(q, q + b);
    reverse(r, r + c);
    vl ans;
    rp(i, 0, x) ans.push_back(p[i]);
    rp(i, 0, y) ans.push_back(q[i]);
    sort(be(ans));
    // reverse(be(ans));
    ll co = 0;
    rp(i, 0, c)
    {
        if (r[i] > ans[i])
            co++;
        else
            break;
    }
    ll aa = 0;
    rp(i, 0, co)
    {
        aa += r[i];
    }
    rp(i, co, x + y)
    {
        aa += ans[i];
    }
    cout << aa << endl;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
const int N = 300, bs = 500;
const double EPS = 0.000001;

int n, a[N];
vector<int> g;

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

	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	bool gg = 0;
	for(int i = 1;i < n;i++){
		if(!gg && a[i] >= a[i + 1]){
		 	continue;
		}
		else if(!gg && a[i] < a[i + 1]){
			g.push_back(a[i]);	
			gg = 1;
		}
		else if(gg && a[i] <= a[i + 1]){
			continue;
		}
		else{
			gg = 0;
			g.push_back(a[i]);
		}
	}
	if(g.size() % 2 == 1)
		g.push_back(a[n]);
	gg = 0;
	ll st = 0, c = 1000;
	for(int x: g){
		//cerr << x << "\n";
		if(!gg){
			st += c / x;
			c %= x;
			gg = 1;
		}	
		else{
			c += st * x;
			st = 0;
			gg = 0;
		}
	}
	cout << c;
}

Measured memory_bytes: 3632
/*
    Problem 5
    https://atcoder.jp/contests/abc095/tasks/arc096_a
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = INF;
    for (int i = 0; i <= max(x, y); i++) {
        int sum = 2 * i * c;
        sum += max(0, x - i) * a + max(0, y - i) * b;
        ans = min(ans, sum);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3608
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int X, A;
    cin >> X >> A;
    if (X < A)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }
    
}

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

int main(){
	auto read_string 	=	[](){ string s; cin >> s; return s; };
	auto read_int       =   [](){ int tmp; cin >> tmp; return tmp; };
	auto read_char      =   [](){ char c; cin >> c; return c; };
	auto str_repeat	 	=	[](string a,int count){	string res = ""; for(size_t i = 0 ; i < count ; i++) res += a; return res;	};
	auto to_lower_case 	= 	[](string s){ string res=""; for(size_t i = 0 ; i < s.size() ; i++) res += tolower(s[i]); return res; };
	auto to_upper_case 	= 	[](string s){ string res=""; for(size_t i = 0 ; i < s.size() ; i++) res += toupper(s[i]); return res; };
	auto read_vec_int   =   [](int count){ vector<int> tmp(count); for(size_t i = 0 ; i < count ; i++) cin >> tmp[i]; return tmp; };
	auto title_case     =   [](string s) { string ret = ""; ret+=toupper(s[0]); ret += s.substr(1); return ret; };


	auto num_divisors = [](int a){
		int ans = 0;
		for(size_t i = 2 ; i < a ; i++){
			if(a % i == 0) ans++;
		}
		return ans+2;
	};

	auto is_odd = [](int a){ return a % 2 == 1; };

	int a = read_int();

	int ans = 0;
	for(size_t i = 1 ; i <= a  ; i++){
		if(is_odd(i) && num_divisors(i) == 8) ans++;
	}

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


Measured memory_bytes: 384
n = int(input())
t = list(map(int, input().split()))
copy_t = t.copy()
m = int(input())
ans = 0
p = []
x = []
for i in range(0,m):
    input_p, input_x = map(int, input().split())
    p.append(input_p)
    x.append(input_x)
for z in range(m):
    for i in range(n):
        if p[z] == i+1:
            ans += x[z]
        else:
            ans += t[i]
    print(ans)
    ans = 0

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,c,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>a>>b>>c;

    int ans = c-min(a-b,c);

    cout<<ans<<"\n";

    return 0;
}


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

#define i64 long long int
#define ran 101101

int n, m;
int x[ran], y[ran];
int p[ran], sz[ran];
i64 ans[ran];

int get_p(int x) {
	return (p[x]==-1) ? x : (p[x] = get_p(p[x]));
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		scanf("%d%d", &x[i], &y[i]);
	}
	
	memset(p, -1, sizeof p);
	for(int i=1;i<=n;i++) sz[i] = 1;
	memset(ans, 0, sizeof ans);
	
	for(int i=m-1;i>=0;i--) {
		int a = get_p(x[i]), b = get_p(y[i]);
		if (a==b) continue;
		
		ans[i] = 1LL*sz[a]*sz[b];
		p[a] = b; sz[b] += sz[a];
	}
	for(int i=1;i<m;i++) ans[i] += ans[i-1];
	for(int i=0;i<m;i++)
		cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int A = 5e2 + 2;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    int freq[n] = {};
    for (int i = 1, x; i < n; i++)
        cin >> x, freq[x - 1]++;
    for (int i = 0; i < n; i++)
        cout << freq[i] << '\n';
    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W=MI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(H):
        a=input()
        for j in range(W):
            dd[a[j]]+=1
            
    L=[]
    for k,v in dd.items():
        L.append(v)
    
    four=0
    two=0
    one=0
    
    for aa in L:
        four+=aa//4
        bb=aa%4
        if bb==2 or bb==3:
            two+=1
        if bb==1 or bb==3:
            one+=1
        
    flag=0    
    if H%2==0 and W%2==0:
        if two==0 and one==0:
            flag=1
    elif H%2==0 and W%2!=0:
        if one==0 and two<=(H//2):
            flag=1
    elif H%2!=0 and W%2==0:
        if one==0 and two<=(W//2):
            flag=1
    else:
        if one<=1 and two<=((H+W)//2):
            flag=1
            
    if flag:
        print("Yes")
    else:
        print("No")
        
            
    
        

main()


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inN(A) cin>>n;for(i=0;i<n;++i)cin>>A[i];
#define rep(i,a,b) for(i=a;i<b;++i)
#define repn for(i=0;i<n;++i)
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define sd second
#define ft first
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define TC //int T;cin>>T;while(T--)
#define n_max 100001
#define mod 1000000007

char A[6][7];
int n,m,k,ans=0;

void rec(int C[],int id)
{
	if(id==n+m)
	{
		int i,j,c=0;
		rep(i,0,n)
		{
			rep(j,0,m)
			{
				if(C[i]&&C[n+j]&&A[i][j]=='#')c++;
			}
		}
		if(c==k)ans++;
		return;
	}
	rec(C,id+1);
	C[id]=1;
	rec(C,id+1);
	C[id]=0;
}

int main() {
    int a,b,p,i,j;
    TC
    {
    	cin>>n>>m>>k;
    	rep(i,0,n)cin>>A[i];
    	int C[n+m];
    	memset(C,0,sizeof(C));
    	rec(C,0);
    	cout<<ans;
    }
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
int n;cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++)cin>>v[i];
sort(v.begin(),v.end());
long long wow=0,ans=pow(10,6);
for(int i=v[0];i<=v[v.size()-1];i++){wow=0;
for(int j=0;j<n;j++){
    wow+=pow(v[j]-i,2);
    if(j==n-1&&wow<ans)ans=wow;
}}
cout<<ans;
}

Measured memory_bytes: 888
mod = 10**9+7
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
ans = 0
m = K
d = 1
n = 1
for i in range(K-1, N):
    ans += A[i]*n
    ans -= A[-i-1]*n
    n *= pow(d, mod-2, mod)
    n = n*m % mod
    m += 1
    d += 1
    ans %= mod
print(ans)


Measured memory_bytes: 63344
x = int(input())
c = 0
ans = 2
for i in range(1000):
    for j in range(int(x / 2)):
        if x == 2:
            c = 1
            break
        elif (x + i) % (j + 2) == 0:
            c = 1
            break
    if c == 0:
        ans = x + i
        break
    else:
        c = 0
print(ans)
            

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

#define INF 100000000

int solve(string &S, string &T) {
  int retv = INF;
  for (size_t i = 0; i <= S.size() - T.size(); i++) {
    int diff_count = 0;
    for (size_t j = 0; j < T.size(); j++) {
      if (S[i + j] != T[j]) {
        diff_count++;
      }
    }
    retv = min(retv, diff_count);
  }

  return retv;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S, T;
  cin >> S >> T;

  // main procedure
  int ans = solve(S, T);

  // output
  cout << ans << endl;

  return 0;
}

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

int main() {
	int H, W; cin >> H >> W;
	vector<string> pic(H);
	for( string &k : pic )cin >> k;
	string waku;
	for( int i = 0; i < W + 2; i++ ){
		waku += "#";
	}
	cout << waku << endl;
	for( int i = 0; i < H; i++ ) cout << "#" << pic[i] << "#" << endl;
	cout << waku << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
mod = 92709568269121

N, M = map(int, input().split())

mod = 10**9+7
def factrial(N):
    fc = [1, 1] + [None] * N
    inv = [0, 1] + [None] * N
    fcInv = [1, 1] + [None] * N
    for i in range(2, N+1):
        fc[i] = i*fc[i-1]%mod
        inv[i] = mod-(inv[mod%i]*(mod//i))%mod
        fcInv[i] = fcInv[i-1]*inv[i]%mod
    return fc, fcInv
fc, fcInv = factrial(1000)

def modCom(n, k):
    return 0 if n < k else fc[n] * fcInv[k] * fcInv[n-k] % mod

print(modCom(N, 2)+modCom(M, 2))


Measured memory_bytes: 38460
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,x,t;

int main()
{
	cin>>n>>x>>t; ll ans=0,nw=0;
	while(nw<n)
	{
		nw+=x;
		ans+=t;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,l;cin>>n>>l;
  int sum=0;
  int eat=inf;
  bool flag=false;
  for(int i=1;i<=n;++i){
    sum+=i+l-1;
    if(abs(i+l-1)<eat){
      eat=abs(i+l-1);
      if(i+l-1<0)flag=true;
    }
  }
  if(flag)eat*=-1;
  cout<<sum-eat<<"\n";
  return 0;
}


Measured memory_bytes: 256