akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
string s, t;
const ll L_MAX = 3000+10;

ll dp[L_MAX][L_MAX]; // dp[i][j] = (s[i],t[j]までの最長共通部分列長)

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

    cin >> s >> t;

    ll n = SZ(s);
    ll m = SZ(t);

    for(ll i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(ll j=0;j<=m;j++){
        dp[0][j] = 0;
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    stack<char> ans;

    while(n!=0 && m!=0){
        if(s[n-1]==t[m-1]){
            ans.push(s[n-1]);
            n--;
            m--;
        }
        else{
            if(dp[n-1][m]>=dp[n][m-1]){
                n--;
            }
            else m--;
        }
    }
    while(!ans.empty()){
        cout << ans.top();
        ans.pop();
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 74100
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A, B, N;
int main(){
  rd(N);
  rd(A);
  rd(B);
  if((A-B)%2==0){
    wt_L("Alice");
    putchar_unlocked('\n');
  }
  else{
    wt_L("Borys");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20180108-2

// --- original code ---
// int N, A, B;
// {
//   rd(N,A,B);
//   if((A-B)%2==0) wt("Alice"); else wt("Borys");
// }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<fstream>
#include<cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define mp make_pair
#define f first
#define s second

struct load{
  int u;
  int v;
  int d;
  int c;
  load(int w,int x,int y, int z)
    : u(w), v(x), d(y), c(z) {}
  load(){}
};

int main(){
  int n,m;
  while(fscanf(stdin,"%d%d",&n,&m),n+m){
    vector<vector<int> > g(n);
    vector<load> l(m);

    REP(i,m){
      int a,b,c,d;
      fscanf(stdin,"%d%d%d%d",&a,&b,&d,&c);
      g[a-1].push_back(i);
      g[b-1].push_back(i);
      l[i] = load(a-1,b-1,d,c);
    }

    vector<bool> visit(n);
    vector<bool> use(m);
    //vector<int> dist(n);
    //vector<int> cost(n);
    int vcnt = 0;

    typedef pair<int,pair<int,pair<int,int> > > data;
    priority_queue<data,vector<data>,greater<data> > pq;

    pq.push(mp(0,mp(0,mp(0,-1))));

    while(pq.size() && vcnt != n){
      data d = pq.top(); pq.pop();

      int pos = d.s.s.f;
      int u   = d.s.s.s;
      int ds  = d.f;
      int cs  = d.s.f;

      if(visit[pos]) continue;
      visit[pos] = true; vcnt++;
      if(u != -1) use[u] = true;

      REP(i,g[pos].size()){
        int id = g[pos][i];
        load ld = l[id];
        int next = (ld.u == pos ? ld.v : ld.u);

        if(visit[next]) continue;

        int cc = ld.c;
        int dd = ds + ld.d;
        pq.push(mp(dd,mp(cc,mp(next,id))));
      }
    }

    int ans = 0;
    REP(i,m) if(use[i]) ans += l[i].c;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int result = 0;
    for (int n = 9; n <= N; n+=2) {
        int cnt = 2;
        for (int i = 2; i < n/2; i++) {
            if(n % i == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            result++;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int main()
{
 int a[3]; 
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+1+3);
    cout<<a[3]*10+a[1]+a[2]<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  bool ans = true;
  rep(i, n) ans &= a[i] % 2 == 0;
  cout << (ans ? "second" : "first") << endl;
  return 0;
}


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


int cal(string a){return 60*((a[0]-'0')*10+(a[1]-'0'))+((a[2]-'0')*10+(a[3]-'0'));}

int main(){
  while(1){
    int cn,s,g,t[200000]={};
    string S,G;
    cin>>cn>>S>>G;
    if(!cn&&S=="0"&&G=="0")break;
    s=cal(S),g=cal(G);
    

    for(int q=0;q<cn;q++){
      int k;
      cin>>k;
      for(int i=0;i<k;i++){
	string A,B;
	int a,b;
	cin>>A>>B;
	a=cal(A),b=cal(B);
	t[a]++;
	t[b]--;
      }
    }
    for(int i=s+1;i<=g;i++) t[i]+=t[i-1];
    int ans=0,cnt=0;
    t[g]=cn;   
    for(int i=s;i<=g;i++)
      if(t[i]<cn)cnt++;
      else ans=max(ans,cnt),cnt=0;
    cout <<max(ans,cnt)<<endl;
  }
  return 0;
}

Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int Digits(llong num){
  int cnt = 0;
  while(num > 0){
    num /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    llong N;
    cin >> N;
    llong A,B;
    int ans = Digits(N);
    for(A = 1;A*A <= N;A++){
      if(N%A !=0) continue;
      B = N / A;
      const int cur = max(Digits(A),Digits(B));
    
      if(ans > cur) ans = cur;
    }

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


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

int main(){
  int N; cin >> N;
  vector<int> A1(N),A2(N);
  for(int i = 0; i < N; i++){
    cin >> A1.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> A2.at(i);
  }
  
  int ans = 0 , local;
  for(int i = 0; i < N ;i++){
    local = 0;
    for(int k = 0; k < i + 1; k++) local += A1.at(k);
    for(int j = i; j < N; j++){
      local += A2.at(j);
    }
    ans = max(ans,local);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
const long long mod_const = 1000000007;
using MIte = multimap<vector<long>, int>::iterator;

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

	vector<int> vA(N, 0);
	for (int i = 0; i != N; ++i) {
		int in = 0;
		cin >> in;
		vA[i] = in;
	}

	// vAにおいてvA[i]より大きい数
	vector<long long> vBigger(N, 0);
	for (int i = 0; i != N; ++i) {
		long long cnt = 0;
		for (int j = 0; j != N; ++j) {
			if (i == j) continue;

			if (vA[i] < vA[j]) {
				cnt++;
			}
		}
		vBigger[i] = cnt;
	}

	// あるiに対してvA[i]<vA[j] (i>j)となるjの数
	vector<long long> vBigger_i(N, 0);
	if (N >= 2) {
		for (int i = 1; i != N; ++i) {
			long long cnt = 0;
			for (int j = 0; j != i; ++j) {
				if (vA[i] < vA[j]) {
					cnt++;
				}
			}
			vBigger_i[i] = cnt;
		}
	}

	long long ans = 0;
	for (int i = 0; i != N; ++i) {
		ans += vBigger[i];
	}
	ans = ans % mod_const;
	if (K % 2 == 0) {
		long long tmp = K / 2;
		ans *= tmp;
		ans = ans % mod_const;
		ans *= (K - 1);
		ans = ans % mod_const;
	}
	else {
		long long tmp = (K-1) / 2;
		ans *= tmp;
		ans = ans % mod_const;
		ans *= K;
		ans = ans % mod_const;
	}

	long long ans2 = 0;
	for (int i = 0; i != N; ++i) {
		ans2 += vBigger_i[i];
	}
	ans2 = ans2 % mod_const;
	ans2 *= K;
	ans2 = ans2 % mod_const;

	long long finans = (ans + ans2) % mod_const;

	cout << finans << endl;




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m, p;
int main() {
	while (cin >> n >> m >> p) {
		if (n == 0)return 0;
		int a[101];
		int sumgold = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			sumgold += a[i];
		}
		sumgold *= 100;
		double onegold = sumgold*(100-p) / 100;
		if (a[m - 1] == 0) {
			cout << 0 << endl;
		}
		else {
			cout << (int)onegold / a[m-1] << endl;
		}
	}
}

Measured memory_bytes: 3028
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  string input;
  cin >> input;
  map<char, int> map;
  for(auto i=input.begin(); i != input.end(); i++){
    map[*i] += 1;
  }
  bool b=true;
  for(auto m: map){
    b &= (m.second % 2 == 0 ? true : false);
  }
  put(b ? "Yes" : "No");
}

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int n,k;
ll cm[100005],a[100005];
int main()
{
    fast();
    n=D();k=D();
    for(int i=0;i<n;++i)a[i]=D();
    cm[0]=0;
    int c=1;
    for(int i=1; i<n; ++i)
    {
      cm[i]=1e9;
      for(int j=1;j<=k;++j){
      if(i-j>=0)
      cm[i]=min(cm[i],cm[i-j]+abs(a[i]-a[i - j]));
      }
    }
    cout<<cm[n-1]<<endl;
}


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

using namespace std;

int main ()
{

    string str,str1,str2;

    cin>>str1>>str2;

    str= str1+str2;

    stringstream s1;
    int num,i=1;

    s1<<str;
    s1>>num;

    while(num>0)
    {
        num= num - i;
        i=i+2;

    }


    if(num==0)
        printf("Yes\n");

    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1005;

int n,m,a[N][N],b[N][N];
char str[N];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for (int j=1;j<=m;j++)
			if (str[j]=='#') a[i][j]=b[i][j]=1;
	}
	for (int i=2;i<n;i++)
		if (i&1)
		{
			for (int j=2;j<m;j++) a[i][j]=1;
		}
		else
		{
			for (int j=2;j<m;j++) b[i][j]=1;
		}
	for (int i=1;i<=n;i++) a[i][1]=b[i][m]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) putchar(a[i][j]?'#':'.');
		puts("");
	}
	puts("");
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) putchar(b[i][j]?'#':'.');
		puts("");
	}
	return 0;
}

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

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

int main() {
    ll N;
    cin >> N;
    int base = 26;
    ll r=N;
    string name;
    for(;;) {
        --r;
        name.push_back((r % 26)+'a');
        r /= 26;
        if (r == 0) {
            break;
        }
    }
    reverse(name.begin(), name.end());
    cout << name << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    cin >> N >> K;
    vector<int> d(K);
    vector<int> A(N,0);
    for(int i=0;i<K;i++){
        cin >> d.at(i);
        vector<int> tmp(d.at(i));
        for(int j=0;j<d.at(i);j++){
            cin >> tmp.at(j);
            A.at(tmp.at(j)-1) += 1;
        }
    }
    
    int cnt=0;
    for(int i=0;i<N;i++){
        if(A.at(i)==0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
# 141A

#　S(天気）：標準入力
S = input()

# Sは Sunny, Cloudy, Rainy のいずれか
# Sは今日の天気であり、周期的に晴れ、くもり、雨の順に変化する

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
elif S == 'Rainy':
    print('Sunny')

Measured memory_bytes: 8888
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    string s;
    cin >> s;
    int n = s.size();
    bool ans = false;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) {
            ans = true;
        }
    }

    if (ans) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}

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

    using namespace std;

    int main()
    {
        unsigned long long int h,n;
        cin>>h;
        cin>>n;
        int a[n];
        int i;
        int sum=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];

            sum=sum+a[i];
        }

        if(sum>=h)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }



        return 0;
    }


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class Size {
		int[] A;
		int[] B;
		Size(int n) {
			A = new int[n];
			B = new int[n + 1];
		}
	}
	
	public static void main(String[] args) {
		String li = new String();
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		try {
			 li = li = bufferedReader.readLine(); 
		} catch (IOException e) {
			System.out.println("e");
		}
		int siz = Integer.parseInt(li);
		Size size = new Size(siz);
		try {
			li = bufferedReader.readLine();
			StringTokenizer stringTokenizer = new StringTokenizer(li);
			for (int i = 0; i < siz; i++) {
				size.A[i] = Integer.parseInt(stringTokenizer.nextToken());
			}
		} catch (IOException e) {
			System.out.println(e);
		}
		countingSort(size.A, size.B, 10001);
		StringBuffer stringBuffer = new StringBuffer(80000);
		for (int i = 1; i <= siz; i++) {
			stringBuffer.append(size.B[i]);
			if (i != siz) stringBuffer.append(" ");
		}
		System.out.println(stringBuffer);
	}

	static void countingSort(int[] A, int[] B, int k) {
		int C[] = new int[k];
		int aLength = A.length;
		int bLength = B.length;
		for (int i = 0; i < aLength; i++) {
			C[A[i]]++;
		}
		for (int i = 1; i < k; i++) {
			C[i] += C[i - 1];
		}
		for (int i = aLength - 1; i >= 0; i--) {
			int p = A[i];
			B[C[p]] = p;
			C[p]--;
		}
//		for (int i = 1; i < bLength; i++) {
//			if (i == bLength - 1) {
//				System.out.println(B[i]);
//			} else {
//				System.out.print(B[i] + " ");
//			}
//		}
	}

}

Measured memory_bytes: 161808
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print('AMBIGUOUS')
elif 1 <= s1 <= 12:
    print('MMYY')
elif 1 <= s2 <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 9036
num=[]

for i in 0...gets.to_i
    a=gets
    num=a.split(nil)
    num.collect!{|n| n.to_i}
    num.sort!
    if num[2]**2==(num[0]**2)+(num[1]**2)
        puts "YES"
    else puts "NO"
    end
end

Measured memory_bytes: 6112
s=input()
t=input()
n=len(s)
d={}
for i in range(n):
    ss=s[i]
    tt=t[i]
    if ss in d and (ss,tt) not in d.items():
        print("No")
        exit()
    if tt in d.values() and (ss,tt) not in d.items():
        print("No")
        exit()
    if ss not in d:
        d[ss]=tt    
print("Yes")

Measured memory_bytes: 74108
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ');
    var a = parseInt(args[0]);
    var b = parseInt(args[1]);
    var c = parseInt(args[2]);
    console.log('%s', a < b && b < c ? 'Yes' : 'No');
});

Measured memory_bytes: 7644
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int acN = 0;
    int waN = 0;
    int tleN = 0;
    int reN = 0;
    for (int cnt = 0; cnt < n; cnt++) {
      String input = sc.next();
      if (input.equals("AC")) {
        acN++;
      }
      if (input.equals("WA")) {
        waN++;
      }
      if (input.equals("TLE")) {
        tleN++;
      }
      if (input.equals("RE")) {
        reN++;
      }
    }

    System.out.println("AC x " + acN);
    System.out.println("WA x " + waN);
    System.out.println("TLE x " + tleN);
    System.out.println("RE x " + reN);
    sc.close();
  }
}


Measured memory_bytes: 59204
from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1
def bfs():
  d = [[float('inf')]*w for i in range(h)]
  dx = [1, 0, -1, 0]
  dy = [0, 1, 0, -1]
  que = deque([])
  que.append((sx, sy))
  d[sx][sy] = 0
  while que:
    p = que.popleft()
    if p[0] == gx and p[1] == gy:
      break
    for i in range(4):
      nx = p[0] + dx[i]
      ny = p[1] + dy[i]
      if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != '#' and d[nx][ny] == float('inf'):
        que.append((nx, ny))
        d[nx][ny] = d[p[0]][p[1]] + 1
  return d[gx][gy]
white = 0
for i in range(h):
  for j in range(w):
    if maze[i][j] == '.':
      white += 1
res = bfs()
if 0 < res < float('inf'):
  print(white - res - 1)
else:
  print(-1)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        for(int i=0; i<N; i++){
            S[i]=sc.next();
        }
        int AC = 0;
        int WA = 0;
        int TLE = 0;
        int RE = 0;

        for(int i=0; i<N; i++){
            if(S[i].equals("AC")){
                AC++;
                continue;
            }else if(S[i].equals("WA")){
                WA++;
                continue;
            }else if(S[i].equals("TLE")){
                TLE++;
                continue;
            }else if(S[i].equals("RE")){
                RE++;
                continue;
            }

        }

        System.out.println("AC x "+AC);
        System.out.println("WA x "+WA);
        System.out.println("TLE x "+TLE);
		System.out.println("RE x "+RE);
	}
}

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

int main() {
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  	if ((A+B) > (C+D)) {
      cout << "Left" << endl;
    }
    else if((A+B) < (C+D)) {
      cout << "Right" << endl;
    }
  	else {
      cout << "Balanced" << endl;
    }
}

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

int main() {
	int a,b;
    cin >> a >> b;
  	if(a==1){
      a=100;
    }
  	if(b==1){
      b=100;
    }
    if(a>b){
      cout << "Alice" << endl;
    }else if(a<b){
      cout << "Bob" << endl;
    }else{
      cout << "Draw" << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long val = String.valueOf(N).length() - 1;
        long ch = 0;
        for (int i = 0; i <= val; i++) {
            ch = ch + N / (long) (Math.pow(10, i)) % 10;
        }
        N = N - (long) (Math.pow(10, val));
        N = N / (long) (Math.pow(10, val));
        for (int i = 1; i <= val; i++) {
            N = N + 9;
        }
        if (ch > N) {
            System.out.println(ch);
        } else {
            System.out.println(N);
        }
    }
}


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

int main (void){

    int n;
    scanf("%d", &n);

    int fn = 0;
    int tmp = n;

    while( tmp != 0 ){
       fn += tmp % 10;
       tmp /= 10;
    }

    if(n % fn == 0)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Map<Integer,Integer>> L = new HashMap<>();
        Map<Integer,Integer> OPT = new HashMap<>();
        for(int i=0;i<n;i++){
            int v = sc.nextInt();
            int k = sc.nextInt();
            OPT.put(v,999999999);
            Map<Integer,Integer> C = new HashMap<>();
            for(int j=0;j<k;j++){
                int u = sc.nextInt();
                int c = sc.nextInt();
                C.put(u,c);
            }
            L.put(v,C);
        }
        OPT.replace(0,0);
        Dijkstra(L,OPT);
        for(int i:OPT.keySet()) System.out.println(i+" "+OPT.get(i));
    }
    public static void Dijkstra(Map<Integer,Map<Integer,Integer>> L,Map<Integer,Integer> OPT){
        Deque<Integer> Q = new ArrayDeque<>();
        Q.add(0);
        while(Q.size()!=0){
            int now = Q.poll();
            for(int i:L.get(now).keySet()){
                if(OPT.get(now)+L.get(now).get(i)<OPT.get(i)) {
                    Q.add(i);
                    OPT.replace(i,L.get(now).get(i)+OPT.get(now));
                }
            }
        }
    }
}


Measured memory_bytes: 39976
#include <iostream>

using namespace std;

int main(){
	string s; cin >> s;
	int len = s.size();
	int points = 0;
	if(s[0]=='A'){
		points++;
	}
	string sub = s.substr(2, len-3);
	int len2 = sub.size();
	int contC = 0;
	for(int i=0;i<len2;i++){
		if(sub[i]=='C'){
			contC++;
		}
	}
	int pos;
	if(contC==1){
		points++;
		for(int i=0;i<len2;i++){
			if(sub[i]=='C'){
				 pos=i;
			}
		}
	}
	
	int contUC = 0;
	for(int i=0;i<len;i++){
		if(i!=0 and i!=pos+2){
			if(s[i]<97){
				contUC++;
			}
		}
	}
	if(contUC==0){
		points++;
	}
	if(points==3){
		cout << "AC" << endl;
	}
	else{
		cout << "WA" << endl;
	}
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc074/tasks/arc083_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VVL ds(N, VL(N));
  rep(i, N) rep(j, N) cin >> ds[i][j];

  rep(i, N) rep(j, N) rep(k, N) {
    if (ds[i][k] + ds[k][j] < ds[i][j]) drop(-1);
  }

  VVL edge_mat(N, VL(N));
  rep(i, N) rep(j, N) edge_mat[i][j] = ds[i][j];

  rep(i, N) rep(j, N) rep(k, N) {
    unless(i != j && j != k && k != i) continue;

    if (ds[i][k] + ds[k][j] == ds[i][j]) {
      edge_mat[i][j] = 0;
      edge_mat[j][i] = 0;
    }
  }

  ll res = 0;
  rep(i, N) rep(j, N) { res += edge_mat[i][j]; }

  res /= 2;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1664
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let v: Vec<usize> = sc.next_vec(n+1);
    let m = 1000000007;
    let mut a = 0;
    let mut c = 0;
    let mut set: Vec<usize> = vec![n+2;n+1];
    for i in 0..n+1 {
        if set[v[i]] < i {
            a = set[v[i]];
            c = n - i;
            break;
        } else {
            set[v[i]] = i;
        }
    }
    let mut stairs: Vec<usize> = (1..n+2).scan(1, |s,x| {*s = *s * x % m; Some(*s)}).collect();
    stairs.insert(0, 1);
    for i in 1..n+2 {
        let mut ans = stairs[n+1] * inv_m(stairs[n+1-i],m) % m * inv_m(stairs[i],m) % m;
        if a + c + 1 >= i {
            ans = (ans + m - stairs[a+c] * inv_m(stairs[a+c+1-i],m) % m * inv_m(stairs[i-1],m) % m) % m
        }
        println!("{}",ans);
    }
}

fn inv_m(n: usize, m: usize) -> usize {
    pow_m(n,m-2,m)
}

fn pow_m(n: usize, mut p: usize, m: usize) -> usize {
    let mut ret = 1;
    let mut r = n;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % m;
            p /= 2;
        } else {
            ret = ret * r % m;
            p -= 1;
        }
    }
    ret
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 9340
n, m = gets.split(" ").map &:to_i
nn = Array.new(n, 1)
h = gets.split(" ").map &:to_i
m.times{
  a, b = gets.split(" ").map &:to_i
  if h[a-1] < h[b-1]
    nn[a-1] = 0
  elsif
    h[a-1] == h[b-1]
    nn[a-1] = 0
    nn[b-1] = 0
  else
    nn[b-1] = 0
  end
#  p nn
}
puts nn.sum

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


int func( int n ){
  if( n%2 != 0 ) return 0;
  return 1+func(n/2);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n);

  for(int i=0;i<n;i++) cin >> a.at(i);
  for(int i=0;i<n;i++){
    b.at(i) = func( a.at(i) );
  }
  
  sort( b.begin(),b.end() );
  cout << b.at(0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int N;
long long X, L;
pair<long long, long long> I[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X >> L;
		I[i].first = X + L;
		I[i].second = X - L;
	}

	sort(I, I + N);

	for (int i = 0; i < N; i++) {
		long long sw = I[i].first;
		I[i].first = I[i].second;
		I[i].second = sw;
	}
	
	int ans = 0;
	long long right_edge = -2000000000;
	for (int i = 0; i < N; i++) {
		if (I[i].first >= right_edge) {
			ans++;
			right_edge = I[i].second;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
string st="CODEFESTIVAL2016";
string s;
int main(){
	cin>>s;
	int cnt=0;
	for(i,0,15) if(s[i]!=st[i]) cnt++;
	print(cnt),puts("");
	exit(0);
}

Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    F = [il() for _ in range(N)]
    P = [il() for _ in range(N)]

    ret = -MAX
    for b in range(1, 1 << 10):
        tmp = 0
        for n in range(N):
            o = 0
            for t in range(10):
                if b >> t & 1 and F[n][t] == 1:
                    o += 1
            tmp += P[n][o]
        ret = max(ret, tmp)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3932
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for i in range(n)]
cd=[[int(i) for i in input().split()] for i in range(m)]
count=[0]*n
distance=[[] for i in range(n)]
for i in range(n):
    for l in range(m):
        distance[i].append(abs(ab[i][0]-cd[l][0])+abs(ab[i][1]-cd[l][1]))
for i in range(n):
    print(distance[i].index(min(distance[i]))+1)

Measured memory_bytes: 3064
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		String s = scanString();
		int n = s.length();
		int dyn[][] = new int[2][n + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= 2; j++) {
				if (i == j) {
					dyn[j - 1][i] = 1;
					continue;
				}
				for (int k = 1; k <= 2; k++) {
					if (j + k > i) {
						continue;
					}
					if (s.substring(i - j, i).equals(s.subSequence(i - j - k, i - j))) {
						continue;
					}
					dyn[j - 1][i] = max(dyn[j - 1][i], dyn[k - 1][i - j] + 1);
				}
			}
		}
		out.print(max(dyn[0][n], dyn[1][n]));
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 62644
N = input()
m = len(N)

a0 = int(N[0])
a1 = int(N[-1])

ans = 0
if m == 1:
  ans = int(N)
else:
  mid = (int(N[1:]) - a1)//10
  t = 10**(m-2)
  ans = 9
  ans += ((a0-1)*t) * 2
  ans += (mid + (a1>=a0)) * 2
  ans += ((a0-1)*t)**2
  ans += ((mid*(a0-1) + min(a0-1, a1))*t) * 2
  ans += (mid + (a1>=a0))**2
  if m >= 3:
    ans += (t - 1) * 2
    ans += ((a0-1)*(t - 1)*t) * 2
    ans += (mid * (t - 1)) * 2
    ans += (a1 * (t - 1)//9) * 2
    ans += (t - 1)**2

print(ans)

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

using namespace std;
int n , ans = 0;
double d;
int main(){
    cin >> n >> d;
    for (int i = 1; i <= n; i++){
        double x , y;
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= d) ans++;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int n;
int a[100000];
int dp[100000];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

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

func main() {
	sc = initScanner(os.Stdin)
	N := scanInt(sc)
	P := scanIntSlice(sc, N)
	Q := scanIntSlice(sc, N)

	ns := make([]int, N)
	for i := 0; i < N; i++ {
		ns[i] = i + 1
	}

	var a, b int
	index := 1
	next := true
	for {
		if equalSlice(ns, P) {
			a = index
		}
		if equalSlice(ns, Q) {
			b = index
		}

		ns, next = nextPermutation(ns)
		index++

		if !next {
			break
		}
	}

	fmt.Println(intAbc(a - b))
}

// 与えられた数列を辞書順に次の数列に変換して返す
// {1, 2, 3, 4, 5} -> {1, 2, 3, 5, 4}
func nextPermutation(ns []int) ([]int, bool) {
	k := -1
	for i := len(ns) - 2; i >= 0; i-- {
		if ns[i] < ns[i+1] {
			k = i
			break
		}
	}

	if k == -1 {
		return ns, false
	}

	l := k + 1

	for i := len(ns) - 1; i >= l; i-- {
		if ns[k] < ns[i] {
			l = i
			break
		} else {
			l = -1
		}
	}

	if l == -1 {
		return ns, false
	}

	ns[k], ns[l] = ns[l], ns[k]

	ns = append(ns[:k+1], reverse(ns[k+1:])...)
	return ns, true
}

func reverse(ns []int) []int {
	rns := make([]int, len(ns))
	for i, v := range ns {
		rns[len(rns)-i-1] = v
	}
	return rns
}

func equalSlice(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}

	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}

	return true
}

func intAbc(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}


Measured memory_bytes: 2384
#include<stdio.h>
int isPrime(int);
int main(){
  int n,x,i;
  int cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isPrime(x))cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}
isPrime(int x){
  int i;
  if(x<2)return 0;
  else if(x==2)return 1;
  if(x%2==0)return 0;
  for(i=3;i*i<=x;i+=2){
    if(x%i == 0)return 0;
  }
  return 1;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int W;
	cin >> W;
	int Z = S.size();
	rep(i, Z) {
		if (i % W == 0) {
			cout << S[i];
		}
	}
	cout << endl;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  int l = S.length();
  int ans = l;
  REP(i, l - 1) {
    if (S.at(i) == S.at(i + 1)) {
      --ans;
      i += 2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;

signed main(){
  int n;
  cin>>n;
  vint a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  int sum=accumulate(all(a),0);
  if(sum%10!=0){cout<<sum<<endl;return 0;}
  rep(i,n){
    int res=sum-a[i];
    if(res%10!=0){
      cout<<res<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
 
  return 0;
}



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

int n;
string str;
map<int,int>mp;

int query(int x) {
	if(mp.find(x)!=mp.end()) return mp[x];
	cout<<x<<endl;
	fflush(stdout);
	cin>>str;
	if(str=="Vacant") exit(0);
	return mp[x]=(str=="Male");
}

int main(void) {
	cin>>n;
	int l=0,r=n-1;
	while(r-l>=2) {
		int mid=(l+r)>>1;
		if(query(mid)^(mid%2)!=(query(l)^(l%2))) r=mid;
		else l=mid;
	}
	for(int i=l; i<=r; i++) query(i);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,a,b;

int main(){
	cin >> a >> b >> n;
	vector<ll> s(a+2,INF),t(b+2,INF);
	s[0] = 0;
	t[0] = 0;
	rep(i,a)cin >> s[i+1];
	rep(i,b)cin >> t[i+1];
	// cout << "!!";
	// rep(i,a+2)cout << s[i] << " ";
	// cout << endl;
	// cout << "!!";
	// rep(i,b+2)cout << t[i] << " ";
	// cout << endl;
	rep(i,n){
		ll x;
		cin >> x;
		ll sv[] = {*(upper_bound(ALL(s),x)-1),*upper_bound(ALL(s),x)};
		ll tv[] = {*(upper_bound(ALL(t),x)-1),*upper_bound(ALL(t),x)};
		ll ans = INF;
		// rep(j,2)cout << sv[j] << " ";
		// cout << endl;
		// rep(j,2)cout << tv[j] << " ";
		// cout << endl;
		rep(j,2){
			rep(k,2){
				if(sv[j] == 0 || sv[j] == INF)continue;
				if(tv[k] == 0 || tv[k] == INF)continue;
				ans = min(ans,abs(sv[j]-tv[k])+min(abs(sv[j]-x),abs(tv[k]-x)));
				// cout <<"!"<< sv[j] << " " << tv[j] << ans << endl;
			}
		}
		cout << ans << endl;
		// cout << *sit << " " << *snx << " " << *tit << " " << *tnx << endl;
		// cout << "!" << p << " " << q << " " << r << " " << s << endl;
	}
}

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

long A = 1000000007;

long power(long m,long n){
	if(n == 1) return m;
	if(n%2 != 0) return ((power(m%A*m%A,n/2))%A*m%A);
	return ((power(m%A*m%A,n/2))%A);
}
	
int main() {
	long m,n;
	cin >> m >> n;
	cout << power(m,n) << endl; 
	return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m;
long long ans;
int main(void){
	register int i;
	n=read(),m=read();
	if(n>2&&m>2){
		printf("%lld\n",1ll*(n-2)*(m-2));
		return 0;
	}
	if(m==1||n==1){
		if(m==1&&n==1)printf("%d\n",1);
		else if(m==1)printf("%d\n",n-2);
		else if(n==1)printf("%d\n",m-2);
		return 0;
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    int n;
    cin >> n;
    v2<int> adj(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            char c; cin >> c;
            if(c-'0'){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }

    int diam = 0;
    for(int i = 0; i < n; i++){
        queue<int> q;
        q.push(i);
        vector<bool> v(n, false);
        v[i] = true;
        vector<int> d(n, -1);
        d[i] = 0;
        vector<int> c(n, -1);
        c[i] = 0;
        while(!q.empty()){
            int top = q.front();
            q.pop();
            for(int next : adj[top]){
                if(!v[next]){
                    v[next] = true;
                    d[next] = 1+d[top];
                    c[next] = !c[top];
                    q.push(next);
                }
                else{
                    if(c[top] == c[next] && top != next){
                        cout << "-1\n";
                        return;
                    }
                }
            }
        }
        for(int i = 0; i < n; i++) diam = max(diam, d[i]);
    }

    cout << diam+1 << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[10000];
int main()
{	int n,k; cin>>n>>k;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(rint i=1;i<=n;i++)
	if(a[i]>k) return !printf("%d\n",i-1);
	else k-=a[i];
	cout<<n-(k>0);
	return 0;
}


Measured memory_bytes: 256