akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int n;
  cin>>n;
  int vec[n];
  string s;
  cin>>s;
  for(int i=0;i<n;i++){
    if(i>=s.size()){
      vec[i]=1;
      continue;
    }
    if(s.at(i)=='1'){
      vec[i]=1;
    }
    if(s.at(i)=='2'){
      vec[i]=2;
    }
    if(s.at(i)=='3'){
      vec[i]=3;
    }
  }
  int ans=0;
  while(n>4000){
    if(n%2==0){
      for(int i=0;i<n/2;i++){
        vec[i]=abs(vec[2*i]-vec[2*i+1]);
      }
      n/=2;
      ans++;
      continue;
    }
    if(n%2==1){
      for(int i=0;i<n-1;i++){
        vec[i]=abs(vec[i]-vec[i+1]);
      }
      n-=1;
      ans++;
      continue;
    }
  }
  while(n>1){
    for(int i=0;i<n-1;i++){
      vec[i]=abs(vec[i]-vec[i+1]);
    }
    n-=1;
  }
  //cout<<ans<<endl;
  cout<<vec[0]<<endl;
}

Measured memory_bytes: 5252
import java.util.*;

public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0;

    public static int[][] happy = new int[100001][3];
    public static long[][] dp = new long[100001][4];
    public final static long oo = -1;

    public static long solve(int idx, int prev) {
        if (idx == n) {
            return 0;
        } else {
            if (dp[idx][prev] == -1) {
                long max = oo;
                for (int i = 0; i < 3; i++) {
                    if (i != prev) {
                        max = Math.max(max, solve(idx + 1, i) + happy[idx][i]);
                    }
                }
                return dp[idx][prev] = max;
            } else {
                return dp[idx][prev];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100001; i++) {
            for (int j = 0; j < 4; j++) {
                dp[i][j] = -1;
            }
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                happy[i][j] = in.nextInt();
            }
        }
        long ans = solve(0, 3);
        System.out.println(ans);
    }

}


Measured memory_bytes: 113236
n = int(input())
res = float('inf')
for a in range(1, int(n/2)+1):
    b = n-a
    tmp = 0
    for c in str(a):
        tmp += int(c)
    for c in str(b):
        tmp += int(c)
    res = min(res, tmp)
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){
  int K, X;
  cin >> K >> X;

  int mi = max(X - (K-1), -1000000);
  int ma = min(X + (K-1), 1000000);

  for(int i=mi; i<=ma; i++)
    cout << i << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)
	ans := 0
	if a >= 13 {
		ans = b
	} else if a >= 6 {
		ans = b / 2
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <string>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  int n;
  cin >> n;
  ll c[n - 1], s[n - 1], f[n - 1];
  for(int i = 0; i < n - 1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  ll time[n];
  for(int i = 0; i < n - 1; i++){
    int t = 0;
    int k = i;
    for(int j = 0; j < n - i - 1; j++){
      if(t <= s[k]){
        t += (s[k] - t);
        t += c[k];
      }
      else if(t % f[k] == 0){
        t += c[k];
      }
      else{
        t += f[k] - t % f[k];
        t += c[k];
      }
      ++k;
    }
    time[i] = t;
  }
  time[n - 1] = 0;

  string ans;
  for(int i = 0; i < n; i++){
    ans += to_string(time[i]);
    ans += "\n";
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100, b *= 100;

    ll ans1 = 0, ans2 = 0;
    double maxNoudo = 0.0;
    exrep(x1, 0, f/a) {
        exrep(x2, 0, (f - a*x1)/b) {
            ll mizu = a*x1 + b*x2;
            if(mizu == 0) {
                continue;
            }
            ll lim = (mizu/100)*e;
            exrep(y1, 0, lim/c) {
                exrep(y2, 0, (lim - c*y1)/d) {
                    ll satou = c*y1 + d*y2;
                    if(mizu + satou > f) {
                        continue;
                    }
                    double noudo = (double)(100*satou)/(double)(mizu + satou);
                    if(maxNoudo <= noudo) {
                        maxNoudo = noudo;
                        ans1 = mizu + satou;
                        ans2 = satou; 
                    }
                }
            }
        }
    }
    
    cout << ans1 << " " << ans2 << endl;
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
 int a,b,c,i,count=0;
 scanf("%d %d %d",&a,&b,&c);
 if(1<=a && a<=10000 && 1<=b && b<=10000 && 1<=c && c<=10000 && a<=b){
  for(i=a;i<b+1;i++){
   if((c%i)==0){
    count++;
   }
  }
  printf("%d\n",count);
 }
 return 0;
}

Measured memory_bytes: 596
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

 /*
  * Всегда прогоняй макс-тест перед 
  * нажатием «Отослать». Всегда.
  */ 

ll sum(ll a, ll b) {
    return ((a + b)%mod + mod)%mod;
}

ll mul(ll a, ll b) {
    return (a*b)%mod;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n);
    vector<ll> y(m);
    fr(i,n) {
        cin >> x[i];
    //    x[i] -= x[0];
    }
    fr(i,m) {
        cin >> y[i];
    //    y[i] -= y[0];
    }
/*
    for (int i = n-1; i >= 0; --i) {
        x[i] = sum(x[i], -x[0]);
    }

    for (int i = m-1; i >= 0; --i) {
        y[i] = sum(y[i], -y[0]);
    }
*/
    vector<ll> sx(n);
    vector<ll> sy(m);
    sx[0] = x[0];
    sy[0] = y[0];
    //cerr << "Sy: ";
    for (int i = 1; i < n; ++i) {
        sx[i] = sx[i-1] + x[i];
    }
    for (int i = 1; i < m; ++i) {
        sy[i] = sy[i-1] + y[i];
        
  //      cerr << sy[i] << ' ';
    }
   
//    cerr << endl;
    ll sumy = 0;

    fr(k,m-1) {
        sumy = sum(sumy, sum(sy[m-1], sum(-sy[k], - mul(m-k-1, y[k]))));
        //err(sum(sy[m-1], sum(sy[k], - mul(m-k-1, y[k]))));
    }

    ll sumx = 0;

    fr(k,n-1) {
        sumx = sum(sumx, sum(sx[n-1], sum(-sx[k], - mul(n-k-1, x[k]))));
//        err(sum(sx[n-1], sum(-sx[k], - mul(n-k-1, x[k]))));
    }

    //err(sumx, sumy);

    cout << mul(sumx, sumy) << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  multiset<int> s;
  multiset<int,greater<int>> s1;
  rep(i,0,k) {s.insert(a[i]); s1.insert(a[i]);}
  int ans= *s1.begin()-*s.begin();
  rep(i,k,n){
    s.erase(a[i-k]);
    s1.erase(a[i-k]);
    s.insert(a[i]);
    s1.insert(a[i]);
    ans=min(ans,*s1.begin()- *s.begin());
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 13272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int x,a, b;
    cin >> x >> a >> b;
    x -= a;
    x -= x/b*b;
    cout << x << endl;
}

Measured memory_bytes: 256
from sys import stdin

def calc(data):
    sum = 0
    current_time = int(data[0])
    counter = 1
    while current_time < int(data[2]) + 0.5:
        sum += int(data[1])
        counter += 1
        current_time = int(data[0]) * counter
    return sum

if __name__ == '__main__':
    input = stdin.readline().rstrip()
    input_array = input.split(" ")
    print calc(input_array)

Measured memory_bytes: 2568
#include<iostream>

using namespace std;
int main()
{
    long long a, b, r, x, tmp;

    cin >> a >> b;

    x = a * b;

    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    /* 最小公倍数を出力 */
    cout << x/b << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？
int main () {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;


bool nprime[10044] = { };
int64_t A[10000];
std::set<int64_t> base;
std::vector<int64_t> prime;

int main()
{
	nprime[0] = nprime[1] = true;
	for (int i = 2; i <= 10000; i++)
	{
		if (!nprime[i]) {
			for (int j = i * 2; j <= 10000; j += i) {
				nprime[j] = true;
			}
		}
	}
	for (int i = 2; i <= 10000; i++) {
		if (!nprime[i]) {
			prime.push_back(i);
		}
	}

	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		auto tmp = A[i];
		for (auto& v : prime) {
			if (tmp % v == 0) {
				base.insert(v);
				tmp /= v;
			}
		}
		if (tmp > 1) {
			base.insert(tmp);
		}
	}

	int64_t res = 0;
	for (auto& k : base)
	{
		int64_t tmp = 0;
		if(k > 1) for (int j = 0; j < N; j++) {
			if (A[j] % k == 0) {
				tmp += A[j];
			}
		}
		res = std::max(res, tmp);
	}
	cout << res << endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

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

	bool ok = true;
	rep(i, n) {
		ll v;
		cin >> v;
		if (v % 2 == 0) {
			if (v % 3 != 0 && v % 5 != 0) {
				ok = false;
			}
		}
	}
	if (ok) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10 ; 
int a[N] , b[N] , c[N] ; 
int dp[N][4]; 

	int n ; 
int calc(int idx , int ch){
	if (idx == n)
		return 0 ; 
	
	int &ret = dp[idx][ch] ; 
	if (ret != -1)return ret ; 
	
	if (idx){
		if (ch == 0)
			ret = max(b[idx]+calc(idx+1 , 1) , c[idx]+calc(idx+1 , 2));
		else if (ch == 1)
			ret = max(a[idx]+calc(idx+1  , 0) , c[idx]+calc(idx+1 , 2));
		else 
			ret = max(a[idx]+calc(idx+1  , 0) , b[idx]+calc(idx+1 , 1));
			

		return ret ; 
	}
	
	ret = a[idx]+calc(idx+1  , 0) ;
	ret = max(ret , b[idx]+calc(idx+1 , 1)) ; 
	ret = max(ret , c[idx]+calc(idx+1 , 2)) ;

	return ret ;
}
int main() {

	scanf("%d" , &n) ;
	
	memset(dp , -1 , sizeof dp) ; 

	for (int i =0 ; i<n  ;++i) {
		scanf("%d %d %d" ,&a[i] , &b[i] , &c[i]) ;
	}
	int ans = calc(0 , 0) ; 
	printf("%d\n" , ans) ; 
	return 0;
}

Measured memory_bytes: 7680
#include <iostream>
#include <vector>
#include <string>

using std::vector;
using std::string;

string flip(const string& s, int l, int r) {
  string result = s;

  for (int i = l, j = r; i <= r; ++i, --j) {
    result[j] = (s[i] == 'R') ? 'L' : 'R';
  }

  return result;
}

int happiness(const string& s) {
  int result = 0;

  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'L') {
      if (i > 0 && s[i - 1] == 'L') {
        result++;
      }
    }
    if (s[i] == 'R') {
      if (i < s.length() - 1 && s[i + 1] == 'R') {
        result++;
      }
    }
  }

  return result;
}

char flip(char lr) {
  return (lr == 'R') ? 'L' : 'R';
}

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;

  int n, k;
  cin >> n >> k;
  std::string s;
  cin >> s;

  // ...RL... source of unhappiness
  // ...RLR... => ...RRR... +2 happiness
  // ...RLLR... => ...RRRR... +2 happiness
  //
  // More than +2 happiness is not possible
  // ...RL...RL... => ...RL...RL... +0
  // ...RL...LL... => ...RR...RL... +0
  // ...RL...RR... => ...RL...RR... +0

  int i = 1;
  char lr = s[0];
  int c = 0;
  while (i < n) {
    if (s[i] == lr) {
      ++i;
      continue;
    }
    int j = i;
    while (j < n - 1 && s[j + 1] == flip(lr)) {
      ++j;
    }

    for (int k = i; k <= j; ++k) {
      s[k] = lr;
    }

    ++c;
    if (c == k) {
      break;
    }

    i = j + 1;
  }

  cout << happiness(s);

  return 0;
}


Measured memory_bytes: 512
S=input()
Q=int(input())

flip=0
fr=''
ba=''
for i in range(Q):
    Qq=input()
    
    if(Qq.count(' ')>0):
        ti,fi,ci=Qq.split()
        if( flip%2==0   ):
            if(fi=='1'):
                fr=str(ci)+fr
            else:
                ba=ba+str(ci)
        else:
            if(fi=='1'):
                ba=ba+str(ci)
            else:
                fr=str(ci)+fr
    else:
        flip+=1
if(flip%2==0):
    print(fr+S+ba)
else:
    print(ba[::-1]+S[::-1]+fr[::-1])

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

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

      n=Integer.parseInt(sc.next());

      if(n==1){
        System.out.println("Hello World");
      }

      if(n==2){
        int a, b;
        a=Integer.parseInt(sc.next());
        b=Integer.parseInt(sc.next());
        System.out.println(a+b);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


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

#define LL long long
struct node {
	int x, y, id;
} a[100005];

struct edge {
	int u, v, d;
	bool operator < (const edge & e) const {
		return d < e.d;
	}
} g[300005];

bool cmpx(node a, node b) {
	return a.x < b.x;
}

bool cmpy(node a, node b) {
	return a.y < b.y;
}

int n, m, f[200005]; LL ans;
int F(int x) {return f[x] == x ? x : f[x] = F(f[x]);};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i=1;i<=n;i++) {
		cin >> a[i].x >> a[i].y;
		a[i].id = i, f[i] = i;
	}

	sort(a+1, a+1+n, cmpx);
	for(int i=1;i<n;i++) g[++m] = (edge) {a[i].id, a[i+1].id, a[i+1].x - a[i].x};
	sort(a+1, a+1+n, cmpy);
	for(int i=1;i<n;i++) g[++m] = (edge) {a[i].id, a[i+1].id, a[i+1].y - a[i].y};
	sort(g+1, g+m+1);
	
	for(int i=1;i<=m;i++) {
		if(F(g[i].u) != F(g[i].v)) {
			ans += g[i].d;
			f[f[g[i].u]] = f[g[i].v];
		}
	}
	cout << ans;
}

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

int main() {
	int N , M; cin >> N >> M;
	vector<int> point(M), dpm(M-1);
	for(int i = 0 ; i < M ; i++){
		cin >> point[i];
	}
	sort(point.begin(),point.end());
	for(int i = 0 ; i < M-1 ; i++){
		dpm[i] = point[i+1] -point[i];
	}
	sort(dpm.begin(),dpm.end());
	reverse(dpm.begin(),dpm.end());
	int ans = 0;
	for(int i = N-1 ; i < M-1 ; i++){
		ans += dpm[i];
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_string();
}

fn main() {
    let n:usize = get_input().parse().unwrap();

    let mut d:Vec<u32> = Vec::with_capacity(n);

    for i in get_input().split_whitespace() {
        d.push(i.parse().unwrap());
    }
    d.sort();

    let ans = d[n/2] - d[n/2-1];
    println!("{}",ans);
}



Measured memory_bytes: 6396
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vec<int> a(N);
    REP(i, N){
        cin >> a[i];
        a[i]--;
    }
    vec<bool> memo(N);
    int now = 0;
    int cnt = 0;
    while(!memo[now]){
        if(now == 1){
            cout << cnt << el;return;
        }
        memo[now] = true;
        now = a[now];
        cnt++;
    }
    cout << -1 << el;
}



Measured memory_bytes: 3724
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
LL N,M;

int main(){
    cin>>N>>M;
    int sum=0;
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        sum+=a;
    }
    cout<<sum/(N+1)+(sum%(N+1)!=0)<<endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

void test_case(){
    
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    
    int n = s.length();
    if( n % 2== 1)
        cout <<"No"<<endl;
    else{
        string s1 = "";
        rng(i, 0, n/2)
            s1 += "hi";
        if( s1 == s)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    
    
	return 0;
}






Measured memory_bytes: 256
#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 (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char now = '@';
    rep(i, n)
    {
        if (s[i] != now)
        {
            ans++;
            now = s[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>:: iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
bool check[maxii];

bool dfs(int node,int c)
{
    check[node]=true;
    arr2[node]=c;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            if(dfs(vi[node][child],c^1)==false)
            {
                return false;
            }
        }
        else if(arr2[node]==arr2[vi[node][child]])
        {
            return false;
        }
        //else if()
    }
    return true;
}

int main()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k)
    {
        cout<<n*x;
    }
    else
    {
        int res=k*x;
        int res1=n-k;
        res1=res1*y;
        cout<<res+res1;
    }
}




Measured memory_bytes: 5904
#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
typedef unsigned long long ull;
const int N=1000005;
int m,a[N];
ll s[N],n;
map<int,int> mp;
int main(){
	scanf("%lld%d%d",&n,&a[1],&m);rll ans=a[1];s[1]=a[1],mp[a[1]]=1;
	for(it i=2;i<=n;++i){
		a[i]=(0ll+a[i-1])*a[i-1]%m;
		if(mp[a[i]]){
			ans+=(s[i-1]-s[mp[a[i]]-1])*((n-i+1)/(i-mp[a[i]]))+s[mp[a[i]]+(n-i+1)%(i-mp[a[i]])-1]-s[mp[a[i]]-1];
			//printf("%d %d %lld %lld\n",(n-i+1)/(i-mp[a[i]]),(n-i+1)%(i-mp[a[i]]),s[i-1]-s[mp[a[i]]-1],s[mp[a[i]]+(n-i+1)%(i-mp[a[i]])-1]-s[mp[a[i]]-1]);
			break;
		}
		ans+=a[i],mp[a[i]]=i,s[i]=s[i-1]+a[i];
	}
	printf("%lld",ans);
	return 0;
}


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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))

#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for(int i=0; i<N; i++)
        cin >> w[i] >> v[i];

    ll dp[N+1][W+1];
    for(int i=0; i<=W; i++)
        dp[0][i] = 0;
    for(int i=0; i<=N; i++)
        dp[i][0] = 0;

    for(int j=1; j<=W; j++){
        for(int i=1; i<=N; i++){
            if(j>=w[i-1]) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout << dp[N][W] << '\n';

    return 0;
   
}

Measured memory_bytes: 82472
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
Read4();
      result=N-K+1;
                    Console.WriteLine(result.ToString());

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll k;  // aの0未満の要素の個数
    if(0 <= a[0]) {
        k = 1;
    }
    else if(a[n-1] < 0) {
        k = n-1;
    }
    else {
        exrep(i, 1, n-1) {
            if(0 <= a[i]) {
                k = i;
                break;
            }
        }
    }

    vl x(n-1), y(n-1);
    exrep(i, k, n-2) {
        x[i-k] = a[0];
        y[i-k] = a[i];
        a[0] -= a[i];
    }
    rep(i, k) {
        x[(n-1) - k + i] = a[n-1];
        y[(n-1) - k + i] = a[i];
        a[n-1] -= a[i];
    }
    
    out(a[n-1]);
    rep(i, n-1) {
        cout << x[i] << " " << y[i] << "\n";
    }
    
    re0;
}

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

typedef double dbl;
dbl x[4], y[4];

bool parallelism() {
	if (x[0] == x[1]) {
		if (x[2] == x[3]) return true;
		else return false;
	}
	else {
		if (x[2] == x[3]) return false;
		else {
			dbl k12 = (y[1] - y[0]) / (x[1] - x[0]);
			dbl k34 = (y[3] - y[2]) / (x[3] - x[2]);
			if (fabs(k12 - k34) < 1e-10) return true;
			else return false;
		}
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> x[j] >> y[j];
		}
		if (parallelism()) cout << "YES\n";
		else cout << "NO\n";
	}
}


Measured memory_bytes: 3088
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for (int i = 1; i <= 3; i++) {
			if (i != a && i != b) {
				System.out.println(i);
			}
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20308
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    cout << b / x - (a - 1) / x + (a == 0 && x > 1) << endl;

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int tmp = i, sum = 0;
		while(tmp != 0)
		{
			sum += tmp % 10;
			tmp /= 10;
		}
		if(sum >= a && sum <= b)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <numeric>
#include <cmath> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
using namespace std; 
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  

typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 


main(){
  string a="KUPC";
  string in;
  while(cin>>in){
    int b[4]={};
    rep(i,in.size()){
      rep(j,a.size())if (in[i] == a[j])b[j]++;
    }
    cout << min(b[0],min(b[1],min(b[2],b[3]))) << endl;
  }
}

Measured memory_bytes: 0
module Main where
import Debug.Trace
import Data.List
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [[Int]] -> [String]
solve [] = []
solve ([h,w]:xs) = iter 1 where
    iter row
        | row == h  = [bar w row ++ "\n"] ++ solve xs
        | otherwise = [bar w row] ++  iter (succ row)

bar :: Int -> Int -> String
bar n r = take n . concat . repeat $ if odd r then "#." else ".#"  

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readUntil :: ([Int] -> Bool) -> IO [[Int]]
readUntil eof = iter where
    iter = readLine >>=
            (\a -> if eof a then return [] else fmap (a:) iter)

eof :: [Int] -> Bool
eof (x0:x1:xs) = [x0, x1] == [0, 0]

main :: IO() 
main = do
    l <- readUntil eof
    mapM_  putStrLn (solve l)



Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int main(){
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    for(int x = 0; x <= n; x++)
        for(int y = 0; y <= m; y++){
            if((y*n) - (x*y) + (m-y) * x == k){
                cout << "Yes\n";
                return 0;
            }
        }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func merge(aa []int, l, m, r int) int64 {
	var cnt int64
	cnt = 0
	li := m - l
	ri := r - m
	ll := make([]int, li+1)
	rr := make([]int, ri+1)
	for i := 0; i < li; i++ {
		ll[i] = aa[l+i]
	}
	ll[li] = 1 << 30
	for i := 0; i < ri; i++ {
		rr[i] = aa[m+i]
	}
	rr[ri] = 1 << 30
	i, j := 0, 0
	for k := l; k < r; k++ {
		if ll[i] <= rr[j] {
			aa[k] = ll[i]
			i++
			continue
		}
		cnt += int64(li - i)
		aa[k] = rr[j]
		j++
	}
	return cnt
}
func mergeSort(aa []int, l, r int) int64 {
	var cnt int64
	cnt = 0

	if l+1 < r {
		m := (l + r) >> 1
		cnt += mergeSort(aa, l, m)
		cnt += mergeSort(aa, m, r)
		cnt += merge(aa, l, m, r)
	}
	return cnt
}
func main() {
	scanner := getScanner()
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	fmt.Fprintln(writer, mergeSort(aa, 0, n))
	writer.Flush()
}

func getScanner() *bufio.Scanner {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}



Measured memory_bytes: 7612
#include<iostream>
using namespace std;
#define MAX (256)

char field[MAX][MAX];
int W, H;
int ans = 0;
int sx, sy;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y){
	if(0 <= x && x < H && 0 <= y && y < W && field[x][y] == '.'){
		ans++;
		field[x][y] = '#';

		for(int i=0; i < 4; i++){
			int nx = x + dx[i]; int ny = y + dy[i];
			dfs(nx, ny);
		}
	}
}

int main(){
	while(cin >> W >> H, W || H){
		ans = 0;
		for(int i=0; i < H; i++){
			for(int j=0; j < W; j++){
				cin >> field[i][j];
				if(field[i][j] == '@'){
					sx = i;
					sy = j;
					field[i][j] = '.';
				}
			}
		}
		dfs(sx, sy);

		cout << ans << endl;
	}

}

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



int main()
{
    ll n;
	cin>>n;
	char s[n];
	cin>>s;
	ll c=0;
	ll i=0,j=n-1;
	while(i<j)
	{
		if(s[j]=='R'&&s[i]=='W')
		{
			swap(s[j],s[i]);
			j--;
			i++;
			c++;
		}
		
		else if(s[j]=='R'&&s[i]!='W')
		{
			i++;
		}
		else
		{
			j--;
		}
	}
	cout<<c;
}

Measured memory_bytes: 3796
N = int(input())
X = list(map(int, input().split()))

min_x = min(X)
max_x = max(X) + 1

min_hp = float("inf")
for i in range(min_x, max_x):
    hp = 0
    for x in X:
        hp += (x - i) ** 2
    if hp < min_hp:
        min_hp = hp

print(min_hp)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5]) co("Yes");
  else co("No");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> arr;
int main(){
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a;
	int array[a-1];
	for(int i = 0; i < a;i++ ){
		cin >> array[i];
	}
	for(int i = 0;i < a;i++){
		if(array[i] >= array[b]){
			c += 1;
			b = i;
	}
	}
	cout << c << endl;
}

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

int main(void){
    char str[101], target_str[101], cpy[201] = {};
    scanf("%s %s", str, target_str);
    strcpy(cpy, str);
    strcat(cpy, str);
    if(strstr(cpy, target_str) == NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2100
n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
median1 = l1[int(n / 2) - 1]
median2 = l1[int(n / 2)]
if median1 == median2:
    for i in range(n):
        print(median1)
else:
    for i in range(n):
        if x[i] <= median1:
            print(median2)
        else:
            print(median1)


Measured memory_bytes: 25224
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>

using namespace std;

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) f=ch=='-'?-1:f,ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int M=100005;
const int P=1000000007;

struct matrix
{
	int r,c;
	int num[3][3];

	inline matrix (){r=c=3,memset(num,0,sizeof num),num[0][0]=num[1][1]=num[2][2]=1;}

	inline matrix operator*(matrix const x)const
	{
		matrix ret;
		ret.r=r,ret.c=x.c,memset(ret.num,0,sizeof ret.num);
		for (int i=0;i<ret.r;++i)
			for (int j=0;j<ret.c;++j)
				for (int k=0;k<c;++k)
					(ret.num[i][j]+=1ll*num[i][k]*x.num[k][j]%P)%=P;
		return ret;
	}
}trs,trs_,f;

inline matrix operator^(matrix x,int y)
{
	matrix ret=matrix();
	for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;
	return ret;
}

int x[M];
int n,m,ans;

void calc()
{
	trs.r=trs.c=3;
	trs.num[0][0]=1,trs.num[1][0]=0,trs.num[2][0]=1;
	trs.num[0][1]=2,trs.num[1][1]=1,trs.num[2][1]=2;
	trs.num[0][2]=1,trs.num[1][2]=1,trs.num[2][2]=2;
	trs_.r=trs_.c=3;
	trs_.num[0][0]=1,trs_.num[1][0]=0,trs_.num[2][0]=0;
	trs_.num[0][1]=2,trs_.num[1][1]=1,trs_.num[2][1]=0;
	trs_.num[0][2]=1,trs_.num[1][2]=1,trs_.num[2][2]=1;
	f.r=1,f.c=3,f.num[0][0]=1,f.num[0][1]=f.num[0][2]=0;
	x[0]=0;
	for (int i=1;i<=m;++i) f=f*(trs^(x[i]-x[i-1]-(i>1)))*trs_;
	f=f*(trs^(n-x[m]-(m>0)));
}

int main()
{
	//freopen("placing.in","r",stdin),freopen("placing.out","w",stdout);
	n=read(),m=read();
	for (int i=1;i<=m;++i) x[i]=read();
	calc(),printf("%d\n",f.num[0][2]);
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 640
#abc177_B_1
list_1 = list(str(input()))
list_2 = list(str(input()))

int_agg_count_max_diff = 10000
for i in range(len(list_1) - len(list_2) + 1):
  list_1_tmp = list_1[i:i+len(list_2)]
  
  int_count_max_diff = 0
  for j in range(len(list_2)):
    if list_1_tmp[j] != list_2[j]:
      int_count_max_diff = int_count_max_diff + 1
  if int_agg_count_max_diff > int_count_max_diff:
    int_agg_count_max_diff = int_count_max_diff
print(int_agg_count_max_diff)

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

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

}


int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ck=b/c-(a-1)/c;
  ll dk=b/d-(a-1)/d;
  ll cd=c*d/gcd(c,d);
  ll cdk=b/cd-(a-1)/cd;
  cout<<b-a+1-(ck+dk-cdk)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;

int main()
{
    IO
    cin>>n>>m;
    if(n>m)
        cout<<"safe"<<endl;
    else
        cout<<"unsafe"<<endl;
    return 0;
}


Measured memory_bytes: 3660
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e5 + 10;
int ar[SIZE];



int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len, mix = 0, even = 0, zero = 0;

	cin >> N;
	for(I = 0; I < N; I++)
	{
		cin >> ar[I];

		int r = ar[I] % 10;

		if(ar[I] % 4 == 0)
			cnt++;
		else if(ar[I] % 2 == 0)
			even++;
		else
			mix++;
	}

	if(cnt >= mix)
		cout << "Yes\n";
	else if(cnt + 1 == mix && even == 0)
		cout << "Yes\n";
	else
			cout << "No\n";


	return 0;
}


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

using i64 = int64_t;

bool check(const vector<i64> &v){
    i64 n = v.size();
    for(auto e: v){
        if(e >= n)return false;
    }
    return true;
}

int main(){
    i64 n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    i64 ans = 0;
    while(!check(v)){
        i64 sum = 0;
        for(auto e: v){
            sum += e / n;
        }
        ans += sum;
        for(auto &e: v){
            i64 tmp = e / n;
            e -= tmp * n;
            e += sum - tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val list = (1..m).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        return@map a to b
    }.sortedBy { it.second }

    var x = 0
    var count = 0

    for ((a, b) in list) {
        if (a > x) {
            x = b - 1
            count++
        }
    }

    println(count)
}

Measured memory_bytes: 81380