akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    if (N % 2) {
        if (S.front() == S.back()) {
            write("Second");
        }
        else {
            write("First");
        }
    }
    else {
        if (S.front() == S.back()) {
            write("First");
        }
        else {
            write("Second");
        }
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N; cin >> N;
  string s;
  cin >> s;
  int ans = N;
  for (int i = 1; i < N; i++) {
    if (s[i] == s[i-1]) ans--;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    string a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            cnt++;
    }
    cout<<cnt;
}



Measured memory_bytes: 3820
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N, i;
    string S, T;
    cin >> N >> S >> T;
    for (i = N; i >= 1; i--) if (S.substr(N - i) == T.substr(0, i)) break;
    cout << 2 * N - i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    int ans = 0;
    int num = -1;
    for(int i=0;i<N;i++){
        if(num != A[i]){
            ans++;
            num = A[i];
        }
    }
    if(ans % 2 == 0){
        ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3404
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;

class disjointset{

    private:
    int sz;
    vector<int>parent_or_size;//親ノードの番号 or -(集合の大きさ)

    public:
    disjointset():sz(0){}
    disjointset(int n):sz(n),parent_or_size(n,-1){}

    //経路圧縮 parent配列の更新
    int root(int n){
        assert(0<=n&&n<sz);
        return (parent_or_size[n]<0?n:parent_or_size[n]=root(parent_or_size[n]));
    }

    void unite(int x,int y){
        assert(0<=x&&x<sz && 0<=y&&y<sz);
        x=root(x);y=root(y);
        if(x==y)return;
        if(-parent_or_size[x]<-parent_or_size[y])std::swap(x, y);
        parent_or_size[x] += parent_or_size[y]; //集合の大きさ更新
        parent_or_size[y] = x;                  //小さい木が大きい木に属する
    }

    bool same(int x,int y){assert(0<=x&&x<sz && 0<=y&&y<sz);return root(x)==root(y);}

    int size(int n){assert(0<=n&&n<sz);return -parent_or_size[root(n)];}
};

int N,Q,t,u,v;
int main(){
    cin>>N>>Q;
    disjointset ds(N);
    for(int i=0;i<Q;i++){
        cin>>t>>u>>v;
        if(t) cout<<ds.same(u,v)<<endl;
        else ds.unite(u,v);
    }
    return 0;
}

Measured memory_bytes: 3976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scaner sc = new Scaner();
        write wr = new write();

        var s=sc.Str;
        int N=s.Length;
        bool tr=false;

        for(int i=0;i<N-1;++i){
            if((s[i]==s[i+1])&&!tr){
                wr.wri((i+1).ToString()+" "+(i+2).ToString());

               tr=true;
            }
        }
        for(int i=0;i<N-2;++i){
            if((s[i]==s[i+2])&&!tr){
                wr.wri((i+1).ToString()+" "+(i+3).ToString());
               tr=true;

            }
        }
        
        if(!tr)wr.wri("-1 -1");
        

    
    }


    static int factmod(int X){
        int ret=1;
        for(int i=1;i<=X;++i){
            ret*=i;
            ret%=MOD;
        }
        return ret;
    }
}





class Scaner
{
    public string Str => Console.ReadLine();

    public string[] StrArr => Str.Split(' ');

    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public char[] CharArr => Str.ToArray();
    public long Long1 => LongArr[0];
    public int Int1 => IntArr[0];
    
}



class write
{
    public  void wri<T>(T x)
    {
        Console.WriteLine(x);
    }
}



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

typedef long long ll;

ll gcd(ll x, ll y){
    if(x > y){
        return gcd(y, x);
    }
    if(x == 0){
        return y;
    }
    return gcd(y%x, x);
}

int main(){
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll hc, lc, hd, ld;
    hc = b/c;
    hd = b/d;
    lc = (a-1)/c;
    ld = (a-1)/d;
    ll cd, dd;
    cd = hc-lc;
    dd = hd-ld;
    ll lcm = c * d / gcd(c, d);
    ll hm = b/lcm;
    ll lm = (a-1)/lcm;
    ll md = hm-lm;
    printf("%lld", b-a+1-cd-dd+md);
    //printf("%lld %lld %lld %lld %lld", b, a, cd, dd, md);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int nC2(int n){ return n*(n-1)/2; }


int main(){
  vector<int> so = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  vector<vector<int>> fac(100, vector<int>(25,0));
  for(int i=1; i<=100; i++){
    rep(s, (int)so.size()){
      int now = i;
      while(1){
        if(now % so[s] == 0){
          fac[i-1][s]++;
          now /= so[s];
        }
        else break;
      }
    }
  }
  rep(i,100){
    if(i==0) continue;
    rep(j,25){
      fac[i][j] += fac[i-1][j];
    }
  }

  int N; cin >> N;
  vector<int> A = fac[N-1];
  // rep(i,25) cout << A[i] << endl;
  int ans = 0;
  for(int i=0; i<25; i++){
    if(A[i]>=74) ans++;
    for(int j=i+1; j<25; j++){
      if(A[i]>=4&&A[j]>=14) ans++;
      if(A[i]>=14&&A[j]>=4) ans++;
      if(A[i]>=24&&A[j]>=2) ans++;
      if(A[i]>=2&&A[j]>=24) ans++;
      for(int k=j+1; k<25; k++){
        if(A[i]>=4&&A[j]>=4&&A[k]>=2) ans++;
        if(A[i]>=4&&A[j]>=2&&A[k]>=4) ans++;
        if(A[i]>=2&&A[j]>=4&&A[k]>=4) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    int w, h, n; cin >> w >> h >> n;
    int sx = 0, sy = 0, ex = w, ey = h;
    REP(i, n){
        int x, y, a; cin >> x >> y >> a;
        switch(a){
        case 1:
            sx = max(sx, x); break;
        case 2:
            ex = min(ex, x); break;
        case 3:
            sy = max(sy, y); break;
        default:
            ey = min(ey, y); break;
        }
    }
    cout << ((sx < ex && sy < ey) ? (ex - sx) * (ey - sy) : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 21:43:24 2018
ABC045C
@author: maezawa
"""

s = input()
n = len(s)-1
sums = 0

for i in range(2**n):
    signs =[]
    for j in range(n):
        if i & (1<<j):
            signs.append('+')
        else:
            signs.append('')
    #print(signs)
    eq = ''
    for k in range(n):
        eq += s[k] + signs[k] 
    eq += s[n]
    #print(eq)
    sums += eval(eq)
    
print(sums)
        

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

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


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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> bi(m);
  for (int i = 0; i < m; i++) cin >> bi.at(i);
  vector<int> ai(m);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ai.at(j);
    }
    int sum = 0;
    for (int j = 0; j < m; j++) {
      sum += bi.at(j)*ai.at(j);
    }
    if (sum+c > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (998244353LL)

ll N, A, B, K;

ll Pow(ll x, ll p)
{
    if (p == 0) return 1;
    else if (p == 1) return x;
    else if (p%2 == 0) {
        ll Tmp = Pow(x, p/2);
        return (Tmp*Tmp) % MOD;
    }
    else return (x * Pow(x, p-1)) % MOD;
}

#if 0
ll INV[300005];
ll Inv(ll x)
{
    if (INV[x] != 0) return INV[x];
    return INV[x] = Pow(x, MOD-2);
}
#endif

ll Inv(ll x)
{
    return Pow(x, MOD-2);
}

ll FACT[300005];
ll Fact(ll x)
{
    if (x == 0) return 1LL;
    else if (x == 1) return 1LL;
    else if (FACT[x] != 0) return FACT[x];
    else return FACT[x] = (x * Fact(x-1)) % MOD;
}

ll INV_FACT[300005];
ll InvFact(ll x)
{
    if (INV_FACT[x] != 0) return INV_FACT[x];
    else return INV_FACT[x] = Inv(Fact(x));
}

ll Comb(ll n, ll p)
{
    ll Ret;
    Ret = Fact(n);
    Ret = (Ret * InvFact(p)) % MOD;
    Ret = (Ret * InvFact(n-p)) % MOD;
    return Ret;
}

ll GetGcd(ll A, ll B)
{
    if (A < B) swap(A, B);
    if (B==0) return A;
    else return GetGcd(B, A%B);
}

pll Dioph(ll A, ll B)
{
    if (A >= B) {
        if (B==0) {
            return {K/A, 0};
        }
        pll Tmp = Dioph(B, A%B);
        return {Tmp.second, Tmp.first - A/B * Tmp.second};
    } else {
        if (A==0) {
            return {0, K/B};
        }
        pll Tmp = Dioph(A, B%A);
        return {Tmp.first - B/A * Tmp.second, Tmp.second};
    }
}

int main(int argc, const char * argv[]) {
    cin >> N >> A >> B >> K;
    
    if (K == 0) {cout << 1 << endl; return 0;}
    ll Gcd = GetGcd(A, B);
    if (K%Gcd != 0) {cout << 0 << endl; return 0;}
    pll P = Dioph(A, B);
    ll dp = abs(B/Gcd);
    ll dq = - A * dp / B;
    ll tmp = P.first/dp;
    P.first = P.first - tmp * dp;
    P.second = P.second - tmp * dq;
    if (P.first < 0) {P.first += dp; P.second += dq;}
    
    ll Res = 0;
    while (P.first <= N && P.second >= 0) {
        if (P.second <= N) {
            Res = (Res + (Comb(N, P.first) * Comb(N, P.second)) % MOD) % MOD;
        }
        P.first += dp;
        P.second += dq;
    }
    
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  
  double y = x / a; 
  double deg;
  if(y < a*b/2){
    double aa = y*2/b;
    deg = (180*atan(b/aa))/M_PI;
  }
  else{
    double bb = (a*b - y)*2/a;
    deg =(180*(atan(bb/a)))/M_PI;
  }
  
  cout << setprecision(10) <<fixed << deg;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

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



Measured memory_bytes: 3116
#include<stdio.h>
int main(void){
	int a[7][2];
	int i;
	for(i=0;i<7;i++){
		scanf("%d%d",&a[i][0],&a[i][1]);
		printf("%d\n",a[i][0]>a[i][1]?a[i][0]-a[i][1]:a[i][1]-a[i][0]);
		
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main(void){
     int H,W ;
     cin >> H >> W ;
     char s[8][8] ;
     int count  = 0 ;
     for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
               cin >> s[i][j] ;
               if(s[i][j]=='#') count++ ;
          }
     } 
    
    if(count==H+W-1){
         cout << "Possible" ;
    }else{
         cout << "Impossible" ;
    }
        
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	VI a(4);
	FOR(i, 0, 4)
		cin >> a[i];
	sort(ALL(a));


	bool ok = a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9;
	if (ok)
		cout << "YES";
	else
		cout << "NO";
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    ll cnt=0;
    int carry=0;
    lmat dp = lmat(n.size(), lvec(2));
    dp[n.size()-1][0] = n[n.size()-1]-'0';
    dp[n.size()-1][1] = 10 -(ll)(n[n.size()-1]-'0');
    for (ll i = n.size()-2; i >=0; i--)
    {
        dp[i][0] = min(dp[i+1][0] + (ll)(n[i]-'0'), dp[i+1][1]+(ll)(n[i]-'0')+1);
        
        dp[i][1] = min(dp[i+1][0] + 10 - (ll)(n[i]-'0'), dp[i+1][1]+ 10 - ((ll)(n[i]-'0')+1));
        
        
    }
    cout << min(dp[0][0], dp[0][1]+1) << endl;
}

Measured memory_bytes: 55964
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void kansuu1(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      kansuu1(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void kansuu2(){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) kansuu1(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d", &u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  kansuu2();
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int bubbleSort(int A[], int N) {
    int c = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = 1; j < N-i; j++) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = true;
                c++;
            }
        }
    }
    return c;
}

int main()
{
    int A[101];
    int N;

    while (cin >> N) {

        if (N == 0)
            break;

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

        cout << bubbleSort(A, N) << endl;
    }

    return 0;
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"

using namespace std;

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

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

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

int  main() {
	
	int n;
	string s, t;
	cin >> n;
	cin >> s;
	cin >> t;

	int cnt = 0;

	rep(i, n) {
		if(s[i] != t[cnt]) cnt = 0;
		if (s[i] == t[cnt])	cnt++;
	}
	
	pr(2*n-cnt);

	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	int res = 0;
	rep(i, s.size()) res += s[i]-'0';
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
//declaration
bool is_leap_year(int y);

int get_leap_years(int* strage, int begin, int enden);
//============end_of_declaration=============================//
int main()
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }
        
        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int* strage, int begin, int enden)
{
    int times = 0;//count how many leap years it has.
    for(int i = begin; i <= enden; i++) {
        if(is_leap_year(i) == true) {
            *(strage + times) = i;
            times++;
        }
    }
    return times;
}

Measured memory_bytes: 1044
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1"# => r#"1"#,
r#"2"# => r#"2"#,
r#"3"# => r#"2"#,
r#"4"# => r#"4"#,
r#"5"# => r#"4"#,
r#"6"# => r#"4"#,
r#"7"# => r#"4"#,
r#"8"# => r#"8"#,
r#"19"# => r#"16"#,
r#"20"# => r#"16"#,
r#"100"# => r#"64"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }
    let mut ans = (1, 0);

    for i in 1..n+1 {
        if i % 2 != 0 {
            continue;
        }
        let mut cnt = 0;
        let mut j = i;
        // println!("{}", i);
        loop {
            j /= 2;
            cnt += 1;

            if j <= 0 || j % 2 != 0 {
                break;
            }
        }
        if ans.1 < cnt {
            ans.0 = i;
            ans.1 = cnt;
        }
    }

    ans.0.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<ll> p(n),pos(n+1,0);
	rep(i,n){
		cin>>p[i];
		pos[p[i]] = i+1;
	}
	ll ans = 0;

	set<ll> sl,sr;
	sl.insert(0);
	sr.insert(n+1);
	for (ll now = n; now >= 1; now--){
		ll x_r = *sr.lower_bound(pos[now]);
		sr.erase(x_r);
		sr.insert(n+1);
		ll x_rr = *sr.lower_bound(x_r);
		sr.insert(x_r);

		ll x_l = *sl.lower_bound(-pos[now]);
		sl.erase(x_l);
		sl.insert(0);
		ll x_ll = *sl.lower_bound(x_l);
		sl.insert(x_l);

		x_l *=-1;
		x_ll *= -1;

		ans += now*(x_r-pos[now])*(x_l-x_ll);
		ans += now*(x_rr-x_r)*(pos[now]-x_l);


		sr.insert(pos[now]);
		sl.insert(-1*pos[now]);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 11136
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e5+4;

vector<int> v[N];

int main()
{
	map<int,int> ma;

	int n;

	scn(n);

	ll ans=0;

	rep(i,1,n+1)
	{
		int val; scn(val);

		if(i-val>=0)
		ans+=ma[i-val];

		ma[i+val]++;
	}

	lpri(ans);

    return 0;
}

Measured memory_bytes: 16416
while True:
    a,op,b = map(str,input().split())

    a = int(a)
    b = int(b)
    if op == "*":
        print(a*b)
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break



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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	int A[N][M], B[M];
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int tmp = C;
		for (int j = 0; j < M; j++) {
			tmp += A[i][j] * B[j];
		}
		if (tmp > 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int Q,c[1000],a[1000],n[1000],ans[1000];
    cin>>Q;
    for(int i=0;i<Q;i++)
    {
        cin>>c[i]>>a[i]>>n[i];
        ans[i]=0;
        while(n[i])
        {
            if(c[i]==0||a[i]==0)break;
            c[i]--;
            a[i]--;
            n[i]--;
            ans[i]++;
        }
        while(a[i])
        {
            if(c[i]<2)break;
            c[i]-=2;
            a[i]--;
            ans[i]++;
        }
        ans[i]+=c[i]/3;
    }
    for(int i=0;i<Q;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n , x ;
cin >> n >> x ;
vector<vector<ll>> v(n, vector<ll>(3,0) );
vector<pair<ll,ll>> s;
ll d=0;
rep(i,n){
  cin >> v[i][0] >> v[i][1] >> v[i][2] ;
  d+=v[i][0]*v[i][1];
  s.emplace_back(v[i][0]*v[i][1]+(x-v[i][0])*v[i][2],i);
}
sort(s.rbegin(),s.rend());
vector<ll> sum;
sum.push_back(s[0].first);
rep(i,n-1)sum.push_back(s[i+1].first+sum.back());
rep(i,n){
  ll z=0,an;
  auto itr = lower_bound(sum.begin(), sum.end(), d);
  z=d-((itr-sum.begin()-1)<0 ? 0 : sum[itr-sum.begin()-1] );
  an=x*(itr-sum.begin());
  if(itr-sum.begin()>i){
    itr = lower_bound(sum.begin(), sum.end(), d+s[i].first);
    z=d-sum[itr-sum.begin()-1]+s[i].first;
    an=x*(itr-sum.begin()-1);
  }
  if(z-v[s[i].second][0]*v[s[i].second][1]>0)an+=v[s[i].second][0]+(z-v[s[i].second][0]*v[s[i].second][1]+v[s[i].second][2]-1)/v[s[i].second][2];
  else an+=(z+v[s[i].second][1]-1)/v[s[i].second][1];
  ans=min(ans,an);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 9076
#include <stdio.h>

int main(void){
  int D, N;
  int i, j, k;
  scanf("%d %d", &D, &N);
  if(D == 0){
    if(N < 100){
      printf("%d\n", N);
    }else{
      printf("%d\n", 101);
    }
  }
  if(D == 1){
    if(N < 100){
      printf("%d\n", N*100);
    }else{
      printf("%d\n", 10100);
    }
  }
  if(D == 2){
    if(N < 100){
      printf("%d\n", N*10000);
    }else{
      printf("%d\n", 1010000);
    }
  }
  return 0;
}


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

int main() {
  int64_t a,b,x;
  cin >> a >> b >> x;
  int64_t cnt = 0;
  cnt = b/x-a/x;
  if(a%x == 0){
    cnt += 1;
  }
  cout << cnt << 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 long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
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++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n, m;

bool exi[100][100];
int c[100][100];

int ma = 0;
vector<int> v;
void dfs(int id) {
	if (id == n)return;
	rep(j, v.size()) {
		if (!exi[v[j]][id]) {
			dfs(id + 1); return;
		}
	}
	int sum = 0;
	v.push_back(id);
	if (v.size() > 1) {
		rep(i, v.size()) {
			int mi = mod;
			rep(j, v.size()) {
				if (i == j)continue;
				mi = min(mi, c[v[i]][v[j]]);
			}
			sum += mi;
		}
	}
	ma = max(ma, sum);
	dfs(id + 1);
	v.pop_back();

	dfs(id + 1);
}

void solve() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--; int cost; cin >> cost;
		c[a][b] = c[b][a] = cost;
		exi[a][b] = exi[b][a] = true;
	}
	dfs(0);
	cout << ma << endl;
}

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


Measured memory_bytes: 3280
import itertools
N, K = [int(_) for _ in input().split()]
A = [0] + [int(_) for _ in input().split()]

cumsum_p = list(
    itertools.accumulate([A[i] if A[i] > 0 else 0 for i in range(N + 1)]))
cumsum_m = list(
    itertools.accumulate([A[i] if A[i] < 0 else 0 for i in range(N + 1)]))
ans = -float('inf')
for i in range(N - K + 1):
    ans = max(ans, -(cumsum_p[i + K] - cumsum_p[i]),
              cumsum_m[i + K] - cumsum_m[i])
ans += cumsum_p[-1]
print(ans)


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

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

    long long int ans = 0;
    for (int i = 1; i <= n; i++) {
        if ((i % 3 != 0) && (i % 5 != 0)) {
            ans += i;
        }
    }

    cout << ans << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_X 1000
#define MAX_Y 1000
#define MAX_Z 1000
#define MAX_K 3000
#define MAX_A 10'000'000'000
#define MAX_ABC 30'000'000'000

i64 X, Y, Z, K;
i64 A[MAX_X];
i64 B[MAX_Y];
i64 C[MAX_Z];

int main() {
    cin >> X >> Y >> Z >> K;
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    sort(A, A + X, greater<i64>());
    sort(B, B + Y, greater<i64>());
    sort(C, C + Z, greater<i64>());

    using T = tuple<i64, i64, i64, i64>;
    auto comp = [](const T &t1, const T &t2) {
        return get<0>(t1) < get<0>(t2);
    };
    priority_queue<T, vector<T>, decltype(comp)> pq(comp);
    set<T> topK;

    T t = make_tuple(A[0] + B[0] + C[0], 0, 0, 0);
    pq.push(t);
    topK.insert(t);

    i64 cnt = 0;
    while (cnt < K) {
        i64 s, i, j, k;
        t = pq.top(); pq.pop();
        tie(s, i, j, k) = t;

        cout << s << endl;
        cnt++;

        auto push = [&](i64 i, i64 j, i64 k, i64 check) {
            if (check) {
                t = make_tuple(A[i] + B[j] + C[k], i, j, k);
                if (topK.count(t) == 0) {
                    pq.push(t);
                    topK.insert(t);
                }
            }
        };
        push(i + 1, j, k, i + 1 < X);
        push(i, j + 1, k, j + 1 < Y);
        push(i, j, k + 1, k + 1 < Z);
    }

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc179
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc179B();
            Console.Out.Flush();
        }

        public static void solve_abc179B()
        {
            int t = Convert.ToInt32(Console.ReadLine());
            int cnt = 0;
            int max = 0;
            while (t-- > 0)
            {
                int[] d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                if (d[0] == d[1])
                {
                    cnt++;
                }
                else
                {
                    cnt = 0;
                }
                max = Math.Max(max, cnt);
            }
            Console.WriteLine(max >= 3 ? "Yes" : "No");
        }

        public static void solve_abc179A()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.EndsWith('s') ? s + "es" : s + "s");
        }
    }
}

Measured memory_bytes: 28456
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
a=""
b=""
for i in range(len(s)):
    a+=(s[i])
for i in range(len(t)):
    b+=(t[i])

c=sorted([a,b])
if c[1]==a:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 38384
if __name__ == "__main__":

	x, y = map(int, input().split())
	a = [1, 3, 5, 7, 8, 10, 12]
	b = [4, 6, 9, 11]
	if (x in a and y in a) or (x in b and y in b):
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 3060
# 定数
A = 0
B = 1
C = 2

# リスト
N = int(input())
a = list()
b = list()
c = list()

dp = list()

for i in range (0, N):
	happiness = list(map(int, input().split()))
	a.append(happiness[A])
	b.append(happiness[B])
	c.append(happiness[C])

for i in range (0, N + 1):
	dp.append([0, 0, 0])


for i in range(1, N + 1):
	dp[i][A] = max(dp[i-1][B] + a[i-1], dp[i-1][C] + a[i-1])
	dp[i][B] = max(dp[i-1][A] + b[i-1], dp[i-1][C] + b[i-1])
	dp[i][C] = max(dp[i-1][A] + c[i-1], dp[i-1][B] + c[i-1])

# N+1日目の幸福度と考えると、添え字は N

print(max(dp[N][A], dp[N][B], dp[N][C]))

Measured memory_bytes: 40484
#include <bits/stdc++.h>
using namespace std;
#define endl '\n' 
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef double db;
typedef pair<int,int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const db EXP = 1e-9;
int main() {
	IO;
	string s;
	int k;
	cin >> k >> s;
	if(s.length() > k) {
		cout << s.substr(0,k) << "..." << endl;
	}
	else cout << s << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll x,y; cin >> x >> y;
    cout << x + y/2 << endl;
}

Measured memory_bytes: 256
/*
ID: jerrywcy
LINK:
LANG: C++
STATUS:
*/
#include <bits/stdc++.h>

#define init(array,x) memset(array,x,sizeof(array))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f;

ull n;
ull a,b;

ull read(){
    ull f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	n=read();
	a=read();b=read();
	if ((b-a)%2==1){
		ull minl=a+(b-a-1)/2;
		// cout<<minl<<endl;
		ull minr=(n-b+1)+(n-(a+(n-b+1)))/2;
		// cout<<minr<<endl;
		printf("%lld\n",min(minl,minr));
	}
	else{
		printf("%lld\n",(b-a)/2);
	}

	return 0;
}

Measured memory_bytes: 256
import Data.Char

main :: IO ()
main = getLine >>= main' . map (\c -> ord c - ord '0')
    where
        main' s = readLn >>= print . solve s

solve :: [Int] -> Int -> Int 
solve xs k
    | all (== 1) ys = 1
    | otherwise = head $ filter (/= 1) ys
    where
        ys = take k xs 

Measured memory_bytes: 508
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x, t;
    cin >> n >> x >> t;
    cout << ((n - 1) / x + 1) * t;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int mod=1000000007,N=100005;
int n,m,x[N];
struct matrix{int t[3][3];}X1,X2,ans,I;

int qm(int x) {return x>=mod?x-mod:x;}
matrix operator * (matrix A,matrix B) {
	matrix C;
	for(RI i=0;i<3;++i)
		for(RI j=0;j<3;++j) C.t[i][j]=0;
	for(RI k=0;k<3;++k)
		for(RI i=0;i<3;++i)
			for(RI j=0;j<3;++j)
				C.t[i][j]=qm(C.t[i][j]+1LL*A.t[i][k]*B.t[k][j]%mod);
	return C;
}
matrix qpow(matrix X,int Y) {
	matrix re=I;
	for(;Y;Y>>=1,X=X*X) if(Y&1) re=re*X;
	return re;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=m;++i) scanf("%d",&x[i]);
	I.t[0][0]=I.t[1][1]=I.t[2][2]=1,ans=I;
	X1.t[0][0]=2,X1.t[0][1]=2,X1.t[0][2]=1;
	X1.t[1][0]=1,X1.t[1][1]=1,X1.t[1][2]=1;
	X1.t[2][0]=1,X1.t[2][1]=0,X1.t[2][2]=1;
	X2.t[0][0]=1,X2.t[0][1]=2,X2.t[0][2]=1;
	X2.t[1][0]=0,X2.t[1][1]=1,X2.t[1][2]=1;
	X2.t[2][0]=0,X2.t[2][1]=0,X2.t[2][2]=1;
	for(RI i=1;i<=m;++i) {
		ans=qpow(X1,x[i]-x[i-1]-1)*ans;
		ans=X2*ans;
	}
	ans=qpow(X1,n-x[m]-1)*ans;
	printf("%d\n",qm(qm(ans.t[0][0]+ans.t[0][1])+ans.t[0][2]));
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	  public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        int a=scan.nextInt();
	        int b=scan.nextInt();
	        System.out.println(a*b+" "+(a+b)*2);
	    }
	    
	}



Measured memory_bytes: 26208
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	VecP x(n);
	rep(i, n) cin >> x[i].fs >> x[i].sc;
	rep(i, n) x[i].fs += x[i].sc;
	sort(all(x));

	ll ans = 1, r = x[0].fs;
	repn(i, n-1){
		if(x[i].fs-2*x[i].sc >= r){
			ans++;
			r = x[i].fs;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n; cin >> n;
	vector<long long> x(n), y(n);
	for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
	long long minxpy = 1e18, minxmy = 1e18;
	long long maxxpy = -1e18, maxxmy = -1e18;
	for (int i = 0; i < n; ++i) {
		minxpy = min(minxpy, x[i] + y[i]);
		minxmy = min(minxmy, x[i] - y[i]);
		maxxpy = max(maxxpy, x[i] + y[i]);
		maxxmy = max(maxxmy, x[i] - y[i]);
	}
	cout << max(maxxpy - minxpy, -minxmy + maxxmy) << endl;

	return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vi A(a), B(b);
    rep(i, a) cin >> A[i];
    rep(i, b) cin >> B[i];
    vi x(m), y(m), c(m);
    rep(i, m) {
        int s, t, u;
        cin >> s >> t >> u;
        s--; t--;
        x[i] = s; y[i] = t; c[i] = u;
    }

    lint res = INF;

    rep(i, m) {
        lint total = A[x[i]] + B[y[i]];
        total -= c[i];
        res = min(res, total);
    }

    sort(all(A));
    sort(all(B));

    res = min(res, A[0] + B[0]);

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4224
use proconio::input;

fn main() {
	input! {
		n: usize,
		wmax: usize,
		wv: [[usize; 2]; n],
	}
	let mut w: Vec<usize> = vec![];
	let mut v: Vec<Vec<usize>> = vec![vec![]; 4];

	for i in 0..n {
		w.push(wv[i][0]);
	}
	w.sort();
	w.dedup();

	for i in 0..n {
		for j in 0..w.len() {
			if wv[i][0] == w[j] {
				v[j].push(wv[i][1]);
			}
		}
	}
	for i in 0..4 {
		v[i].sort_by_key(|&x| std::cmp::Reverse(x));
	}

	let mut sv: [usize; 4] = [0; 4];
	let mut mval = 0;
	for i in 0..=n {
		if i > v[0].len() {
			break;
		}
		if i > 0 {
			sv[0] += v[0][i-1];
		}
		for j in 0..=n-i {
			if j > v[1].len() {
				break;
			}
			if j > 0 {
				sv[1] += v[1][j-1];
			}
			for k in 0..=n-i-j {
				if k > v[2].len() {
					break;
				}
				if k > 0 {
					sv[2] += v[2][k-1];
				}
				for m in 0..=n-i-j-k {
					if m > v[3].len() {
						break;
					}
					if m > 0 {
						sv[3] += v[3][m-1];
					}
					let mut sw = 0;
					match w.len() {
						1 => {sw = w[0]*i;},
						2 => {sw = w[0]*i + w[1]*j;},
						3 => {sw = w[0]*i + w[1]*j + w[2]*k;},
						4 => {sw = w[0]*i + w[1]*j + w[2]*k + w[3]*m;},
						_ => {},
					}
					if sw > wmax {
						continue;
					}
					mval = std::cmp::max(mval, sv[0] + sv[1] + sv[2] + sv[3]);
				}
				sv[3] = 0;
			}
			sv[2] = 0;
		}
		sv[1] = 0;
	}
	println!("{}", mval);
}


Measured memory_bytes: 2148
while 1:
    try:
        x1,y1,x2,y2,x3,y3,x4,y4=map(float,input().split())
        if y2-y1==0:
            if x3==x4:print("YES")
            else:print("NO")
        elif y4-y3==0:
            if x1==x2:print("YES")
            else:print("NO")
        else:
            if abs((x2-x1)/(y2-y1)*(x4-x3)/(y4-y3)+1)<0.0000001:print("YES")
            else:print("NO")
    except:break


Measured memory_bytes: 5588