akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;






signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for(auto &x:s)
        {
            if(x=='?')
            {
                x='D';
            }
            cout<<x;
        }
        cout<<endl;
    }
    return 0;
}


















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

int main(){

    while(1){
        int n, m; cin >> n >> m;
        if(!n) break;
        vector<int> max_score(n, 0);
        vector<int> min_score(n, 0);

        for(int i = 0; i < m; i++){
            int s, k; cin >> s >> k;
            vector<int> c(k);
            for(int j = 0; j < k; j++){
                cin >> c[j];
                c[j]--;
                max_score[c[j]] += s;
            }
            
            if(k == 1){
                min_score[c[0]] += s;
            }
        }

        int ans = 0;

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

                ans = max(ans, max_score[i] - min_score[j] + 1);
            }
        }
    
    cout << ans << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[s.size() - 1]) {
        if (s.size() % 2 == 0) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {
        if (s.size() % 2 == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }
}

Measured memory_bytes: 512
let quick_sort a cmp =
  let rec partition p r =
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec exchange i j =
      if j = r then (swap (i + 1) r; i + 1)
      else if cmp a.(j) a.(r) <= 0 then (swap (i + 1) j; exchange (i + 1) (j + 1))
      else exchange i (j + 1)
    in exchange (p - 1) p
  and doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let calc_cost a n =
  let b = Array.copy a in
  quick_sort b compare;
  let min_a = b.(0) in
  let max_a = b.(n - 1) in
  let b_i = Array.make (max_a + 1) 0 in
  Array.iteri (fun i e -> b_i.(e) <- i) b;
  let v = Array.make n false in
  let rec doit i cost =
    if i = n then cost
    else if v.(i) then doit (i + 1) cost
    else
      let rec aux j ws =
        v.(j) <- true;
        let w = a.(j) in
        if v.(b_i.(w)) then w :: ws
        else aux b_i.(w) (w :: ws)
      in
      let ws = aux i [] in
      let n_w = List.length ws in
      let sum_w = List.fold_left (+) 0 ws in
      let min_w = List.fold_left min max_a ws in
      doit (i + 1) (cost + (min (sum_w + (n_w - 2) * min_w) (sum_w + min_w + (n_w + 1) * min_a)))
  in doit 0 0

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  Printf.printf "%d\n" (calc_cost a n)

Measured memory_bytes: 2924
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n =  sc.nextInt();
    int m =  sc.nextInt();
 	long h[] = new long[n];
 	boolean jud[] = new boolean[n];
 	int c =0;

    for(int i=0;i<n;i++) {
    	h[i] = sc.nextLong();
    	jud[i] = false;
    }

    for(int i=0;i<m;i++) {
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	if(h[a-1]<h[b-1]) {
    		jud[a-1] =true;
    	}
    	else if(h[a-1]>h[b-1]){
    		jud[b-1] =true;
    	}
    	else if(h[a-1]==h[b-1]) {
    		jud[a-1] =true;
    		jud[b-1] =true;
    		}
    }

    for(int i=0;i<n;i++) {
    	if(jud[i]==true) {
    		c++;
    	}
    }
    System.out.println(n-c);
  }
}

Measured memory_bytes: 60128
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var total = 0;

            while (!array.Any(z => z % 2 != 0))
            {
                array = array.Select(x => x / 2).ToArray();
                total++;
            }
            Console.WriteLine(total);
        }
    }
}


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

int main(){
    int N,n,sum=0;
    cin>>N;
    n = N;
    while(N>0){
        sum += N%10;
        N/=10;
    }
    if(n%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
//rohitaas_15
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define int ll
#define um(a,b) unordered_map<a,b>
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
//#define endl "\n"
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
/*ll constructSTUtil(vr v,ll start,ll end,int *st,ll index)
{
	if(start==end)
	{
		st[index]=v[start];
		return st[index];
	}
	ll mid=(start+end)/2;
	st[index]=constructSTUtil(v,start,mid,st,2*index)+constructSTUtil(v,mid+1,end,st,2*index+1);
	return st[index];
}
ll *constructST(vr v,ll n)
{
	ll po=(ll)(ceil(log2(n)));
	ll msize=2*power(2,po)+1;
	vr st[msize];
	constructSTUtil(v,0,n-1,st,1);
	return st;
}*/
ll ask1(ll y)
{
	cout<<1<<" "<<y<<endl;
	ll x;
	cin>>x;
	return x;
}
ll repair()
{
	cout<<2<<endl;
	return 0;
}
bool compare(pair<ll,ll> &a,pair<ll,ll> &b)
{
	return a.second<b.second;
}
signed main()
{
	/*#ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	 #endif
     */
	 /*ll t;
	 cin>>t;
	 while(t--)
	 {
	 	*/
	 	ll s,w;
	 	cin>>s>>w;
	 	if(w>=s)
	 	{
	 		show("unsafe");
	 	}
	 	else
	 	{
	 		show("safe");
	 	}



	
	 	
	 	
	//}
	/*cout<<"Case #"<<cccc-t<<": ";
		cout<<*/

}


Measured memory_bytes: 3632
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 5e5+5; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{
	// FIO;
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	int n,q;
	cin>>n>>q;
	int a[n];
	for(int i = 0; i < n; i++)
		cin>>a[i];
	Query queries[q]; 
	for(int i = 0; i < q; i++){

		cin>>queries[i].l>>queries[i].r;
		queries[i].l--;
		queries[i].r--;
		queries[i].idx = i;
	}
	// int q = sizeof(queries)/sizeof(queries[0]); 
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    str s; cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy";
    }else if(s == "Cloudy"){
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int[] x=new int[3];
x[0]=sc.nextInt();
x[1]=sc.nextInt();
x[2]=sc.nextInt();
Arrays.sort(x);
int temp=2*x[2]-x[1]-x[0];
int ans;
if(temp%2==1){ans=(temp+2)/2+1;}else{ans=temp/2;}
out.println(ans);
}}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

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

        int s = 0;
        int tmp = n;
        for (int i = 0; i < 10; i++) {
            s += tmp % 10;
            tmp /= 10;
        }

        if (n % s == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i + 100*j + 50*k == x) ans++;
      }
    }
  }
  cout << ans << endl;
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n;
    if(n%2){
        cout<<0;
        return 0;
    }
    n/=2;
    int x=5;
    while(n/x){
        ans+=n/x;
        x*=5;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,X=0;
    cin>>N;
    int A[N+1],ans[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    A[N]=0;
    for(int i=0;i<=N;i++){
        int k=0;
        k=A[i]-A[i-1];
        if(k<0){
            k=k*(-1);
        }
        X=X+k;
    }
    for(int i=0;i<N;i++){
        int a,b,c;
        a=A[i]-A[i-1];
        b=A[i+1]-A[i];
        c=A[i+1]-A[i-1];
        if(a<0){
            a=a*(-1);
        }
        if(b<0){
            b=b*(-1);
        }
        if(c<0){
            c=c*(-1);
        }
        ans[i]=X-a-b+c;
        cout<<ans[i]<<endl;
    }
    
}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int a[5],k;
    for (int i=0;i<5;i++) {
        cin >> a[i];
    }
    cin >> k;

    sort (a,a+5);
    if (a[4]-a[0]>k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

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

using namespace std;

int main(void)
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> l[i];
    }

    int sum = 0;
    int count = 1;
    for (size_t i = 0; i < n; i++)
    {
        sum += l[i];
        if (sum > x)
        {
            break;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
if n%1000==0:
  print(0)
else:
  ans=n//1000
  print((1+ans)*1000-n)

Measured memory_bytes: 65132
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
int n = str.length();
if(str[n-1] == 's'){
	  str+= 'e';
	  str += 's';
	  cout<<str<<endl;
	  return 0;
}
else{
	 str += 's';
	 cout<<str<<endl;
	 return 0;
}
}


Measured memory_bytes: 3664
import java.util.Scanner;
import java.util.ArrayList;
public class Main
{
  public static void main(String args[])
  {
    Scanner input=new Scanner(System.in);
    
    int g=input.nextInt();
    int w=input.nextInt();
    if(g>=1 && g<=100 && w>=0 && w<= (g*g))
    {
      g=g*g;
      w=g-w;
      System.out.println(w);
    }
  }
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

const ll MOD =998244353;
 
// a^n MOD を計算する
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} MOD を計算する
ll modinv(ll a) {
    return modpow(a, MOD - 2);
}

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void comInit()
{
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;

    for(int i=2; i<MAX; i++)
    {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n, int r)
{
    if(n<r)
        return 0;
    if(n<0 || r<0)
        return 0;
    
    return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}


int N, M ,K;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    comInit();
    cin >> N >> M >> K;

    ll ans = 0;
    rep(i, K+1)
    {
        ans+=(com(N-1, i)*(M*modpow(M-1, N-i-1)%MOD)%MOD);
        ans%=MOD;
    }

    cout << ans%MOD << endl;
 

 

 

    return 0;
}



Measured memory_bytes: 15612
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull B=5575777;
int K;
 
int n,m;
char a[5000];
char b[5000];
ull po[5000];

int main(){
  po[0]=1;
  for(int i=1;i<5000;i++)po[i]=po[i-1]*B;
   
  scanf("%s %s",a,b);
  n=strlen(a);
  m=strlen(b);
 
  int ans=0;
  for(int K=1;K<=min(n,m);K++){

    unordered_set< ull > st;
    ull key,d;
     
    key=0,d=1;
    for(int i=0;i<n;i++){
      key+= po[ (int)a[i] ];
      if(i-K>=0){
        key-= po[ (int)a[i-K] ];
      }else d*=B;
      if(i>=K-1)st.insert(key);
    }
     
    key=0,d=1;
    for(int i=0;i<m;i++){
      key+= po[ (int)b[i] ];
      if(i-K>=0){
        key-= po[ (int)b[i-K] ];
      }else d*=B;
      
      if(i>=K-1)
        if( st.count(key)>0 )
          ans=K;
    }
     
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3408
import java.io.*;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Pattern p=Pattern.compile("the|this|that");
        String str;
        try{
            while((str=br.readLine())!=null){
                char[] ch=str.toCharArray();
                for(int j=0;!p.matcher(str).find()&&j<26;j++){
                    for(int i=0;i<ch.length;i++){
                        if('a'<=ch[i]&&ch[i]<'z'){
                            ch[i]++;
                        }else if(ch[i]=='z'){
                            ch[i]='a';
                        }
                    }
                    if(p.matcher(String.valueOf(ch)).find()){
                        break;
                    }
                }
                System.out.println(ch);
            }
        }catch(Exception e){
        }
    }
}

Measured memory_bytes: 17896
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

const int N=3e5+5;
int n,a[N],calc[N],tl,ans;
map<int,int> M;

int ask(int x)
{
	int i;
	for(i=30;~i;--i)
		if(x&(1<<i))
			break;
	return (1<<i+1)-x;
}

void cc()
{
	int i,l=1;
	M.clear();
	for(i=1;i<=tl;++i) ++M[calc[i]];
	sort(calc+1,calc+tl+1);
	for(i=tl;i;--i)
	{
		if(!M[calc[i]]) continue;
		int mx=ask(calc[i]);
		if(mx!=calc[i])
		{
			if(M[mx])
				--M[calc[i]],--M[mx],++ans;
		}
		else
		{
			if(M[mx]>1)
				M[mx]-=2,++ans;
		}
	}
}

bool cmp(int x,int y)
{
	return (x&1)<(y&1);
}
void init()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	while(n)
	{
		tl=0;
		sort(a+1,a+n+1,cmp);
		for(i=n;i;--i)
		{
			if(!(a[i]&1)) break;
			calc[++tl]=a[i];
		}
		cc();n=i;
		for(i=1;i<=n;++i) a[i]>>=1;
	}
	printf("%d\n",ans);
}

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

Measured memory_bytes: 10752
import java.util.*;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        try{

            while (sc.hasNext()) {

                String str = sc.nextLine();
                Deque<Integer> deq = new ArrayDeque<Integer>();

                String[] s_array = str.split(" ");

                if (s_array.length > 2) {

                    for (int i = 0; i < s_array.length; i++) {

                        if (s_array[i].toString().equals("*")) {

                            deq.addFirst((deq.removeFirst() * deq.removeFirst()));

                        } else if (s_array[i].toString().equals("/")) {

                            int x = deq.removeFirst(), y = deq.removeFirst();
                            deq.addFirst(y/x);

                        } else if (s_array[i].toString().equals("+")) {

                            deq.addFirst((deq.removeFirst() + deq.removeFirst()));

                        } else if (s_array[i].toString().equals("-")) {

                            int x = deq.removeFirst(), y = deq.removeFirst();
                            deq.addFirst(y-x);

                        } else {

                            deq.addFirst(Integer.valueOf(s_array[i].toString()));

                        }
                    }

                    System.out.printf("%d\r\n", deq.removeFirst());

                }

            }

        } finally {

            sc.close();

        }

    }
}


Measured memory_bytes: 26252
if __name__ == '__main__':
    # from time import perf_counter
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())

    pow_ = [0] * 31

    # perf = perf_counter()

    x = m
    divisor = 2
    power = 0
    while x % divisor == 0:
        x //= divisor
        power += 1
    if power > 0:
        pow_[power] += 1

    divisor = 3
    while x > 1 and divisor ** 2 <= m:
        power = 0
        while x % divisor == 0:
            x //= divisor
            power += 1
        if power > 0:
            pow_[power] += 1
        divisor += 2
    if x > 1:
        pow_[1] += 1

    # print('prime_factorization', perf_counter() - perf)
    # print(pow_)

    # def prime_factorization(n):
    #     i = 2
    #     res = []
    #     while i * i <= n:
    #         cnt = 0
    #         while n % i == 0:
    #             n /= i
    #             cnt += 1
    #         if cnt > 0:
    #             res.append(cnt)
    #         i += 1
    #     if n > 1:
    #         res.append(1)
    #     return res

    # perf = perf_counter()
    # res = prime_factorization(m)
    # print('prime_factorization', perf_counter() - perf)
    # print(res)

    # perf = perf_counter()

    ans = 1
    t = 1
    d = 1
    for power, cnt in enumerate(pow_[1:], 1):
        # 1 <= power <= 30
        t = t * (n - 1 + power) % mod
        d = d * pow(power, mod - 2, mod) % mod
        # print(power, cnt, ans, t, d)
        ans = ans * pow(t * d % mod, cnt, mod) % mod
        # for _ in range(cnt):
        #     ans = ans * t * d % mod
    print(ans)
    # print('calculation', perf_counter() - perf)

# TLEの原因は、巨大素数の判定
# divisor ** 2 <= m
# で探索を打ち切って、m>1なら巨大な素数
# 冪数をリストにappendする方式の方が数ms速いが、
# 冪数indexに該当素数数を加算していくと
# 最後の計算で、同じ冪数を一括計算できるから、大差ないか


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

ll M;

ll f(ll x) {
    return (x*x)%M;
}

pii floyd(int x0) {
    int t = f(x0), h = f(f(x0));
    while(t != h) {
        t = f(t);
        h = f(f(h));
    }
    int mu = 0; h = x0;
    while(t != h) {
        t = f(t);
        h = f(h);
        mu++;
    }
    int lambda = 1; h = f(t);
    while(t != h) {
        h = f(h);
        lambda++;
    }
    return mp(mu, lambda);
}

int main() {
    ll N, X;
    scanf("%lld %lld %lld", &N, &X, &M);
    pii tmp = floyd(X);
    int mu = tmp.first, lambda = tmp.second;

    ll ans = 0;
    ll x = X;
    REP(i, mu) {
        if(N == 0) break;
        ans += x;
        x = f(x);
        N--;
    }

    vector<ll> data, acc;
    data.pb(0);
    acc.pb(0);
    REP(i, lambda) {
        data.pb(x);
        acc.pb(acc.back() + data.back());
        x = f(x);
    }

    ll c = N / lambda;
    N %= lambda;
    ans += c * acc[lambda] + acc[N];
    printf("%lld\n", ans);

}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main()
{
	LL n;
	cin >> n;

	LL ans = 0;
	for (LL i = 1; i <= n; ++i) {
		LL k = n/i;
		LL term = k*(k+1)/2 * i;
		ans  += term;
	}
	cout << ans << "\n";

}



Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string S){
    REP(i, S.length()) S[i] = 'x';
    cout<<S<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
# 末尾3つの塩基配列を4進数で表記して記録する。

def base_10to(n,m):
    if (n//m):
        return base_10to(n//m, m) + str(n%m)
    return str(n%m)


def base_10from(n,m):
    a = 0
    for i in range(len(n)):
        a*=m
        a+=int(n[i])
    return a


n = int(input())

dp = [[0 for i in range(64)] for j in range(n)]


for i in range(64):
    a = base_10to(i,4)
    a= a.zfill(3)
    if a=='012' or a=='102' or a=='021':
        dp[2][i]=0
    else:
        dp[2][i]=1

for i in range(2,n-1):
    for j in range(64):
        a = base_10to(j, 4)
        a = a.zfill(3)
        if a[1:]=='02':
            for k in [0,2,3]:
                dp[i+1][base_10from(a[1:]+str(k),4)] += dp[i][j]
        elif a[1:]=='10' or a[1:]=='01' or a[:2]=='01' or (a[0]=='0' and a[2]=='1'):
            for k in [0,1,3]:
                dp[i+1][base_10from(a[1:]+str(k),4)] += dp[i][j]
        else:
            for k in [0,1,2,3]:
                dp[i+1][base_10from(a[1:]+str(k),4)] += dp[i][j]

print(sum(dp[-1])%(10**9+7))

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 2123;
const ll MOD = 998244353;

char s[maxn];
ll dp[maxn][maxn], fac[maxn], ifac[maxn];
int avail[2][maxn];

ll inv(ll a) {
    ll ret = 1, pw = MOD - 2;
    while (pw) {
        if (pw & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        pw >>= 1;
    }
    return ret;
}

ll C(int n, int m) {
    if (m < 0 || m > n) return 0;
    return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    fac[0] = fac[1] = 1;
    ifac[0] = ifac[1] = 1;
    FOR(i, 2, n) fac[i] = fac[i - 1] * i % MOD;
    FOR(i, 2, n) ifac[i] = inv(fac[i]);
    FOR(i, 1, n) {
        avail[0][i] = avail[0][i - 1];
        avail[1][i] = avail[1][i - 1];
        if (s[i] == '0') avail[0][i] += 2;
        else if (s[i] == '1') avail[0][i]++, avail[1][i]++;
        else avail[1][i] += 2;
    }
    dp[0][0] = 1;
    REP(i, n) REP(j, min(avail[0][i] + 1, i + 1)) {
            int used[2] = {j, i - j};
            if (used[1] > avail[1][i]) continue;
            if (avail[0][i + 1] > used[0]) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
            if (avail[1][i + 1] > used[1]) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        }
    ll ans = 0;
    REP(i, avail[0][n] + 1) {
        int rem[2] = {avail[0][n] - i, avail[1][n] - n + i};
        ll way = dp[n][i] * C(n, rem[0]) % MOD;
        ans = (ans + way) % MOD;
    }
    printf("%lld", ans);
}

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

int main(){
  long int k,n;
  cin >> k >> n;
  vector<long int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int max_d = 0;
  for(int i=0;i<n;i++){
    int d=0;
    if(i == n-1) d =k-a[i]+a[0];
    else d=(a[i+1])-a[i];
    max_d=max(max_d,d);
  }
  int ans = k - (max_d);
  cout << ans << endl;
  return 0;
}//答え移した

Measured memory_bytes: 1792
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

ans1 = (N //(A+B))*A
mod = (N%(A+B))
ans2 = min(mod, A)

print(ans1+ans2)

Measured memory_bytes: 5940
antenna = []
N = 5
for _ in range(N):
    antenna.append(int(input()))
k = int(input())
ans = 'Yay!'
for i in range(N - 1):
    for j in range(1, N):
        if antenna[j] - antenna[i] > k:
            ans = ':('
            break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>


int main()
{
	using namespace std;
	const int N = 3;
	string ss;
	cin >> ss;
	int result = 0;
	for (int i = 0; i < ss.size(); i++) {
		if (ss[i] == 'o') {
			result++;
		}
	}
	cout << 700 + 100 * result << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader scan = new FastReader();
		String s = "ATCG";
		int curr = 0, max = 0;
		char[] a = scan.next().toCharArray();
		for(char c : a) {
			if(s.contains(c+"")) max = Math.max(max, ++curr);
			else curr = 0;
		}
		System.out.println(max);
	}
	
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


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

    int sum = 0;
    REP(i,N){
        sum += L+i;
    }

    int R = L+N-1;

    if(L>0) cout << sum-L << endl;
    else if(L<=0 && 0<=R) cout << sum << endl;
    else cout << sum-R << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define reg register
typedef long long ll;
inline int read(){
    reg int x=0,f=1;reg char ch=getchar();
    for(;!isdigit(ch);f=ch=='-'?-1:1,ch=getchar());
    for(;isdigit(ch);x=x*10+(ch^48),ch=getchar());
    return x*f;
}
const int MN=1e5+5;
struct seg{int l,r,id;}a[MN],b[MN];
inline bool cmp1(seg a,seg b){return a.r==b.r?a.l<b.l:a.r<b.r;}
inline bool cmp2(seg a,seg b){return a.l==b.l?a.r<b.r:a.l<b.l;}
int n;
bool vis[MN];
ll ans1,ans2;
int main(){
	n=read();
	for(reg int i=1;i<=n;i++)a[i].l=read(),a[i].r=read(),a[i].id=i,b[i]=a[i];
	std::sort(a+1,a+1+n,cmp1);std::sort(b+1,b+1+n,cmp2);
	reg int lt=1,rt=n,f=0,pos=0;
	while(lt<=rt){
		while(vis[a[lt].id])lt++;while(vis[a[rt].id])rt--;
		if(f){
			if(a[lt].r<pos)ans1+=pos-a[lt].r,pos=a[lt].r;vis[a[lt++].id]=1;
		}
		else{
			if(b[rt].l>pos)ans1+=b[rt].l-pos,pos=b[rt].l;vis[a[rt--].id]=1;
		}
		f^=1;
	}
	ans1+=std::abs(pos);memset(vis,pos=0,sizeof(vis));f=lt=1;rt=n;
	while(lt<=rt){
		while(vis[a[lt].id])lt++;while(vis[a[rt].id])rt--;
		if(f){
			if(a[lt].r<pos)ans2+=pos-a[lt].r,pos=a[lt].r;vis[a[lt++].id]=1;
		}
		else{
			if(b[rt].l>pos)ans2+=b[rt].l-pos,pos=b[rt].l;vis[a[rt--].id]=1;
		}
		f^=1;
	}
	printf("%lld\n",std::max(ans1,ans2+std::abs(pos)));
    return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 10
#define M 1020
using namespace std;

char a[N][M];
int b[N], c[N];

int main(void)
{
    int n, m, k;
    int i, j, s, o, p, v;

    scanf("%d %d %d", &n, &m, &k);
    for(i = 0; i < n; i ++)
        scanf("%s", a[i]);

    for(s = 0, o = n * m; s < (1 << (n - 1)); s ++)
    {
        for(i = p = 0; i < n; i ++)
        {
            b[i] = p;
            c[i] = 0;
            if(s & (1 << i))
                p ++;
        }
        p ++;

        for(j = v = 0; j < m; j ++)
        {
            for(i = 0; i < n; i ++)
                if(a[i][j] == '1')
                    c[b[i]] ++;
            // for(i=0;i<p;i++)cout<<c[i]<<' ';cout<<endl;
            for(i = 0; i < p; i ++)
                if(c[i] > k)
                {
                    v ++;
                    for(i = 0; i < p; i ++)
                        c[i] = 0;
                    for(i = 0; i < n; i ++)
                        if(a[i][j] == '1')
                            c[b[i]] ++;
                    for(i = 0; i < p; i ++)
                        if(c[i] > k)
                            goto h;
                    break;
                }
        }
        o = min(o, v + __builtin_popcount(s));
        h:;
    }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100], b[100100];

vector<int> G[100100];

int calc(int v, int prev) {
    int res = 0;
    int zero = 0;
    for (int u : G[v]) {
        if (u == prev) continue;
        int ret = calc(u, v);
        res += ret;
        if (ret == 0)
            zero++;
    }
    res += max(0, zero-1);
    return res;
}

int solve() {
    for (int i = 0; i < n-1; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    int s = -1;
    for (int i = 0; i < n; i++) {
        if (G[i].size() >= 3) {
            s = i;
            break;
        }
    }
    if (s < 0)
        return 1;

    return calc(s, -1);
}

void input() {
    cin >> n;
    for (int i = 0; i < n-1; i++) cin >> a[i] >> b[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 13168
n,m = (int(i) for i in input().split())
par,rank,q = [i for i in range(n+1)],[0 for i in range(n+1)],set()
def root(x):
	if par[x]!=x: par[x] = root(par[x])
	return par[x]
def unite(x,y):
	x2,y2 = root(x),root(y)
	if x2!=y2:
		if rank[x2]<rank[y2]: par[x2] = y2
		else: par[y2] = x2
		if rank[x2]==rank[y2]: rank[x2]+=1
for i in range(m):
    x,y,z = (int(i) for i in input().split())
    unite(x,y)
for i in range(1,n+1): q.add(root(i))
print(len(q))

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

if __name__=='__main__':
  a, b ,c= map(int, input().strip().split())
  if a>c:
    a=a-c
  else:
    b=b+a-c
    a=0
    if b<0:
      b=0
  
  print(a,b)

Measured memory_bytes: 3060
left, right = map(int, input().split())
mod = 2019

min_mod = float("inf")
for i in range(left, min(right, left + mod)):
    for j in range(i + 1, min(right + 1, i + 1 + mod)):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)


Measured memory_bytes: 3064
// E - Handshake

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int MOD = 1e9 + 7;

const ll MAX_N = 100001;
const ll MAX_A = 100000;

ll A[MAX_N];
ll A_csum[MAX_N]; // 値が大きい側からの累積和
ll N, M;

// t <= Ax + Ay となる組み合わせの数を求める
// Ax = A[i]ごとに二分探索で数を求めて合計する -> O(NlogN)

ll get_n_comb(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (N - idx);
	}

	//cout << "t=" << t << " -> comb=" << result << endl;

	return result;
}

// t <= Ax + Ay となる組み合わせの数がk以上となる最大のtを求める
ll get_max_t(ll k) {
	ll ok = 0;
	ll ng = 2 * MAX_A + 1;

	while(ng - ok > 1) {
		ll trying = (ok + ng) / 2;

		if (get_n_comb(trying) >= k) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

// t <= Ax + Ay となる組み合わせについて総和を求める
ll get_sum_ge(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (A[i] * (N - idx)) + A_csum[idx]; // Axの和 + Ayの和
	}

	//cout << "t=" << t << " sum=" << result << endl; // **** debug ****

	return result;
}

int main() {

	cin >> N >> M;

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

	sort(A, A+N);

	// 値が大きい側からの累積和を作成（get_sum_ge()で用いる）
	A_csum[N-1] = A[N-1];
	for (int i=N-2; i>=0; i--) {
		A_csum[i] = A[i] + A_csum[i+1];
	}

	// t <= Ax + Ay となる組み合わせの数がM以上となる最大のtを求める
	ll max_t = get_max_t(M);
	//cout << "max_t = " << max_t << endl; // **** debug ****

	// get_sum_ge(t)では t == Ax + Ay となる握手が複数存在する場合に余分な握手が含まれてしまうので
	// （(t == max_t) の和） + （(t >= max_t + 1) の和）で求める
	ll n_max_t = M - get_n_comb(max_t + 1); // t == max_t となる場合の数
	ll ans = (max_t * n_max_t) + get_sum_ge(max_t + 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <algorithm>
#define SENTINEL  2000000000
static const long long MAX = 100000;


typedef struct pp{
    long long A;
    long long B;
}P;

int cnt;
P A[MAX], L[MAX/2 + 2], R[MAX/2 + 2];


void Merge(P A[], long long n, long long left, long long  mid, long long right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].A = R[n2].A = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i].A <= R[j].A)
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void MSort(P A[], long long n, long long left, long long right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        MSort(A, n, left, mid);
        MSort(A, n, mid, right);
        Merge(A, n, left, mid, right);
    }
}

int main()
{
    long long N, M;
    //long long P[MAX];
    scanf("%lld %lld", &N, &M);
    for (int i = 0; i < N; ++i) scanf("%lld %lld", &A[i].A, &A[i].B);

    MSort(A, N, 0, N);
    long long ans = 0;
    long long current = 0;
    long long l = M;

    for (int i = 0; i < N; ++i)
    {
        if (l - A[i].B >= 0LL)
        {
            ans += A[i].A * A[i].B;
            l -= A[i].B;
        }
        else
        {
            ans += A[i].A * l;
            l = 0LL;
        }

        if (l == 0LL) break;

    }

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

Measured memory_bytes: 3328
public class Hello{
    public static void Main(){
        // Your code here!
        string r = System.Console.ReadLine();
        string[] r2 = r.Split(' ');
        int x = int.Parse(r2[0]);
        int y = int.Parse(r2[1]);
        string ans ="";
        if (x>y) ans = "a > b";
        if (x<y) ans = "a < b";
        if (x==y) ans ="a == b";
        System.Console.WriteLine(ans);
    }
}



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

using namespace std;

#define N 1000000
bool t[N+1];

int main(){
	
	for(long i=0;i<N+1;i++){
		t[i]=true;
	}
	t[1]=false;
	
	for(long i=2;i<N+1;i++){
		if(t[i]){
			for(long j=2;j*i<N+1;j++){
				t[i*j]=false;
			}
		}
	}

	while(1){
		long a,d,n;
		cin >> a >> d >> n;
		
		if(a==0) break;
		
		int b=0;
		
		for(double i=0;a<N+1;i++){
			
			if(t[a]){
				b++;
			}
			if(b==n){
				cout << a << endl;
				break;
			}
			a+=d;
		}
	}
	return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007,m;
ll dist(pair<ll,ll> a,pair<ll,ll> b)
{
    ll res;
    res=(a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
    return res;
}
int main(){
    
   ll n,m;
   cin>>n>>m;
   n=ceil((n*1.0)/m);
   cout<<n<<endl;
}


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

using namespace std;

typedef long long LL;


int main() {
    int n; scanf("%d", &n);
    LL A = 1, T = 1;
    for(int i = 0; i<n; ++i) {
        LL a, t;
        scanf("%lld %lld", &a, &t);
        LL k = max((A+a-1)/a, (T+t-1)/t);
        A = k*a;
        T = k*t;
    }
    printf("%lld\n",A+T);
}



Measured memory_bytes: 384
n = int(input())
s = [input() for i in range(n)]

from collections import Counter

cnt = {"AC": 0, "WA": 0, "TLE":0, "RE":0}
for si in s:
    cnt[si] += 1

print("AC x " + str(cnt["AC"]))
print("WA x " + str(cnt["WA"]))
print("TLE x " + str(cnt["TLE"]))
print("RE x " + str(cnt["RE"]))

Measured memory_bytes: 16484