akhauriyash/Code-Regression huggingface dataset:
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n;
vector<vector<ll>> edge(1e5+10);
vector<ll> d1(1e5+10);
vector<ll> dn(1e5+10);
    
void saiki(vector<ll>& ref, ll distance, ll parent, ll now){
    ref[now] = distance;
    distance++;
    
    for (auto e : edge[now]) {
        if(e == parent)continue;
        saiki(ref,distance,now,e);
    }
}

int main() {
    // 黒陣営に属する数、白陣営に属する数、黒と白との間にある数
    // 距離から自動的に決まる
    
    std::cin >> n;
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    
    saiki(d1,0,-1,0);
    saiki(dn,0,-1,n-1);
    
    ll result = 0;
    
    for (int i = 0; i < n; i++) {
        if(d1[i] <= dn[i]){
            result++;
        }
    }
    if( result*2>n ){
        std::cout << "Fennec" << std::endl;
    }else{
        std::cout << "Snuke" << std::endl;
    }
}


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

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 10;
    int x,a;
    cin>>x>>a;
    if(x<a) ans = 0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    (26)
#define EPS         (1e-10)
#define INF         (1000000005LL)
#define MOD         (1000000007LL)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
// ciling(x/y) = (x+y-1)/y

typedef long long ll;
typedef unsigned long long ull;
// }}}

int f(ll a, ll b) {
    int acount = 0, bcount = 0;
    while(a > 0L){
        a/=10L;
        acount++;
    }
    while(b > 0L){
        b/=10L;
        bcount++;
    }
    return max(acount, bcount);
}

int main() {
    ll n;cin >> n;
    int ans = 10000;
    for(ll i=1L;i*i<=n;i++){
        ll j = n/i;
        if(n%i == 0L){
            ans = min(ans, f(i, j));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  long long a;
  // double b;
  string b;
  cin >> a >> b;

  int bb = 100 * (b[0] - '0') + 10 * (b[2] - '0') + 1 * (b[3] - '0');

  // int bb = (int)(100 * b);
  cout << ((a * bb) / 100) << endl;

  return 0;
}


Measured memory_bytes: 3608
from collections import deque

U = 0
R = 1
D = 2
L = 3
CNT = 4

directions = [[0, 1], [0, -1], [1, 0], [-1, 0]]

while True:
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        break

    maze = [[[1, 1, 1, 1, float('inf')] for _ in range(W)] for _ in range(H)]
    maze[0][0][U] = 0
    maze[0][0][CNT] = 0
    maze[H-1][W-1][D] = 0
    for h in range(H*2-1):
        A = list(map(int, input().split()))
        # 横の壁を取り去る
        if h % 2 == 0:
            for w, a in enumerate(A):
                if a == 0:
                    maze[h//2][w][R] = 0
                    maze[h//2][w+1][L] = 0
        # 縦の壁を取り去る
        else:
            for w, a in enumerate(A):
                if a == 0:
                    maze[h//2][w][D] = 0
                    maze[h//2+1][w][U] = 0

    q = deque([[0, 0]])
    while q:
        y, x = q.popleft()
        for dy, dx in directions:
            if 0 <= y+dy < H and 0 <= x+dx < W:
                if (dy == 1 and maze[y][x][D] == 0) or \
                    (dy == -1 and maze[y][x][U] == 0) or \
                    (dx == 1 and maze[y][x][R] == 0) or \
                    (dx == -1 and maze[y][x][L] == 0):
                    if maze[y+dy][x+dx][CNT] > maze[y][x][CNT] + 1:
                        maze[y+dy][x+dx][CNT] = maze[y][x][CNT] + 1
                        q.append([y+dy, x+dx])

    if maze[H-1][W-1][CNT] == float('inf'):
        print(0)
    else:
        print(maze[H-1][W-1][CNT]+1)



Measured memory_bytes: 6260
def main():
    A, B = map(int, input().split())
    x1 = int(B // 0.1)
    x2 = int(A // 0.07)

    for i in range(x1, x2):
        if int(i*0.08) == A and int(i*0.1) == B:
            print(i)
            return
    else:
        print(-1)
        return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;

int main()
{
    FIO
    ll n; cin>>n;
    ll ans = 0;
    for(ll i = 1 ; i<= n ; i++)
        ans += (i * (n-i+1));
    for(int i = 0 ; i< n -1 ; i++)
    {
        ll u, v; 
        cin>>u>>v;
        ans -= (min(u, v) * (n - max(u, v) + (ll) 1));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

int main() {
	

int N,A,B;
cin>>N>>A>>B;
int a=0,b=0,c=0;
fx(N){
	int aa;
	cin>>aa;
	if(aa<=A){
		a++;
	}else if(aa>B){
		b++;
	}else{
		c++;
	}
}
ce(min({a,b,c}))


}

Measured memory_bytes: 256
import java.util.*;


/**
 * Created by shoya on 2017/04/12.
 */
public class Main {
    public static void main(String... args){
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        KruskalClass krus = new KruskalClass(V, E);
        //System.out.printf("%d %d \n", V, E);
        for (int i = 0; i < E; i++) {
            int s = sc.nextInt();
            int d = sc.nextInt();
            int c = sc.nextInt();
            //System.out.printf("%d %d %d\n", s, d, c);
            krus.addEdge(s, d, c);
        }
        System.out.println(krus.kruskal());
        return;
    }

    public static class KruskalClass {
        class edge {
            int node1, node2, cost;
            edge(int node1, int node2, int cost){
                this.node1 = node1;
                this.node2 = node2;
                this.cost = cost;
            }
        }

        private int V, E;
        List<edge> edges = new ArrayList<edge>();

        KruskalClass(int V, int E){
            this.V = V;
            this.E = E;
        }

        public void addEdge(int source, int dest, int cost){
            edges.add(new edge(source, dest, cost));
        }

        public int kruskal(){
            UFT uft = new UFT(V);
            edges.sort((a, b) -> a.cost - b.cost);
            //Collections.sort(edges);

            int res = 0;
            for (edge e : edges){
                if (!uft.same(e.node1, e.node2)) {
                    uft.unite(e.node1, e.node2);
                    res += e.cost;
                }
            }
            return res;
        }

    }

   public static class UFT {
        int size;
        int rootsOfNodes[];

        public UFT(int n){
            size = n;
            int i = 1;
            while (i < n) i *= 2;
            rootsOfNodes = new int[n];
            for (int j = 0; j < n; j++)
                rootsOfNodes[j] = j;
        }

        private int depth(int node, int depth){
            if (node == rootsOfNodes[node])
                return depth;
            return depth(rootsOfNodes[node], depth + 1);
        }

        public void unite(int x, int y){
            int lower;
            int root;
            if (depth(x, 0) > depth(y, 0)) {
                lower = x;
                root = root(y);
            }
            else {
                lower = y;
                root = root(x);
            }
            while(lower != rootsOfNodes[lower]){
                int next = rootsOfNodes[lower];
                rootsOfNodes[lower] = root;
                lower = next;
            }
            rootsOfNodes[lower] = root;
        }

        private int root(int node) {
            if (node == rootsOfNodes[node])
                return node;
            return root(rootsOfNodes[node]);
        }

        public boolean same(int x, int y){
            return root(x) == root(y);
        }

        void print(){
            for (int i = 0; i < size; i++)
                System.out.printf("%d <-- Root -- %d\n", rootsOfNodes[i], i);
        }

    }


}

Measured memory_bytes: 108808
while True:
  n, m = map(int, input().split())
  if n == 0 and m == 0:
    break
  if n != 0 and m != 0:
    t_all = [0] + sorted(list(map(int, input().split())) + list(map(int, input().split())))
  else:
    t_all = [0] + sorted(map(int, input().split()))
  ans = 0
  for i in range(1, n + m + 1):
    ans = max(ans, t_all[i] - t_all[i - 1])
  print(ans)


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

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];

  REP(i,n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int n, m, k;
	cin >> n >> m >> k;
	string s[n];
	int ans = 0;
	for (int i = 0; i < n; ++i) cin >> s[i];
	for (int i = 0; i < (1LL << n); ++i) {
		for (int j = 0; j < (1LL << m); ++j) {
			int cnt = 0;
			for (int r = 0; r < n; ++r) {
				if (i & (1LL << r)) continue;
				for (int c = 0; c < m; ++c) {
					if (j & (1LL << c)) continue;
					cnt += (s[r][c] == '#');
				}
			}
			ans += (cnt == k);
		}
	}
	cout << ans << endl;
	return 0;
}

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


//DEFINE
#define rep(i, a, b) for (i = a; i < b; i++)
#define rev(i, n, b) for (i = n; i >= b; i--)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int>>
#define sll set<long long int>
#define mll map<long long int, long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int, long long int>
#define vpll vector<pair<long long int, long long int>>
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define w(t) while (t--)
#define booster ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	while(k--)
	{
		int d;
		cin>>d;
		for(int i=0;i<d;i++)
		{
			int x;
			cin>>x;
			a[x]++;
		}
	}
	int cnt=0;
	for(int i=1;i<n+1;i++)
	{
		if(a[i]==0)
		{
			cnt+=1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  int ans=0;
  
  for(int i=0;i<=100;i++) {
    if(A<=i && i<=B && C<=i && i<=D) ans++;
  }
  if(ans) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int n;
  int A[200000];
  int i,j,max=-999999999;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=n-1;i>=0;i--){

    if(A[i]<max)continue;
    
    for(j=i-1;j>=0;j--){
      if(A[i]-A[j]>max) max = A[i]-A[j];
    }
  }
  printf("%d\n",max);


  
  return 0;
}

      



Measured memory_bytes: 2632
#include "stdio.h"

int main(void)
{
    char S[100000];
    int count_1 = 0;
    int count_2 = 0;
    int ans;
    
    
    scanf("%s", S);
    for(int i = 0 ; i< 50000; ++i){

        
        /* 左端が１で始まるパターン */

        if(S[2*i] ==  '0'){
            count_1 = count_1 + 1;            
        }
        if(S[2*i+1] == '1'){
            count_1 = count_1 + 1;            
        }


        /* 左端が０で始まるパターン */
        if(S[2*i] ==  '1'){
            count_2 = count_2 + 1;            
        }
        if(S[2*i+1] == '0'){
            count_2 = count_2 + 1;            
        }
        
        if(S[2*i+1] == NULL){
            break;            
        }
    }
    if(count_1 < count_2){
        ans = count_1;
    }
    else{
        ans = count_2;
    }
    
    printf("%d", ans);
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>

using namespace std;

int N;
map<char,int> M;
vector<string> V;

bool come[26];
bool edge[26][26];

void init(){
  M.clear();
  V.clear();
  fill(come,come+26,false);
  memset(edge,false,sizeof(edge));
}

void input(){
  V.resize(N);
  for(int i = 0; i < N; i++)
    cin >> V[i];
}

void dfs(int pos){
  if(come[pos]) return;
  come[pos] = true;
  for(int i = 0; i < 26; i++){
    if(edge[pos][i]) dfs(i);
  }
}

void solve(){
  for(int i = 0; i < V.size(); i++){
    char s = V[i][0];
    char g = V[i][V[i].length()-1];
    M[s]++;
    M[g]--;
    edge[s-'a'][g-'a'] = true;
  }

  dfs(V[0][0]-'a');

  for(int i = 0; i < V.size(); i++){
    char s = V[i][0];
    char g = V[i][V[i].length()-1];
    if(M[s] || M[g] || !come[s-'a'] || !come[g-'a']){
      cout << "NG" << endl;
      return;
    }
  }
  cout << "OK" << endl;
}

int main(){
  while(cin >> N && N){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 2068
/*input
12 5 2
cabbabaacaba
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s;
int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	int ans=k;
	REP(i,n-1) ans*=(k-1);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

ll gcd (ll a, ll b){
    ll k = a % b;
    while (k > 0){
        a = b;
        b = k;
        k = a % b;
    }
    return b;
}

int main() {
    int d; cin >> d;
    vector<int> ar(26);
    rep(i,26) cin >> ar[i];
    vector<vector<int>> sc(d,vector<int>(26));
    rep(i,d) rep(j,26) cin >> sc[i][j];
    vector<int> la(26,0);
    rep(i,d){
        int ma = -10000000;
        int as = 0;
        int ima = 0;
        rep(j,26){
            ima += ar[j] * (i+1 - la[j]);
        }
        rep(j,26){
            int sp = sc[i][j];
            sp -= ima;
            sp += ar[j] * (i+1 - la[j]);
            if (ma < sp){
                ma = sp;
                as = j+1;
            }
        }
        cout << as << endl;
    }
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;

int main() {

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i, n)cin >> a[i];
    ll x2 = 0;
    rep(i, n) {
        if (i % 2) x2 -= a[i];
        else x2 += a[i];
    }
    vector<int> ans(n);
    ans[0] = x2 / 2;
    rep(i, n - 1) {
        ans[i + 1] = a[i] - ans[i];
    }
    rep(i, n)ans[i] *= 2;
    rep(i, n) {
        cout << ans[i] << ' ';
    }
    cout << endl;

}



Measured memory_bytes: 2048
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define MEM(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

LL solve() {
    int L, R, d;
    cin >> L >> R >> d;

    LL res = 0;

    for (int i = L; i <= R; i++) {
        if (i % d == 0) res++;
    }

    return res;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();

    int t = 1;

    // cin >> t;

    for (int _ = t; _ > 0; _--) {
        cout << solve() << endl;
    }

    return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
struct query{
	int a,b,c,d;
} qu[51];
int n,m,q,a[21],b[21];
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>qu[i].a>>qu[i].b>>qu[i].c>>qu[i].d;
	for(int i=1;i<=n;i++)
		a[i]=0;
	for(int i=n+1;i<=m+n-1;i++)
		a[i]=1;
	for(int i=1;i<=n;i++)
		b[i]=1;
	int ans=0,res=0;
	for(int i=1;i<=q;i++)
		if(b[qu[i].b]-b[qu[i].a]==qu[i].c)
			ans+=qu[i].d;
	do{
		res=0;
		int cnt=0,tot=1;
		for(int i=1;i<=n+m;i++)
			if(a[i])
				tot++;
			else
				b[++cnt]=tot;
		for(int i=1;i<=q;i++)
			if(b[qu[i].b]-b[qu[i].a]==qu[i].c)
				res+=qu[i].d;
		ans=max(ans,res);
	}while(next_permutation(a+1,a+n+m+1));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
"""
http://abc065.contest.atcoder.jp/tasks/abc065_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    N = int(input())
    a = [int(input()) for _ in range(N)]
    a.insert(0, '@')            #  1起算にするためのダミー


    possible = False
    next_btn = a[1]
    visited = set([1])
    while next_btn not in visited:
        if next_btn == 2:
            possible = True
            break
        visited.add(next_btn)
        next_btn = a[next_btn]
    if possible:
        print(len(visited))
    else:
        print(-1)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 13216
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


mod = 10 ** 9 + 7

n = I()
if n % 1000:
    print(1000 - n % 1000)
else:
    print(0)

Measured memory_bytes: 81452
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    string N, S;
    cin >> N >> S;
    
    string abc = "abcdefghijklmnopqrstuvwxyz";
    int ans = 0;
    for (int i = 0; i < S.length(); ++i){
    	string X = S.substr(0, i);
    	string Y = S.substr(i);
    	// cout << X << " " << Y << endl;
	int numX[26] = {0};  // バケット
	int numY[26] = {0};  // バケット
	for (int j = 0; j < X.length(); ++j) {
	        for (int k = 0; k < 26; ++k) {
	        	if (X[j]==abc[k]) numX[k]++;  // d[i] が 1 個増える
	        }
	}
	for (int j = 0; j < Y.length(); ++j) {
	        for (int k = 0; k < 26; ++k) {
	        	if (Y[j]==abc[k]) numY[k]++;  // d[i] が 1 個増える
	        }	
    	}
    	for (int j = 0; j < 26; ++j){
    		numX[j] = numX[j] * numY[j];
    	}
	int sum = 0;
	for (int j = 0; j < 26; ++j) {
		// if (min(1,numX[j])==1) cout << abc[j];
		sum += min(1,numX[j]);
	}
	// cout << endl;
	// cout << i << " " << sum << endl;
	if (sum>ans) ans = sum;
    }
 
	//出力
    cout << ans << endl;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll a,b;
	cin>>a>>b;
	ll x=0;
	ll j=0;
	bool p=false;
	ll c=b;
	while(b>0) {b/=10;x++;}
	double m=a*pow(10,x);
	m+=(double)c;
	for(int i=1;i<=10000;i++){
		j=i*i;
	 if(m==j){p=true;break;}
	}
	if(p)cout<<"Yes";
	else cout<<"No";
}
	

Measured memory_bytes: 384
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a+1,max(c,d)+1):
    if c < i and i < b:
        continue
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla >= 2:
        dou = False
    if flb >= 3 and i >= b+1 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,x,l,dp[N],ans=0;
vector<pair<ll,ll> > des;
int main(){
	ll i,pos;
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++)
	{
		cin>>x>>l;
		des.push_back(make_pair(x-l,x+l));
	}
	sort(des.begin(),des.end());
	for(i=des.size();i>=0;i--)
	{
		pos=lower_bound(des.begin(),des.end(),make_pair(des[i].S,(ll)0))-des.begin();
		if(pos==des.size())
		{
			dp[i]=max((ll)1,dp[i+1]);
		}
		else
		{
			dp[i]=max(dp[i+1],dp[pos]+1);
		}
	}
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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 T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  rep(i, 0, N) cin >> x[i];

  int ans = abs(X-x[0]);
  rep(i, 1, N) {
    ans = gcd(ans, abs(X-x[i]));
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#conding utf-8
N,Q=map(int,input().split())
S=input()
lr=[[int(i) for i in input().split()] for i in range(Q)]

AC=[0]
tmp=0
for i in range(N-1):
  if S[i:i+2]=="AC":
    tmp=tmp+1
  AC.append(tmp)

for i in range(Q):
  print(AC[lr[i][1]-1]-AC[lr[i][0]-1])

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

int main() {
  int n, a;
  cin >> n >> a;
  if(a % 2 == 0||n % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int i,n,temp,cnt,q,b,s,g,sum=100000;
	int num[4] = { 0 };

	scanf("%d", &n);
	while (n)
	{
		cnt = 4;
		i = 0;
		sum *= 1.05;
		temp = sum;
		while (cnt)
		{
			num[i]= temp%10;
			temp /= 10;
			++i;
			--cnt;
		}
		if (num[0] != 0 || num[1] != 0 || num[2] != 0)
		{
			sum = sum-num[2]*100-num[1]*10-num[0]+1000;
		}
		--n;
	}
	printf("%d\n",sum);
	
	
	return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
const int maxn=200005;
int n;
char s[maxn];
deque<int>Q[26];
bool vis[maxn];
int c[maxn];
void add(int x){
	while(x<=n)
		++c[x],x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)
		res+=c[x],x-=x&-x;
	return res;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	REP(i,1,n)Q[s[i]-'a'].push_back(i);
	bool flag=0;
	REP(i,0,25)
		if(Q[i].size()&1){
			if(flag){puts("-1");return 0;}
			else flag=1;
		}
	flag=0;
	long long ans=0;
	DREP(i,n,1){
		int x=s[i]-'a';
		if(i==Q[x].front())flag=1;
		if(i<=Q[x].front())continue;
		else{
			int p=Q[x].front();
			ans+=p-1-query(p),add(p),Q[x].pop_front();
			if(flag)++ans;
		}
	}
	write(ans,'\n');
	return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
    int a,b; cin >> a >> b;
    int maxx = max(a,b);
    int minn = min(a,b);
    int total = maxx;
    if(maxx-1>minn) total+=maxx-1;
    else total+=minn;
    cout << total;

    
    return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a, b, c;
    cin>>a>>b>>c;
    string tmp = "";
    tmp += toupper(a[0]);
    tmp += toupper(b[0]);
    tmp += toupper(c[0]);
    cout<<tmp<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	Int n; cin >> n;
	Int power = 1;
	for (Int i = 1; i <= n; i++) {
		power = (power*i) % 1000000007;
	}
	cout << power;
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int M = 1000000007;

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

	vector<int> c;
	{
		vector<int> a(n);
		cin >> a;

		rep(i,n){
			if(c.empty() or c.back() != a[i]){
				c.emplace_back(a[i]);
			}
		}
	}

	vector<int> t(200005, 0);
	int cur = 1;
	rep(i,c.size()){
		if(i > 0 and c[i] == c[i + 1]) continue;

		(cur += t[c[i]]) %= M;
		t[c[i]] = cur;
		//show(cur)
		//cout << c << endl;
	}
	cout << cur << endl;
}


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {

	private static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		String[] firstLine = scan.nextLine().split(" ");
		int a = Integer.valueOf(firstLine[0]);
		int b = Integer.valueOf(firstLine[1]);
		int ans = a + b;
		if (ans < a - b) {
			ans = a - b;
		}
		if (ans < a * b) {
			ans = a * b;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


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

    bool flag = false;
    int pos;
    int ans;
    rep(i, S.size()) {
        if (S[i] != '1') {
            flag = true;
            ans = S[i] - '0';
            pos = i;
            break;
        }
    }

    if (flag) {
        if (K > pos) print(ans);
        else print(1);
    }
    else print(1);
}



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

#define ll long long 
#define ii pair<ll,ll> 

ll n, g[2], s[2], b[2];
ll ans[10000], finalAns = 0;
bool visited[10000];

ll dp(ll num, ll ma, ll sa, ll mb, ll sb, ll mc, ll sc){
	if(visited[num])
		return ans[num];
	visited[num] = true;
	ans[num] = num;
	if(num >= ma)
		ans[num] = max(ans[num], dp(num-ma, ma, sa, mb, sb, mc, sc)+sa+ma);
	if(num >= mb)
		ans[num] = max(ans[num], dp(num-mb, ma, sa, mb, sb, mc, sc)+sb+mb);
	if(num >= mc)
		ans[num] = max(ans[num], dp(num-mc, ma, sa, mb, sb, mc, sc)+sc+mc);
	return ans[num];
}

int main(){
	scanf("%lld", &n);
	scanf("%lld %lld %lld", &g[0], &s[0], &b[0]);
	scanf("%lld %lld %lld", &g[1], &s[1], &b[1]);
	int back = (g[0]-g[1] > 0) + (s[0]-s[1] > 0) + (b[0]-b[1] > 0);
	// A -> B, then B -> A
	ll midAns = dp(n, g[0], g[1]-g[0], s[0], s[1]-s[0], b[0], b[1]-b[0]);
	// printf("mid = %lld, back = %d\n", midAns, back);

	// Find final ans
	if(back == 3){
		// Use dp
		memset(visited, 0, sizeof visited);
		finalAns = dp(midAns, g[1], g[0]-g[1], s[1], s[0]-s[1], b[1], b[0]-b[1]);
	}else if(back > 0){
		// Find sulprus trade
		vector<ii> trade;
		if(g[0]-g[1] > 0)
			trade.push_back(ii(g[1], g[0]));
		if(s[0]-s[1] > 0)
			trade.push_back(ii(s[1], s[0]));
		if(b[0]-b[1] > 0)
			trade.push_back(ii(b[1], b[0]));
		// Use brute force
		for(ll i = 0; i <= midAns; ++i){
			if(i*trade[0].first > midAns)
				break;
			// Try trading trade1 i times
			ll tmpFinal = midAns + i*(trade[0].second-trade[0].first);
			// Trade the rest witn trade2
			if(trade.size() > 1){
				ll rem = midAns - i*(trade[0].first);
				ll numTrade = rem/trade[1].first;
				tmpFinal += numTrade*(trade[1].second-trade[1].first);
			}
			// printf("tmpFinal = %lld, %lld\n", tmpFinal, i);
			finalAns = max(finalAns, tmpFinal);
		}
	}else{
		finalAns = midAns;
	}
	printf("%lld\n", finalAns);
}

Measured memory_bytes: 640
/* -------------------------------- */
/* Name: MD. Khairul Basar          */
/* Institute: HSTU                  */
/* Dept: CSE                        */
/* Email: khairul.basar93@gmail.com */
/* -------------------------------- */

#include <bits/stdc++.h>
/* all header files */

#define fs            first
#define sc            second
#define sp            printf(" ")
#define nl            printf("\n")
#define pb(a)         push_back(a)

#define setzero(a)    memset(a,0,sizeof(a))
#define setneg(a)     memset(a,-1,sizeof(a))
#define setinf(a)     memset(a,126,sizeof(a))

#define tc1(x)        printf("Case %d: ",x)
#define tc2(x)        printf("Case #%d: ",x)
#define tc3(x)        printf("Case %d:\n",x)
#define tc4(x)        printf("Case #%d:\n",x)

#define iin(x)        scanf("%d",&x)
#define din(x)        scanf("%lf",&x)
#define lin(x)        scanf("%lld",&x)
#define clin(x)       scanf("%I64d",&x)

#define pr1(x)        cout<<x<<"\n"
#define pr2(x,y)      cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)    cout<<x<<" "<<y<<" "<<z<<"\n"
#define pr4(w,x,y,z)  cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define fast          ios::sync_with_stdio(0)
#define read          freopen("input.txt","r",stdin)
#define write         freopen("output.txt","w",stdout)
#define prflag1(flag) printf("%s\n",(flag)?"YES":"NO")
#define prflag2(flag) printf("%s\n",(flag)?"Yes":"No")
#define prflag3(flag) printf("%s\n",(flag)?"yes":"no")
/* macro definitions */

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int>pii;
typedef pair<LL, LL>pll;
typedef vector<int>vi;
typedef vector<LL>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
/* type definitions */

LL MOD_EXPO(LL b, LL p, LL m)
{
    if(p==0) return 1;
    LL ret=MOD_EXPO(b,p/2,m)%m;
    ret=(ret*ret)%m;
    return ((p&1) ? (ret*b)%m : ret%m);
}
LL POWER(LL N, LL K)
{
    LL i,ans=1;
    for(i=1;i<=K;i++) ans*=N;
    return ans;
}
int SET(int N, int pos)
{
    return (N | (1<<pos));
}
int RESET(int N, int pos)
{
    return (N & !(1<<pos));
}
bool CHECK(int N, int pos)
{
    return (N & (1<<pos));
}
/* necessary functions */

int dx4[]= {1,-1,0,0};
int dy4[]= {0,0,1,-1};
int dx6[]= {0,0,1,-1,0,0};
int dy6[]= {1,-1,0,0,0,0};
int dz6[]= {0,0,0,0,1,-1};
int dx8[]= {1,-1,0,0,-1,1,-1,1};
int dy8[]= {0,0,1,-1,1,1,-1,-1};
int dkx8[]= {-1,1,-1,1,-2,-2,2,2};
int dky8[]= {2,2,-2,-2,1,-1,1,-1};
/* direction arrays */

int tc=1;
const double eps=1e-9;
const double pi=acos(-1.0);
const long long int mx=1e5;
const long long int mod=1e9+7;
/* global declarations */

int main()
{
    string s1,s2,s3,ss;
    cin>>s1>>s2>>s3;
    ss="A";
    ss+=s2[0];
    ss+="C";
    pr1(ss);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int g[30];
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) g[s[i]-'a']++;
	for(int i=0;i<26;i++){
		if(g[i]==0){
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=1e6+51,inf=0x3f3f3f3f;
struct Edge{
	ll to,prev;
};
struct SegmentTree{
	ll l,r,minn;
};
Edge ed[MAXN<<1];
SegmentTree tree[MAXN<<2];
priority_queue<ll,vector<ll>,greater<ll> >q;
ll cnt,tot,kk,x,ptr;
ll last[MAXN],rid[MAXN],deg[MAXN],res[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
template <class T>
inline ll Min(T x,T y)
{
	return x<y?x:y;
}
template <class T>
inline ll Max(T x,T y)
{
	return x>y?x:y;
}
inline void addEdge(ll from,ll to)
{
	ed[++tot].prev=last[from];
	ed[tot].to=to;
	last[from]=tot;
}
inline void update(ll node)
{
	tree[node].minn=Min(tree[node<<1].minn,tree[(node<<1)|1].minn);
}
inline void create(ll l,ll r,ll node)
{
	tree[node].l=l,tree[node].r=r;
	if(tree[node].l==tree[node].r)
	{
		tree[node].minn=inf;
		return;
	}
	ll mid=(l+r)>>1;
	create(l,mid,node<<1);
	create(mid+1,r,(node<<1)|1);
	update(node);
}
inline void changePoint(ll pos,ll val,ll node)
{
	if(tree[node].l==tree[node].r)
	{
		tree[node].minn=val;
		return;
	}
	ll mid=(tree[node].l+tree[node].r)>>1;
	if(pos<=mid)
	{
		changePoint(pos,val,node<<1);
	}
	else
	{
		changePoint(pos,val,(node<<1)|1);
	}
	update(node);
}
inline ll queryMin(ll l,ll r,ll node)
{
	if(l<=tree[node].l&&r>=tree[node].r)
	{
		return tree[node].minn;
	}
	ll mid=(tree[node].l+tree[node].r)>>1,res=inf;
	if(l<=mid)
	{
		res=Min(res,queryMin(l,r,node<<1));
	}
	if(r>mid)
	{
		res=Min(res,queryMin(l,r,(node<<1)|1));
	}
	return res;
}
inline void toposort()
{
	ll top;
	for(register int i=1;i<=cnt;i++)
	{
		if(!deg[i])
		{
			q.push(i);
		}
	} 
	while(!q.empty())
	{
		top=q.top(),q.pop(),res[top]=++ptr;
		for(register int i=last[top];i;i=ed[i].prev)
		{
			deg[ed[i].to]--;
			if(!deg[ed[i].to])
			{
				q.push(ed[i].to);
			}
		}
	}
}
int main()
{
	cnt=read(),kk=read();
	for(register int i=1;i<=cnt;i++)
	{
		rid[read()]=i;
	}
	create(1,cnt,1);
	for(register int i=cnt;i;i--)
	{
		x=queryMin(rid[i]+1,Min(rid[i]+kk-1,cnt),1);
		if(x>=1&&x<=cnt)
		{
			addEdge(rid[i],rid[x]),deg[rid[x]]++;
		}
		x=queryMin(Max(rid[i]-kk+1,1),rid[i]-1,1);
		if(x>=1&&x<=cnt)
		{
			addEdge(rid[i],rid[x]),deg[rid[x]]++;
		}
		changePoint(rid[i],i,1);
	}
	toposort();
	for(register int i=1;i<=ptr;i++)
	{
		printf("%d\n",res[i]);
	}
}

Measured memory_bytes: 42624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vll = vector<ll>;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using Pll = pair<ll, ll>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INFll = 1ll<<60;


template<typename T>
struct edge {
  int v; T w;
  edge(int v, T w) : v(v), w(w) {}
};
template<typename T>
using Graph = vector<vector<edge<T>>>;

string rev(string s) { reverse(all(s)); return s; }

map<string, int> idS[2];
vector<string> s[2];


int main() {
  int n; cin >> n;
  Vll c(n);
  rep(i, n) {
    string x;
    cin >> x >> c[i];
    s[0].push_back(x);
    s[1].push_back(rev(x));
  }

  int N = 0;
  VVV nid(2, VV(n));
  rep(r, 2) rep(i, n) rep(j, sz(s[r][i])+1) nid[r][i].push_back(N++);

  Graph<ll> G(N);
  rep(r, 2) rep(i, n) rep2(j, 1, sz(s[r][i])+1) rep(k, n) {
    auto s1 = rev(s[r][i].substr(0, j));
    auto s2 = s[r][k];

    int l = sz(s2);
    int mn = min(j, l);
    if (s1.substr(0, mn) != s2.substr(0, mn)) continue;
    
    int r2 = r;
    int i2 = i;
    int j2 = abs(j-l);
    if (j < l) r2 ^= 1, i2 = k;
    G[nid[r][i][j]].emplace_back(nid[r2][i2][j2], c[k]);
  }

  Vll dist(N, INFll);
  priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
  rep(i, n) {
    int x = nid[0][i][sz(s[0][i])];
    dist[x] = c[i];
    pq.emplace(dist[x], x);
  } 
  while (!pq.empty()) {
    auto [d, u] = pq.top(); pq.pop();
    if (dist[u] < d) continue;
    for (auto &[v, w] : G[u]) {
      if (chmin(dist[v], d+w)) pq.emplace(dist[v], v);
    }
  }

  ll ans = INFll;
  rep(r, 2) rep(i, n) rep(j, sz(s[r][i])+1) {
    auto t = s[r][i].substr(0, j);
    if (t == rev(t)) chmin(ans, dist[nid[r][i][j]]);
  }
  cout << (ans == INFll ? -1 : ans) << '\n';
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<float> ma(n);
	REP(i,n) cin >> ma[i];
	float t = 0;
	int f = n;
	float ans = 0;
	while(ma.size()!=1) {
		sort(ma.begin(),ma.end());
		reverse(ma.begin(),ma.end());
		t = ma[f-1] + ma[f-2];
		t/=2;
		ma.pop_back();
		ma.pop_back();
		ma.push_back(t);
		ans += t;
		f--;
 		//  cout << t << endl;

	}

  cout << t << endl;
}


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

int main() {
    int m,d,money[10],sum[10];
    string str[10];
    for(int i=0;i<9;i++){
        cin >> str[i] >> m >> d;
        sum[i]=m+d;
        money[i]=m*200+d*300;
    }
    for(int i=0;i<9;i++){
        cout << str[i] << ' ' << sum[i] << ' ' << money[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int dp[1<<26];
const int INF = 1e9;
 
int main() {
    string S;
    cin >> S;
    rep(i,0,(1<<26)) dp[i] = INF;
    dp[0] = 0;
    int stat = 0;
    rep(i,0,SZ(S)){
        stat ^= 1 << (S[i]-'a');
        rep(j,0,26) {
            int tmp = (stat^(1<<j));
            dp[stat] = min(dp[stat], dp[tmp]+1);
        }
    }
    cout<<max(dp[stat],1)<< endl;
    return 0;
}


Measured memory_bytes: 262788