akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    string s,t;
    vector<ll> c(26,0),c2(26,0);
    cin >> s >> t;
    rep(i, s.size()){
        ++c[s[i] - 'a'];
        ++c2[t[i] - 'a'];
        if (c[s[i] - 'a'] != c2[t[i] - 'a']) {
            No;
            return 0;
        }
    }
    Yes;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
  cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
  if(a[i] == a[i+1]){cout << "NO" << endl;
                    return 0;}
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
S = input()

d = {}
for s in S:
    if s not in d:
        d[s] = 1 
    else:
        d[s] += 1 

flag = False
if len(d) == 2:
    flag = True
    for s in d:
        if d[s] != 2:
            flag = False 
if flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    long double n, m, sum = 0;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    if (a[m - 1] < sum / (4 * m)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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


int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int ans=0;
      for(int i=1;i<=n/2;i++)
	{
	  int sum=i;
	  for(int j=i+1;sum<n;j++)
	    {
	      sum+=j;
	      if(sum==n)
		{
		  ans++;
		  break;
		}
	    }

	}

      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


int dp[2][2001][2001] = {};
int n, m;
vector<int> s, t;
int dfs(bool bef, int cs, int ct) {
	if (~dp[bef][cs][ct])
		return dp[bef][cs][ct];
	int res = -1;
	if (cs < n && s[cs] == 1 - bef) {
		int buf = dfs(1 - bef, cs + 1, ct);
		res = max(res, buf + 1);
	}
	if (ct < m && t[ct] == 1 - bef) {
		int buf = dfs(1 - bef, cs, ct + 1);
		res = max(res, buf + 1);
	}
	if (res == -1)
		res = bef-1;
	dp[bef][cs][ct] = res;
	return res;
};
signed main() {

	scnaf("%d %d", &n, &m);
	s.resize(n);
	t.resize(m);
	char str[2001];
	scnaf("%s", str);
	REP(i, n) {
		s[i] = str[i] == 'I';
	}
	scnaf("%s", str);
	REP(i, m) {
		t[i] = str[i] == 'I';
	}

	Fill(dp, -1);
	int ans = 0;
	REP(i, n) {
		REP(j, m) {
			ans = max(ans, dfs(0, i, j));
		}
	}
	pritnf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 34796
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n;
    while(cin >> n){
        if(n == 0)return 0;
        bool now = false;
        bool l = false;
        bool r = false;
        int ans = 0;
        for(int i = 0;i < n;i++){
            string s;cin >>s;
            if(s == "lu"){
                l = true;
            }
            if(s == "ru"){
                r = true;
            }
            if(s == "ld"){
                l = false;


            }
            if(s == "rd"){
                r = false;
            }
            if(!r && !l && now){
                ans++;
                now = false;
            }
            if(r && l && !now){
                ans++;
                now = true;
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3140
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <cstring>
#include <stdio.h>
using namespace std;

int numlen = 0;

long long strSum(string str){
	long long sum = 0;
	string tmp;

	for(int i=0; i<str.length(); ++i){
		if (str[i] != '+'){
			tmp += str[i];
		}
		else{
			sum += stoll(tmp);
			tmp="";
		}
	}
	sum += stoll(tmp);
	return sum;
}

long long solve(string str, int i){
	long long sum = 0;
	if (str[str.length()-1] == '+'){
		return 0;
	}
	if (str.length() <= i){
		return strSum(str);
	}

	sum += solve(str, i+1);
	str.insert(i+1, "+");
	sum += solve(str, i+2);

	return sum;
}


int main(){
	string S;
	cin >> S;

	numlen = S.length() -1;

	long long total = 0;
	total = solve(S, 0);
	cout << total << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            var line = Console.ReadLine();
            if (string.IsNullOrEmpty(line))
            {
                break;
            }
            var vs = line.Split(' ').Select(double.Parse).ToArray();
            var v1 = vs.Take(3).Select(x => x * vs[4]).ToArray();
            var v2 = vs.Skip(3).Select(x => x * vs[1]).ToArray();
            //var xs = v1.Zip(v2, (x, y) => x - y).ToArray();
            //var xResult = xs[2] / xs[0];
            var xResult = (v1[2] - v2[2]) / (v1[0] - v2[0]);
            var yResult = (vs[2] - vs[0] * xResult) / vs[1];
            Console.WriteLine("{0:0.000} {1:0.000}", Math.Floor(xResult * 1000) / 1000, Math.Floor(yResult * 1000) / 1000);
        }
    }
}

Measured memory_bytes: 6204
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int, input().split()))
lcm = lcm_list(A)

ans = 0
for i in A:
    ans += (lcm - 1) % i
print(ans)


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


bool check(long long n, long long s, long long b){
    if(b<2) return false;
    long long sum = 0;
    while(n>0){
        sum+=n%b;
        n/=b;
    }
    return sum==s;
}


int main(){
    long long n, s, maxsum=-1;
    cin>>n>>s; if(n==s){ cout<<n+1; return 0;}
    /*for(int i =2; i< n; i++){
        long long buf=n;
        long long sum=0;
        while(buf>0){
            sum+=buf%i;
            cout<<buf%i<<" ";
            buf/=i;
        }
        //maxsum = max(sum, maxsum);
        cout<<" separator "<<i<<" "<<sum;
        if(sum==s) cout<<" equals ";
        cout<<endl;
    }*/
    long long answer = 10000000000000;
    for(long long i=1; i<(long long)sqrt(n)+10000; i++){
        if(check(n, s, i)) answer = min(answer, i);
        long long a=i, b=s-i; if(b<0) continue;
        long long base = (n-b)/a;
        if(check(n, s, base)) answer = min(answer,base);
    }
    cout<<(answer!=10000000000000?answer: -1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> con(n);
  long long ans = 0,mini = 0;

  for(int i = 0;i < n;i++){
    cin >> con[i];
  }
  sort(con.begin(),con.end(),greater<long long>());
  mini = con[0];
  for(int i = 1;i < n;i++){
    ans += con[i / 2];
  }
  cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

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

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  int n,m; cin >> n >> m;
  map<int,int> C;
  int M = m;
  for(int i = 2; i*i <= M; i++) {
    while(m%i == 0) {m /= i; C[i]++;}
  }
  if(m != 1) C[m]++;

  COMinit();

  ll ans = 1LL;
  for(auto c : C) {
    int q = c.second;
    ans *= COM(q+n-1,q);
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  string s; cin >> s;
  int n = 0;
  for(int i = 0 ; i < sz(s) ; i++){
    n += s[i] - '0';
  }
  cout << (n % 9 == 0 ? "Yes" : "No");LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
#include <deque>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
#define revrep(i,n) for(decltype(n) i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

char s[1005][1005];
ll cost[1005][1005];
struct cell {
    ll h, w;
    ll warp;
};
int offset[] = { -1, 0, 1, 0, -1 };
int main() {
    ll ans=0, H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    rep(i,H+1) rep(j,W+1) cost[i][j] = Inf;
    rep(i,H) rep(j,W) cin >> s[i+1][j+1];
    deque<cell> posq;
    posq.push_front({Ch,Cw,0});
    cost[Ch][Cw] = 0;
    while (posq.size()) {
        auto p = posq.front();
        posq.pop_front();
        rep(i,4) {
            auto h = p.h + offset[i];
            auto w = p.w + offset[i+1];
            if (h <= 0 || w <= 0 || h > H || w > W)
                continue;
            if (s[h][w] == '.' && cost[h][w] > p.warp) {
                posq.push_front({h, w, p.warp});
                cost[h][w] = p.warp;
            }
        }
        for (int i=-2; i<=2; ++i) {
            for (int j=-2; j<=2; ++j) {
                if (i == 0 && j== 0)
                    continue;
                if (abs(i) == 1 && j== 0)
                    continue;
                if (i == 0 && abs(j) == 1)
                    continue;
                auto h = p.h + i;
                auto w = p.w + j;
                if (h <= 0 || w <= 0 || h > H || w > W)
                    continue;
                if (s[h][w] == '.' && cost[h][w] > p.warp+1) {
                    posq.push_back({h, w, p.warp+1});
                    cost[h][w] = p.warp+1;
                }
            }
        }
    }
    ans = cost[Dh][Dw];
    if (ans == Inf)
        ans = -1;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 998244353;


ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> X(200100, 0);
    ll high = 0;
    vector<int> A(N);
    REP(i,N){
        ll d;
        cin >> d;
        X[d] += 1;
        chmax(high, d);
        A[i] = d;
    }

    if(A[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    if(X[0] != 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    ll last = 1;
    REPi(i, 1, high+1){
        ll x = X[i];
        if(x == 0){
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * mod_pow(last, x, MOD)) % MOD;
        ans %= MOD;
        last = x;
        //cout << ans << endl;
    }

    cout << ans%MOD << endl;
    return 0;
}


Measured memory_bytes: 2176
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int,input().split())
    X.append((x, i))
    Y.append((y, i))
X.sort()
Y.sort()
Distance = []
for i in range(N-1):
    Distance.append((X[i+1][0] - X[i][0], X[i][1], X[i+1][1]))
    Distance.append((Y[i+1][0] - Y[i][0], Y[i][1], Y[i+1][1]))
Distance.sort()
UFT = UnionFind(N)
ans = 0
for i in range(2*(N-1)):
    d, p, q = Distance[i]
    if not UFT.same(p, q):
        UFT.union(p, q)
        ans += d
    if UFT.size(0) == N:
        break
print(ans)

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

int main()
{
	int n,m;
	cin>>n>>m; 
	
	if(n==1&&m==4)
	{
		cout<<"Yes";
		return 0;
	}
	if(n*4<m)
	{
		cout<<"No";
		return 0;
	}
	
	int sum=n*4-m; 
	if(sum%2==0)
	{
		int c1=sum/2; 
		int t1=n-c1; 
		if(t1*4+c1*2==m&&t1>=0&&c1>=0)
		{
			cout<<"Yes";
			return 0;
		}
		else
		{
			cout<<"No";
			return 0;
		}
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
int gcd(int x,int y)
{
    int tool;
    while(y)
    {
        tool=x%y;
        x=y;
        y=tool;

    }
    return x;
}
int main()
{
    int k,ans=0;
    cin>>k;
    ans+=k*k+(k-1)*(2*k-1);
    for(int i=2; i<=k; i++)
    {
        for(int j=2; j<=k; j++)
            for(int m=2; m<=k; m++)
                ans+=gcd(i,gcd(j,m));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15
#define f first
#define s second
 
const int N = 1e5 + 15;
 
int cnt[N];
 
set<int> s;
 
int main(){
	int n;
	cin >> n;
	map<ll, ll> m;
	for(int i=0; i < n; i++){
		int x;
		cin >> x;
		m[x]++;
	}
	vector<ll> v;
	ll res = 0;
	for(auto it = m.begin(); it != m.end(); it++){
		if(it->second < 2)
			continue;
		if(it->second >= 4)
			res = max(res, (it->first) * (it->first));
			
		v.pb(it->first);
		
	}
	
	if(v.size() > 0){
		int l = v.size();
		res = max(res, v[l-1] * v[l-2]);
	}
	cout << res << endl;
	return 0;
}


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

int main(int, char**) {
        string S;
        cin >> S;
        int w;
        cin >> w;
        int l = S.size();
        for (int i=0; w * i + 1 <= l; i++) {
                cout << S[w * i];
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    ll n,t;
    cin >> n >> t;

    vector<ll> a(n);
    for(auto &x:a)
        cin >> x;
    
    ll maxben=0,ben=0,termmax=a[n-1],ans=0;
    for(ll i=n-2;i>=0;i--){
        if(a[i]>a[i+1]){
            if(termmax<=a[i]){
                termmax=a[i];
            }else
                continue;
        }else{
            ben=termmax-a[i];
            if(maxben<ben){
                maxben=ben;
                ans=0;
                ans++;
            }else if(maxben==ben){
                ans++;
            }else
                continue;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
// AtCoder Problemsが黄色いので

#include <iostream>
 
using namespace std;
 
 int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    
    if( A <= C && C <= B ) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

A = ""

for _ in range(H):
  s = input()
  if len(set(s)) == 1 and s == "." * W:
    H -= 1
  else:
    for i in s:
      A += i

if len(A) == 0:
  print(A)

else:
  M = []

  for i in range(W):
    if A[i] == ".":
      for j in range(i + W,H * W,W):
        if A[j] == "#":
          break
      else:
        M.append(i)

  A = [A[i] for i in range(H * W) if not (i % W) in M]
  W = W - len(M)
  
  S = ""
  
  for i in range(H * W):
    S += A[i]
    if (i + 1) % W == 0:
      print(S)
      S = ""

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int n;
int a[15];
vector<int> x[15], y[15];

bool state(int z){
    // 0:不親切, 1:正直者
    for (int i = 0; i < n; i++){
        if(((z >> i) & 1) == 1){
            for (int j = 0; j < a[i]; j++){
                if (((z >> x[i][j]) & 1) != y[i][j]){
                    return false;
                }
            }
        }
    }
    // cout << z << endl;
    return true;    
}

int main(){

    cin >> n;
    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            int X, Y;
            cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        if (state(i)){
            int num = 0;
            for (int j = 0; j < n; j++){
                if(((i >> j) & 1) == 1) {
                    num++;
                }
                // cout << (i >> j) << endl;
            }
            // cout << i << " " << num << endl;
            ans = max(ans, num);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int ans,n,m,a[MAX],b[MAX];
bool alv[404][404],book[MAX];
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)a[i]=read(),b[i]=read();
	for(int i=1;i<=n;++i)
	{
		alv[i][i]=true;
		for(int j=m;j;--j)
		{
			int u=a[j],v=b[j];
			if(alv[i][u]&&alv[i][v]){book[i]=true;break;}
			if(alv[i][u]||alv[i][v])alv[i][u]=alv[i][v]=true;
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			if(book[i]||book[j])continue;
			bool fl=false;
			for(int k=1;k<=n;++k)if(alv[i][k]&&alv[j][k]){fl=true;break;}
			if(!fl)++ans;
		}
	printf("%d\n",ans);
}


Measured memory_bytes: 1152
N, M = map(int, input().split())
p, S = [], []
for i in range(M):
    _p, _s = input().split()
    p.append(int(_p)-1)
    S.append(_s)

ac, wa = [0]*N, [0]*N
for i in range(M):
    if ac[p[i]] == 1:
        continue
    if S[i] == "AC":
        ac[p[i]] = 1
    else:
        wa[p[i]] += 1

acs, was = 0, 0
for i in range(N):
    if ac[i] == 1:
        acs += 1
        was += wa[i]
print(acs, was)



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

using namespace std;

typedef long long ll;

int main()
{
	string S;
	cin >> S;
	
	bool odd = true;
	bool even = true;

	for (int i = 0; i < S.length(); i++)
	{
		char ch = S.at(i);

		if ((i + 1) % 2 == 0)//偶数
		{
			if (ch == 'R')
			{
				even = false;
			}
		}
		else//奇数
		{
			if (ch == 'L')
			{
				odd = false;
			}
		}

		if (odd == false || even == false)
		{
			break;
		}
	}

	if (odd && even)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}



	return 0;

}

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

vector<int> to[2010];
int kyori[2010][2010];
 
int main(void){
    for(int i=0;i<2010;i++){
        for(int j=0;j<2010;j++) kyori[i][j]=-1;
    }
    int n,X,y;
    cin>>n>>X>>y;
    for(int i=1;i<=n-1;i++){
        to[i].push_back(i+1);
        to[i+1].push_back(i);
    }
    to[X].push_back(y);
    to[y].push_back(X);
    
    for(int i=1;i<=n;i++){
        queue<int> q;
        q.push(i);
        kyori[i][i]=0;
        while(!q.empty()){
            int now=q.front();
            q.pop();
            for(int x:to[now]){
                if(kyori[i][x]!=-1) continue;
                kyori[i][x]=kyori[i][now]+1;
                q.push(x);
                
            }
        }
    }
    int K[2010]={};
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            K[kyori[i][j]]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout<<K[i]/2<<endl;
    }
}


Measured memory_bytes: 16128
N,C,K=map(int,input().split())
from collections import deque
T=[int(input())for _ in range(N)]
T.sort()
T=deque(T)

ans=1
bus=T[0]+K
count=0
while T:
    i=T.popleft()
    if i>bus:
        bus=i+K
        ans+=1
        count=1
    elif count==C:
        bus=i+K
        ans+=1
        count=1
    else:
        count+=1
print(ans)

Measured memory_bytes: 8128
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int *A,*B;

int an,bn,mn;

int min(int a,int b){
    return a > b ? b : a;
}

int main(void){
    int i,j;
    int sp;

    scanf("%d %d %d",&an,&bn,&mn);
    
    A = (int*)malloc(sizeof(int)*an);
    B = (int*)malloc(sizeof(int)*bn);

    int sa = INT_MAX,sb = INT_MAX;
    for(i = 0;i < an;i++){
        scanf("%d",&(A[i]));
        sa = min(sa,A[i]);
    }
    for(i = 0;i < bn;i++){
        scanf("%d",&(B[i]));
        sb = min(sb,B[i]);
    }

    sp = sa + sb;
    for(i = 0;i < mn;i++){
        int x,y,c;
        scanf("%d %d %d",&x,&y,&c);
        if(A[x-1] + B[y-1] - c < sp){
            sp = A[x-1] + B[y-1] - c;
        }
    }
    printf("%d\n",sp);

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> t(n),x(n),y(n);
  for(int i=0;i<n;i++){
     cin>>t[i]>>x[i]>>y[i];
    int g=x[i]+y[i]-t[i];
    if(g%2!=0||x[i]+y[i]>t[i]){
      cout<<"No"<<endl;
      exit(0);
  }
  }
      cout<<"Yes"<<endl;
  }

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <iomanip>

using int64 = long long;

class Combination {
private:
    constexpr static int64 DEFAULT = -1;
    std::vector<std::vector<int64>> c;
public:
    Combination(int max)
    {
        c.assign(max, std::vector<int64>(max, DEFAULT));
    }

    // calc nCr
    int64 calc(int n, int r)
    {
        if (n < r)
            return 0LL;

        if (n == r || r == 0)
            return 1LL;

        if (c[n][r] != DEFAULT)
            return c[n][r];

        return c[n][r] = calc(n - 1, r - 1) + calc(n - 1, r);
    }
};

int main()
{
    int N, A, B;
    std::cin >> N >> A >> B;
    std::vector<int64> v(N);
    for (int i = 0; i < N; i++)
        std::cin >> v[i];

    std::sort(v.rbegin(), v.rend());
    int64 max_sum = std::accumulate(v.begin(), std::next(v.begin(), A), 0LL);
    std::cout << std::fixed << std::setprecision(6)
              << (double)max_sum / A << std::endl;

    Combination comb(51);
    int min_value_count_all = 0;
    for (int i = 0; i < N; i++)
        if (v[i] == v[A - 1])
            min_value_count_all++;

    int64 pattern = 0;
    if (v[0] == v[A - 1]) {
        for (int i = A; i <= B; i++)
            pattern += comb.calc(min_value_count_all, i);
    }
    else {
        int min_value_count = 0;
        for (int i = 0; i < A; i++)
            if (v[i] == v[A - 1])
                min_value_count++;

        pattern = comb.calc(min_value_count_all, min_value_count);
    }
    std::cout << pattern << std::endl;

    return 0;
}


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

long long N;
map<long long, long long> ans;

int main(){
	cin >> N;
	for(long long i = 0; i < N-1; i++) {
		long long tmp;
		cin >> tmp;
		tmp--;
		ans[tmp]++;
	}

	for(long long i = 0; i < N; i++) {
		cout << ans[i] << endl;

	}

}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int mn[n + 1];
    mn[0] = 0;
    mn[1] = a[1];
    int cnt = 1;
    for (int i = 2; i <= n; i++) {
        mn[i] = a[i];
        mn[i] = min(mn[i], mn[i - 1]);
        if (a[i] < mn[i - 1]) cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int unsigned long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int n;
   cin>>n;
   map<string,int> mp;
   loop(i,0,n)
    {
      string s;
      cin>>s;
      mp[s]++;
    }
   cout<<"AC x "<<" "<<mp["AC"]<<END;
   cout<<"WA x "<<" "<<mp["WA"]<<END;
   cout<<"TLE x "<<" "<<mp["TLE"]<<END;
   cout<<"RE x "<<" "<<mp["RE"]<<END;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3632
#!/usr/bin/env python3

data = []
for i in range(int(input())):
    data.append(int(input()))

un = [num for num in data if num % 10 == 0]
data = [num for num in data if num % 10 != 0]

if len(data) == 0:
    print(0)
else:
    if sum(un+data) % 10 != 0:
        print(sum(un+data))
    else:
        print(sum(un+data)-min(data))

Measured memory_bytes: 3060
//mod
#include <iostream>
using namespace std;

// return gcd(a,b)
// obtain x,y s.t. ax+by=gcd(a,b)
long long extgcd(long long a, long long b, long long &x, long long &y)
{
    if(b==0){
        x = 1;
        y = 0;
        return a;
    }
    long long d = extgcd(b, a%b, y, x);
    y  -= a/b * x;
    return d;
}

//return a^n mod p
long long modpow(long long a, long long n, long long p)
{
    if(n==1) return a%p;
    if(n%2==1) return (a*modpow(a,n-1,p))%p;
    long long t = modpow(a, n/2, p);
    return (t*t)%p;
}

//return a^-1 mod p (p is a prime number)
long long fermat(long long a, long long p)
{  
    if(p==2) return 0; 
    return modpow(a,p-2,p);
}

//require len(factorials)==len(invs)==n+1
void prepareCOM(long long n, long long p, long long* factorials, long long* invs)
{
    long long f = 1;
    factorials[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        f = (f*i) % p;
        factorials[i] = f;
    }

    //obtain n!^-1
    long long inv = fermat(factorials[n],p);
    //obtain n!-1~1!^-1
    invs[n] = inv;
    for (long long i = n; i > 0 ; i--)
    {
        inv = (inv*i)%p;
        invs[i-1] = inv;
    }
}

//return nCa mod p
long long modCOM(long long n, long long a, long long p)
{
    //obtain f=n!
    long long fna = n%p;
    long long fa = 1;
    for (long long i = n-1; i > n-a; i--)
    {
        fna = (fna*i)%p;
    }
    for (long long i = 2; i <= a; i++)
    {
        fa = (fa*i)%p;
    }

    long long inv_a  = fermat(fa,p);

    return (fna*inv_a)%p;
}

int main(){
    long long n;
    long long a,b;

    cin >> n >> a >> b;
    long long p = 1e9+7;

    long long totalComb = (modpow(2,n,p)-1)%p;
    
    //prepare 
    long long nCa = modCOM(n,a,p);
    long long nCb = modCOM(n,b,p);

    //cout << ((totalComb-nCa-nCb)%p+p)%p;//avoiding being minus
    long long x = totalComb-nCa-nCb;
    cout << (x>0 ? x%p : (x%p+p)%p);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>

using std::map;

int N;
map<int, int> S;

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N ; ++i) {
    int x;
    scanf("%d", &x);
    ++S[x];
  }

  int ans = 0;
  for (const auto &x : S) {
    if (x.first <= x.second) ans += x.second - x.first;
    else ans += x.second;
  }

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


Measured memory_bytes: 4736
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <random>
#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<61 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	ll n ; cin >> n ;
	vll p(n) ;
	for(auto &i:p) cin >> i ;
	vll a(n),b(n) ;
	for(int i=0;i<n;i++) a.at(i) = (i+1)*30000 ;
	for(int i=1;i<=n;i++) b.at(n-i) = i*30000 ;
	for(int i=0;i<n;i++) a.at(p.at(i)-1) += i+1 ;
	for(int i=0;i<n;i++) cout << a.at(i) << (i==n-1?"\n":" ") ;
	for(int i=0;i<n;i++) cout << b.at(i) << (i==n-1?"\n":" ") ;
}


Measured memory_bytes: 3856
n,k=map(int,input().split())
p=[int(i)-1 for i in input().split()]
c=[int(i) for i in input().split()]
max_c=min(c)

def calc(x):
    global n,k
    next=x
    ma=max_c
    s=0
    l=[]
    for i in range(n):
        next=p[next]
        s+=c[next]
        l.append(c[next])
        ma=max(ma,s)
        if next==x:
            break
    if s<=0:
        return ma

    cycle=k//(i+1)
    rest=k%(i+1)
    ans=(cycle-1)*s+ma
    f=s*cycle
    for j in range(rest):
        f+=l[j]
        ans=max(ans,f)
    return ans

A=max_c
for start in range(n):
    A=max(A,calc(start))
print(A)


Measured memory_bytes: 82336
def palindrome(s):
    f = True
    for i in range(len(s) // 2):
        if s[i] != s[-i - 1]:
            f = False
            break
    return f

s = input().rstrip()

n = len(s)
p1 = (n - 1) // 2
p2 = (n + 3) // 2
if palindrome(s) and palindrome(s[:p1]) and palindrome(s[p2-1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

string s;

void main() {
    scan(s);
    writeln(s[0] ~ (s.length.to!int - 2).to!string ~ s[$-1]);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(25)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define debug(x) cout << "DEBUG " << x << endl
using namespace std;
typedef pair<int, int> pii;

char m[MAXN][MAXN];
int dist[MAXN][MAXN][MAXN][MAXN];

int x[]= {1, -1, 0, 0};
int y[] = {0, 0, 1, -1};

int main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ios::sync_with_stdio(false);
	int l, c;
	cin >> l >> c;
	for(int i = 0; i < l; i++)
		for(int j = 0; j < c; j++)
			cin >> m[i][j];
	
	for(int i = 0; i < l; i++) 
		for(int j = 0; j < c; j++)
			for(int k = 0; k < l; k++)
				for(int z = 0; z < c; z++)
					dist[i][j][k][z] = INF;
	
	for(int i = 0; i < l; i++) 
		for(int j = 0; j < c; j++) {
			dist[i][j][i][j] = 0;
			for(int k = 0; k < 4; k++) {
				if(i+x[k] >= 0 && i+x[k] < l && j+y[k] >= 0 && j+y[k] < c) {
					dist[i][j][i+x[k]][j+y[k]] = 1;
					dist[i+x[k]][j+y[k]][i][j] = 1;
				}
			}
		}
	
	for(int i = 0; i < l; i++) 
		for(int j = 0; j < c; j++) {
			if(m[i][j] == '#') continue;
			for(int k = 0; k < l; k++)
				for(int z = 0; z < c; z++) {
					if(m[k][z] == '#') continue;
					for(int x = 0; x < l; x++)
						for(int h = 0; h < c; h++) {
							if(m[x][h] == '#') continue;
							dist[k][z][x][h] = min(dist[k][z][x][h], dist[k][z][i][j]+dist[i][j][x][h]);
						}
					}
		}
	int ans = 0;
	for(int i = 0; i < l; i++) 
		for(int j = 0; j < c; j++) {
			int posans = 0;
			for(int k = 0; k < l; k++)
				for(int z = 0; z < c; z++)
					if(dist[i][j][k][z] != INF) posans = max(posans, dist[i][j][k][z]); 
			ans = max(posans, ans);
		}
	cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int ll;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pow2(i) (1LL << (i))
#define modi(a,b) ((a%b+b)%b)
#define uni(a,b) (((a+b)*(a+b+1)/2)+b)
const int MAXN=1e9+7;
ll int_pow(ll base, ll exp){
	ll result=1;
	while (exp){
		if (exp & 1)
		   result *= base;
		exp/=2;
		base*=base;
	}
	return result;
}
map<ll,ll>dp;
ll func(ll n){
	if (n==0)return dp[0]=1;
	if (n==1)return dp[1]=2;
	if (!dp[n/2])dp[n/2]=func(n/2);
	if (!dp[(n-1)/2])dp[(n-1)/2]=func((n-1)/2);
	if (!dp[(n-2)/2])dp[(n-2)/2]=func((n-2)/2);
	return dp[n]=((dp[n/2]+dp[(n-1)/2]+dp[(n-2)/2])%MAXN);
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;cin >> n;
	cout << func(n);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    K,A,B = inputMap()
    
    if A+2 >= B:
        print(1+K)
        sys.exit()
        
    sai = A+1
    ans = 1
    if K < sai:
        print(1+K)
        sys.exit()
        
    else:
        sai = A-1
        K = K-sai
        
        if K % 2 == 1:
            K -= 1
            ans = 1
            kai = int(K / 2)
            ans += (B-A)*kai
            ans += A
            
        else:
            kai = int(K / 2)
            ans = (B-A)*kai
            ans += A
        
    print(ans)
    #print(48518828981938099)
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38768
import sys
X, Y = map(int,input().split())
kame = 4
turu = 2

for i in range(0,X+1):
  nkame = i
  nturu = X-i
  ashi = nkame*kame + nturu*turu
  if ashi == Y:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 9180
n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

Measured memory_bytes: 8068
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	vector<vector<LL>> dp(2, vector<LL>(s.size()));

	dp[0][0] = 2;
	dp[1][0] = 1;

	for (int i = 1; i < s.size(); i++) {
		
		if (s[i] == '1') {
			dp[0][i] += dp[0][i - 1] * 2;
			dp[0][i] = (dp[0][i] + MOD) %MOD;

			dp[1][i] += dp[0][i-1];
			dp[1][i] = (dp[1][i] + MOD) % MOD;
			
			dp[1][i] += dp[1][i-1]*3;
			dp[1][i] = (dp[1][i] + MOD) % MOD;
		}

		if (s[i] == '0') {
			dp[0][i] += dp[0][i-1];
			dp[0][i] = (dp[0][i] + MOD) % MOD;

			dp[1][i] += dp[1][i-1] * 3;
			dp[1][i] = (dp[1][i] + MOD) % MOD;
		}
		
	}

	cout << (dp[0][s.size()-1] + dp[1][s.size()-1]+MOD)%MOD<< endl;

	return 0;
}

Measured memory_bytes: 2816
from collections import Counter
n = int(input())
lst = list(map(int, input().split()))

if len(set(lst)) == 1:
    print(n//2)
else:
    a = lst[0:n:2]
    b = lst[1:n:2]

    acnt = Counter(a)
    bcnt = Counter(b)

    amax = acnt.most_common()[0]
    bmax = bcnt.most_common()[0]
    if amax[0] != bmax[0]:
        print((n//2 - amax[1]) + (n//2 - bmax[1]))
    else:
        try:
            asecond = acnt.most_common()[1]
        except:
            asecond = (-1, 0)
        try:
            bsecond = bcnt.most_common()[1]
        except:
            bsecond = (-1, 0)
        res1 = (n//2 - amax[1]) + (n//2 - bsecond[1])
        res2 = (n//2 - asecond[1]) + (n//2 - bmax[1])
        print(min([res1, res2]))

Measured memory_bytes: 70532
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

std::vector<int > edge[100004];
std::vector<int > c(100004);
std::vector<int > ans(100004);
std::vector<bool> visited;
std::priority_queue<int > queue;

void dfs(int n, int p){
  for (int i=0; i<edge[n].size(); i++){
    int tgt=edge[n][i];
    if (visited[tgt]) continue;
    //std::cout << "tgt=" << tgt << std::endl;
    visited[tgt]=true;
    int highest=queue.top();
    //std::cout << "highest in dfs=" << highest << std::endl;
    queue.pop();
    ans[tgt]=highest;
    dfs(tgt, n);
  }
  return;
}

int main(){
  int N;
  scanf("%d", &N);
  int a, b;
  visited=std::vector<bool>(100004, false);
  for (int i=0; i<N-1; i++){
    scanf("%d", &a);
    scanf("%d", &b);
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  long long sum=0;
  for (int i=0; i<N; i++){
    scanf("%d", &c[i]);
    sum+=c[i];
    queue.push(c[i]);
  }
  //std::sort(c.begin(), c.end(), std::greater<int >());
  int highest=queue.top();
  queue.pop();
  //std::cout << "highest=" << highest << std::endl;
  std::cout << sum-highest << std::endl;
  ans[0]=highest;
  visited[0]=true;
  dfs(0, -1);
  for (int i=0; i<N; i++){
    printf("%d%c",ans[i],(i==N-1)?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <unordered_map>
#include <cstring>
#include <string>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int N;
unordered_map<string, bool> om;

void solve() {

	char W[11];

	scanf("%s", W);
	char last = W[strlen(W)-1];
	string s = W;
	om[s] = true;


	REP(i, 1, N) {
		char W2[11];
		scanf("%s", W2);

		if ( W2[0] != last) {
			puts("No");
			return;
		}

		string s2 = W2;
		
		if (om.count(s2)) {
			puts("No");
			return;
		} else {
			om[s2] = true;
		}

		last = W2[strlen(W2)-1];


	}

	puts("Yes");
	return;

}

int main(void) {
    scanf("%d", &N);
    
    solve();

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {


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

        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();

        for(int i = 0; i < 10; i++){
            x = r * x - d;
            System.out.println(x);
        }
        return;
    }


}


Measured memory_bytes: 21844
if __FILE__ == $0
    line = gets.split(' ').map(&:to_i)
    hdir = ['U','D']
    wdir = ['R','L']
    h = 0
    w = 0
    sx = line[0]
    sy = line[1]
    tx = line[2]
    ty = line[3]
    flag = 0
    for i in 1..2 do
        for j in 1..2 do
            if flag == 1 then
                print(hdir[~h])
            end
            for i in sx .. tx-1 do
                print(wdir[w])
            end
            for i in sy .. ty-1 do
                print(hdir[h])
            end
            if flag == 1 then
                print(wdir[~w])
            end
            h = ~h
            w = ~w
        end
        tx = tx+1
        ty = ty+1
        flag = 1
    end
end

Measured memory_bytes: 1788
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    6
    2 3 3 1 3 1

    j-i = A[i]+A[j]
    A[i]+i = j-A[j]
    L[i] = A[i]+i
    R[i] = i-A[i]
    """
    N = read_int()
    A = read_ints()
    L = sorted(a+i for i, a in enumerate(A))
    R = sorted(i-a for i, a in enumerate(A))
    i, j = 0, 0
    count = 0
    total = 0
    prev_a = None
    for a in L:
        if a != prev_a:
            count = 0
            while j < len(R) and a >= R[j]:
                if a == R[j]:
                    count += 1
                else:
                    count = 0
                j += 1
        total += count
        prev_a = a
    return total


if __name__ == '__main__':
    print(solve())


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

#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using ll = long long;

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

    constexpr int M = 2019;

    string S;
    cin >> S;

    int N = S.size();
    vector<int> dp(M, 0);
    ll result = 0;
    REP(i, N) {
        vector<int> dp_next(M, 0);
        REP(r, M) {
            dp_next[(r * 10) % M] = dp[r];
        }
        ++dp_next[0];
        int d = S[i] - '0';
        REP(r, M) {
            dp[(r + d) % M] = dp_next[r];
        }
        result += dp[0];
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
bool myComparison(const pair<string,int> &a,const pair<string,int> &b)
{
       return a.second<b.second;
}
long long val(char x){
    if(x=='7'|| x=='9')
    return 4;
    else
    return 3;
}
void man()
{
    long long n;
    cin>>n;
    if(n%2==0)
    cout<<n/2<<endl;
    else
    cout<<n/2+1;

}

    
    
    
    
    
    
    
    
    
    
    
    












int main() {
   // int t;
   // cin>>t;
   // while(t--)
   {
      man();
    }
	// your code goes here
	return 0;
}

Measured memory_bytes: 256