akhauriyash/Code-Regression huggingface dataset:
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
public class Main {
    public static void main(String args[]) {
        Sc sc = new Sc(System.in);
        String s = sc.n();
        int wins = 0;
        for(int i = 0; i<s.length(); i++) {
            if(i%2 == 0 && s.charAt(i) == 'p') wins--;
            if(i%2 == 1 && s.charAt(i) == 'g') wins++;
        }
        System.out.println(wins);
    }
}
class Sc {
    public Sc(InputStream i) {
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasM() {
        return peekToken() != null;
    }

    public int nI() {
        return Integer.parseInt(nextToken());
    }

    public double nD() { 
        return Double.parseDouble(nextToken());
    }

    public long nL() {
        return Long.parseLong(nextToken());
    }

    public String n() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null) 
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}

Measured memory_bytes: 10960
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
#define NUM 100001
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}

int main(){
  LL N,A[5],k=pow(10,16),ans=4;
  int i;
  scanf("%lld",&N);
  for(i=0;i<5;i++)scanf("%lld",&A[i]);
  for(i=0;i<5;i++)if(k>A[i])k=A[i];
  if(N%k!=0)ans++;
  ans+=N/k;

  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128
def main() -> None:
    n = input()

    if n[-1] in ['2', '4', '5', '7', '9']:
        print('hon')
    elif n[-1] in ['0', '1', '6', '8']:
        print('pon')
    else:
        print('bon')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8964
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s = input()


def search(s):
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            return i+1, i+2
        if len(s) > i+2 and s[i] == s[i+2]:
            return i+1, i+3
    return -1, -1


if __name__ == "__main__":
    a, b = search(s)
    if a == -1:
        print("-1 -1")
    else:
        print(a, end="")
        print(' ', end="")
        print(b, end="")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

ll k;

vector <vector<ll>> graph;
vector <vector<ll>> depth;
vector <bool> visited;

void dfs(ll u = 1,ll d = k,ll p = -1){
	if (visited[u]) return;
	visited[u] = true;
	if (depth[d].size() <= 1) depth[d].push_back(u);
	for (ll v : graph[u]){
		if (v == p) continue;
		if (visited[v]) continue;
		dfs(v,d-1,u);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	ll current = 0;
	vector <ll> lol;
	vector <ll> value(n);
	graph.resize(n);
	depth.resize(k+1);
	visited.resize(n,false);
	for (int z=n-1;z>=0;z--){
		if (z+c+1 <= n-1 && s[z+c+1] != 'x'){
			if (value[z+c+1] > current){
				current = value[z+c+1];
				lol.clear();
				lol.push_back(z+c+1);
			}
			else lol.push_back(z+c+1);
		}
		if (s[z] == 'x') continue;
		for (int x=0;x<min(10,int(lol.size()));x++){
			graph[z].push_back(lol[x]);
		}
		value[z] = current+1;
	}
	for (int z=0;z<n;z++){
		if (value[z] > k) return 0;
	}
	for (int z=0;z<n;z++){
		if (visited[z]) continue;
		if (value[z] == k){
			dfs(z);
		}
	}
	set <ll> ans;
	for (int z=0;z<=k;z++){
		if (depth[z].size() == 1) {
			ans.insert(depth[z][0]);
		}
	}
	for (ll i : ans){
		cout << i+1 << endl;
	}
}

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

int main(){
    int n0, n1;
    cin >> n0 >> n1;
    int ans = 0;
    for(int i=n0; i<=n1; i++){
        int x = i;
        int x0 = x%10;
        x /= 10;
        int x1 = x%10;
        x /= 10;
        int x2 = x%10;
        x /= 10;
        int x3 = x%10;
        x /= 10;
        int x4 = x;
        if(x0 == x4 && x1 == x3) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

vector<int> adj[100005];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, u, v;
    cin >> n >> u >> v;
    for (int i = 0; i < n - 1; ++ i) {
        int a , b;
        cin >> a >> b;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }
    queue<pair<int, int>> Q;
    vector<int> dt(n + 1, 0);
    vector<bool> vis(n + 1, false);
    Q.push({u, 0});
    vis[u] = true;
    while (!Q.empty()) {
        auto p = Q.front();
        Q.pop();
        for (auto& x : adj[p.first]) {
            if (!vis[x]) {
                dt[x] = p.second + 1;
                Q.push({x, dt[x]});
                vis[x] = true;
            }
        }
    }
    vector<int> da(n + 1, 0);
    vis = vector<bool> (n + 1, false);
    Q.push({v, 0});
    vis[v] = true;
    while (!Q.empty()) {
        auto p = Q.front();
        Q.pop();
        for (auto& x : adj[p.first]) {
            if (!vis[x]) {
                da[x] = p.second + 1;
                Q.push({x, da[x]});
                vis[x] = true;
            }
        }
    }
    int ans = INT_MIN;
    for (int i = 1; i <= n; ++ i) {
        if (adj[i].size() == 1 && dt[i] < da[i]) {
            ans = max(ans, da[i] - 1);
        }
    }
    cout << ans;
}

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


int main() {
  ll n, k, q, tmp;
  cin >> n >> k >> q;
  vector<int>a(n, k-q);
  rep(i,q) {
    cin >> tmp;
    tmp--;
    a[tmp]++;
  }
  
  rep(i,n) {
    if(a[i]<=0) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
  
  
  
  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,m;
  cin >> n >> m;
  vector<pair<int64_t,int64_t>> a(n);
  vector<pair<int64_t,int64_t>> b(m);
  int64_t i;
  for(i=0;i<n;i++){
    int64_t c,d;
    cin >> c >> d;
    a.at(i)=make_pair(c,d);
  }
  for(i=0;i<m;i++){
    int64_t c,d;
    cin >> c >> d;
    b.at(i)=make_pair(c,d);
  }
  int64_t j;
  for(i=0;i<n;i++){
    int64_t sum=abs(a.at(i).first-b.at(0).first)+abs(a.at(i).second-b.at(0).second);
    pair<int64_t,int64_t> mini;
     mini.second=1;
    for(j=0;j<m;j++){
      mini.first=abs(a.at(i).first-b.at(j).first)+abs(a.at(i).second-b.at(j).second);
      if(mini.first<sum){
        sum=mini.first;
        mini.second=j+1;
      }
    }
    cout << mini.second << endl;
  }
}
   
  


Measured memory_bytes: 256
n, m, p = map(int, input().split())
graph = [[] for _ in range(n)]
edge = []
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((b, -c+p))
    edge.append((a, b, -c+p))

INF = float('inf')
d = [INF] * n
d[0] = 0
for i in range(n):
    for v_from, v_to, cost in edge:
        if d[v_from] != INF and d[v_to] > d[v_from] + cost:
            d[v_to] = d[v_from] + cost

exist = True
for i in range(n):
    for v_from, v_to, cost in edge:
        if d[v_from] != INF and d[v_to] > d[v_from] + cost:
            d[v_to] = d[v_from] + cost
            if v_to == n - 1:
                exist = False

if not exist:
    print(-1)
else:
    print(max(0, -d[n-1]))


Measured memory_bytes: 49496
#include<iostream>
#include<string>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::string;

int main(){
    string S,z;
    z = 'Z';
    cin >> S;
    if(S<=z){
        cout << 'A';
    }else{
        cout << 'a';
    }
}

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

int main() {
	int a[10002];
	int x;
	cin >> x;
	long int mi = 1000000, ma = -10000000, sum = 0;
	for (int i = 0; i< x; i++) {
		cin >> a[i];
		sum += a[i];
		if (mi > a[i])mi = a[i];
		if (ma < a[i])ma = a[i];
	}
	cout << mi << ' ' << ma << ' ' << sum << endl;
}


Measured memory_bytes: 3124
#include <stdio.h>
int main(){
  char ans[5], sei[5];
  int i,j,hit=0,brow=0;

  while(1){
    hit=0;
    brow=0;
    scanf("%s %s",ans,sei);
    if(ans[0]=='0'&&sei[0]=='0')break;
    for(i=0;i<4;i++){
      if(ans[i]==sei[i])hit++;
    }
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(ans[i]==sei[j]&&i!=j)brow++;
      }
    }
    printf("%d %d\n",hit,brow);
  }
  return 0;
}

Measured memory_bytes: 968
#include <stdio.h>

int main() {
	int n, m, x, y, k;
	double prob;

	scanf("%d%d", &n, &m);
	prob = 0;
	for (x = 1; x <= n; x++) {
		y = x;
		k = 0;
		while (y < m) {
			y *= 2;
			k++;
		}
		prob += 1.0 / (1 << k);
	}
	printf("%.12f\n", prob / n);
	return 0;
}


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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> h(n);
rep(i, n){
  cin >> h[i];
}
vector<vector<ll>> g(n);
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a - 1].push_back(b - 1);
  g[b - 1].push_back(a - 1); 
}
rep(i,n){
  bool ok=1;
  for(auto r:g[i])if(h[r]>=h[i])ok=0;
  if(ok)ans++;
}

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

Measured memory_bytes: 9860
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i  = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 10000000;

    for(int i = 1; i <= 100; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += pow(a[j] - i, 2);
        }
        if(sum < ans) ans = sum;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int dfs(vector<vector<int>> &vw, int lv, int vt, int w, int wb, int wlim){
  if(lv == 4){
    if(w > wlim) return 0;
    else return vt;
  }
  int ret = dfs(vw, lv+1, vt, w, wb, wlim);
  int sum = 0;
  rep(i, vw.at(lv).size()){
    sum += vw.at(lv).at(i);
    if(w + (i+1)*(lv+wb) > wlim) break;
    int r = dfs(vw, lv+1, vt+sum, w + (i+1)*(lv+wb), wb, wlim);
    // cerr << r << endl;
    if(r > ret) ret = r;
  }
  return ret;
}

int main(){
  int n, w;
  cin >> n >> w;
  vector<vector<int>> vw(4, vector<int>());
  int wb = -1;
  rep(i, n){
    int ww, v;
    cin >> ww >> v;
    if(i == 0) wb = ww;
    vw.at(ww-wb).push_back(v);
  }
  rep(i, 4){
    sort(vw.at(i).begin(), vw.at(i).end(), greater<int>());
  }
  int ans = dfs(vw, 0, 0, 0, wb, w);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
int main(){
	int N;cin>>N;
	long A[N];map<long,int> count;
	int temp=0;vector<long> B;
	rep(i,0,N){
		cin>>A[i];
		if(count[A[i]]==0){
            temp++;
		    if(temp<=3) B.push_back(A[i]);
        }count[A[i]]++;
	}
    if(temp>3) cout<<"No"<<endl;
    else if(temp==1){
        if(B[0]==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else if(temp==2){
        int a=min(count[B[0]],count[B[1]]);
        int b=max(count[B[0]],count[B[1]]);
        if((B[0]==0||B[1]==0)&&(a*2==b)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else if(temp==3){
        if((B[0]^B[1])==B[2]){
            int a=count[B[0]];
            int b=count[B[1]];
            int c=count[B[2]];
            
            if(a==b&&b==c) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
constexpr char el = '\n';
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;

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

  vl a(n+1), b(m+1);
  rep(i, n) {
    cin >> a[i+1];
  }
  rep(i, m) {
    cin >> b[i+1];
  }

  rep(i, n) {
    a[i+1] += a[i];
  }
  rep(i, m) {
    b[i+1] += b[i];
  }

  ll ans = 0;
  rep(i, n+1) {
    if (a[i] > k) break;
    ll cnt = i+(upper_bound(all(b), k-a[i])-b.begin())-1;
    cmax(ans, cnt);
  }
  cout << ans << el;
}


Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
const int N=110;

int n,m,bel[N],a[N][N];
bool E[N][N],vis[N];
vector<int> vec[N][N];

bool find(int i) {
	for(int j=1;j<=n;j++)
		if(!vis[j]&&E[i][j]) {
			vis[j]=1;
			if(!bel[j]||find(bel[j])) { bel[j]=i;return 1; }
		}
	return 0;
}

void print() {
	for(int i=1;i<=n;i++,cout<<'\n')
		for(int j=1;j<=m;j++) cout<<a[i][j]<<' ';
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) {
			int x;cin>>x;
			vec[i][(x-1)/m+1].push_back(x);
		}
	for(int i=1;i<=m;i++) {
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++) E[j][k]=(!vec[j][k].empty());
		memset(bel,0,sizeof(bel));
		for(int j=1;j<=n;j++) memset(vis,0,sizeof(vis)),find(j);
		for(int j=1;j<=n;j++) {
			int k=bel[j];
			a[k][i]=vec[k][j].back();
			vec[k][j].pop_back();
		}
	}
	print();
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(a[j][i]>a[k][i]) swap(a[j][i],a[k][i]);
	print();
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> shain(n);
	vector<int> a(n);
	for(int i=1;i<n;i++){
		cin >> a[i];
	}
	for(int i = 1; i<n; i++){
		shain[a[i]-1]++;
	}
	for(int i=0;i<n;i++) cout<< shain[i] << endl;
	return 0;
}


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

long long n,ans;

void dfs(long long x,long long a,long long b,long long c){
  if(x>n) return;
  if(a&&b&&c){ans++;}
  dfs(10*x+3,1,b,c);
  dfs(10*x+5,a,1,c);
  dfs(10*x+7,a,b,1);
}

int main(){
  cin >> n;
  ans=0;
  dfs(0,0,0,0);
  cout << ans << endl;
}

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

map<string , long long>m;

int main(){
 long long n,a,b,x;
 set<string>lst;
 string s;
 cin >>n;
 for(long long i=0;i<n;i++){
 cin>>s;
 m[s]++;
 }
 cout << "AC x " << m["AC"] << endl;
 cout << "WA x " << m["WA"] << endl;
 cout << "TLE x " << m["TLE"] << endl;
 cout << "RE x " << m["RE"] << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define inf (long long)1e9
using namespace std;

struct data {
  long long x, y, d, c, dis;
};

int dir[4] = {0, 1, 0, -1};
long long h, w, n, sx, sy, gx, gy;
vector<string> a;
string s;
vector<vector<vector<vector<long long>>>> dist;
vector<long long> memo;

long long c_to_int(char x) {
  if(x == 'E') return 0;
  if(x == 'S') return 1;
  if(x == 'W') return 2;
  if(x == 'N') return 3;
  if(x == 'C') return 4;
  if(x == 'T') return 5;
  if(x == '~') return 6;
  return -1;
}
long long move_to_int(char x) {
  if(x == '^') return 0;
  if(x == 'v') return 1;
  if(x == '<') return 2;
  if(x == '>') return 3;
  return -1;
}
bool isvalid(const data &now) {
  return a[now.x + dir[now.d]][now.y + dir[1 ^ now.d]] ==
         '.';
}
long long solve();

int main() {
  cin >> h >> w;
  a.resize(h);
  for(int i = 0; i < h; ++i) cin >> a[i];
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dist.assign(h, vector<vector<vector<long long>>>(
                     w, vector<vector<long long>>(
                            4, vector<long long>(n, inf))));
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      if(a[i][j] == 's') {
        sx = i;
        sy = j;
        a[i][j] = '.';
      }
      else if(a[i][j] == 'g') {
        gx = i;
        gy = j;
        a[i][j] = '.';
      }
  memo.assign(n, 0);
  stack<int> st;
  for(int i = 0; i < n; ++i) {
    memo[i] = i + 1;
    if(s[i] == '[' || s[i] == '{') st.push(i);
    if(s[i] == ']') {
      memo[st.top()] = i + 1;
      st.pop();
    }
    if(s[i] == '}') {
      memo[st.top()] = i + 1;
      memo[i] = st.top();
      st.pop();
    }
  }
  data now = {sx, sy, 3, 0, 0};
  while(now.c < n &&
        now.dis < dist[now.x][now.y][now.d][now.c]) {
    dist[now.x][now.y][now.d][now.c] = now.dis;
    data nextp = now;
    if(s[now.c] == ']' || s[now.c] == '}') {
      now.c = memo[now.c];
      continue;
    }
    long long com = move_to_int(s[now.c]);
    if(com == -1) {
      bool neg = 0, comres = 0;
      ++nextp.c;
      com = c_to_int(s[nextp.c]);
      if(com == 6) {
        neg = 1;
        com = c_to_int(s[++nextp.c]);
        assert(com >= 0 && com < 6);
      }
      if(com < 4)
        comres = com == nextp.d;
      else if(com == 4)
        comres = !isvalid(nextp);
      else
        comres = 1;
      comres ^= neg;
      if(comres) {
        ++nextp.c;
        now = nextp;
      }
      else
        now.c = memo[now.c];
      continue;
    }
    if(com <= 1) {
      if(com == 1) (nextp.d += 2) %= 4;
      if(isvalid(nextp)) {
        nextp.x += dir[nextp.d];
        nextp.y += dir[1 ^ nextp.d];
      }
      if(com == 1) (nextp.d += 2) %= 4;
    }
    else if(com == 2)
      (nextp.d += 3) %= 4;
    else
      (nextp.d += 1) %= 4;
    ++nextp.dis;
    nextp.c = memo[now.c];
    now = nextp;
  }
  long long res = inf;
  for(int i = 0; i < 4; ++i)
    for(int j = 0; j < n; ++j)
      res = min(res, dist[gx][gy][i][j]);
  if(res == inf) return -1;
  return res;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

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

    while(!isPrime(x))
        x++;

    cout << x;

    return 0;
}


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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

array<int, 100000> A = {};

int main()
{
	fastIOS();

	string c;
	cin >> c;

	if (c == "a")
		cout << "vowel" << "\n";
	else if (c == "e")
		cout << "vowel" << "\n";
	else if (c == "i")
		cout << "vowel" << "\n";
	else if (c == "o")
		cout << "vowel" << "\n";
	else if (c == "u")
		cout << "vowel" << "\n";
	else
		cout << "consonant" << "\n";
}

Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  var list = [];
  var output = "Yes";
  for(var i = 1; i <= 9; i++){
    for(var j = 1; j <= 9; j++){
      list.push(i*j);
    }
  }
  if(list.indexOf(input) == -1){
     output = "No";
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 11468
N, M, Q = map(int, input().split(" "))
abcd = []
for i in range(Q):
    abcd.append(list(map(int, input().split(" "))))
A_s_cand = []

for i_1 in range(1, M + 1):
    for i_2 in range(i_1, M + 1):
        for i_3 in range(i_2, M + 1):
            for i_4 in range(i_3, M + 1):
                for i_5 in range(i_4, M + 1):
                    for i_6 in range(i_5, M + 1):
                        for i_7 in range(i_6, M + 1):
                            for i_8 in range(i_7, M + 1):
                                for i_9 in range(i_8, M + 1):
                                    for i_10 in range(i_9, M + 1):
                                        A_s_cand.append([i_1, i_2,i_3,i_4,i_5,i_6,i_7,i_8,i_9,i_10])
                                        
                                        
A_s = []
for a in A_s_cand:
    A_s.append(a[:N])

ans_cand = []
for a in A_s:
    ans = 0
    if len(a) <= N:
        for i in abcd:
            if a[i[1] - 1] == a[i[0] - 1] + i[2]:
                ans += i[3]
        ans_cand.append(ans)

print(max(ans_cand))
    

Measured memory_bytes: 40408
/*
 * AtCoder Beginner Contest 161 C - Replacing Integer
 *
 * Time: 1ms
 * Memory: 256KB
 *
 * Author: DragonLee
 */

#include <iostream>
#include <cmath>

using namespace std;
typedef long long LL;

int main() {
    LL N, K;
    cin >> N >> K;
    cout << min(N % K, K - N % K) << endl;
    return 0;
}

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

int main() {
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n = s.length(); 
	if(n>k){
    char arr[n + 1]; 
  
    strcpy(arr, s.c_str()); 
    
    for(int i=0;i<k;i++)
    cout<<arr[i];
    
    cout<<"...";
	}
	else
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	ll n,w,p;
	while(scanf("%lld%lld%lld",&n,&w,&p),n){
		ll s=0,d;
		rep(i,0,n){
			ll t;
			scanf("%lld",&t);
			s+=t;
			if(i+1==w)d=t;
		}
		printf("%lld\n",d?s*(100-p)/d:0);
	}
}


Measured memory_bytes: 2032
DIC_TYPE = {"S":0, "H":1, "C":2, "D":3}
TRUMP = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
         [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
         [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
         [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]


n = int(input())
for _ in range(n):
    egara, number = input().split()
    TRUMP[DIC_TYPE[egara]].remove(int(number))

# ↑削除 ↓表示

for key, value in DIC_TYPE.items():
    for i in range(len(TRUMP[value])):
        print( key + " " + str(TRUMP[value][i]) )



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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

string s;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    if (n == 2) {
        if (s[0] == s[1]) {
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    bool ok = false;
    rep(i, n - 2) {
        int cnt[26] = {};
        cnt[s[i] - 'a']++;
        cnt[s[i + 1] - 'a']++;
        cnt[s[i + 2] - 'a']++;
        rep(j, 26) {
            if (cnt[j] >= 2) {
                ok = true;
                break;
            }
        }
        if (ok) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}


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

using namespace std;

int main( )
{	
    int n;
    int maxProfit = 1-1000000000;
    int Ri = 2000000000;
   
    cin>>n;
    
    vector<int> R(n);
    vector<int>::iterator itr = R.begin( );
    vector<int>::iterator itrE = R.end( );
    
    for( ; itr!=itrE; itr++ ) {
    	cin>>*itr;
    }
    itr = R.begin( );
    for( ; itr!=itrE; itr++ ) {
        if( maxProfit < *itr - Ri ) {
       		maxProfit = *itr - Ri;
       	}
       	if( *itr < Ri ) {
    		Ri = *itr;
    	}
    }    

    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1796
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if a == usize::default() {
        b
    } else {
        gcd(b % a, a)
    }
}

fn prime_fact(m: usize) -> BTreeMap<usize, usize> {
#[doc = "O(sqrt(m))"]
    let mut m = m;
    let mx = (m as f64).sqrt() as usize;
    let mut map = BTreeMap::new();
    for i in 2..mx + 1 {
        while m % i == 0 {
            m /= i;
            *map.entry(i).or_insert(0) += 1;
        }
    }
    if m > 1 {
        map.insert(m, 1);
    }
    map
}

fn solve() {
    let (a,b) = get!(usize, usize);

    let e = gcd(a,b);
    let map = prime_fact(e);
    let n = map.len();

    println!("{}", n+1);
}


Measured memory_bytes: 8572
use maplit::hashmap;
use num::{rational::Ratio, One, Signed as _};
use proconio::input;
use std::{
    fmt,
    iter::Product,
    ops::{Add, Mul, Sub},
};

fn main() {
    input! {
        n: usize,
        abs: [(i64, i64); n],
    }

    let mut zeros = 0;
    let mut horz = 0;
    let mut vert = 0;
    let mut others = hashmap!();

    for (a, b) in abs {
        match (a.signum(), b.signum()) {
            (0, 0) => zeros += 1,
            (1, 0) | (-1, 0) => horz += 1,
            (0, 1) | (0, -1) => vert += 1,
            _ => *others.entry(Ratio::new(a, b)).or_insert(0) += 1usize,
        }
    }

    let ans = others
        .iter()
        .map(|(grad, &num1)| {
            let num2 = *others.get(&-grad.recip()).unwrap_or(&0);
            if grad.is_negative() && num2 > 0 {
                ModInt::unchecked(1)
            } else {
                xor_combinations(num1, num2)
            }
        })
        .product::<ModInt>()
        * xor_combinations(horz, vert)
        + ModInt::unchecked(zeros)
        - ModInt::unchecked(1);
    println!("{}", ans);
}

fn xor_combinations(a: usize, b: usize) -> ModInt {
    return pow2(a) + pow2(b) - ModInt::unchecked(1);

    fn pow2(exp: usize) -> ModInt {
        num::pow(ModInt::unchecked(2), exp)
    }
}

const P: usize = 1_000_000_007;

#[derive(Clone, Copy, Debug)]
struct ModInt {
    repr: usize,
}

impl ModInt {
    fn new(val: usize) -> Self {
        Self { repr: val % P }
    }

    fn unchecked(repr: usize) -> Self {
        Self { repr }
    }
}

impl One for ModInt {
    fn one() -> Self {
        Self::unchecked(1)
    }
}

impl fmt::Display for ModInt {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt::Display::fmt(&self.repr, fmt)
    }
}

impl Add for ModInt {
    type Output = Self;

    fn add(self, rhs: Self) -> Self {
        Self::new(self.repr + rhs.repr)
    }
}

impl Sub for ModInt {
    type Output = Self;

    fn sub(self, rhs: Self) -> Self {
        Self::new(P + self.repr - rhs.repr)
    }
}

impl Mul for ModInt {
    type Output = Self;

    fn mul(self, rhs: Self) -> Self {
        Self::new(self.repr * rhs.repr)
    }
}

impl Product for ModInt {
    fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
        iter.fold(Self::unchecked(1), Mul::mul)
    }
}


Measured memory_bytes: 22336
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    ll res = 0;
    FOR(i, 1, N + 1) {
        res += (ll)i * (N - i + 1);
    }
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        res -= (ll)u * (N - v + 1);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 1234;
char s[MAXN];
int maze[MAXN][MAXN];
int lvl[MAXN][MAXN];
int sx[4] = {-1, 1, 0, 0}, sy[4] = {0, 0, 1, -1};

struct node {
    int x, y, val;
    node(int _x, int _y, int _val) : x(_x), y(_y), val(_val) {}
    bool operator < (const node &a) const {
        return val < a.val;
    }
};

bool check(int x, int y, int H, int W) {
    if (x < 0 || y < 0 || x > H || y > W)
        return 0;
    return maze[x][y];
}

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    int ch, cw, dh, dw;
    scanf("%d %d", &ch, &cw);
    scanf("%d %d", &dh, &dw);
    for (int i = 1; i <= H; i++) {
        scanf("%s", s + 1);
        for (int j = 1; j <= W; j++) {
            lvl[i][j] = -1;
            if (s[j] == '.') maze[i][j] = 1;

        }
    }
    deque<node> pq;
    pq.push_front(node(ch, cw, 0));
    while (!pq.empty()) {
        auto cur = pq.front();
        pq.pop_front();
        if (lvl[cur.x][cur.y] != -1 && lvl[cur.x][cur.y] <= cur.val) continue;
        lvl[cur.x][cur.y] = cur.val;
        for (int i = 0; i < 4; i++) {
            int xx = cur.x + sx[i], yy = cur.y + sy[i];
            if (check(xx, yy, H, W))
                pq.push_front(node(xx, yy, cur.val));
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int xx = cur.x + i, yy = cur.y + j;
                if (check(xx, yy, H, W))
                    pq.push_back(node(xx, yy, cur.val + 1));
            }
        }
    }
    printf("%d\n", lvl[dh][dw]);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 14656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) (((1+x)*x)/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}

ll modpow(ll a, ll n, ll mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll com(ll n, ll r){
    ll res = 1;
    for(int k=1;k<=r;k++){
        res = res * (n-(k-1)) % MOD1;
        res = res * modinv(k, MOD1) % MOD1;
    }
    return res;
}

ll per(ll n, ll r){
    ll res = 1;
    for(int k=1;k<=r;k++){
        res = res * (n-(k-1)) % MOD1;
    }
    return res;
}

ll fac(ll n){
    return per(n, n);
}
int main(void){
  initialize();
  ll n,m,i,j,k,mmin,mmax,in,ax;
  ll result=0;
  int a[LIMIT2]={0};
  int b[LIMIT1]={0};
  char s[LIMIT1];

  scanf("%lld %lld",&n,&k);
  mmin=0;
  mmax=n;
  in=0;
  ax=n;
  for(i=1;i<=n+1;i++){
    if(i>=k){
      result += mmax-mmin+1;
      result %= MOD1;
    }
    in++;
    ax--;
    mmin+=in;
    mmax+=ax;
  }
  printf("%lld",result);
  
  return 0;
}



Measured memory_bytes: 1732
#define M_PI 3.14159265359
#include <math.h>
#include <stdio.h>


int main(void){
    // Your code here!
    int a,b,x;
    scanf("%d %d %d\n", &a, &b, &x);
    if(a*a*b/2 >= x)
        printf("%.7lf\n", atan((double)a*b*b/(2*x))*180/M_PI);
    else
        printf("%.7lf\n", atan(2*((double)a*a*b-x)/(a*a*a))*180/M_PI);
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}


int main()
{
    int n = 1;
    int L;
    cin >> L;
    L--;
    vector<int> A;
    vector<int> B;
    vector<int> C;
    vector<pair<int,int>> need;
    while(L > 3){
        int d = (L+1)/2;
        A.PB(n);A.PB(n);
        B.PB(n+1);B.PB(n+1);
        C.PB(d);C.PB(0);
        if(L%2 == 0){
            need.PB(make_pair(n,L));
            d++;
        }
        L-=d;
        n++;
    }

    if(L == 3){
        A.PB(n);A.PB(n);A.PB(n);A.PB(n);
        B.PB(n+1);B.PB(n+1);B.PB(n+1);B.PB(n+1);
        C.PB(3);C.PB(2);C.PB(1);C.PB(0);
    }
    else if(L == 2){
        A.PB(n);A.PB(n);A.PB(n);
        B.PB(n+1);B.PB(n+1);B.PB(n+1);
        C.PB(2);C.PB(1);C.PB(0);
    }
    else if(L == 1){
        A.PB(n);A.PB(n);
        B.PB(n+1);B.PB(n+1);
        C.PB(1);C.PB(0);

    }
    else{
        while(true);
    }
    printf("%d %d\n",n+1,(int)(A.size()+need.size()));
    _for(i,0,A.size()){
        printf("%d %d %d\n",A[i],B[i],C[i]);
    }
    _for(i,0,need.size()){
        printf("%d %d %d\n",need[i].first,n+1,need[i].second);
    }
    return 0;
}


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

pair <int ,int> p[100000];

bool cmp(pair <int ,int> a ,pair <int ,int> b)
	{
		return a.second<b.second ;
	}

void initialize(int t)
	{
	for(int i=1 ;i<=t ;i++)
		p[i-1].first=i ;
	} 
int main()
	{
	int n ,ans ;
	cin>>n ;
	initialize(n) ;
	for(int i=0 ;i<n ;i++)
		cin>>p[i].second ;
	sort(p ,p+n ,cmp) ;
	for(int j=0 ;j<n ;j++)
		cout<<p[j].first<<" " ;
	cout<<endl ;
	} 

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,n = 0;
  char w[11], t[1001];
 
  scanf("%s", w);
 
  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);
 
  printf("%d\n",n);
 
  return 0;
}


Measured memory_bytes: 2096
def bfs(p):
    stack=[p]
    check = [-1]*n
    check[p] = 0
    while len(stack):
        v = stack.pop()
        for i in root[v]:
            if check[i] == -1:
                check[i]=check[v]+1
                stack.append(i)
    return check
    


n,u,v = map(int,input().split())
u -= 1
v -= 1
root = [[] for i in range(n)]
for _ in range(n-1):
    a, b = (int(x) for x in input().split())
    root[b-1].append(a-1)
    root[a-1].append(b-1)

move_count_u = bfs(u)
move_count_v = bfs(v)

ans = 0

for i in range(n):
    if move_count_u[i] < move_count_v[i]:
        ans = max(move_count_v[i]-1, ans)
print(ans)

Measured memory_bytes: 67308
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
    fast;

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n;
    cin >> n;
    if(n % 2 == 1) {
        cout << 0 << "\n";
        return 0;
    }
        ll ans = 0;
        ll div = 5;
        while(n / div > 0) {
            if(n % 2 == 0) {
                ans += (n/div)/2;
            }
            else {
                ans += ((n/div)+1)/2;
            }
            div *= 5;
        }
    cout << ans << "\n";

    time_p=clock()-time_p;
    cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
 public static void main(String[] args){
   Scanner s = new Scanner(System.in);
   int a = s.nextInt();
   int b = s.nextInt();
   int t = s.nextInt();
   
   int r = t/a;
   System.out.print(r*b);
 }
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll N, K;
    cin >> N >> K;
    N %= K;
    cout << min(N, K - N) << endl;
}

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

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

using namespace std;

signed main() {
    fast;
    //freopen("input.txt", "r", stdin);
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll d = abs(a-b);
    if(d%2 == 0){
        cout << d/2 << endl;
        exit(0);
    }
    ll f = (a-1) + (d+1)/2;
    ll s = (n-b) + (d+1)/2;
    cout << min(f,s) << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {

  int n;
  cin >> n;
  vector<int> costs( n );
  for ( int i = 0; i < n; i++ ) {
    costs[i] = 0;
  }
  int lim = n * (n - 1) / 2;
  for ( int i = 0; i < lim; i++ ) {
    int a, b, p, q;
    cin >> a >> b >> p >> q;
    if (p < q) {
      costs[b - 1] += 3;
    } else if (p > q) {
      costs[a - 1] += 3;
    } else {
      costs[a - 1] += 1;
      costs[b - 1] += 1;
    }
  }
  for ( const int cost : costs ) {
    int count = 1;
    for ( const int val : costs ) {
      if ( val > cost ) count++;
    }
    cout << count << endl; 
  }
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int N,M,T[110],P,X,sum = 0;

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> T[i]; sum += T[i];
  }
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> P >> X;
    cout << sum-(T[--P]-X) << endl;
  }
}

Measured memory_bytes: 256