akhauriyash/Code-Regression huggingface dataset:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
#print(A,B,C,X)

count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      total= 500*a + 100*b + 50*c
      if total == X:
        count += 1
    

print(count)

Measured memory_bytes: 67416
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int x = n * 800;
		int y = (n / 15) * 200;

		int ans = x - y;

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a == b && b!=c || a == c && b!=c || b == c && c!=a){
        g("Yes");
        return;
    }
    g("No");
    return;
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
  //  cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

  lli a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e - a <= k){
    COUT("Yay!");
  }else{
    COUT(":(");
  }
  
  
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, Q, A[100003], K;

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

  cin >> N >> K >> Q;
  int a;
  rep(i, Q){
    cin >> a;
    a--;
    A[a]+=1;
  }

  rep(i, N){
    if (K-(Q-A[i])<=0) cout << "No" << "\n";
    else cout << "Yes" << "\n";
  }

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

//nもrも10^5くらいのときにはこれ使うと良き
//二項係数の計算
const int MAX = 510000;
ll fac[MAX],finv[MAX],inv[MAX];

//テーブルの初期化
void COMinit(){
	fac[0] = fac[1] = 1;//階乗
	finv[0] = finv[1] = 1;//階乗の逆元
	inv[1] = 1;//逆元(1の逆元は1)
	for(int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;//累積積的な感じ
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;//inv[i] = iの逆元(mod mod)
		finv[i] = finv[i - 1] * inv[i] % mod;//階乗の逆元の計算
	}
}



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


int main(){
	int n,K;cin>>n>>K;
	COMinit();

	if (K > COM(n - 1,2)) cout << -1 << endl;
	else{
		vector<vector<bool>> g(n + 1,vector<bool> (n + 1,false));
		int m = 0;
		for(int i = 2; i <= n; i++) {
			g[1][i] = true;
			m++;
		}
		for(int i = 2; i <= n; i++) {
			for(int j = i + 1; j <= n; j++) {
				g[i][j] = true;
				m++;
			}
		}
		for(int i = 0; i < K; i++) {
			bool flag = true;
			for(int j = 2; j <= n; j++) {
				for(int k = j + 1; k <= n; k++) {
					if (g[j][k] && flag){
						g[j][k] = false;
						flag = false;
						m--;
					}
				}
			}
		}
		cout << m << endl;
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				if (g[i][j])cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int h, w, c, AnswerH[1000], AnswerW[1000];

	c = 0;

	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0) { break; }

		for (int s = 0; s < 20000; s++)
		{
			for (int i = 1; i <= 142; i++)
			{
				if (s == 0 && i == 1) { i = h + 1; }

				for (int j = 1; j <= 142; j++)
				{
					if (i * i + j * j == h * h + w * w + s && i < j)
					{
						AnswerH[c] = i;
						AnswerW[c] = j;

						goto Exit;
					}
				}
			}
		}

	Exit:;

		c++;
	}

	for (int i = 0; i < c; i++)
	{
		cout << AnswerH[i] << ' ' << AnswerW[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def depth(adj, node, parent=None):
    ret = 0
    for child in adj[node]:
        if child == parent:
            continue
        d = depth(adj, child, node) + 1
        ret = max(ret, d)
    return ret


def main():
    N, U, V = list(map(int, input().split(' ')))
    U -= 1
    V -= 1
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj[A].append(B)
        adj[B].append(A)

    path = [-1] * N

    def find_path_on_tree(to_node, node, parent=None, d=0):
        if node == to_node:
            path[d] = node
            return True
        for child in adj[node]:
            if child == parent:
                continue
            if not find_path_on_tree(to_node, child, node, d + 1):
                continue
            path[d] = node
            return True
        return False

    find_path_on_tree(U, V)  # to U from V
    path = [node for node in path if node != -1]
    dist = len(path) - 1
    partial_depth = depth(adj, path[(dist // 2) + 1], path[dist // 2])
    print(partial_depth + (dist // 2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 123584
import java.util.Scanner;

//B	Touitsu
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.nextLine());
		String A = sc.nextLine();
		String B = sc.nextLine();
		String C = sc.nextLine();

		int ans = 0;
		for (int i = 0; i < N; i++) {
			char cA = A.charAt(i);
			char cB = B.charAt(i);
			char cC = C.charAt(i);
			if (cA == cB && cA != cC && cB != cC) {
				ans++;
			}
			if (cA != cB && cA == cC && cB != cC) {
				ans++;
			}
			if (cA != cB && cA != cC && cB == cC) {
				ans++;
			}
			if (cA != cB && cA != cC && cB != cC) {
				ans++;
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    ll n;
    cin >> n;
    ll num = 1;
    int b = 0;
    vector<char> a(0);
    ll c = 0;
    while (c < n) {
        num *= 26;
        c += num;
        b++;
    }
    if (num >= 26) num /= 26;
    rep(i, b) {
        a.push_back('a' + ((n - 1) % 26));
        n -= ((n - 1) % 26);
        n /= 26;
        num /= 26;
    }
    reverse(a.begin(), a.end());
        rep(i, a.size()) {
        cout << a.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,x; cin>>n>>x;
	int t;
	cin>>t;
	int ans=max(0ll,t-x);
	t=min(t,x);
	int l=t;
	For(i,1,n-1){
		cin>>t;
		ans+=max(0ll,l+t-x);
		t=min(t,x-l);
		l=t;
	}
	cout<<ans<<'\n';
	return 0;
}





























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

int compare_int(const void *a, const void *b){
    if (*(long long int*)b>*(long long int*)a){return 1;}
    if (*(long long int*)b<*(long long int*)a){return -1;}
    return 0;
}

int min_int(int A,int B){if (A<B){return A;}return B;}

int main(int argc, char const *argv[]){
    int i,j,t,X,Y,Z,K;
    scanf("%d%d%d%d",&X,&Y,&Z,&K);
    long long int A[X],B[Y],C[Z],AB[X*Y];
    for ( i = 0; i < X; i++){scanf("%lld",&A[i]);}
    for ( i = 0; i < Y; i++){scanf("%lld",&B[i]);}
    for ( i = 0; i < Z; i++){scanf("%lld",&C[i]);}

    t=0;
    for ( i = 0; i < X; i++){
        for ( j = 0; j < Y; j++){
            AB[t]=A[i]+B[j];
            t++;
        }
    }

    qsort(AB,X*Y,sizeof(long long int),compare_int);
    qsort(C,Z,sizeof(long long int),compare_int);

    int K1=min_int(K,X*Y);
    int K2=min_int(K,Z);
    long long int ans[K1*K2];

    t=0;
    for ( i = 0; i < K1; i++){
        for ( j = 0; j < K2; j++){
            ans[t]=AB[i]+C[j];
            t++;
        }
    }
    // qsort(A,X,sizeof(long long int),compare_int);
    // for ( i = 0; i < X; i++){printf("%lld\n",A[i]);}
    // printf("\n");
    // for ( i = 0; i < Z; i++){printf("%lld\n",C[i]);}
    // printf("\n");
    // for ( i = 0; i < K; i++){printf("%lld\n",ans[i]);}
    // printf("\n");
    qsort(ans,K1*K2,sizeof(long long int),compare_int);
    for ( i = 0; i < K; i++){printf("%lld\n",ans[i]);}

    return 0;
}


Measured memory_bytes: 54920
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"

const int  MOD=1000000007 ;

void solve() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sz=s.size();

    for(int i=0;i<sz;i=i+1){
        char c;
        c=s[i];
        c=c+n;
        if(c>'Z'){
            c=c-'Z'+'A'-1;   //Princy Shekhaliya
        }
        s[i]=c;
    }
    cout<<s<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

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

void ti(){
  #ifndef ONLINE_JUDGE
    freopen("in.txt", "r+", stdin);
    freopen("out.txt", "w", stdout);
  #endif
}

int main(){

  // ti();
  string s; cin>>s;
  string t; cin>>t;

  int diff = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] != t[i]){
      diff++;
    }
  }

  cout<<diff<<endl;
  return 0;
}


Measured memory_bytes: 3912
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.lang.Math;
import java.util.HashMap;
public class Main {
	public static int useBs(int[] arr, int targetValue) {	
		int a =  Arrays.binarySearch(arr, targetValue);
		if(a >=0 && a<arr.length)
			return a;
		else
			return -1;
	}
	public static void printArray(int []a) {
		for(int i=0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
		System.out.println();
	}
	public static void printArrayLong(long []a) {
		for(int i=0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
		System.out.println();
	}
	static boolean isPalindrome(String s) {
		int l=s.length();
		for(int i=0;i<l/2;i++)
		{
			if(s.charAt(i)!=s.charAt(l-i-1))
				return false;
		}
		return true;
	}
	static String revString(String str)
	{
		return new StringBuffer(str).reverse().toString();
	}
	static String sortString(String s) {
		char a[]=s.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
	static int sumList(List<Integer>a) {
		return a.stream().mapToInt(Integer::intValue).sum();
	}
	static int sumArray(int []a) {
		int sum=0;
		for(int i=0;i<a.length;i++) {
			sum+=a[i];
		}
		return sum;
	}
    public static void main(String[]args) throws java.lang.Exception{
    	Scanner sc=new Scanner(System.in);
//    	int t=1;
//    	while(t-->0) {
//    		int a[]=new int[5],ans=0;
//    		for(int i=0;i<4;i++) {
//    			a[i]=sc.nextInt();
//    			if(a[i]==0)ans=i+1;
//    		}
//    		System.out.println(ans);
//    	}
    	int x=sc.nextInt();
    	boolean ans=true;
    	int y=sc.nextInt();
    	for(int i=x*2;i<=x*4;i+=2) {
    		if(i==y) {
    			ans=true;
    			break;
    		}else ans=false;
    	}
    	if(ans)System.out.println("Yes");
    	else System.out.println("No");
    }
}


Measured memory_bytes: 27116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll MOD = 998244353, INF = 1e9 * 1e9 + 10, eps = 1e-7;

ll dp[3003][3003];

int main()
{
    fastInp;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    dp[a][b] = 1;
    for (int j = a; j <= c; j++) {
        for (int k = b; k <= d; k++) {
            if (j == a && k == b) continue;

            if (j == a) {
                dp[j][k] = dp[j][k - 1] * j;
                dp[j][k] %= MOD;
                continue;
            }

            if (k == b) {
                dp[j][k] = dp[j - 1][k] * k;
                dp[j][k] %= MOD;
                continue;
            }

            dp[j][k] = (dp[j - 1][k] * k) % MOD + (dp[j][k - 1] * j) % MOD - (dp[j - 1][k - 1] * (j - 1) * (k - 1)) % MOD;
            dp[j][k] = (dp[j][k] + MOD * 10) % MOD;
        }
    }
    
    cout << dp[c][d];
    return 0;
}

Measured memory_bytes: 74024
#include <iostream>
using namespace std; 
int main() {  
  int n, sum=100000; 
  cin >> n;  
  for(int i=0; i<n; i++) {
    sum += sum*5/100;   
    if(sum%1000!=0) {     
      sum /= 1000;   
      sum *= 1000; 
      sum += 1000;  
    } 
  }  
  cout << sum << endl;  
  return 0;
}


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

typedef long long LL;
const int N = 200005, mod = 1000000007;

int f[N], n, m, pow2[N], head[N], tot;
struct _edge { int l, r, w; } E[N];
struct edge { int to, nxt, cost; } e[N << 1];

void up(int &x, int y) { x = std::max(x, y); }
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
LL X;
void link(int x, int y, int cost) {
	e[++tot] = (edge) { y, head[x], cost }, head[x] = tot;
	e[++tot] = (edge) { x, head[y], cost }, head[y] = tot;
}
int fa[N][17], max[N][17], dep[N];
void dfs(int x) {
	for (int i = 1; i < 17; ++i) {
		fa[x][i] = fa[fa[x][i - 1]][i - 1];
		up(max[x][i] = max[x][i - 1], max[fa[x][i - 1]][i - 1]);
	}
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != fa[x][0]) {
			fa[e[i].to][0] = x, max[e[i].to][0] = e[i].cost;
			dep[e[i].to] = dep[x] + 1, dfs(e[i].to);
		}
}
int path_max(int x, int y) {
	int m = 0;
	if (dep[x] < dep[y]) std::swap(x, y);
	for (int i = dep[x] - dep[y]; i; i &= i - 1)
		up(m, max[x][__builtin_ctz(i)]), x = fa[x][__builtin_ctz(i)];
	for (int i = 16; ~i; --i)
		if (fa[x][i] != fa[y][i])
			up(m, max[x][i]), up(m, max[y][i]), x = fa[x][i], y = fa[y][i];
	if (x != y) up(m, max[x][0]), up(m, max[y][0]);
	return m;
}
char rbuf[(int) 2e7], *in = rbuf;
template <class T>
void read(T &x) {
	char ch;
	while (std::isspace(ch = *in++)); x = ch & 15;
	while (std::isdigit(ch = *in++)) x = x * 10 + (ch & 15);
}
void solve() {
	read(n), read(m), read(X), tot = 0;
	for (int i = 1; i <= n; ++i) f[i] = i, head[i] = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j < 17; ++j) fa[i][j] = max[i][j] = 0;
	for (int i = 1; i <= m; ++i) read(E[i].l), read(E[i].r), read(E[i].w);
	std::sort(E + 1, E + m + 1, [] (_edge a, _edge b) { return a.w < b.w; });
	LL min_span = 0;
	for (int i = 1; i <= m; ++i) {
		int rx = find(E[i].l), ry = find(E[i].r);
		if (rx != ry)
			f[rx] = ry, min_span += E[i].w, link(E[i].l, E[i].r, E[i].w);
	}
	dfs(1);
	int geq = 0, gt = 0;
	for (int i = 1; i <= m; ++i) {
		LL q = min_span + E[i].w - path_max(E[i].l, E[i].r);
		gt += q > X, geq += q >= X;
	}
	if (X < min_span)
		std::cout << 0 << '\n';
	else if (X == min_span)
		std::cout << (pow2[m] - pow2[gt + 1] + mod) % mod << '\n';
	else
		std::cout << (pow2[geq + 1] - pow2[gt + 1] + mod) % mod << '\n';
}
int main() {
	std::fread(rbuf, 1, 2e7, stdin);
	pow2[0] = 1; for (int i = 1; i <= 200001; ++i) pow2[i] = 2LL * pow2[i - 1] % mod;
	int tc = 1; while (tc--) solve();
	return 0;
}

Measured memory_bytes: 10752
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
*/
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
const ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff ;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// GLOBAL VARIABLES ////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

/////////////////// FUNCTIONS ////////////////////////////////////
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
bool ispow2(ll x){ return x && (!(x&(x-1)));}
ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
  random_device rd; mt19937 genr(rd());

#ifdef DEBUG
  auto tStart = chrono::system_clock::now();
  //freopen("op.txt","w",stdout);
#endif

  string s,ans; cin>>s;
  int n; cin>>n;
  for(int i=0;i<s.size();i+=n) ans+=s[i];
  cout<<ans<<'\n';

#ifdef DEBUG
  auto diff=chrono::system_clock::now()-tStart;
	cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
  return 0;
}


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

int main(void){
    int N;
    cin >> N;
    int d[N];
    
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    sort(d, d + N);    
    cout << d[N/2] - d[N/2 - 1] << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

#define n 37

struct Card{
  char suit;
  char value;
};

void BubbleSort(struct Card C[],int N)
{
  int i,j;
  struct Card t;
  
  for(i = 0;i <= N-1;i++){
    for(j = N-1;j >= i+1;j--){
      if(C[j].value < C[j-1].value){
	t = C[j];
	C[j] = C[j-1];
	C[j-1] = t;
      }
    }
  }
}

void SelectionSort(struct Card C[],int N){
  int i,j,minj;
  struct Card t;
  
  for(i = 0;i <= N-1;i++){
    minj = i;
    for(j = i ;j <= N-1;j++){
      if (C[j].value < C[minj].value){
	minj = j;
      }
    }
      t = C[i];
      C[i] = C[minj];
      C[minj] = t;
  }
}



int isStable(struct Card in[],struct Card out[],int N)
{
  int i;
  for(i=0;i<N;i++){
    if(in[i].suit != out[i].suit){
      //printf("%c %c    %c %c",in[i].suit,in[i].value,out[i].suit,out[i].value);
      return 0;
    }
  }
  return 1;
}




int main(){
  struct Card C1[n],C2[n];
  int N,i;
  char ch;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c %c",&C1[i].suit,&C1[i].value);
  }
  for(i=0;i<N;i++){
    C2[i] = C1[i];
  }
  /*i=0;
  while(i<N){
    if(i){
      printf(" ");
    }
    printf("%c%c",C1[i].suit,C1[i].value);
    i++;
  }
  printf("\n");*/
  
  
  BubbleSort(C1,N);
  SelectionSort(C2,N);

  i=0;
  while(i<N){
    if(i){
      printf(" ");
    }
    printf("%c%c",C1[i].suit,C1[i].value);
    i++;
  }
  printf("\n");
  
  printf("Stable\n");

  i=0;
  while(i<N){
    if(i){
      printf(" ");
    }
    printf("%c%c",C2[i].suit,C2[i].value);
    i++;
  }
  printf("\n");

  if(isStable(C1,C2,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  return 0;

}



Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int k, n;
    cin >> k >> n;

    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a[n] = k + a[0];

    int r = 0;
    for (int i = 0; i < n; i++) {
        r = max(r, a[i + 1] - a[i]);
    }

    cout << k - r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
    ll N,Z,W;
    ll a[2000];
    cin >> N >> Z >> W;
    for(int i=0;i<N;i++) cin >> a[i];
    if(N == 1){
        cout << abs(W-a[N-1]) << endl;
        return 0;
    }
    cout << max(abs(a[N-1]-a[N-2]),abs(W-a[N-1])) << endl;;
    return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    string week[7];
    week[0] = "SUN";
    week[1] = "MON";
    week[2] = "TUE";
    week[3] = "WED";
    week[4] = "THU";
    week[5] = "FRI";
    week[6] = "SAT";
    for(int i= 0; i < 7; i++){
        if(S == week[i]){
            cout << 7-i << endl;
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
struct DSU
{
    int parts;
    vector<int> rt, sz;

    DSU(int n)
    {
        rt.resize(n + 1);
        sz.resize(n + 1, 1);
        iota(rt.begin(), rt.end(), 0);
        parts = n;
    }

    int root(int k)
    {
        while (k != rt[k])
            k = rt[k] = rt[rt[k]];
        return k;
    }

    void U(int u, int v)
    {
        int r1 = root(u), r2 = root(v);
        if (r1 == r2)
            return;
        parts--;
        if (sz[r1] > sz[r2])
            swap(r1, r2);
        sz[r2] += sz[r1];
        sz[r1] = 0;
        rt[r1] = rt[r2];
    }
};
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    DSU d(n);
    while (m--)
    {
        ll u, v;
        cin >> u >> v;
        d.U(u, v);
    }
    cout << d.parts - 1;
}

Measured memory_bytes: 4000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi P(N);
	REP(i, N) {
		cin >> P[i];
	}
	int sum = 0;
	int maxv = 0;
	REP(i, N) {
		maxv = max(maxv, P[i]);
		sum += P[i];
	}
	cout << sum - maxv / 2 << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import Control.Applicative
import Data.Char

toInt :: String -> Integer
toInt str = 
    let skipSpace :: String -> String
        skipSpace "" = ""
        skipSpace (' ':xs) = skipSpace xs
        skipSpace x = x
        toDigit :: String -> Integer
        toDigit "" = 0 :: Integer
        toDigit (x:xs) 
            | isDigit x = (fromIntegral $ digitToInt x) + (toDigit xs) * 10 :: Integer
        in toDigit $ skipSpace $ reverse $ skipSpace str



main = do
    a <- mod <$> (toInt <$> getLine) <*> return 500 
    b <- toInt <$> getLine
    putStrLn $ if (a <= b) then "Yes" else "No"


Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25

using namespace std;


int gcd(int a, int b)
{
	return ( b > 0 )? gcd(b, a%b) : a ;
}

int lcm(int a, int b)
{
	return ( a / gcd(a, b) * b);
}

int a, b;

int main()
{
	while( cin >> a >> b, !cin.eof())
	{
		cout << gcd(a,b) <<" "<< lcm(a,b) << endl;
	}

	return 0;
}

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

int main() {
    int a,b,k; cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0) {
            cout << "OK" << endl;
            exit(0);
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,m,ans=0;
  cin>>n>>m;
  vector<pair<long long int,long long int>> v;
  rep(i,n){
    long long int a,b;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());
  
  rep(i,n){
    if(v[i].second<m){
      ans+=v[i].first*v[i].second;
      m-=v[i].second;
    }else{
      ans+=v[i].first*m;
      break;
    }
  }
  cout<<ans<<endl;
}
///////////////////////////



Measured memory_bytes: 2420
#include<stdio.h>

int main()
{
  char  x1[100], x2[100];
  int  n, i, prev;
  long int  cnt=0; 

  scanf("%d %s %s", &n, x1, x2);

  if(x1[0] == x2[0]){
    cnt = 3;
    i = 1;
    prev=1;
  }else{
    cnt = 6;
    i = 2;
    prev=2;
  }
  while( i < n){
    if(x1[i] == x2[i]){
       if(prev == 1){
         cnt = cnt * 2 % 1000000007; 
       }else{
         cnt = cnt * 1 % 1000000007; 
       }
        i++;
       prev=1;
    }else
    if(x1[i]==x1[i+1] && x2[i]==x2[i+1]){
      if(prev == 1){
         cnt = cnt * 2 % 1000000007;
       }else{
       cnt = cnt * 3 % 1000000007; 
       }
       i += 2;
       prev=2;
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val (N,M,X,Y) = readIntList()
    val x = Math.max(readIntList().max()!!,X)
    val y = Math.min(readIntList().min()!!,Y)

    println(if (x < y) "No War" else "War")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toInt)


Measured memory_bytes: 37952
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(mut d: Vec<u64>, mut t: Vec<u64>) -> bool {
    d.sort();
    t.sort();
    let (d, t) = (d, t);
    let (mut i, mut j) = (0, 0);
    loop {
        if j >= t.len() {
            return true;
        } else if i >= d.len() {
            return false;
        }
        if d[i] == t[j] {
            i += 1;
            j += 1;
        } else {
            i += 1;
        }
    }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let n = sc.next();
    let d = sc.vec(n);
    let m = sc.next();
    let t = sc.vec(m);
    print_yesno(solve(d, t), "YES", "NO");
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 10492
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

queue <int> qs[300];
bool used[300];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < M; j++){
        int A;
        cin >> A;
        qs[i].push(A);
      }
    }

    int ans = INT_MAX;
    for(int j = 0; j < M; j++){
      map <int, int> front_count;
      for(int i = 0; i < N; i++){
        auto tmp = qs[i].front();
        while(used[tmp - 1] && !qs[i].empty()){
          qs[i].pop();
          tmp = qs[i].front();
        }
        if(qs[i].empty()){
          break;
        }

        if(front_count.find(tmp) != front_count.end()){
          front_count[tmp] ++;
        } else {
          front_count[tmp] = 1;
        }
      }

      if(qs[0].empty()){
        break;
      }

      int max_count = 0;
      int max_count_sport = -1;
      for(auto it = front_count.begin(); it != front_count.end(); it++){
        if(max_count < it->second){
          max_count = it->second;
          max_count_sport = it->first;
        }
      }
      ans = min(ans, max_count);
      used[max_count_sport - 1] = true;
      front_count.erase(max_count_sport);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.HashSet

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = HashSet<String>(n shl 1)
    repeat(n) {
        val a = readLine()!!
        if (a in aa) {
            aa.remove(a)
        } else {
            aa.add(a)
        }
    }
    println(aa.size)
}


Measured memory_bytes: 39156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();

            for (String s : input) {
                numbers.add(Integer.parseInt(s));
            }

            String result = "Yes";
            if (numbers.get(1) > 500 * numbers.get(0)) {
                result = "No";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val hs = List.fill(n)(sc.nextLong)

  val max = execute(hs.head, hs.tail, 0, 0)
  println(max)

  @scala.annotation.tailrec
  def execute(target: Long, remains: List[Long], accum: Int, max: Int): Long =
    remains match {
      case Nil => max
      case _ if target >= remains.head => execute(remains.head, remains.tail, accum + 1, Math.max(accum + 1, max))
      case _ => execute(remains.head, remains.tail, 0, max)
    }
}


Measured memory_bytes: 54532
import itertools
import copy

n, m = map(int, input().split())
List = [list(map(int, input().split())) for i in range(m)]
check = [0 for _ in range(n)]
res = 0

def all_1(res_list):
    leng = len(res_list)
    for i in range(leng):
        if res_list[i] == 0:
            return False
    return True

def coo(i, check):
    global res
    b = copy.deepcopy(check)
    if b[i-1] == 0:
        b[i-1] = 1
        if all_1(b):
            res += 1
        length = len(List)
        for j in range(length):
            if List[j][0] == i:
                coo(List[j][1], b)
        for j in range(length):
            if List[j][1] == i:
                coo(List[j][0], b)
        
        
coo(1, check)
print(res)

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define rrepeat(i, k, j) for(int i=(j) - 1; i >= (int)(k); i--)
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }

const int INF = 1 << 30;
const int MAX_W = 401;

int main() {
    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    vector<int> a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];
    
    vector<vector<int>> DP(MAX_W, vector<int>(MAX_W, INF));
    int ans = INF;
    DP[0][0] = 0;
    rep(n, N) {
        rrepeat(ma, a[n], MAX_W) {
            rrepeat(mb, b[n], MAX_W) {
                set_min(DP[ma][mb], DP[ma - a[n]][mb - b[n]] + c[n]);
                if(ma * Mb == mb * Ma) set_min(ans, DP[ma][mb]);
            }
        }
    }    
    cout << (ans < INF ? ans : -1) << endl;
    return 0;
}


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

typedef long long ll;

ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int mx = 0, last = -1, idx = 0;
    int i = 0, j = 1, cnt;
    while(j < n){
        cnt = 0;
        idx = j;
        bool flag = 0;
        while( j < n && arr[j] <= arr[j-1]){
            cnt++;
            j++;
            flag = true;
        }
        if(flag)mx = max(mx, j - idx);
        if( j == idx) j++;
    }
    cout << mx << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
const ll mod = 1000000007;
int main(){
    ll n,i,j,x,ans=0LL,divider=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a.at(i);
    rep(i,60){
        x=0LL;
        rep(j,n){
            if(((a.at(j)%(2*divider)/divider)==1))x++;
        }
        divider*=2LL;
        x*=(n-x);
        rep(j,i)x=(x*2)%mod;
        ans+=x;
        ans%=mod;
    }
    cout << (ans%mod) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef vector < vector <int> > matrix;

int n, d, dp[10007][107][2];
string s;
const int mod = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a >= mod) a -= mod;
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	cin >> d;
	n = (int)s.length();
	dp[0][0][1] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < d; j++){
			for(int dg = 0; dg <= 9; dg++){
				add(dp[i][(j + dg) % d][0], dp[i - 1][j][0]);
				if(dg > s[i - 1] - '0') continue;
				add(dp[i][(j + dg) % d][(dg == s[i - 1] - '0') ? 1 : 0], dp[i - 1][j][1]);
			}
		}
	}
	cout << (dp[n][0][1] + dp[n][0][0] - 1 + mod) % mod;
}


Measured memory_bytes: 8704
#include <cstdio>
#include <cmath>
#include <algorithm>
using std::min;
int *a;
int N,K;

int main(void)
{
    int i,left,right,minValue=0x7FFFFFFF;
    scanf("%d%d",&N,&K);
    a=new int [N];
    for(i=0;i<N;i++)
        scanf("%d",a+i);
    for(i=0;i<N-K+1;i++)
    {
        left=i;
        right=left+K-1;
        minValue=min(minValue,abs(a[left]-a[right])+min(abs(a[left]),abs(a[right])));
    }
    printf("%d\n",minValue);

    delete [] a; 
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var res = "Yes";
            for (int i = 0; i < s.Length; i++)
            {
                if ((i+1)%2 == 0)
                {
                    if(s[i] == 'R')
                    {
                        res = "No";
                        break;
                    }
                }
                else
                {
                    if (s[i] == 'L')
                    {
                        res = "No";
                        break;
                    }
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


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

vector<string> findNextPoint(string str)
{
	vector<string> next;
	
	int zero;
	rep(i, 8) if(str[i] == '0')
		zero = i;
	
	rep(i, 4)
	{
		int nx = zero % 4 + dx[i];
		int ny = zero / 4 + dy[i];
		
		if(0 <= nx && nx < 4 && 0 <= ny && ny < 4)
		{
			swap(str[ny * 4 + nx], str[zero]);
			next.push_back(str);
			swap(str[ny * 4 + nx], str[zero]);
		}
	}
	
	return next;
}

void init(map<string, int>& cost)
{
	string v = "01234567";
	
	do cost[v] = INF;
	while (next_permutation(ALL(v)));
}

void calc(map<string, int>& cost)
{
	cost["01234567"] = 0;
	
	queue<string> que;
	for(que.push("01234567"); !que.empty(); que.pop())
	{
		string now = que.front();
		vector<string> next = findNextPoint(now);
		
		rep(i, next.size())
		{
			if(cost[now] + 1 < cost[next[i]])
			{
				cost[next[i]] = cost[now] + 1;
				que.push(next[i]);
			}
		}
	}
}

int main()
{
	map<string, int> cost;

	init(cost);
	calc(cost);
	
	while(true)
	{
		char num;
		string board;
		
		rep(i, 8)
		{
			cin >> num;
			board += num;
		}
		
		if(cin.eof()) break;
		
		cout << cost[board] << endl;
	}
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int c,a,b;
    cin>>c>>a>>b;
    cout<<(c*a)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[100000],y[100000];
P p[100000];
signed main(){
	int a,b=0,c=0;
	cin>>a;
	f(i,a){
		cin>>x[i]>>y[i];
		p[i].F=x[i]+y[i];
		p[i].S=i;
	}
	sort(p,p+a);
	for(int i=a-1;i>=0;i--){
		if((a-i)%2)b+=x[p[i].S];
		else c+=y[p[i].S];
	}
	cout<<b-c<<endl;
	return 0;
}


Measured memory_bytes: 3328
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, m;

    cin >> n >> m;

    int ans = 0;

    if(n == 1){
        cout << m << endl;
        return 0;
    }
    for(int i = 1; i * n <= m; i++){
        if(m % i == 0){
            ans = i;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n;
    cin >> n;
    ll ans = 0ll;
    vector<char> c{'M', 'A', 'R', 'C', 'H'};
    sort(c.begin(), c.end());
    map<char, ll> s;
    REP(i, 5) s[c[i]] = 0ll;
    REP(i, n){
        string _s;
        cin >> _s;
        if(find(c.begin(), c.end(), _s[0]) != c.end()) s[_s[0]]++;
    }
    do{
        ans += (s[c[0]] * s[c[1]] * s[c[2]]);
    } while(next_permutation(c.begin(), c.end()));
    ans /= 2*3*2;
    cout << ans << "\n";
}

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


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((s (read-line)))
    (loop for b = 0 then (logxor b 1)
          for c across s
          count (= b (- (char-code c) 48)) into res
          finally (println (min res (- (length s) res))))))

#-swank(main)


Measured memory_bytes: 8804
def solve(t):
    same=0
    count=0
    for i in range(len(t)):
        same+=1
        if i==len(t)-1 or t[i]!=t[i+1]:
            count+=same//2
            same=0
    return count

s=input()
k=int(input())
f=True
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        f=False
if f==True:
    print(len(s)*k//2)
else:
    st=s+s;
    scount=solve(s)
    stcount=solve(st)
    print(scount+(stcount-scount)*(k-1))





Measured memory_bytes: 3064