akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

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



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    rep(i, sz(s)){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    print(s);
}



Measured memory_bytes: 3772
/*
  AOJ #3001
  title:GPA Janken
  @kankichi573
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N;

struct A_st{
  int no;
  double val;
  int point;}
  a[100001];

int score[100001];

int compA( const void * a , const void * b ) {

  if( ((struct A_st * )a)->val > ((struct A_st * )b)->val)
    return -1;

  else
    if( ((struct A_st * )a)->val == ((struct A_st * )b)->val)
      return 0;

  return 1;
}

int eq_next(int l)
{
  int i;
  if(l==N-1)
    return(0);
  for(i=1;i<N-l;i++)
    {
      //printf(":%d:%d :",l,l+i);
      //printf(":%lf:%lf|",a[l].val,a[l+i].val);
      //printf(":%d\n",a[l].val==a[l+i].val);
      if(a[l+i].val != a[l].val)
        return(i-1);
    }
  return(i-1);
}
void check_draw()
{
  int i,j,ret;
  i=0;
  while(i<N)
    {
      ret=eq_next(i);
      //if(ret)
      //printf("eq=%d\n",ret);
      if(ret)
        {
          for(j=i;j<=i+ret+1;j++)
            a[j].point=(N-1-i)*3-ret*2;
          i+=ret+1;
        }
      else
        {
          a[i].point = (N-1-i)*3;
          i++;
        }
    }

}
void dump()
{
  int i;
  for(i=0;i<N;i++)
    printf("%lf [%d] [=%d]\n",a[i].val,a[i].no,a[i].point);
}

void output()
{
  int i;
  for(i=0;i<N;i++)
    score[a[i].no]=a[i].point;
  for(i=0;i<N;i++)
    printf("%d\n",score[i]);
}

int main()
{
  int i;

  memset(a,0,sizeof(a));
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      a[i].no = i;
      scanf("%lf",&a[i].val);
    }
  qsort(a,N,sizeof(struct A_st),compA);
  check_draw();
  //dump();
  output();
  return(0);
}

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

#define mx 10001

using namespace std;

struct edge{
  int u, v, cst;
  edge() {}
  edge(int _u, int _v, int _cst): u(_u), v(_v), cst(_cst) {}

  bool operator<(const edge& e) const{
    return cst < e.cst;
  }
};

struct UnionFind{
  int n;
  vector<int> par, rank;
  UnionFind() {}
  UnionFind(int _n): n(_n) {
    for(int i = 0; i < n; ++i){
      par.push_back(i);
      rank.push_back(0);
    }
  }

  int find(int v){
    if(par[v] == v) return v;
    return par[v] = find(par[v]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return ;

    if(rank[x] < rank[y]){
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }

    return ;
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
};

int n, m;
vector<edge> vec;

int kruskal(int p){
  int s = 0, t = vec[p].cst;
  UnionFind uf = UnionFind(n);

  for(int i = p; i < vec.size(); ++i)
    if(!uf.same(vec[i].u, vec[i].v)){
      uf.unite(vec[i].u, vec[i].v);
      s = vec[i].cst;
    }

  for(int i = 1; i < n; ++i)
    if(!uf.same(0, i)) return mx;

  return (s-t);
}

int main()
{
  int a, b, w;

  while(cin>>n>>m && (n+m)){
    while(m--){
      cin >> a >> b >> w;
      --a; --b;
      vec.push_back(edge(a, b, w));
    }
    sort(vec.begin(), vec.end());
    a = mx;

    for(int i = 0; i < vec.size(); ++i)
      a = min(a, kruskal(i));

    cout << ((a == mx)? -1 : a) << endl;
    vec.clear();
  }

  return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
vl table(10001, 0);

int main(void){
  
  I(N);
  FOR(x, 1, 10000) {
    FOR(y, 1, 10000-x*x) {
      FOR(z, 1, 10000-x*x-y*y) {
        ll n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n <= 10000) table[n]++;
      }
    }
  }
  FOR(i, 1, N+1) {
    P(table[i]);
  }

}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

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

	ll p = n%k;

	ll ans = min(abs(p-k),p);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int bar[a],haight[a];
    bar[0]=0;
    for(int i=0;i<a;i++)
    cin>>haight[i];
    for(int i=0;i<a;i++){
        if(i==0)
        continue;
        if(i==1)
            bar[1]=abs(haight[0]-haight[1]);
        else{
        int b=abs(haight[i]-haight[i-1])+bar[i-1];
        int c=abs(haight[i]-haight[i-2])+bar[i-2];
        if(b<c)
        bar[i]=b;
        else
        bar[i]=c;
        }
        
    }
    cout<<bar[a-1]<<endl;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long long         ll;
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef vector<ll>		  vll;


const ll OO = 1e16;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

int adjMax[11][11];

int Dijkstra1( int src, int dest = -1)    
{
	int n = 10;
	vi vis(n, 0), dist(n, OO), prev(n, -1);
	dist[src] = 0;

	while (true) {
		int val = OO, idx = -1;
		lp(i, n)
		if (!vis[i] && dist[i] < val) val = dist[i], idx = i;

		if (idx == -1 || idx == dest)    break;
		vis[idx] = 1;

		lp(i, n)
		if (dist[i] > (val = dist[idx] + adjMax[idx][i]))
			dist[i] = val, prev[i] = idx;   // Relax
	}
	return dest == -1 ? -1 : dist[dest];
}
int n, m;
int main(){
	fast();
	cin >> n >> m;
	
	lp(i, 10)
		lp(j, 10)
		cin >> adjMax[i][j];

	ll res = 0;
	
	lp(i , n)
		lp(j, m){
			int u;
			cin >> u;
			if (u >= 0 && u < 10){
				res += Dijkstra1(u, 1);
			}
			
		}
	cout << res << endl;
	return 0;
}
//mosta7il_

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = m * (m - 1) + n * (n - 1);

        System.out.println(ans / 2);
    }
}

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

int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  if(x > 0){
    ll times = x/d;
    if(times >= k){
      cout << x - d * k << endl;
      return(0);
    }  

    ll y = x - times*d;
    ll z = abs(x - (times+1)*d);
    ll remain = k - times;

    if(remain % 2 == 0){
      cout << y << endl;
    }else{
      cout << z << endl;
    }
  }else{
    ll times = abs(x)/d;
    if(times >= k){
      cout << abs(x + d * k) << endl;
      return(0);
    }  

    ll y = abs(x + times*d);
    ll z = x + (times+1)*d;
    ll remain = k - times;

    if(remain % 2 == 0){
      cout << y << endl;
    }else{
      cout << z << endl;
    }    
  }
  
  return(0);
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair
#define maxn 100005
using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;
int n,dp[maxn],dp1[maxn];
vector <P> adj[maxn];//to,cst.
void dfs(int u,int f){
	for(int i=0;i<(int)adj[u].size();i++){
		P p = adj[u][i];
		int v = p.first;
		if(v == f) continue;
		dfs(v,u);
		dp[u] = max(dp[u],dp[v] + p.second);
	}
}
void dfs1(int u,int f){//work dp1 for u's sons.
	int maxi = 0,maxpos,secmax = 0;
	for(int i=0;i<(int)adj[u].size();i++){
		P p = adj[u][i];
		int v = p.first;
		if(v == f) continue;
		dfs1(v,u);
		if(dp[v] + p.second > maxi){
			secmax = maxi;
			maxi = dp[v] + p.second;
			maxpos = i;
		}else if(dp[v] + p.second > secmax){
			secmax = dp[v] + p.second;
		}
	}
	for(int i=0;i<(int)adj[u].size();i++){
		P p = adj[u][i];
		int v = p.first;
		if(v == f) continue;
		dp1[v] = dp1[u];
		if(i == maxpos) dp1[v] = max(dp1[v],secmax);
		else dp1[v] = max(dp1[v],maxi);
		dp1[v] += p.second;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		adj[u + 1].push_back(mp(v + 1,w));
		adj[v + 1].push_back(mp(u + 1,w));
	}
	dfs(1,-1);
	dp1[1] = 0;
	dfs1(1,-1);
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dp[i] + dp1[i]);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 18772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
//int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;

struct edge {
    edge() : link_to(0), cost(0) {}
    edge(int t, int c) : link_to(t), cost(c) {}
    int link_to;
    int cost;
};

vector<int> memo(100010, -1);

int rec(vector<vector<edge>>&graph, int v) {
    if (memo[v] != -1) return memo[v];
    int ret{0};

    for (auto e : graph[v]) {
        ret = max(ret, rec(graph, e.link_to) + e.cost);
    }
    return memo[v] = ret;
}

int main(int argc, char **argv) {
    i64 n,m;
    cin >> n >> m;

    vector<vector<edge>> graph(n);

    for (int i=0; i<m; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        graph[x].push_back(edge(y, 1));
    }

    int ans{0};
    for (int i=0; i<n; ++i) {
        ans = max(ans, rec(graph, i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
/*上からみてく
配列をN+1個用意して、N＋１番目を０にしておく
最大値から順に数字を減らしていって、その数をiとする
数字がiを超えたとき、次の数字がiより小さかったらansに１たす
*/
using namespace std;
int main(){
  int N;
  cin>>N;
  vector <int> num(N+1);
  num[N] = 0;
  int ma = 0;
  for(int i = 0;i<N;i++){
    cin>>num[i];
    ma = max(ma,num[i]);
  }
  int ans = 0;
  for(int i = ma;i>0;i--){
    for(int k = 0;k<N+1;k++){
      if(num[k]>=i){
        if(num[k+1]<i){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef struct list {
    int i;
    struct list* next;
} LinkedList;

void push(LinkedList *list, int i) {
    LinkedList *l = malloc(sizeof(LinkedList*));
    l->i = i;

    while(list->next != NULL) {
        list = list->next;
    }
    list->next = l;
}

void show(LinkedList *list) {
    while(list != NULL) {
        printf("%d, ", list->i);
        list = list->next;
    }
    printf("\n");
}

int get_longest_path(LinkedList **path, int node, int *DP) {
    LinkedList *list = path[node];
    if (DP[node] != -1)
        return DP[node];
    int max = 0;
    if (list == NULL) {
        return DP[node] = 0;
    }
    while(list != NULL) {
        int length = get_longest_path(path, list->i, DP);
        if (length > max) {
            max = length;
        }
        list = list->next;
    }
    DP[node] = max + 1;
    return DP[node];
}

int     main() {
    int N;
    int M;

    scanf("%d", &N);
    scanf("%d", &M);

    int *x = malloc((M + 1) * sizeof(int));
    int *y = malloc((M + 1) * sizeof(int));
    LinkedList **path = malloc((N + 1) * sizeof(LinkedList*));
    int *DP = malloc((N + 1) * sizeof(int));
    //initialize
    for (int i = 1; i <= N; i++) {
        path[i] = NULL;
        DP[i] = -1;
    }

    for (int i = 1; i <= M; i++) {
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
        if (path[x[i]] == NULL) {
            LinkedList *list = malloc(sizeof(LinkedList*));
            list->i = y[i];
            list->next = NULL;
            path[x[i]] = list;
        } else {
            push(path[x[i]], y[i]);
        }
    }

    int max = 0;
    for (int i = 1; i <= N; i++) {
        //printf("%d: ", i);
        //show(path[i]);
        int length = get_longest_path(path, i, DP);
        //printf("length: %d\n", length);
        if (max < length)
            max = length;
    }
    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    int count = 0;
    rep(i,n){
        string s = to_string(i+1);
        if(s.length() % 2 == 1){
            count++;
        }
    }
    cout << count << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
PROGRAM-ID.                      ABC_047_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(11).
    01 a       PIC 9(3).
    01 b       PIC 9(3).
    01 c       PIC 9(3).
    01 x       PIC 9(3).
    01 q       PIC 9(3).
    01 r       PIC 9(1).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO a b c.

    COMPUTE x = a + b + c.
    DIVIDE 2 INTO x GIVING q REMAINDER r.

    IF r = 1 THEN
        DISPLAY "No"
    ELSE
        IF a = q OR b = q OR c = q THEN
            DISPLAY "Yes"
        ELSE
            DISPLAY "No"
        END-IF
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
/*input
4 3
0 12 71
81 0 53
14 92 0
1 1 2 1
2 1 1 2
2 2 1 3
1 1 2 2
*/
#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())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
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;
}



int main()
{
	string s;
	cin>>s;
	if(SZ(s)==2) cout<<s;
	else{
		reverse(ALL(s));
		cout<<s;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
  string s;
  map<string,string> word;
  word["101"] = " ";
  word["000000"] = "\'";
  word["000011"] = ",";
  word["10010001"] = "-";
  word["010001"] = ".";
  word["000001"] = "?";
  word["100101"] = "A";
  word["10011010"] = "B";
  word["0101"] = "C";
  word["0001"] = "D";
  word["110"] = "E";
  word["01001"] = "F";
  word["10011011"] = "G";
  word["010000"] = "H";
  word["0111"] = "I";
  word["10011000"] = "J";
  word["0110"] = "K";
  word["00100"] = "L";
  word["10011001"] = "M";
  word["10011110"] = "N";
  word["00101"] = "O";
  word["111"] = "P";
  word["10011111"] = "Q";
  word["1000"] = "R";
  word["00110"] = "S";
  word["00111"] = "T";
  word["10011100"] = "U";
  word["10011101"] = "V";
  word["000010"] = "W";
  word["10010010"] = "X";
  word["10010011"] = "Y";
  word["10010000"] = "Z";
  while(getline(cin,s)){
    string x,y,z;
    int r = 0;
    for(int i=0; i<s.size(); i++){
      if(s[i] == 'A'){x+="00000";}
      if(s[i] == 'B'){x+="00001";}
      if(s[i] == 'C'){x+="00010";}
      if(s[i] == 'D'){x+="00011";}
      if(s[i] == 'E'){x+="00100";}
      if(s[i] == 'F'){x+="00101";}
      if(s[i] == 'G'){x+="00110";}
      if(s[i] == 'H'){x+="00111";}
      if(s[i] == 'I'){x+="01000";}
      if(s[i] == 'J'){x+="01001";}
      if(s[i] == 'K'){x+="01010";}
      if(s[i] == 'L'){x+="01011";}
      if(s[i] == 'M'){x+="01100";}
      if(s[i] == 'N'){x+="01101";}
      if(s[i] == 'O'){x+="01110";}
      if(s[i] == 'P'){x+="01111";}
      if(s[i] == 'Q'){x+="10000";}
      if(s[i] == 'R'){x+="10001";}
      if(s[i] == 'S'){x+="10010";}
      if(s[i] == 'T'){x+="10011";}
      if(s[i] == 'U'){x+="10100";}
      if(s[i] == 'V'){x+="10101";}
      if(s[i] == 'W'){x+="10110";}
      if(s[i] == 'X'){x+="10111";}
      if(s[i] == 'Y'){x+="11000";}
      if(s[i] == 'Z'){x+="11001";}
      if(s[i] == ' '){x+="11010";}
      if(s[i] == '.'){x+="11011";}
      if(s[i] == ','){x+="11100";}
      if(s[i] == '-'){x+="11101";}
      if(s[i] == '\''){x+="11110";}
      if(s[i] == '?'){x+="11111";}
    }
    for(int i=0; i<x.size(); i++){
      y+=x[i];
      z+=word[y];
      if(r != z.size()){r = z.size();y.clear();}
    }
    cout <<z<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long x = getCount(a - 1, c, d);
		long y = getCount(b, c, d);
		System.out.println(b - a + 1 - (y - x));
	}
	
	static long getCount(long x, long y, long z) { // x以内で、yかzで割り切れる数
		long ans = x / y;
		ans += x / z;
		ans -= x / (y * z / gcd(y, z));
		return ans; 
	}
	
	static long gcd(long x, long y) {
		if (x % y == 0) {
			return y;
		}
		return gcd(y, x % y);
	}
}


Measured memory_bytes: 22612
#include"bits/stdc++.h"
#include<atcoder/modint.hpp>
#include<atcoder/lazysegtree.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

using mint = modint998244353;
vector<mint> mpow10;

struct S {
    mint val;
    int size;
};
S op(S a, S b) {
    return S{ a.val * mpow10[b.size] + b.val, a.size + b.size };
}
S e() {
    return S{ 0, 0 };
}
struct F {
    int val;
    bool act;
};
S mapping(F f, S x) {
    if (!f.act)return x;
    mint tmp = mpow10[x.size] - 1;
    tmp *= f.val;
    tmp /= 9;
    return S{ tmp, x.size };
}
F composition(F f, F g) {
    if (f.act)return f;
    return g;
}
F id() {
    return { 0, false };
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    mpow10.push_back(1);
    rep(i, N + 10) {
        mpow10.push_back(mpow10.back() * 10);
    }

    vector<S> init(N, { mint(1), 1 });
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);
    rep(_, Q) {
        int L, R, D;
        cin >> L >> R >> D;
        L--; R--;
        seg.apply(L, R + 1, F{ D, true });
        cout << seg.all_prod().val.val() << endl;
        //lst.update(L, R, D);
        //cout << lst.query(0, N - 1).val() << endl;
    }
    return 0;
}


Measured memory_bytes: 11876
s = str(input())
w = int(input())
d=list(s)
if len(d)%w==0:
  a = int(len(d)/w)
else:
  a = int(len(d)/w)+1
e=[]
for i in range(a):
    e.append(s[i*w])
f = ''
 
for x in e:
    f += x
    
print(f)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 200005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

ll n;

ll arr[M];

void initialize() {
    for (ll i = 1; i <= n; i++) {
        arr[i] = i;
    }
}

ll root(ll c) {
    while (arr[c] != c) {
        arr[c] = arr[arr[c]];
        c = arr[c];
    }
    return c;
}

void unite(ll p, ll q) {
    arr[root(p)] = root(q);
}

bool find(ll p, ll q) {
    if (root(p) == root(q)) return true;
    else return false;
}


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

    initialize();

    while (m--) {
        ll a, b;
        cin >> a >> b;
        unite(a, b);
    }

    vector<ll> ans(n + 1, 0);

    for (ll i = 1; i <= n; i++) {
        ans[root(i)]++;
    }

    cout << *max_element(ans.begin(), ans.end()) << endl;

    return 0;
}

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

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, ans = 0, bsum = 0, mnb = INT_MAX;
	cin >> n;
	bool aleq = 1;
	for(int i=0; i<n; i++) {
		int a, b;
		cin >> a >> b;
		if(a != b) {
			aleq = 0;
		}
		if(a < b) {
			ans += b;
		} else if(a == b) {
			ans += b;
		}else{
			bsum += b;
			mnb = min(mnb, b);
		}
	}
	if(aleq)
		return !(cout << 0);
	if(mnb != INT_MAX) {
		ans += bsum - mnb;
	}
	cout << ans;
}

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

int main()
{
  ll a,b;
  ll c,d;

  cin >> a >> b >> c >> d;

  ll cnum=0;
  ll dnum=0;
  ll lnum=0;
  ll lcm=0;
  ll k=c*d;
  ll r;
  cnum=(b/c)-((a-1)/c);
  dnum=(b/d)-((a-1)/d);
  if(d<c){
    ll temp=c;
    c=d;
    d=temp;
  }
  r=d%c;
  while(r!=0){
    d=c;
    c=r;
    r=d%c;
  }
  lcm = k/c;
  lnum=(b/lcm)-((a-1)/lcm);
  ll ans;
  //cout << cnum << dnum << lnum << endl;
  
  ans = (b-a+1)-(cnum+dnum)+lnum;
cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 3030;
bool sugar[N];

bool g(pi p, pi q){
    int pa = p.se, pb = p.fi;
    int qa = q.se, qb = q.fi;
    return pa*qb > qa*pb;
}

bool melt(int e, int s, int w){
    return e*w >= s*100;
}

int main(){
    int a,b,c,d,e,f;
    cin >>a >>b >>c >>d >>e >>f;

    sugar[0] = true;
    rep(i,N)if(sugar[i]){
        sugar[min(N-1,i+c)] = true;
        sugar[min(N-1,i+d)] = true;
    }

    pi ans(100*a,0);
    rep(i,31)rep(j,31)if(i+j>0){
        int water = 100*(i*a+j*b);
        if(water>f) continue;
        rep(k,N)if(sugar[k]){
            if(water+k>f) continue;
            if(!melt(e,k,water)) continue;

            pi t(water+k, k);
            if(g(t,ans)) ans = t;
        }
    }

    cout << ans.fi << " " << ans.se << endl;
    return 0;
}


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

const int MAX = 1e5 + 10;
typedef long long int ll;
typedef pair<ll,ll> pii;

vector<pii> a[MAX];
ll dist[MAX]={0};

void dfs(int x,int p) {

	for(auto y:a[x]) {
		if(y.first != p) {
			//cout<<"Adding edge : "<<x<<" -> "<<y.first<<" wright : "<<y.second<<endl;
			dist[y.first] = dist[x] + y.second;
			dfs(y.first,x);
		}
	}
}

int main()
{
	int n; cin>>n;
	for(int i=0;i<n-1;i++) {
		ll u,v,w; cin>>u>>v>>w;
		pii t; t.first = v; t.second = w;
		pii y; y.first = u; y.second = w;
		//cout<<u<<" "<<v<<" "<<w<<endl;
		a[u].push_back(t); a[v].push_back(y);
	}

	ll q,k; cin>>q>>k;
	dfs(k,k);
	//for(int i=1;i<=n;i++) cout<<i<<" : "<<dist[i]<<endl;
	while(q--) {
		int x1,x2; cin>>x1>>x2;
		cout<<dist[x1]+ dist[x2]<<endl;
	}
}

Measured memory_bytes: 14336
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    # 何個符号反転できるか？
    # -> 1 ～ N - 1 個反転できる
    # N - 1個: (((v - w) - x) - y) - z
    # N - 2個: ((v - w) - x) - (y - z)
    # ...
    #     2個: (v - w) - ((x - y) - z)
    #     1個: v - (((w - x) - y) - z)
    neg_cnt = sum([1 for a in A if a < 0])
    M = 0
    proc = list()
    if neg_cnt == N:
        # 全部負：絶対値が一番小さいもの以外を全て符号反転
        A.sort(reverse=True)
        x = A[0]
        for y in A[1:]:
            proc.append((x, y))
            x -= y
        M = x
    elif neg_cnt == 0:
        # 全部非負：一番小さいものだけ符号反転
        A.sort()
        x = A[0]
        for y in A[1:-1]:
            proc.append((x, y))
            x -= y
        x, y = A[-1], x
        proc.append((x, y))
        M = x - y
    else:
        # k個が負（1 <= k <= N - 1）：負の値を全て符号反転
        A.sort()
        x = A[-1]
        for y in A[:neg_cnt-1]:
            proc.append((x, y))
            x -= y
        former = x
        x = A[neg_cnt-1]  # the last negative element
        for y in A[neg_cnt:-1]:
            proc.append((x, y))
            x -= y
        latter = x
        proc.append((former, latter))
        M = former - latter
    print(M)
    for p in proc:
        x, y = p
        print('{} {}'.format(x, y))


if __name__ == '__main__':
    main()

Measured memory_bytes: 24704
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}

	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			int a,b;
			cin>>a>>b;
			if(a<=9 && b<=9 && a>=1 && b>=1) cout<<a*b<<endl;
			else cout<<-1<<endl;		
		}
		return 0;
	}

Measured memory_bytes: 3636
#include <cstdio>
int cnt[62];
char sigma[62], ans[129], query[129];
int editdist() {
	int x;
	printf("? %s\n", query);
	fflush(stdout);
	scanf("%d", &x);
	return x;
}
int main() {
	for(int i=0; i<26; ++i) sigma[i]='a'+i;
	for(int i=0; i<26; ++i) sigma[26+i]='A'+i;
	for(int i=0; i<10; ++i) sigma[52+i]='0'+i;
	for(int i=0; i<62; ++i) {
		for(int j=0; j<128; ++j) query[j]=sigma[i];
		query[128]=0;
		cnt[i]=128-editdist();
	}
	int tot=0, len=0;
	for(int i=0; i<62; ++i) tot+=cnt[i];
	for(int i=0; i<62; ++i) {
		if(len==0) {
			len=cnt[i];
			for(int j=0; j<cnt[i]; ++j) ans[j]=sigma[i];
		} else {
			for(int k=cnt[i], l=0; k>=1; --k) {
				int r=len;
				while(l<r) {
					int mid=(l+r+1)/2;
					for(int j=0; j<mid; ++j) query[j]=ans[j];
					for(int j=0; j<k; ++j) query[mid+j]=sigma[i];
					query[mid+k]=0;
					if(editdist()==tot-mid-k) l=mid; else r=mid-1;
				}
				++len;
				for(int j=len; j>l; --j) ans[j]=ans[j-1];
				ans[l]=sigma[i];
			}
		}
	}
	ans[len]=0;
	printf("! %s\n", ans);
	return 0;
}


Measured memory_bytes: 3792
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
int fpow(int x, int y) { 
	if (y < 0) return 1; 
	int res = 1; 
	while (y) { 
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
const int MAX_N = 2005; 
int N, K, f[MAX_N][MAX_N], sum[MAX_N]; 
int main () { 
	cin >> N >> K; 
	f[0][N + 1] = 1; 
	for (int i = 1; i <= K; i++) {
		sum[N + 1] = f[i - 1][N + 1];
		for (int j = N; j; j--) sum[j] = (sum[j + 1] + f[i - 1][j]) % Mod;
		for (int j = 1; j <= N - i + 1; j++) f[i][j] = sum[j];
	}
	printf("%lld\n", 1ll * fpow(2, N - K - 1) * sum[2] % Mod);
	return 0; 
} 

Measured memory_bytes: 15360
N = int(input())
left, right, both = 0, 0, 0
ans = 0
for i in range(N):
    s = input()
    if s[0] == "B":
        if s[-1] == "A":
            both += 1
        else:
            left += 1
    elif s[-1] == "A":
        right += 1
    for j in range(len(s) - 1):
        if s[j] == "A" and s[j + 1] == "B":
            ans += 1
# print(left, right, both, ans)

if min(left, right) >= 1:
    bonus = min(left, right) + both

elif max(left, right) == 0:
    bonus = max(both - 1, 0)

else:
    bonus = both

print(ans + bonus)

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

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int>ab(110);
    for(int i=0;i<M*2;i++)cin >> ab.at(i);

    for(int i=1;i<N+1;i++){
        cout << count(ab.begin(),ab.end(),i) <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;
ll mat[15][15];

void solve()
{
    ll n, m, x;
    cin >> n >> m >> x;

    basic_string <ll> price;

    for(ll i=0; i<n; i++)
    {
        ll t = nxt();
        price += t;

        for(ll j=0; j<m; j++)
        {
            cin >> mat[i][j];
        }
    }

    ll ans = LONG_MAX;

    for(ll i=1; i < (1LL << n); i++)
    {
        ll current = 0;

        basic_string <ll> temp(m, 0);

        for(ll j=0; j<n; j++)
        {
            if((1LL << j) & i)
            {
                for(ll k=0; k<m; k++)
                {
                    temp[k]+=mat[j][k];
                }

                current += price[j];
            }
        }

        bool f = true;

        for(ll k=0; k<m; k++)
        {
            if(x > temp[k])
            {
                f =  false;
            }
        }

        if(f)
        {
            ans = min(current, ans);
        }
    }

    if(ans == LONG_MAX)
    {
        cout << -1 << endl;
    }

    else
    {
        cout << ans << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

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

    return 0;
}

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

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;


#define N_MAX 200000
#define M_MAX 100

int n;
int s[N_MAX];
int t[N_MAX];

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

int solve(){
	int i;

	if (n == 1) {
		printf("%d\n", s[0]);
		return 0;
	}

	switch (n % 2) {
	case 0:
		for (i = n - 1; i > 0; i -= 2) {
			printf("%d ", s[i]);
		}
		for (i = 0; i < n; i += 2) {
			printf("%d", s[i]);
			if (i == n - 2) {
				putchar('\n');
			} else {
				putchar(' ');
			}
		}
		break;
	case 1:
		for (i = n - 1; i >= 0; i -= 2) {
			printf("%d ", s[i]);
		}
		for (i = 1; i < n; i += 2) {
			printf("%d", s[i]);
			if (i == n - 2) {
				putchar('\n');
			} else {
				putchar(' ');
			}
		}
		break;
	}

	return 0;
}

int main(void){
	int i;

	scanf("%d", &n);

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

	solve();

	return 0;
}


Measured memory_bytes: 2816
# coding: utf-8

import math
import re
import numpy as np
import copy

#読み込む
S = input()
T = input()

ans = len(S)

#高々(10^3)^2
for i in range(len(S) - len(T)):
    #何文字違うかをチェック
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i+j]:
            cnt += 1

    if cnt < ans:
        ans = cnt

if len(S) == len(T):
    cnt = 0
    for i in range(len(S)):
        if T[i] != S[i]:
            cnt += 1

    ans = cnt

print(ans)



Measured memory_bytes: 27164
#include<stdio.h>
int main(void)
{
	int v1, v2,l[10],distance,c;
	double d;
	int i;

	while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
		&l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
		distance = 0;
		c = 0;
		for (i = 0; i < 10; i++) {
			distance += l[i];
		}

		if (((double)distance * v1) == (v1 + v2))
			d = distance / 2;
		else
			d = ((double)distance * v1) / (v1 + v2);
		for (i = 0; i < 10; i++) {
			c += l[i];
			if (c == d) {
				printf("%d\n", i + 1);
				break;
			}
			else if (c > d) {
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

unsigned long xor128(){
    static unsigned long x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned long t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

int n;

int func(bitset<10000> query)
{
    cout << '?';
    for(int i=0; i<n; ++i){
        if(query[i])
            cout << '1';
        else
            cout << '0';
    }
    cout << endl;

    int ret;
    cin >> ret;
    return ret;
}


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

    bitset<10000> ret;

    while(--k >= 0){
        int m = 0;
        bitset<10000> query;
        for(int i=0; i<n; ++i){
            query[i] = (xor128() % 2 == 1) && !ret[i];
            if(query[i])
                ++ m;
        }

        if(func(query) == 0){
            ++ k;
            continue;
        }

        while(m > 1){
            bitset<10000> query2;
            int m2 = 0;
            for(int i=0; i<n; ++i){
                if(query[i] && m2 < m / 2){
                    query2[i] = true;
                    ++ m2;
                }
            }

            if(func(query2) == 1){
                query = query2;
                m = m2;
            }else{
                query ^= query2;
                m -= m2;
            }
        }

        ret |= query;
    }

    bool first = true;
    for(int i=0; i<n; ++i){
        if(ret[i]){
            if(first){
                cout << '!' << (i+1);
                first = false;
            }else{
                cout << ' ' << (i+1);
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 860
s=gets.chomp
maxlength=1
(2..s.length-2).each do |value|
  next if value%2==0
  forwardS=s[0..value/2]
  backS=s[value/2+1..value]  
  maxlength = value if forwardS == backS && maxlength < value
end
puts (maxlength+1)

Measured memory_bytes: 1788
#include<stdio.h>
main()
{
	int a[5], i, j, p;
	for (i=0; i<3; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i=2; i>0; i--)
	{
		for (j=0; j<i; j++)
		{
			if (a[i]<a[j])
			{
				p=a[i];
				a[i]=a[j];
				a[j]=p;
			}
		}
	}
	printf("%d\n", (a[2]-a[1])+(a[1]-a[0]));
	return 0;
}

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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int n;

int tak, nie;

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		int x;
		scanf("%d", &x);
		if (x&1)
			nie++;
		else
			tak++;
	}
	if ((!tak && nie==1) || !(nie&1))
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


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

using namespace std;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(0); //Don't delete this line!
    long long n;
    cin >> n;
    vector<long long> v;
    while(n--){
        long long l;
        cin >> l;
        v.push_back(l);
    }
    long long pairs=0;
    sort(v.begin(),v.end());
    vector<long long>::iterator up;
    for(long long i=0;i<v.size()-1;i++){
        for(long long j=i+1;j<v.size();j++){
            if(v[i]!=v[j]){
            long long add = (v[i]+v[j])-1;
            up = upper_bound(v.begin(),v.end(),add);
            pairs += up - lower_bound(v.begin(),v.end(),(v[j]+1));
            //cout << i << " " << j << " " << pairs << '\n';
            }
        }
    }
    cout << pairs;
}


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

using namespace std;

typedef long long ll;


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    if(N % 2 == 0){
        for(int i = 1 ; i <= M ; ++i){
            int now = 0;
            int left = 0;
            if(i % 2 == 1){
                now = (i+1) / 2;
                left = (N+1) - now; 
            }
            else{
                now = (N/2 - i/2);
                left = now + (i);
            }
            cout << now << ' ' << left << endl;
        }
    }
    else{
        for(int i = 0 ; i < M ; ++i){
            cout << 1 + i << ' ' << (N) - i << endl;
        }
    }

    return 0;


}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll a, v, b, w, t;

void input() {
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
}

void solve() {
  if (0 <= abs(a - b) && abs(a - b) <= t * (v - w)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(void){
  int a,b,c,count = 0,minB,minA;
  cin >> a >> b >> c;
  minB = min(b,c);
  count += minB * 2;
  c -= minB;
  b -= minB;

  minA = min(a,c);
  count += minA;
  c -= minA;
  a -= minA;
  if(c != 0)count++;
  count += b;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    string S, T, U;
    ll A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (S == U)
    {
        A--;
    }
    else
    {
        B--;
    }

    cout << A << " " << B << endl;
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A>>B;
  string S;
  cin >>S;
  int count=0;
  for(int i=0;i<S.size();i++){
      if(S.at(i)=='-'){
      count++;
      } 
    }
      if(count!=1){
       cout <<"No" <<endl;
       return 0;
      }

  if(S.at(A)=='-'){
      cout <<"Yes"<<endl;
  }
  else{
      cout <<"No"<<endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long con[210000];

int main() {
    while (cin >> N) {
        memset(con, 0, sizeof(con));
        for (int i = 0;i < N; ++i) {
            int a;
            cin >> a;
            con[a+1]++;
        }
        
        long long res = 0;
        for (int i = 1; i <= 100000; ++i) {
            chmax(res, con[i-1] + con[i] + con[i+1]);
        }
        
        cout << res << endl;
    }
}















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

int main()
{
	long long int numbers[100];
	long long int table[100][21] = {0};
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> numbers[i];

	table[0][numbers[0]] = 1;
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = 0; j <= 20; j++)
		{
			if (table[i][j] == 0) continue;
			if (j + numbers[i + 1] <= 20) table[i + 1][j + numbers[i + 1]] += table[i][j];
			if (j - numbers[i + 1] >= 0) table[i + 1][j - numbers[i + 1]] += table[i][j];
		}
	}

	cout << table[n - 2][numbers[n - 1]] << endl;

	return 0;
}

Measured memory_bytes: 3096