akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T1BC2019_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();




            int leftBlackCount = 0;
            int rightWhiteCount = 0;

            int[] counts = new int[n+1];

            for (int i = 0; i < n; ++i)
            {
                if (s[i] == '#')
                {
                    ++leftBlackCount;
                }

                counts[i + 1] = leftBlackCount;
            }

            for (int i = n - 1; i >= 0; --i)
            {
                if (s[i] == '.')
                {
                    ++rightWhiteCount;
                }

                counts[i] += rightWhiteCount;
            }

            Array.Sort(counts);

            Console.WriteLine("{0}", counts[0]);
        }
    }
}


Measured memory_bytes: 14560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define z 1000000007
#define sh 100000

int main()
{
 
	
    
    ll n,m,i,j;
    cin>>n>>m;
    ll dp[n][m];
    string s[n];
    memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++)
    	cin>>s[i];
    for(i=0;i<m;i++)
    {
    	if(s[0][i]!='.')
    		break;
    	if(s[0][i]=='.')
    	dp[0][i]=1;
	}
    for(i=0;i<n;i++)
    {
    	if(s[i][0]!='.')
    		break;
    	if(s[i][0]=='.')
    	dp[i][0]=1;
	}

	for(i=1;i<n;i++)
	{
		for(j=1;j<m;j++)
		{
			if(s[i][j]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%z;
		}
	}
	
	cout<<dp[n-1][m-1];
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

ll N;
int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> btmp(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    sort(b.begin(), b.end());
    
    // 29 bit 求める
    ll ans = 0;
    REP(k, 29) {
        ll mod_num = 1<<(k+1);
        ll T = 1 << k;
        REP(i, N) {
            btmp[i] = b[i] % mod_num;
        }
        sort(btmp.begin(), btmp.end());
        
        int one_num = 0;
        REP (i, N) {
            ll A = a[i] % mod_num;
            // [T, 2*T)
            int s = (int) (lower_bound(btmp.begin(), btmp.end(), T - A) - btmp.begin());
            int e = (int) (lower_bound(btmp.begin(), btmp.end(), 2 * T - A) - btmp.begin());
            one_num += e - s;
            
            // [3*T, 4*T)
            s = (int) (lower_bound(btmp.begin(), btmp.end(), 3 * T - A) - btmp.begin());
            e = (int) (lower_bound(btmp.begin(), btmp.end(), 4 * T - A) - btmp.begin());
            one_num += e - s;
        }
        if (one_num % 2) {
            ans |= 1<<k;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 2100000
#define INF 1001000000
using Graph=vector<vector<int>>;

int main(){
  int N,S;
  cin>>N>>S;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }

  vector<vector<ll>> dp(N+1,vector<ll>(S,0));
  dp.at(0).at(0)=1;
  for(ll i=1;i<=N;i++){
    for(int j=0;j<S;j++){
      dp.at(i).at(j)=dp.at(i-1).at(j);
    }
    if(A.at(i-1)<S){
      dp.at(i).at(A.at(i-1))+=i;
      dp.at(i).at(A.at(i-1))%=MOD;
    }
    for(int j=1;j+A.at(i-1)<S;j++){
      dp.at(i).at(j+A.at(i-1))+=dp.at(i-1).at(j);
      dp.at(i).at(j+A.at(i-1))%=MOD;
    }
  }

  ll ans=0;
  for(ll i=0;i<N;i++){
    if(S-A.at(i)==0){
      ans+=(i+1)*(N-i);
    }else if(S-A.at(i)>0){
      ans+=dp.at(i).at(S-A.at(i))*(N-i);
    }
    ans%=MOD;
  }

  cout<<ans<<endl;
}


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

int main(void)
{
  string s;
  cin >> s;
  if(s[1]==s[2] &&(s[0]==s[1] ||
    s[2]==s[3]))
  {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(void) {
    ll X;cin>>X;
    ll money = 100;
    ll result = 0;
    while (money < X) {
        ll n_money = money * 1.01;
        result++;
        money = n_money;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll l=0;
    ll r=powl(10,10);
    ll x;cin>>x;
    while(r-l>1){
        ll i=(l+r)/2;
        if((i*(i+1))/2>=x){
            r=i;
        }else{
            l=i;
        }
    }
    cout<<r<<endl;
    
    return 0;
}





Measured memory_bytes: 3616
#include<stdio.h>
#include<algorithm>
using namespace std;
     int bubblesort(int n,int num[]){
        bool flag=1;
        int i=0,count=0;
        int temp;
        while(flag){
            flag=0;
            for(int j=n-1;j>=i+1;j--){
                if(num[j]<num[j-1]){
                    swap(num[j],num[j-1]);
                    flag=1;
                    count++;
                }
            }
            i++;
        }
        return count;
     }
     int main(){
     int n,count;
     while(~scanf("%d",&n) && n>=1 && n<=100){
        int num[100];
        for(int i=0;i<n;i++)
            scanf("%d",&num[i]);
        count=bubblesort(n,num);
        for(int i=0;i<n;i++){
            printf("%d",num[i]);
          if(i<n-1)
            printf(" ");
          else
            printf("\n");
        }
        printf("%d\n",count);
   }
   return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }
    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x; //大きさが正になるよ
        return true;
    }
    int size(int x)
    {
        return -par[root(x)];
    }
};

using Edge = pair<int, pair<int,int>>;
using Graph = vector<Edge>;
Graph edges;

signed main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    vector<int> ids(n);
    iota(ALL(ids), 0);
    sort(ALL(ids), [&](int i, int j) {
        return x[i] < x[j];
    });
    for (int i = 0; i < n-1; i++)
    {
        int u = ids[i], v = ids[i + 1];
        edges.push_back((Edge(x[v] - x[u], {u, v})));
    }

    sort(ALL(ids), [&](int i, int j) {
        return y[i] < y[j];
    });
    for (int i = 0; i < n - 1; i++)
    {
        int u = ids[i], v = ids[i + 1];
        edges.push_back((Edge(y[v] - y[u], {u, v})));
    }
    //kruskal法
    sort(ALL(edges));
    UnionFind uni(n);
    int ans = 0;
    for(auto e :edges){
        int u = e.second.first;
        int v = e.second.second;
        int cnt = e.first;
        if(uni.issame(u,v)){
            continue;
        }
        uni.merge(u, v);
        ans += cnt;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

ll X;
vector<ll> v;

ll pow(ll n){
    return n*n*n*n*n;
}

int main(){
    cin >> X;
    v.push_back(0);
    for(int i=1;i<=200;i++){
        ll x = pow(i);
        v.push_back(x);
        v.push_back(-x);
    }
    sort(v.begin(), v.end());
    for(int i=0;i<=401;i++){
        for(int j=0;j<=401;j++){
            if(i==j) continue;
            if(v[i] - v[j] == X){
                cout << i - 200 << " " << j - 200 << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

const int MAX = 55556;
int prime[MAX];

int main() {
    int n;
    cin >> n;
    prime[1] = prime[0] = 1;
    for (int i = 2; i * i <= MAX; i++) {
        if (prime[i] == 0) {
            for (int j = 2; i * j <= MAX; j++) {
                prime[i * j] = 1;
            }
        }
    }
    vector<int> v;
    for (int i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            if (i % 5 == 1) v.push_back(i);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << v[i] << " \n"[i == n - 1];
    }
    return 0;
}


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

using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;
	string str;
	cin >> str;

	if(n % 2 == 0) {
		REP(i, n / 2) {
			if(str[i] != str[i + n / 2]) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
	}
	else cout << "No\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        int result = 0;
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer card[] = new Integer[n];
        
        for (int i=0; i < n; i++){
            card[i] = sc.nextInt();
        }
            
        Arrays.sort(card,Collections.reverseOrder());
        
        int alice = 0;
        int bob = 0;
        
        for (int i=0; i < n; i++){
            if (i % 2 == 0){
                alice += card[i];
            } else{
                bob += card[i];
            }
        }
        
        System.out.println(alice - bob);
        sc.close();
    }
}


Measured memory_bytes: 23764
/* 
 * Range Minimum Queries AtcoderARC098C
 * https://arc098.contest.atcoder.jp/tasks/arc098_c
 */

#include <bits/stdc++.h>
#define gor(A, B, E) for (int A = B; A <= E; A++)
#define dor(A, B, E) for (int A = B; A >= E; A--)
#ifndef ONLINE_JUDGE
#define dbg(x) std::cout<<#x<<'='<<x<<std::endl
#else
#define dbg(x) 
#endif
typedef long long ll;
namespace IO {
template <typename T>
void read(T & v) {
    register char ch;register T f=1,x=0;
    do{ch=getchar();if(ch=='-') f=-1;}while(!isdigit(ch));
    do{x=x*10+ch-'0';ch=getchar();}while(isdigit(ch));v=x*f;}
}
const int N = 2e3 + 2, INF = 0x7fffffff, MOD = 1e9 + 7;

namespace Problem {
    int n, k, q, a[N], t[N], b[N], c[N], ans=INF;

    void work(int x) {
        int l, r;
        l = r = 1, b[0] = 0;
        while (l <= n){
            c[0] = 0;
            while(l <= n && a[l] < x) l++;
            r = l;
            while(r <= n && a[r] >= x) r++;
            for (int i = l; i < r && i <= n; i++)
                c[++c[0]] = a[i];
            if (c[0] >= k) {
                std::sort(c + 1, c + c[0] + 1);
                gor(i, 1, c[0] - k + 1)
                    b[++b[0]] = c[i];
            }
            l = r;
        }
        std::sort(b + 1, b + b[0] + 1);
        if (b[0] >= q)
            ans = std::min(ans, b[q] - b[1]);
    }

	void solve() {
		using namespace IO;
        read(n), read(k), read(q);
        gor(i, 1, n)
            read(a[i]),
            t[i] = a[i];
        std::sort(t + 1, t + n + 1);
        gor(i, 1, n) work(t[i]);
        printf("%d", ans);
    }
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
    Problem::solve();
    return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = []
b = []
c = []

for i in range(n):
    ai = list(map(int, input().split()))
    a.append(ai)

for i in range(m):
    bi = list(map(int, input().split()))
    b.append(bi)

for i in range(n):
    ci = []
    for j in range(l):
        cij = 0
        for k in range(m):
            cij += a[i][k] * b[k][j]
        ci.append(cij)
    c.append(ci)

for i in range(n):
    print(" ".join(list(map(str, c[i]))))

Measured memory_bytes: 8792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

bool solve(int a, int b, int k){
	int len = (a + b) / (min(a, b) + 1);
	int lo = 0, hi = a + 1, mid;
	
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		int lb = (mid + len - 1) / len - 1;
		int rb = b - lb, ra = a - mid;
		
		if(rb <= len * (ra + 1ll)) lo = mid;
		else hi = mid;
	}
	if(k < lo + (lo + len - 1) / len - 1) return k % (len + 1) == len;
	k = a + b - 1 - k;
	return k % (len + 1) != len;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	while(n--){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		for(int i = c - 1; i < d; i++) cout << char('A' + solve(a, b, i));
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string s;
  cin >>s;
  //bool ist=false;
  
  //if (n%10 == 9 || n/10 ==9)ist=true;
  
  if (s[0]==s[2]){
    cout << "Yes";
  }else{
    cout << "No";
  }
  

    return 0;
}






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

using namespace std;

using ll = long long;

using vi = vector<int>;
using vll = vector<ll>;

using pi = pair<int, int>;
using pll = pair<ll, ll>;

constexpr auto MOD = 1e9 + 7;
constexpr auto INF = 0x3f3f3f3f;

#define rep(i, a, b) for (auto i = a; i < b; ++i)

template <class T> inline T square(T x) { return x * x; };

template <class T> void print(const T &val) { cout << val << '\n'; }

template <class Iterator> void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; ++it) {
    cout << *it << ' ';
  }

  cout << '\n';
}

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

  int a, b;
  cin >> a >> b;
  print(a * b);
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

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

		String a = sc.next();
		String b = sc.next();
		System.out.println(Math.sqrt(Integer.parseInt(a + b)) % 1 == 0 ? "Yes" : "No");

		sc.close();
	}
}


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

int main(void){
	char f[51][51];
	int n, m, i, j, dp[3][51]={0};
	scanf("%d%d", &n, &m);
	for(i=0; i<n; ++i){ scanf("%s", f[i]); }
	for(i=0; i<m; ++i){ if(f[0][i]!='W'){ ++dp[0][0]; } }
	if(n==3){
		for(i=0; (i<m); ++i){
			if(f[0][i]!='W'){ ++dp[2][n-1]; }
			if(f[1][i]!='B'){ ++dp[2][n-1]; }
			if(f[2][i]!='R'){ ++dp[2][n-1]; }
		}
		printf("%d\n", dp[2][n-1]);
		return(0);
	}
	dp[1][1]=dp[0][1]=dp[0][0];
	for(i=0; i<m; ++i){ 
		if(f[1][i]!='W'){ ++dp[0][1]; }
		if(f[1][i]!='B'){ ++dp[1][1]; }
	}
	dp[2][1]=1e9;
	for(i=2; i<n-2; ++i){
		dp[0][i]=dp[0][i-1];
		dp[1][i]=min(dp[1][i-1], dp[0][i-1]);
		dp[2][i]=min(dp[2][i-1], dp[1][i-1]);
		for(j=0; j<m; ++j){
			if(f[i][j]!='W'){ ++dp[0][i]; }
			if(f[i][j]!='B'){ ++dp[1][i]; }
			if(f[i][j]!='R'){ ++dp[2][i]; }
		}
	}
	dp[1][n-2]=min(dp[1][n-3], dp[0][n-3]);
	dp[2][n-2]=min(dp[2][n-3], dp[1][n-3]);
	for(i=0; i<m; ++i){ 
		if(f[n-2][i]!='B'){ ++dp[1][n-2]; }
		if(f[n-2][i]!='R'){ ++dp[2][n-2]; }
	}
	dp[2][n-1]=min(dp[1][n-2], dp[2][n-2]);
	for(i=0; i<m; ++i){ if(f[n-1][i]!='R'){ ++dp[2][n-1]; } }
	printf("%d\n", dp[2][n-1]);
	return(0);
}


Measured memory_bytes: 2728
// Ringo's Favorite Numbers

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n;

int main() {
    cin >> n;
    //vector<int> a(n, 0);

    bool all_even = true;

    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp % 2 != 0) {
            all_even = false;
        }
    }

    if (all_even) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#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 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(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll 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 sum(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));}
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>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<vector<pll>> edge(n+1);
	rep(i,n-1){
		ll u,v,w;
		cin>>u>>v>>w;
		edge[u].emplace_back(v,w);
		edge[v].emplace_back(u,w);
	}
	queue<int> q;
	q.push(1);
	vi ed(n+1,-1);
	ed[1]=0;
	vb edb(n+1,false);
	while(!q.empty()){
		int p =q.front();
		q.pop();
		if(edb[p])continue;
		edb[p]=true;
		for(auto t:edge[p]){
			ll v,w; tie(v,w)=t;
			if(!edb[v]){
				ed[v]=w%2?1-ed[p]:ed[p];
				q.push(v);
			}
		}
	}
	range(i,1,n+1)puta(ed[i]);
	return 0;
}

Measured memory_bytes: 8320
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)2e3 + 5;

vector<int> adj[MAXN];
                
int dist[MAXN][MAXN];

bitset<2005> B[MAXN];

int n, k;

int ans;

void dfs(int v, int pr, int st, int d) {
	dist[st][v] = d;

	for (int to : adj[v]) {
		if (to == pr) {
			continue;
		}

		dfs(to, v, st, d + 1);
	}
}

void solve() {
	scanf("%d %d", &n, &k);

	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d %d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);		
	}	

	for (int i = 1; i <= n; ++i) {
		dfs(i, -1, i, 0);
	}

	int diameter = 0;
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			diameter = max(diameter, dist[i][j]);		
		}
	}

	k = min(k, diameter);

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (dist[i][j] > k) {
				B[i].set(j, 1);
			}
		}
	}

	ans = n - 1;

	for (int a = 1; a <= n; ++a) {
		for (int b = a + 1; b <= n; ++b) {
			int d = dist[a][b];

			if (d != k) {
				continue;
			}

			int cur = (B[a] | B[b]).count();            
			ans = min(ans, cur);
		}	
	}

	printf("%d\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 16640
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 66;
int a[maxn],b[maxn];
int n;
ll k;
int c[maxn];
ll p2[64];
void cal(ll x) {
	for(int i=0;i<64;i++) {
		if(x%2) a[i]++;
		else b[i]++;
		x/=2;
	}
}

void calk(ll k) {
	for(int i=0;i<64;i++) {
		c[i]=k%2;
		k/=2;
	}
}

void solve() {
	bool f=1;
	ll w;
	ll ans=0;
	for(int i=62;i>=0;i--) {
		if(f) {
			if(a[i]>=b[i]) {
				w=a[i];
				if(c[i]) f=0;
			}else {
				if(c[i]==0) w=a[i];
				else {
					w=b[i];
				}
			}
		}else {
			if(a[i]>=b[i]) w=a[i];
			else w=b[i];
		}
		ans += w*p2[i];
	}
	cout<<ans<<endl;
}

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	ll x;
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++) {
		scanf("%lld",&x);
		cal(x);
	}
	calk(k);
	
	p2[0]=1;
	for(int i=1;i<64;i++) p2[i]=p2[i-1]*2;
	solve();
	
	return 0;
}














Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  if(N<K){
    cout<<1<<endl;
  }
  else if(N%K==0){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
a = list(map(int, input().split()))


# In[8]:


a_set = set(a)
if len(a_set) == 1:
    if sum(a) == 0:
        ans = "Yes"
    else:
        ans = "No"
elif len(a_set) == 2:
    a1,a2 = sorted(a_set)
    if a1 == 0 and N == a.count(a1)*3:
        ans = "Yes"
    else:
        ans = "No"
elif len(a_set) == 3:
    a1,a2,a3 = a_set
    if (a1^a2^a3 == 0) and (a.count(a1)==a.count(a2)==a.count(a3)):
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"
    
print(ans)


# In[ ]:






Measured memory_bytes: 20684
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int a[100000],b[100000];
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
signed main(){
	int n,k,ma=0;
	cin>>n>>k;
	f(i,n){
		cin>>a[i];
		if(i) b[i-1]=abs(a[i]-a[i-1]);
		ma=max(ma,a[i]);
	}
	int z=mod;
	f(i,n-2){
		if(i) z=gcd(z,b[i+1]);
		else z=gcd(b[0],b[1]);
	}
	if(z==0&&a[0]==k) puts("POSSIBLE");
	else if((z==0&&a[0]!=k)||ma<k||a[0]%z!=k%z)puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int result = Math.min(a * n, b);

        System.out.println(result);
    }
}


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

using i64 = int64_t;

constexpr int INF = 500;

struct State{
    int y, x, cost;
};

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> maze;
    for(int i=0;i<h;++i){
        string s;
        cin >> s;
        maze.push_back(s);
    }

    int ans = 0;
    for(int si=0;si<h;++si){
        for(int sj=0;sj<w;++sj){
            if(maze[si][sj] == '#')continue;
            for(int gi=0;gi<h;++gi){
                for(int gj=0;gj<w;++gj){
                    if(maze[gi][gj] == '#')continue;
                    vector<vector<int>> mini(h, vector<int>(w, INF));
                    mini[si][sj] = 0;
                    queue<State> que;
                    que.push({si, sj, 0});
                    int min_cost = INF;
                    while(!que.empty()){
                        auto cur = que.front(); que.pop();
                        if(cur.y == gi && cur.x == gj){
                            min_cost = cur.cost;
                            break;
                        }
                        for(int k=0;k<4;++k){
                            int nx = cur.x + dx[k], ny = cur.y + dy[k];
                            if(nx < 0 || ny < 0 || nx >= w || ny >= h)continue;
                            if(maze[ny][nx] == '#')continue;
                            if(cur.cost + 1 >= mini[ny][nx])continue;
                            mini[ny][nx] = cur.cost + 1;
                            que.push({ny, nx, cur.cost + 1});
                        }
                    }
                    assert(min_cost < INF);
                    ans = max(ans, min_cost);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll a,b,c,d;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	REP(bit,8) {
		vector<ll> used(3,0);
		ll buf=bit;
		REP(i,3) {
			if(buf%2) used[i]=1;
			buf/=2;
		}
		ll sum=0;
		if(used[0]) sum+=a+b;
		else sum+=a-b;
		if(used[1]) sum+=c;
		else sum-=c;
		if(used[2]) sum+=d;
		else sum-=d;
		if(sum==7) {
			cout<<a;
			if(used[0]) cout<<"+";
			else cout<<"-";
			cout<<b;
			if(used[1]) cout<<"+";
			else cout<<"-";
			cout<<c;
			if(used[2]) cout<<"+";
			else cout<<"-";
			cout<<d;
			cout<<"=7"<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 764
import java.util.*;
class Main {
    static int diagonal;
    public static void main (String []args){
	Scanner sc = new Scanner(System.in);
	int h = sc.nextInt();
	int w = sc.nextInt();
	while(h > 0 && w > 0){
	    diagonal = h*h + w*w;
	    printResult(h,w);
	    h = sc.nextInt();
	    w = sc.nextInt();
	}
    }
    static void printResult(int height,int width){
	boolean isfirst = true;
	while(diagonal < 150*150+150*150){
	    if(isfirst){
		for(int h=height+1;h<150;h++){
		    for(int w=h+1;w<150;w++){
			if((h*h+w*w)==diagonal) {
			    System.out.println(h +" " + w);
			    return;
			}
		    }
		}
		isfirst = false;
	    }else{
		for(int h=1;h<150;h++){
		    for(int w=h+1;w<150;w++){
			if((h*h+w*w)==diagonal) {
			    System.out.println(h +" " + w);
			    return;
			}
		    }
		}
	    }
	    diagonal++;
	}
    }	
}

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

using namespace std;

int main() {
	string s, s1, s2;
	cin >> s;
	int64_t q; cin >> q;
	int64_t t, f, rv = 0;
	char c;
	while(q--){
		cin >> t;
		if(t == 1){
			rv = 1-rv;
		}
		else{
			cin >> f >> c;
			if(f == 1){
				if(rv == 0) s1 = c+s1;
				else s2 = s2+c;
			}
			else{
				if(rv == 0) s2 = s2+c;
				else s1 = c+s1;
			}
		}
	}
	if(rv){
		for(int64_t i = s2.size()-1; i >= 0; i--) cout << s2[i];		
		for(int64_t i = s.size()-1; i >= 0; i--) cout << s[i];		
		for(int64_t i = s1.size()-1; i >= 0; i--) cout << s1[i];		
		cout << endl;
	}
	else cout << s1 << s << s2 << endl;
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var C = input[2];
            var K = input[3];

            Console.WriteLine(A + B >= K ? Math.Min(A, K) : 2 * A + B - K);
        }
    }
}


Measured memory_bytes: 28236
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define nm "A" 
#define stdi freopen(nm".in","r",stdin);
#define stdo freopen(nm".out","w",stdout);
#define IO stdi stdo                   
#define ll long long                   
#define ld long double                                                                                                           
#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;                    
const ll maxn=1e6+123,MX=1e9,inf=1e9,block=2;
ll n,cnt[500],ans;
string s[500];
vector< pair < int , int > > v[maxn];
void calc( pair<int,int>a,pair<int,int>b){
	// a+b=a.f+a.s=b.f+b.s
	// b-a=b.s-a.f=a.s-b.f
	// 2*b=x+y
	int y=b.s-a.f+n;
	cnt[y%n]++;
}
int main(){
	cin>>n;    	
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			v[(i+j)%n].pb(mp(i,j));
	for(int x=0;x<n;x++){
		for(int q=0;q<v[x].size();q++){
		 	for(int w=0;w<v[x].size();w++){   
		 		if(s[v[x][q].f][v[x][q].s]==s[v[x][w].f][v[x][w].s])
		 			calc(v[x][q],v[x][w]);
            }
		}	
	}
	for(int a=0;a<n;a++)
		for(int b=0;b<n;b++)
			if(cnt[(a-b+n)%n]==n*n)
				ans++;
	cout<<ans;
}


Measured memory_bytes: 25088
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
long long sum[N], tot;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[a[i]]++;
    for (int i = 1; i <= n; i++) {
        tot += sum[i] * (sum[i] - 1) / 2;
    }
    for (int i = 1; i <= n; i++) {
        printf("%lld\n", tot - (sum[a[i]] - 1));
    }
    return 0;
}

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

int partition(vector<int> &a,int p,int r){
    int x = a[r];
    int i = p - 1;
    for(int j = p;j < r;j++){
        if(a[j] <= x){
            i = i+1;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i + 1;
}

int main(){
    int n,part;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    part = partition(a,0,a.size() - 1);
    for(int i = 0;i < n;i++){
        if(i == part){
            printf("[%d]",a[i]);
        }else printf("%d",a[i]);
      if(i != n - 1){
        printf(" ");
      }else {
        printf("\n");
      }
    }
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
#include <stack>
#define ll long long
using namespace std;
int t,n,m;
int a,b,c;
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        int x=floor(b/a);
        int ans=0;
        if(x>c) ans=c;
        else ans=x;
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t; cin>>s>>t;
	bool ret=true;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			ret=false;
			break;
		}
	}
	if(ret) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3624
#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 <cmath>         // sqrt
#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 <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N + 1);
  rep(i, N - 1)
  {
    cin >> A.at(i);
    B.at(A.at(i))++;
  }

  rep2(i, 1, N + 1)
  {
    cout << B.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 6432
program new2
  implicit none
  integer :: N,M,i,migi,hidari
  integer,allocatable :: L(:,:)

  read(*,*) N,M

  allocate(L(M,2))
!  read(*,*) L                                                                                                                                           
  do i=1,M
     read(*,*) L(i,1),L(i,2)
  enddo
  hidari=maxval(L(:,1))
  migi=minval(L(:,2))
  !write(*,*) hidari,migi                                                                                                                                
  if(migi.lt.hidari) then
     write(*,'(i0)') 0
  else
     write(*,'(i0)') migi-hidari+1
  endif
  deallocate(L)



end program new2





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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(unsigned int key){
  NodePointer n;

  for(n = nil->next ; n != nil ;n = n->next){
    if(n->key == key) return n; }
    return nil;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t;
  t = nil->prev;
  nil->prev->prev->next = nil;
  nil->prev =nil->prev->prev;
  free(t);
}

void delete(int key){
  NodePointer t;
  t = listSearch(key);
  if(t != nil) deleteNode(t);
  }


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32928
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val K = input.nextInt()
    val S = input.next()
    
    if (S.length <= K) {
      println(S)
    } else {
      println("${S.substring(0, K)}...")
    }
  }
}

Measured memory_bytes: 36484
#include<bits/stdc++.h>
using namespace std;
int f[100009];
main()
{
    string s;
    cin >> s;
    int x = (s.size()-1)/2 , y= (s.size())/2, ans = 0;
    if (s.size()%2) ans++;
    for (int i = s.size()%2; i <= x; i++)
    {
        if(s[x-i] == s[x-i+1] && s[y+i] == s[y+i-1]) ans++;
          else break;
    }
    cout << y+ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    int mx = (n-1)*(n-2)/2;
    if (k > mx) {cout << -1 << endl; return 0;}
    int ct = n-1;
    vector<P> ans;
    rep(i,n-1) ans.push_back(P(1,i+2));
    if (mx == k) {
        cout << ct << endl;
        rep(i,ans.size()) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
        return 0;
    } else {
        for (int i = 2; i < n; i++) {
            for (int j = i+1; j <= n; j++) {
                ans.push_back(P(i,j));
                mx--;
                ct++;
                if (mx == k) {
                    cout << ct << endl;
                    rep(i,ans.size()) {
                        cout << ans[i].first << " " << ans[i].second << endl;
                    }
                    return 0;
                }
            }
        }
    }
}

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

n = int(input())
arr = []
for i in range(n):
    arr.append(int(input()))
count = max(arr[0]-1,0)
index = 2
for i in range(1,n):
    if arr[i] > index:
        count += (arr[i] - 1) // index
    if arr[i] == index:
        index += 1
print(count)


Measured memory_bytes: 7132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  long double r;
  cin >> r;
  cout << fixed << setprecision(12) << r*M_PI*2 << endl;
  
  return 0;
    

}


Measured memory_bytes: 3812
N = int(input())
c = 0
ans = False
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        c += 1
    else:
        c = 0
    if c >= 3:
        ans = True
print('Yes' if ans else 'No')

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	char s[20];

	cin>>s;

	FOR(i,19){
		if(s[i]==',')cout<<" ";
		else cout<<s[i];
	}

	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	sort(all(s));
	if (s[0] == 'A' && s[1] == 'A' && s[2] == 'B') cout << "Yes\n";
	else if (s[0] == 'A' && s[1] == 'B' && s[2] == 'B') cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    xy = []
    for _ in range(N):
        xy.append(LI())
    xy2g = defaultdict(int)
    g2xy = defaultdict(set)
    for x, y in xy:
        y = -y
        gx = xy2g[x]
        gy = xy2g[y]
        if gx != 0 and gy != 0 and gx != gy:  # merge
            if len(g2xy[gx]) < len(g2xy[gy]):
                gx, gy = gy, gx
            for xy in g2xy[gy]:
                xy2g[xy] = gx
            g2xy[gx] |= g2xy[gy]
            g2xy[gy].clear()
        else:
            g = gx or gy or x
            xy2g[x] = xy2g[y] = g
            g2xy[g] |= {x, y}
    ans = -N
    for xys in g2xy.values():
        nx = sum(xy > 0 for xy in xys)
        ny = len(xys) - nx
        ans += nx * ny
    return ans

print(main())

Measured memory_bytes: 114396
#include <bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main(){
    int a,b,x;
    cin>>a>>b>>x;
    double y=2.0*x/a/b;
    double ans;
    if(y<=a)
        ans=atan(b/y);
    else{
        double v=a*a*b-x;
        double t=v/a*2/a;
        ans=atan(t/a);
    }
//    printf("%.10f\n",y);
//    printf("%.10f\n",b/y);
    printf("%.10f\n",ans*180/PI);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
	
	public static final int CONSTANTE = 3;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int line1 = Integer.parseInt(br.readLine());
		int[][] array = new int[line1][CONSTANTE];
		
		for(int i = 0; i < line1 ; i++) {
			String[] S = br.readLine().split(" ");
			array[i][0] = Integer.parseInt(S[0]);
			array[i][1] = Integer.parseInt(S[1]);
			array[i][2] = Integer.parseInt(S[2]);
		}
		int[] array1 = new int[CONSTANTE];
		int[] array2 = new int[CONSTANTE];
		
		for(int i = 0; i < CONSTANTE; i++) {
			array1[i] = array[0][i];
		}
		System.out.println(metodo(line1, array, array1, array2));
	}
	
	public static int metodo(int number, int[][] a, int[] array, int[] array1) {
		
		for(int i = 1; i < number ; i++) {
			for(int j = 0; j < CONSTANTE; j++) {
				for(int k = 0; k < CONSTANTE; k++) {
					if(j == k) continue;
					array1[j] = Math.max(array1[j], a[i][j]+ array[k]);
				}
			}
			array = array1;
			array1 = new int[CONSTANTE];
		}
		
	
		return Math.max(array[0], Math.max(array[1], array[2]));
	}
}

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

int main(){
  int n;
  cin >> n;
  int ans=0;
  map<string, int> get;
  for (int i=0; i<n; i++){
    string s;
    cin >> s;
    if(get.count(s))get[s]++;
    else{
      get[s]=1;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 19116