akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	map<int,ll> mp;
	rep(i,n){
		mp[s[i]-'a']++;
	}
	ll ans=1;
	for(auto x:mp){
		ans*=(x.sc+1);
		ans%=MOD;
	}
	cout<<(ans+MOD-1)%MOD<<endl;
}


Measured memory_bytes: 512
listSi = [0,0,0,0]
ic = int(input())
icz = 0
while True:
  icz += 1
  i = input()
  if i == "AC":
    listSi[0] += 1
  elif i == "WA":
    listSi[1] += 1
  elif i == "TLE":
    listSi[2] += 1
  elif i == "RE":
    listSi[3] += 1
  if icz == ic:
    break
print(f"AC x {listSi[0]}")
print(f"WA x {listSi[1]}")
print(f"TLE x {listSi[2]}")
print(f"RE x {listSi[3]}")


Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C;
    cin >> A >> B >> C;
        
    for(int i=1;i<=100;i++){
        if((A*i)%B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    
}

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

int main() {
 int i,j,k,s,g,b,r,n[2],d[2][30],t[2][65537],f[2][65537],a[65537];
 for (i=0;i<65536;i++) { a[i]=0; for (j=1;j<65536;j*=2) a[i]+=(j & i)>0;}
 while(cin >> n[0] >> n[1] && n[0]+n[1]!=0) {
	 for (j=0;j<2;j++) {
	  for (i=0;i<n[j];i++) {
		 for (k=0,s=0;k<16;k++) { cin >> g; if (j==1) g=1-g; s+=g << k;}
		 d[j][i]=s;
	    } 
     }
    for (j=0;j<2;j++) for (i=0;i<65536;i++) {f[j][i]=t[j][i]=-1;} f[0][0]=0; t[0][0]=0; 
    for (i=0,r=0;i<n[0];i++) {
		for (j=0;j<65536;j++) {
		s= j | d[0][i];	  
		if (f[r][j]==i && t[r][j]>t[1-r][s] && t[r][j]>t[r][s]) { t[1-r][s]=t[r][j]; f[1-r][s]=i;}} 
		r=1-r;
		for (j=0;j<65536;j++) {
			if (f[r][j]!=i) continue;
			for (k=0;k<n[1];k++) {
				s=j & d[1][k]; b=a[j]-a[s];
				if (t[r][s]<b+t[r][j] && t[1-r][s]<b+t[r][j]) { f[1-r][s]=i+1; t[1-r][s]=b+t[r][j];}
			}
		}
		r=1-r;
	}
	s=0;
	for (j=0;j<2;j++) for (i=0;i<65535;i++) if (t[j][i]>s) s=t[j][i];
	cout << s << endl;
  }
 return 0;
 } 

Measured memory_bytes: 2440
A,B,C=map(int,input().split())
ms=[0]*B
i=1
ans='NO'
while True:
  m=A*i%B
  if m==C:
    ans='YES'
    break
  else:
    if ms[m]==0:
      ms[m]=1
    else:
      break
  i+=1
  pass
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<queue>
#define MAX 100005
using namespace std;
 
int main(){
  int n, i;
  long long lsum[MAX], rsum[MAX], a[MAX], c, ans = -(1e14 + 5);
  priority_queue<long long> l, r;
  scanf("%d", &n);
  lsum[0] = 0; rsum[n] = 0;
  for(i = 0; i < n; i++){
    scanf("%lld", &c);
    lsum[0] += c;
    l.push(c*(-1));
  }
  for(i = 1; i <= n; i++){
    scanf("%lld", &a[i]);
    if(l.top()*(-1) < a[i]){
      lsum[i] = lsum[i-1] + a[i] - l.top()*(-1);
      l.pop();
      l.push(a[i]*(-1));
    }else lsum[i] = lsum[i-1];
  }
  for(i = 0; i < n; i++){
    scanf("%lld", &c);
    rsum[n] += c;
    r.push(c);
  }
  for(i = n; i > 0; i--){
    if(r.top() > a[i]){
      rsum[i-1] = rsum[i] + a[i] - r.top();
      r.pop();
      r.push(a[i]);
    }else rsum[i-1] = rsum[i];
  }
  for(i = 0; i <= n; i++)
    ans = max(ans, lsum[i] - rsum[i]);
  printf("%lld\n", ans);
}


Measured memory_bytes: 4852
N = raw_input()
A1 = raw_input()
L1 = A1.split(" ")
A2 = raw_input()
L2 = A2.split(" ")
ans = 0
pre_ans = 0
pre_L1 = map(int, L1)
pre_L2 = map(int, L2)

for i in range(int(N)):
    if i == 0:
        sum_L1 = pre_L1[0]
        sum_L2 = sum(pre_L2[:])
    elif i == int(N) - 1:
        sum_L1 = sum(pre_L1[:])
        sum_L2 = pre_L2[-1]
    else:
        sum_L1 = sum(pre_L1[:i + 1])
        sum_L2 = sum(pre_L2[i:])

    pre_ans = sum_L1 + sum_L2
    if ans < pre_ans:
        ans = pre_ans

print ans

Measured memory_bytes: 2692
#include <iostream>
#include <cstdio>

using namespace std;
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
      String S = sc.next();
      String T = sc.next();
      
      char[]S1 = S.toCharArray();
      char[]T1 = T.toCharArray();
      
      for(int i =0; i<N; i++){
       System.out.print(S1[i]+""+T1[i]);
      }
    }
}

Measured memory_bytes: 21844
import java.util.Comparator
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	while(true){
		val a = scn.nextInt()
		val b = scn.nextInt()
		if (a==0 && b==0) break
		val n = scn.nextInt()
		val ngs = Array(n){Pair(scn.nextInt()-1, scn.nextInt()-1)}
		ngs.sortWith(Comparator { o1, o2 ->
			if (o1.first!=o2.first) o1.first-o2.first
			else o1.second-o2.second
		})

		var k = 0
		val map = Array(a){IntArray(b){0} }
		for (i in map.indices){
			for (j in map[i].indices){
				if (i==0 && j==0) {
					map[0][0]=1
					continue
				}
				if (k<ngs.size && ngs[k].first==i && ngs[k].second==j) k++
				else {
					map[i][j] = when {
						i==0 -> map[i][j-1]
						j==0 -> map[i-1][j]
						else -> map[i-1][j] + map[i][j-1]
					}
				}
			}
		}
		println(map.last().last())
	}
}


Measured memory_bytes: 31600
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main ()
{
  string s;
  cin>>s;
  if(s[s.length()-1]=='3')
    cout<<"bon";
  else if(s[s.length()-1]=='0'||s[s.length()-1]=='1'||s[s.length()-1]=='6'||s[s.length()-1]=='8')
    cout<<"pon";
  else
    cout<<"hon";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a[60];
	ll n;
	cin>>n;
	repeat(i,0,n)
		cin>>a[i];
	ll ans=0;
	repeat(i,0,n)
	repeat(j,i+1,n)
		ans+=a[i]*a[j];
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int x;
    scanf("%d",&x);
    if(x%2==0)
        printf("%d\n",x/2);
    else printf("%d\n",(x/2)+1);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k, cnt = 0, sum = 0;
  cin >> n >> k;
  vector<int> a(n), list(n + 1, 0);
  for (int i = 0; i < n;i++){
    cin >> a[i];
    if(list[a[i]]==0){
      cnt++;
    }
    list[a[i]]++;
  }
  if(cnt<=k){
    cout << 0 << endl;
    return 0;
  }
  sort(list.begin(), list.end());
  for (int i = 0;i<=n;i++){
    if(list[i]==0)
      continue;
    sum += list[i];
    cnt--;
    if(cnt<=k){
      break;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4812
//MYNAMEISSHARIFUL AND IFTE_HAKIM_K are teammates

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    multiset<int>st;
    multiset<int>::iterator itr;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int now=a[i];
        itr=st.upper_bound(-now);
       // cout<<"paise "<<*itr<<endl;
        if(itr!=st.end())
        {
            //cout<<"1st "<<endl;
            int ase=*itr;
            st.erase(itr);
            st.insert(-now);
        }
        else
        {
           // cout<<"2nd "<<endl;
            ans++;
            st.insert(-now);
        }
    }
    cout<<ans<<endl;
}


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

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

if( N==2||N==4||N==5||N==7||N==9){
cout <<"hon"<<endl;
}
else if( N==0||N==1||N==6||N==8 ){
cout <<"pon"<<endl;
}  
else if (N==3){
cout <<"bon"<<endl;
}     

else if (N%100%10==2||N%100%10==4||N%100%10==5||N%100%10==7||N%100%10==9) {  
cout <<"hon"<<endl;
}    
else if (N%100%10==0||N%100%10==1||N%100%10==6||N%100%10==8) {  
cout <<"pon"<<endl;
}    
else if ( N%100%10==3) {  
cout <<"bon"<<endl;
} 
}    
    
    
   

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;
const double PI=3.14159265358979323846264;
typedef pair<int,int> P;

int main(void){
   int N,M;
   int ans;
   int A[20000];
   cin >> N >> M;
   ans=N;
   for(int a=0;a<M;a++){
       cin >> A[a];
       ans-=A[a];
   }
   if(ans<0){
       cout << "-1";
    }else{
        cout << ans;
    }

}

Measured memory_bytes: 3676
fn get_line() -> String {
    use std::io;
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.pop().unwrap();
    buf
}

fn main() {
    let mut abcde = [0; 5];
    for i in abcde.iter_mut() {
        *i = get_line().parse::<i32>().unwrap();
    }

    let mut min = 10;
    for i in abcde.iter_mut() {
        if *i % 10 != 0 {
            if *i % 10 < min {
                min = *i % 10;
            }

            *i = (*i / 10 + 1) * 10;
        }
    }

    let sum: i32 = abcde.iter().sum();
    println!("{}", sum - 10 + min);
}


Measured memory_bytes: 4352
#include <stdio.h>

#define N 1000000


int main() {
  	int n,q,c=0;
	int S[N],T[N];
	int key;
	
  scanf("%d",&n);
  
  for(int i=0; i<n; i++) scanf("%d",&S[i]);
  scanf("%d",&q);
	for(int i=0; i<q; i++) scanf("%d",&T[i]);
	
	//ShellSort(S,n);
	//ShellSort(T,q);

	for(int j=0; j<q; j++){
		
		key = T[j];
		
		for(int i=0; i<n; i++){
			
			if(key==S[i]){c++;break;}
			
				
		}
		
		
	}
	

  printf("%d\n",c);
  return 0;
}




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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int mul(int a, int b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    int n, k, ans = 1, K; cin >> n >> k;
     K = k;
    vector <int> p, neg, z;
    vector<pair<ll,ll>>v;
    for(ll i=0;i<n;i++){
        ll x, s; cin >> x;
    if(x > 0) {
      p.push_back(x);
      s = 1;
    }
    if(x < 0) {
      neg.push_back(abs(x));
      s = -1;
    }
    if(x == 0) {
      z.push_back(x);
      s = 1;
    }
    v.push_back({abs(x), s});
    }
    sort(p.begin(),p.end());
    sort(neg.begin(),neg.end());
    sort(v.begin(),v.end());
    int i=p.size()-1,j=neg.size()-1;
    if(k%2){
        if(!p.empty()){
            ans=mul(ans,p[i]);
            i--;
            k--;
        }
    }
    while(k && (i>0 || j>0)){
        int a = -INF, b = -INF;
     if(i >= 1) {
       a = p[i] * p[i-1];
     }
     if(j >= 1) {
       b = neg[j] * neg[j-1];
     }
     if(a > b) {
       ans = mul(ans, a);
       k-=2; i-=2;
     }
     else {
       ans = mul(ans, b);
       k-=2; j-=2;
     }
    }
    if(k) {
    if(!z.empty()) {
      ans = 0;
    } else {
      ans = 1;
      for(int l = 0; l < K; l++) {
         ans = mul(ans, v[l].first * v[l].second);
      }
    }
  }
  cout << ans << '\n';
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}



Measured memory_bytes: 9444
import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt



  val res =
    if(Math.abs(n - m) >= 2) 0L
    else {
      val max = Math.max(n,m)
      val min = Math.min(n,m)

      val fact = (1L to Math.max(n,m).toLong).foldLeft(Vector.empty[Long]){case (vec, k) =>
        if(vec.isEmpty) Vector(k)
        else vec :+ vec.last * k % 1000000007L
      }

      if(max > min){
        fact(max - 1) * fact(min - 1) % 1000000007L
      }else {
        ( fact(max - 1) * fact(min - 1) % 1000000007L) * 2L % 1000000007L
      }
    }

  println(res)

}

Measured memory_bytes: 46152
#include<iostream>
#include<vector>
#include<cmath>
//これ以上MAXを大きくできない…、スタックオーバーフロー
#define MAX 2000000

using namespace std;

#if 1

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

#endif


int main(){
  //エラトステネスの篩を実装する
  int n;cin >> n;
  #if 0
  int N[MAX+1];//i番目が整数iに対応(1~100000)(1-オリジン)
  //0になったところは素数、1は素数ではない
  int l=int(sqrt(MAX));
  for(int i=2;i<l+1;i++){
    if(N[i]==0){
      for(int j=1;j<=floor(MAX/i);j++){
        if(j!=1){
          N[j*i]=1;
        }
      }
    }
  }
  #endif
  int c=0;
  for (int i=0;i<n;i++){
    int k;cin >> k;if(isPrime(k))c+=1;
    //if(k>2000000){if(isPrime(k))c+=1;}
    //else if(N[k]==0) c+=1;
  }
  cout << c << endl;
}



Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, q;
int a[200000];
int u;
int solve(int t) {
	int r = lower_bound(a, a + n, u + t) - a;
	if (r >= n || a[r] > u + t) r--;
	int l = lower_bound(a, a + n, u - t) - a;
	if (a[l] < u - t) l++;
	return r - l + 1;
}
int b[200000];
int c[200000], d[200000];
//偶数、奇数
signed main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) b[i] = a[i];
		else b[i] = b[i - 1] + a[i];
		if (i % 2 == 0) {
			if (i == 0) c[i] = a[i];
			else c[i] = c[i - 2] + a[i];
		}
		else {
			if (i == 1) d[i] = a[i];
			else d[i] = d[i - 2] + a[i];
		}
	}
	for (int i = 0; i < q; i++) {
		cin >> u;
		int s = -1, e = 2000000000, t;
		while (e - s > 1) {
			t = (s + e) / 2;
			//solveはtまで離れたときのSnukeが食べるお菓子の寮
			int k = n - (upper_bound(a, a + n, u + t) - a);
			//kは勅題が食べるお菓子の寮
			int o = solve(t);
			if (o >= k) e = t;
			else s = t;
		}
		//eはスヌケが食べるお菓子の差分
		int k = n - (upper_bound(a, a + n, u + e) - a);
		int w = solve(e);
		int r = lower_bound(a, a + n, u + e) - a;
		if (r >= n || a[r] > u + e) r--;
		int l = lower_bound(a, a + n, u - e) - a;
		if (a[l] < u - e) l++;
		//l~rがスヌケの割り当て
		//高橋はkこ食べる
		//スヌケはwこ食べる
		int ans = b[r] - (l == 0 ? 0 : b[l - 1]);
		if (w > k) {
			ans -= a[r];
			r--;
		}
		if (r - l + 1 == n - r - 1) {
			if (l - 2 >= 0) {
				if (l % 2 == 0) ans += c[l - 2];
				else ans += d[l - 2];
			}
		}
		else {
			if (l - 1 >= 0) {
				if (l % 2 == 0) ans += d[l - 1];
				else ans += c[l - 1];
			}
		}
		cout << b[n - 1] - ans << endl;
	}
}

Measured memory_bytes: 7040
#include <iostream>

int main(){
	const int x = 600;
	int d;
	
	while(std::cin >> d){
		int sum = 0; //面積の合計値
		for(int i = d; i < x; i += d){
			sum += i*i*d;
		}
		
		std::cout << sum << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int h,res = 0;;
        for(int i=0;i<n;i++){
            h = Integer.parseInt(sc.next());
            if(h>=k){
                res++;
            }
        }
        System.out.println(res);
        sc.close();
    }
    
}

Measured memory_bytes: 45888
a = str(input())
cnt=[]
for j in range(1, len(a)):
    c=1
    for i in range(j,len(a)):
        if a[i]==a[i-1]:
            c +=1
        else:
            break
    cnt.append(c)

if max(cnt) >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n; string s; cin >> n >> s;
  vector<bool> sheep(n+1,false);

  rep(bit, 4){
    // if(bit & 1) sheep[0] = true;
    // if(bit & 10) sheep[1] = true;
    sheep[0] = (bit & 1);
    sheep[1] = (bit & 10);
    for(int i = 1; i < n; i++){
      if(s[i] == 'o' && sheep[i] || s[i] == 'x' && !sheep[i]) sheep[i+1] = sheep[i-1];
      else sheep[i+1] = !sheep[i-1];
    }
    if(sheep[0] == sheep[n] && ( (s[0] == 'o') == sheep[0] ) == (sheep[n-1] == sheep[1]) ) {
      rep(i, n) std::cout << (sheep[i] ? "S" : "W");
      return 0;
    }
  }

  std::cout << -1 << '\n';
}


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

int main() {
  int N, n2;
  string S;
  cin >> N;
  cin >> S;
  
  n2 = N % 2;
    if(n2 == 1){
      cout << "No" << endl;
    } else {
      string s1, s2;
      N /= 2;
      s1 = S.substr(0,N);
      s2 = S.substr(N,N);
      if(s1 == s2){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
}


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

int main(void) {
    int n;
    std::cin >> n;
    std::string s;
    std::map< std::string, int > m;
    for (int i = 0; i < n; i++) {
        std::cin >> s;
        m[s] = 1;
    }
    int count = 0;
    for (const auto& [key, value] : m) {
        count++;
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m; cin >> n >> m;
  n--;m--;
  int sum = 0;
  if (n > 0)
  	sum = n * (n + 1) / 2;
  if (m > 0)
  sum += m * (m + 1) / 2;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

void output(int n, int elements[])
{
	for (int i = 0; i < n; i++)
		cout << elements[i] << '\n';
}

int insertion_sort(int n, int elements[], int g)
{
	int cnt = 0;
	for (int i = g; i < n; i++) {
		int key = elements[i],
			j = i - g;
		while (0 <= j && key < elements[j]) {
			elements[j + g] = elements[j];
			j -= g;
			cnt++;
		}
		elements[j + g] = key;
	}
	return cnt;
}

void shell_sort(int n, int elements[])
{
	int cnt = 0, m = 0, g[13] = { 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161 };
	
	for (; g[m] <= n && m < 13; m++);
	cout << m << '\n';
	for (int i = m - 1; 0 <= i; i--) {
		cout << g[i] << (i == 0 ? "" :  " ");
		cnt += insertion_sort(n, elements, g[i]);
	}
	cout << '\n';
	cout << cnt << '\n';
}

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

	int n;
	cin >> n;
	int *elements = new int[n];

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

	shell_sort(n, elements);
	output(n, elements);
	delete[] elements;
	return 0;
}

Measured memory_bytes: 4896
from collections import defaultdict
import sys

h, w, m = map(lambda x: int(x), input().split())

y_to_num = [0] * h
x_to_num = [0] * w
existing_h_to_w = defaultdict(set)


for _ in range(m):
    hh, ww = map(lambda x: int(x), input().split())
    y_to_num[hh-1] += 1
    x_to_num[ww-1] += 1
    existing_h_to_w[hh-1].add(ww-1)

max_vertical_num = max(y_to_num)
max_horizontal_num = max(x_to_num)

y_coor_with_max_num = [i for i, num in enumerate(y_to_num) if num == max_vertical_num]
x_coor_with_max_num = [i for i, num in enumerate(x_to_num) if num == max_horizontal_num]

# print(y_coor_with_max_num, x_coor_with_max_num, existing_h_to_w)

for y in y_coor_with_max_num:
    for x in x_coor_with_max_num:
        if x not in existing_h_to_w[y]:
            print(max_vertical_num + max_horizontal_num)
            sys.exit()

print(max_vertical_num + max_horizontal_num - 1)

Measured memory_bytes: 133660
import math

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

if x >= a*a*b/2:
  theta_rad = (a*a*b-x)*2/(a*a*a)
  theta = math.degrees(math.atan(theta_rad))
else:
  theta_rad = a*b*b/(x*2)
  theta = math.degrees(math.atan(theta_rad))
print(theta)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>

using namespace std;

int d1[401];
int d2[401];
int f[401];
int g[401][401];
vector <int> v[401];

void dfs(int x) {
    int i;
    
    f[x] = 1;
    
    for (i = 0; i < v[x].size(); i++) {
        if (f[v[x][i]] == 1) continue;
        
        dfs(v[x][i]);
    }
}

int main() {
    int n, h, p = 200, i, j;
    
    scanf("%d %d", &n, &h);
    
    for (i = 0; i < n; i++) {
        int a, b, c, d, x, y;
        
        scanf("%d %d %d %d", &a, &b, &c, &d);
        
        if (c == 0) {
            x = a;
        } else {
            x = -c;
        }
        
        if (d == 0) {
            y = -b;
        } else {
            y = d;
        }
        
        g[x + p][y + p]++;
    }
    
    for (i = 0; i <= p * 2; i++) {
        for (j = 0; j <= p * 2; j++) {
            if (g[i][j] > 0) {
                d1[i] += g[i][j];
                d2[j] += g[i][j];
                v[i].push_back(j);
            }
        }
    }
    
    for (i = 0; i < p; i++) {
        if (d1[i] > d2[i]) {
            puts("NO");
            
            return 0;
        } else if (d1[i] < d2[i]) {
            d1[i] = d2[i];
            v[i].push_back(p);
        }
    }
    
    for (i = p + 1; i <= p * 2; i++) {
        if (d1[i] < d2[i]) {
            puts("NO");
            
            return 0;
        } else if (d1[i] > d2[i]) {
            d2[i] = d1[i];
            v[p].push_back(i);
        }
    }
    
    dfs(p);
    
    for (i = 0; i <= p * 2; i++) {
        if (f[i] == 0 && d1[i] > 0) {
            puts("NO");
            
            return 0;
        }
    }
    
    puts("YES");
    
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[200010],s[400020];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<400020;i++){
		s[i]=INF;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll j=200010;
	bool flag=true;
	for(int i=0;i<n;i++){
		ll now=a[i];
		s[j]=now;
		if(flag){
			flag=false;
			j-=(i+1);
		}
		else{
			flag=true;
			j+=(i+1);
		}
	}
	if(n%2==0){
		for(int i=0;i<400020;i++){
			if(s[i]==INF){
				continue;
			}
			cout << s[i] <<" ";
		}
	}
	else{
		for(int i=400019;i>=0;i--){
			if(s[i]==INF){
				continue;
			}
			cout <<s[i]<< " ";
		}
	}
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int tb[10][10];

int X(int a,int b){return tb[a][b];}

int check(vector<int>a){
  int res=0;
  for(int i=0;i<a.size();i++)res=X(res,a[i]);
  return res;
}

int main(){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)cin>>tb[i][j];

  int ans=0;
  for(int i=0;i<10000;i++){
    int n=i;
    vector<int> a;
    while(n)a.push_back(n%10),n/=10;
    while(a.size()<4)a.push_back(0); 
    reverse(a.begin(),a.end());
    int res=check(a);
    a.push_back(res);
    set <vector<int> > used;
    
    int flg=0;
    for(int i=0;i<5;i++)
      for(int j=0;j<10;j++){
	int tmp=a[i];
	if(a[i]==j)continue;
	a[i]=j;
	flg|=!check(a);
	a[i]=tmp;
      }

    for(int j=0;j<a.size()-1;j++){
      swap(a[j],a[j+1]);      
      if(a[j]==a[j+1])continue;
      if(used.count(a))continue;
      used.insert(a);
      if(!check(a))flg=1;
      swap(a[j],a[j+1]);
    }
    ans+=flg;
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int h = Integer.parseInt(input[0]);
        int a = Integer.parseInt(input[1]);

        System.out.println(h / a + (h % a > 0 ? 1 : 0));
    }
}

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

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  vector<int> h(M,0),w(M,0);
  vector<int> x(H,0),y(W,0);
  set<pair<int,int>> v;
  rep(i,M){
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    x[h[i]]++; y[w[i]]++;
    v.insert({h[i],w[i]});
  }

  int h_m = 0;
  rep(i,H) h_m = max(h_m, x[i]);
  int v_m = 0;
  rep(i,W) v_m = max(v_m, y[i]);

  vector<int> a;
  rep(i,H) if(x[i] == h_m) a.push_back(i);
  vector<int> b;
  rep(i,W) if(y[i] == v_m) b.push_back(i);  

   for(auto i : a){
    for(auto j : b){
       if(v.find({i,j}) == v.end()){
         cout << h_m + v_m << endl; 
         return 0;      
       }
     }
   }
  
  cout << h_m + v_m - 1 << endl;
  return 0;
}


Measured memory_bytes: 26028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		if(s.equals(u)) {
			a--;
		}else {
			b--;
		}
		System.out.println(a + " " + b);
	}

}


Measured memory_bytes: 21844
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    string s1="CODEFESTIVAL2016", s2;
    int cnt=0;
    cin >> s2;
    for(int i=0;i<16;i++){
        if(s1[i]!=s2[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
	  //Scanner cin = new Scanner();
	  string input;
	  while (!string.IsNullOrEmpty(input = Console.ReadLine()))
	  {
	    int cnt = 0, s = 0;
	    while (input.IndexOf("JOI", s) != -1)
	    {
	      ++cnt;
	      s = input.IndexOf("JOI", s) + 1;
	    }
      Console.WriteLine(cnt);
	    cnt = s = 0;
      while (input.IndexOf("IOI", s) != -1) {
        ++cnt;
        s = input.IndexOf("IOI", s) + 1;
      }
      Console.WriteLine(cnt);
	  }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

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

int main(){
  int N,a,b,c,d;
  cin >> N;
  a=N/1000;
  d=N%10;
  c=(N%100-N%10)/10;
  b=(N%1000-N%100)/100;
  if(a==b&&b==c){
    cout << "Yes" << endl;
  }
  else if(b==c&&c==d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b;
	int x;

	scanf("%d %d", &a, &b);

	for(x=1; x<=1000; x++){
		if((int)(x*0.08) == a && (int)(x*0.1) == b){
			break;
		}
	}

	if(x > 1000){
		printf("-1");
	}else{
		printf("%d", x);
	}

	return 0;
}


Measured memory_bytes: 128
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define mod 1000000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	ll n;
	cin>>n;
	queue<ll> q;
	for(int i=1;i<=9;i++)
		q.push(i);
	int cnt = 0;
    vector<ll> v;
	while(cnt < n)
	{
		++cnt;
		ll x = q.front();
		q.pop();
		v.pb(x);
		ll a = x%10;
		if(a-1>=0)
			q.push(x*10+a-1);
		q.push(x*10+a);
		if(a+1<=9)
			q.push(x*10+a+1);
	}
	cout<<v[n-1];
	return 0;
}

		
			



Measured memory_bytes: 2548
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

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

    int a, b, C;
    cin >> a >> b >> C;

    double radian = C * M_PI / 180.0;
    double area = 0.5 * a * b * sin(radian);
    double perimeter = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(radian));
    double height = b * sin(radian);

    printf("%.8f\n", area);
    printf("%.8f\n", perimeter);
    printf("%.8f\n", height);
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 string s,t; 
 cin>>s;
 ll n=s.length();
 string bef;
 ll ans=0;
 rep(i,0,n){
  t+=s[i];
  if(bef!=t){
   bef=t;
   ans++;
   t="";
  }
 }
 pr(ans);
return 0;}


Measured memory_bytes: 3752
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(4);
    vector<string> b={"AC","WA","TLE","RE"};
    rep(i,n){
        string s;
        cin >> s;
        rep(j,4){
            if(s==b[j]){
                a[j]++;
            }
        }
    }
    rep(i,4){
        cout << b[i] << " "<< "x" <<  " " << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

class Job {
    final int time;
    final int limit;

    Job(int time, int limit) {
        this.time = time;
        this.limit = limit;
    }
}

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        PriorityQueue<Job> jobs = new PriorityQueue<>(Comparator.comparing(j -> j.limit));
        for (int i = 0; i < N; i++) {
            jobs.add(new Job(sc.nextInt(), sc.nextInt()));
        }

        System.out.println(check(jobs) ? "Yes" : "No");
    }

    boolean check(Queue<Job> jobs) {
        int current = 0;
        while (!jobs.isEmpty()) {
            Job job = jobs.poll();
            current += job.time;
            if (current > job.limit) return false;
        }

        return true;
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 162076
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    K = INT()
    S = INPUT()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10048
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=1000000000;
const double eps=1e-10;

bool Is_Prime(int n){
  if(n==1) return false;
  else if(n==2)return true;
  else if(n%2==0)return false;

  for(int i=3;i*i<=n;i+=2){
    if(n%i==0)return false;
  }
  return true;
}
map<int,int> prime_fac(int n){
  map<int,int> ret;
  for(int i=2;i*i<=n;i++){
    while(n%i==0){
      ret[i]++;
      n/=i;
    }
  }
  if(n!=1)ret[n]=1;
  return ret;
}

signed main(){
  int n;
  cin>>n;
  map<int,int> mp;
  LOOP(i,2,n+1){
    if(Is_Prime(i))mp[i]++;
    else{
      map<int,int> p=prime_fac(i);
      for(auto x:p){
        mp[x.F]+=x.S;
      }
    }
  }
  int ans=1;
  for(auto x:mp){
    //cout<<x.F<<' '<<x.S<<endl;
    ans*=(x.S+1);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int M[N][N];
int d[N], n;

void bfs(int s){
  int i, u;
  queue<int> q;
  q.push(s);
  for(i=0;i<n;i++) d[i] = INFTY;
  d[s] = 0;
  while(!q.empty() ){
    u = q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY)continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  } // end while

  for(i=0;i<n;i++)cout << i+1 << " " << ((d[i] == INFTY)?(-1):d[i]) << endl;
  
}

int main(){
  
  int u, k, v;
  int i, j;
  
  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j] = 0;
  }

  for(i=0;i<n;i++){
    cin >> u >> k;
    u--; // change to origin
    for(j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include<math.h>
#include<bits/stdc++.h>
#include <map>
#include <algorithm>
#include <cmath>



using namespace std;
const int INF = 1e9+7;
void solve(string p,string q,int n,int m){
    int dp[n+1][m+1];

    for(int i=0;i<n+1;i++){
        for(int j=0;j<m+1;j++){
            if(i==0 || j==0)dp[i][j] = 0;
            else if( p[i-1] == q[j-1] )dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int index = dp[n][m];
    char lcs[index+1];
    lcs[index] = '\0';

    int i = n, j = m;
    while (i > 0 && j > 0)
    {
      // If current character in X[] and Y are same, then
      // current character is part of LCS
      if (p[i-1] == q[j-1])
      {
          lcs[index-1] = p[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }

      // If not same, then find the larger of two and
      // go in the direction of larger value
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }

   // Print the lcs
   cout <<lcs<<endl;
}

int main(){
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    solve(s,t,n,m);
}

Measured memory_bytes: 38816
n = int(input())
A = [int(i) for i in input().split()]

m4 = 0
even = 0
for i in range(n):
    if A[i] % 4 == 0:
        m4 += 1
    if A[i] % 2 == 0:
        even += 1
        
if m4 >=  n // 2 or even == n or (n - even) == m4:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
N,M=map(int,input().split())
G = [list() for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)
#O(M)
flag = False
for i in G[1]:
    if N in G[i]:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  
  int count = 1;
  int dst = 0;
  for(int i = 0; i < n; i++) {
    dst += d[i];
    if(dst <= x) {
      count++;
    }
    else {
      break;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();

            int N = int.Parse(line[0]);
            int A = int.Parse(line[1]);
            int B = int.Parse(line[2]);

            if (N*A >= B)
            {
                Console.WriteLine(B);
            }
            else
            {
                Console.WriteLine(N*A);
            }
        }
    }


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll n , a , b , k;

int main()
{
    _FastIO;
    cin >> n >> k;
    ll ans = 1;
    ll p = 0;
    for(ll i = 1; i < 35; i++){
        ans *= k;
        if(ans > n){
            p = i;
            break;
        }
        if(ans == n){
            p = i + 1;
            break;
        }
    }
    cout << p << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for(int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> h[i];

    for(int py = 0; py < 101; ++py) {
        for(int px = 0; px < 101; ++px) {
            int height = -1;
            for(int i = 0; i < N; ++i) {
                if(h[i] > 0) {
                    int hoge = h[i] + abs(px - x[i]) + abs(py - y[i]);
                    if(height == -1) height = hoge;
                    else {
                        if(height != hoge) {
                            height = -1; break;
                        }
                    } 
                }
            }
            if(height != -1) {
                for(int i = 0; i < N; ++i) {
                    if(h[i] == 0) {
                        int hoge = abs(px - x[i]) + abs(py - y[i]);
                        if(height > hoge) {
                            height = -1; break;
                        }
                    }
                }
            }
            if(height != -1) {
                cout << px << " " << py << " " << height << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

        vector<int> S(N + 1);
        rep(i, N) cin >> S[i];

        sort(S.begin(), S.begin() + N);
        int ans = 1;
        rep(i, N - 1)
        {
                if (S[i] < S[i + 1])
                {
                        ans++;
                }
                else
                        continue;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<int> divisor(int n) { 
    vector<int> res;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

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

  int N, M; cin >> N >> M;
  vector<int> d;
  d = divisor(M);
  sort(d.begin(), d.end());
  cout << M / (*lower_bound(d.begin(), d.end(), N)) << endl;
  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = M/N; i > 0; --i){
        if (M%i == 0){
            cout << i << endl;
            exit(0);
        }
    }
    return 0;
}


Measured memory_bytes: 256