akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

long long N, K, dp[4009][2009][2], fact[2009], mod = 924844033; vector<pair<int, int>>V;

int main() {
	cin >> N >> K;
	fact[0] = 1; for (int i = 1; i <= 2008; i++) fact[i] = (fact[i - 1] * i) % mod;
	for (int i = 1; i <= 2 * K; i++) {
		if (i > N) continue;
		for (int j = i; j <= N; j += 2 * K) {
			if (j > K) V.push_back(make_pair(i, j - K));
			if (j <= N - K) V.push_back(make_pair(i, j + K));
		}
	}
	V.push_back(make_pair(-1, -1));
	dp[0][0][0] = 1;
	for (int i = 0; i < V.size(); i++) {
		for (int j = 0; j <= N; j++) {
			bool OK = true; if (i >= 1 && (V[i].first == V[i - 1].first || V[i].second == V[i - 1].second)) OK = false;
			// 付ける場合
			dp[i + 1][j + 1][1] += dp[i][j][0];
			if (OK == true) dp[i + 1][j + 1][1] += dp[i][j][1];
			dp[i + 1][j][0] += dp[i][j][0];
			dp[i + 1][j][0] += dp[i][j][1];
			dp[i + 1][j][0] %= mod;
			dp[i + 1][j + 1][1] %= mod;
		}
	}
	long long sum = 0;
	for (int i = 0; i <= N; i++) {
		if (i % 2 == 0) sum += dp[V.size()][i][0] * fact[N - i];
		else sum -= dp[V.size()][i][0] * fact[N - i];
		sum += mod*mod; sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

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




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
const long double pi = acos(-1.0L);
int main()
{
   ll a,b;
   cin>>a>>b;
   cout<<a*b;
    
    
    
    
    
     
}

Measured memory_bytes: 3644
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b;

int main(){
    INIT;
    cin >> a >> b;
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		int j = i;
		while(j < s.size() - 1 && s[j] == s[j + 1]) {
			j++;
		}
		cnt++;
		i = j;
	}
	cout << cnt -  1 << endl;
	return 0;
}

Measured memory_bytes: 512
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};

console.log(main().toString());

function main() {
    let n = next();
    let a = nexts(n);

    let sum = xArray(0, n + 1);
    let map = new Map();
    map.set(0, 1);
    for (let i = 0; i < n; i++) {
        let t = sum[i] + a[i];
        sum[i + 1] = t;
        map.set(t, 1 + (map.has(t) ? map.get(t) : 0));
    }
    //console.log(map);
    let keys = map.keys();
    let ans = 0;
    for (let key of keys) {
        let v = map.get(key);
        ans += (v * (v - 1)) / 2;
    }
    return ans;
}


Measured memory_bytes: 78936
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;





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

    string s;
    cin >> s;
    int n = s.length()-1;
    int ans=0;
    int res=0;
    rep(i,1<<n){
        ans = s[0]-'0';
        rep(j,s.length()-1){
            if(i>>j&1){
                ans+=s[j+1]-'0';
            }else{
                ans-=s[j+1]-'0';
            }
        }
        if(ans == 7){
            rep(j,4){
                cout << s[j];
                if(j-3){
                    if(i>>j&1){
                        cout << '+';
                    }else{
                        cout << '-';
                    }
                }
            }
            cout << "=7" << endl;
            return 0;

        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
    for(int i=0; i<3;i++){
      pq.add(sc.nextInt());
    }

    int min_1;
    int min_2;

    min_1 = pq.poll();
    min_2 = pq.poll();

    System.out.println(min_1*min_2/2);
  }
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char a[1010];
	int x;
	cin>>a;
	cout<<a[0];
	x=strlen(a);
	x=x-2;
	cout<<x;
	cout<<a[x+1];
	cout<<endl;
}


Measured memory_bytes: 256
//created by pyoxiao on 2020/05/10
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 998244353, p = mod;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL inv(LL x) {
    return fpow(x, mod - 2, mod);
}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
const int N = 2e5 + 7;
LL n, m, k, jc[N];
void init(int n)  //预处理 阶乘 及 逆元(p为质数) O(n)
{
    jc[0] = jc[1] = 1;
    for (int i = 2; i <= n; ++i) {
        jc[i] = (LL)jc[i - 1] * i % p;
    }
}
LL C(LL a, LL b)  //组合数（p为质数）
{
    if (b > a)
        return 0;
    return (LL)jc[a] * fpow(jc[b], p - 2, p) % p * fpow(jc[a - b], p - 2, p) % p;
}
void solve() {
    scanf("%d %d %d", &n, &m, &k);
    LL ans = 0;
    for(int i = 0; i <= min(k, n - 1); i ++) {
        LL cur = C(n - 1, i) * m % mod * fpow(m - 1, n - i - 1) % mod;
        (ans += cur) %= mod;
    }
    printf("%lld\n", (ans % mod + mod) % mod);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    init(N - 1);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 5388
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    int A, B, C, ans;
    
    cin >> A >> B >> C;
    
    if(A == B) ans = C;
    else if (A == C) ans = B;
    else ans = A;
    
    cout << ans << endl;
    
    return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int A,B,C;
	cin>>A>>B>>C;
	
	for(int i=0;i<1000000;i++){
		int k = A * i;
		if(k%B==C){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	
	cout<<"NO"<<endl;
	
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isVowel(char c){
	return (c=='a' or c=='e' or c=='i' or c=='o' or c=='u');
}
int main() {
	// your code goes here
	string s;
	cin>>s;
	printf("%s\n", isVowel(s[0]) ? "vowel" : "consonant");
	return 0;
}

Measured memory_bytes: 256
from itertools import product
from copy import copy

cards = list(map(int, input().split()))
k = int(input())
success = False
for ops in product(range(3), repeat=k):
    c = copy(cards)
    for op in ops:
        c[op] *= 2
    if c[1] > c[0] and c[2] > c[1]:
        success = True
if success:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 68788
#include <iostream>

using namespace std;

long long int H, W, num[27] = {}, one = 0, two = 0, four = 0, sum = 0, sum1 = 0, sum2 = 0;
char a[101][101] = {};

int main() {
	cin >> H >> W;
	four = (H / 2) * (W / 2);
	if (H % 2 == 1)two += W / 2;
	if (W % 2 == 1)two += H / 2;
	if (H % 2 == 1 && W % 2 == 1)one = 1;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
			num[a[i][j] - 'a' + 1]++;
		}
	}
	for (int i = 1; i <= 26; i++) {
		if (num[i]%2 == 1) {
			sum1++;
			if ((num[i] - 1) % 4 == 2) {
				sum2 += (num[i] - 1) / 2;
			}
		}
		else if (num[i]%4 == 2) {
			sum2++;
		}
		sum += num[i];
	}
	if (sum != one + two * 2 + four * 4) {
		cout << "No" << endl;
		return 0;
	}
	if (sum1 > one) {
		cout << "No" << endl;
		return 0;
	}
	if (sum2 > two) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define REP(i) for((i)=1;(i)<10;(i)++)
using namespace std;

int main(void){
  int i,j;
  REP(i){REP(j){
      cout<<i<<"x"<<j<<"="<<i*j<<endl;
    }
  }
  return 0;
}

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

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >> m;
    vector<string> t(m);
    for(int i=0;i<m;i++){
        cin >> t[i];
    }
    map<string,int> ma;
    for(int i=0;i<n;i++){
        ma[s[i]]++;
    }
    for(int i=0;i<m;i++){
        ma[t[i]]--;
    }
    int ans = 0;
    for(auto x:ma){
        ans = max(ans,x.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    ll n,w;
    cin>>n>>w;
    vector<ll> item(n),value(n);
    for(int i=0;i<n;i++) cin>>item[i]>>value[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-item[i-1]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-item[i-1]]+value[i-1]);
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=w;j++) cout<<dp[i][j]<<' ';
    //     cout<<endl;
    // }
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 79232
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) ((a < 0) ? -a : a)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

int main() {
	int n = ri();
	char s[n+1];
	for (int i = 0; i <= n; i++) s[i] = '\0';
	scanf("%s", s);
	
	int first = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E') first++;
	}
	
	int res = first;
	int cur = first;
	for (int i = 1; i < n; i++) {
		if (s[i-1] == 'W') cur++; // <-
		if (s[i] == 'E') cur--;   // ->
		res = min(res, cur);
	}
	
	printf("%d", res);
	
	return 0;
}


Measured memory_bytes: 512
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N, long long K, std::vector<long long> h) {
  vector<ll> dp(N, INF);
  dp[0] = 0;
  rep(n, N) rep1(k, K) {
    chmin(dp[n + k], dp[n] + abs(h[n] - h[n + k]));
  }
  ANS(dp[N - 1]);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> h(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&h[i]);
  }
  solve(N, K, std::move(h));
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=0;
  rep(i,n-1){
    ans+=a[i]/2;
    a[i]%=2;
    ll mi=min(a[i],a[i+1]);
    if(mi==1){
      ans++;
      a[i]--;
      a[i+1]--;
    }
  }
  ans+=a[n-1]/2;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

H, W = mi()
S = []
for _ in range(H):
  S.append(input().split())


sni = 0 #タテ
snj = 0 #ヨコ
for i, s in enumerate(S):
  for j, word in enumerate(s):
    if word == 'snuke':
      sni = i + 1
      snj = j

print(chr(ord('A')+snj)+str(sni))





Measured memory_bytes: 38256
#include <stdio.h>

int main(void){
	long a,b;
	long m,n;
	while(scanf("%ld %ld",&a,&b) != EOF){
		m = a;
		n = b;
		
		while(m != 0&&n != 0){
			if(m > n){
				m %= n;
			}else{
				n %= m;
			}
		}
		
		if(m > n){
			printf("%ld %ld\n",m,a/m*b);
		}else{
			printf("%ld %ld\n",n,a/n*b);
		}
	}
	return 0;

}

Measured memory_bytes: 1024
A,B,K = map(int, input().split())
ans = []
if A + K - 1< B - K + 1:
    ans = [A + i for i in range(K)] + [B - i for i in reversed(range(K))]

else:
    if A + K - 1 < B and A <= B - K + 1:
        ans = [A + i for i in range(K)] + [B - i for i in reversed(range(B - (A + K - 1)))]
    else:
        ans = [i for i in range(A,B+1)]

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a,b;
int main()
{
    a=read();b=read();
    if(a%b==0) return 0*puts("-1");
    else printf("%d",a);
    return 0;
}

Measured memory_bytes: 256
def main():
    n, d = map(int, input().split())

    count = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if (x**2 + y**2) ** 0.5 <= d:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9612
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();		//要素数
		
		for(int i = 0; i < num; i ++ ){		//要素数分処理
			insertionSort(num, scanner);
		}
		
		scanner.close();
	}
	
	public static void output(int[] array, int num){
	   //出力
	   StringBuilder sb = new StringBuilder("");
	   sb.append(array[0]);
	   for (int i = 1; i < num; i++) {
		  sb.append(" ").append(array[i]);
	   }
		System.out.println(sb);
	}
	
	public static void insertionSort(int num,  Scanner scanner){
		int off = scanner.nextInt();		//いらないけど仕方ない
		int ver_num = scanner.nextInt();	//頂点数
		int[] array = new int[num];			//格納用配列
		//頂点の分その場所を1にしていく
		for(int i = 0; i < ver_num; i ++ ){
			array[scanner.nextInt() - 1] = 1;
		}
		output(array, num);					//出力呼び
	}
}


Measured memory_bytes: 29012
#include<stdio.h>

#define MOD 10000

int N ,K ;
int plan[ 100 + 1 ][ 4 + 1 ][ 4 + 1 ] ;
int _now[ 100 + 1 ] ;

int Cnt( int day ,int prev ,int now )
{
	if( day == N )
	{
		return 1 ;
	}

	int &next = _now[ day ] ;
	if( next > 0 )
	{
		if( prev == now && now == next )
		{
			return 0 ;
		}
		
		return Cnt( day + 1 ,now ,next ) ;
	}

	int &value = plan[ day ][ prev ][ now ] ;
	if( value > 0 )
	{
		return value ;
	}

	int nex ,cnt = 0 ;
	for( nex = 1 ; nex <= 3 ; ++nex )
	{
		if( prev != now || now != nex )
		{
			cnt = (cnt + Cnt( day + 1 ,now ,nex )) % MOD ;
		}
	}

	return (value = cnt) ;
}


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

	++N ;

	int i ,day ,menu ;
	for( i = 0 ; i < K ; ++i )
	{
		scanf( "%d %d" ,&day ,&menu ) ;

		_now[ day ] = menu ;
	}

	printf( "%d\n" ,Cnt( 1 ,0 ,0 )) ;

	return 0 ;
}


Measured memory_bytes: 2724
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    if (n==7 || n==5 || n==3) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 23380
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
const int INF = 1000000000;

int n, m, p[10000], c, e;
int d[10001], dp[10001];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  sort(p, p + n, greater<int>());
  d[0] = 0;
  for (int i = 0; i < n; i++) d[i + 1] = d[i] + p[i];
  for (int i = 0; i < n; i++) dp[i + 1] = INF;
  dp[0] = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &c, &e);
    for (int j = n; j >= 0; j--) {
      dp[min(n, j + c)] = min(dp[min(n, j + c)], dp[j] + e);
      if (j + c < n) dp[j + c] = min(dp[j + c], dp[j + c + 1]);
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) ans = max(ans, d[i] - dp[i]);
  printf("%d\n", ans);
}



Measured memory_bytes: 2900
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll count=1;
    while(true){
        ll x;cin>>x;
        if(x)cout<<"Case "<<count<<": "<<x<<endl;
        else break;
        count++;
    }
    return 0;
}


Measured memory_bytes: 3004
#include <stdio.h>

int main () {
	int a, b;
	scanf ("%d %d", &a, &b);
	
	int x[a], y[b];
	x[0] = 2, y[0] = 1;
	
	int max = 0;
	if (a > b) {
		max = a;
	} else max = b;
	
	if (a > 1) {
		for (int i = 1; i < a; i++) {
			x[i] = x[i-1] + 2;
		}
	}
	
	if (b > 1) {
		for (int i = 1; i < b; i++) {
			y[i] = y[i-1] + 2;
		}
	}
	
	int sum[max*max];
	int k = 0, fin = 0;
	if (a > 1) {
		for (int i = 0; i < a; i++) { //even
			for (int j = i+1; j < a; j++) {
				sum[k] = x[i] + x[j];
				if (sum[k] % 2 == 0) {
					fin++;
				}
				k++;
			}		
		}
	}
	
	if (b > 1) {
		for (int i = 0; i < b; i++) { //even
			for (int j = i+1; j < b; j++) {
				sum[k] = y[i] + y[j];
				if (sum[k] % 2 == 0) {
					fin++;
				}
				k++;
			}		
		}
	}
		
	
	printf ("%d\n", fin);
}

Measured memory_bytes: 1764
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int h, w;
vs a;
ll dp[1010][1010];

ll get_pattern(int x, int y) {
    if (y >= h || x >= w || a[y][x] == '#') return 0;
    if (y == h - 1 && x == w - 1) return 1;
    if (dp[y][x] == -1) {
        ll pattern = get_pattern(x + 1, y) + get_pattern(x, y + 1);
        dp[y][x] = pattern % DIV;
    }
    return dp[y][x];
}

int main() {
    cin >> h >> w;
    a.resize(h);
    rep(i, h) cin >> a[i];

    rep(y, h) rep(x, w) dp[y][x] = -1;

    ll ans = get_pattern(0, 0);
    cout << ans << endl;

}

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

int n;
int dp[5][4001];
int x=1;

int func(int i,int j){
    if (dp[i][j]>=0) {
        return dp[i][j];
    }
    int res=0;
    if(i==4){
        if (j==n) {
            return 1;;
        }
        else{
            return 0;
        }
    }
    else{
        for (int k=0; k<=1000; k++) {
            res+=func(i+1, j+k);
        }
    }
    return dp[i][j]=res;
}

int main(){
    while (cin>>n) {
        for (int i=0; i<5; i++) {
            for (int j=0; j<4001; j++) {
                dp[i][j]=-1;
            }
        }
        cout<<func(0,0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[3*n];
    rep(i,0,3*n){
        scanf("%lld",&a[i]);
    }
    sortdown(a,3*n);
    rep(i,0,n){
        ans+=a[2*i+1];
    }

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


Measured memory_bytes: 4860
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// 多重vectorを可変引数テンプレートで http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//

#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  string S;
  cin >> N >> K >> S;
  S[K - 1] = tolower(S[K - 1]);
  cout << S << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 1000000001
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  ull N; cin>>N;
  ull ans = 1;
  for(ull i = 1; i <= N; i++) {

    ans = (ans * i) % (1000000000 + 7);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x.sort()

d = deque()
for i in range(N):
    d.append(x[i+1] - x[i])

g = d[0]
for j in d:
    g = gcd(g, j)
print(g)


Measured memory_bytes: 88172
s = input()
t = input()
flag = False
tlen = len(t)
slen = len(s)

def same(a,b):
    for aa, bb in zip(a,b):
        if not(aa =="?" or aa == bb):
            return False
    return True

if tlen <= slen:
    for i in range(slen-tlen,-1,-1):
        if same(s[i:i+tlen],t):
            flag = True
            s = s[:i]+t+s[i+tlen:]
            break
ans = ""
if flag:
    for ss in s:
        if ss == "?":
            ans += "a"
        else:
            ans += ss
    print(ans)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned short US;

string s;

US sinriti(char x) {
	if (x == '0') return 0;
	if (x == '1') return 65535;
	
	US ret = 0;
	for (int i = 0; i < 16; i++) {
		if ((i >> ('d' - x)) % 2) {
			ret += ((US)1 << i);
		}
	}
	return ret;
}

//[l, r)
US getSinriti(int l, int r) {
	if (r - l == 1) { return sinriti(s[l]); }
	if (s[l] == '-') { return ~getSinriti(l + 1, r); }
	
	int dep = 0;
	for (int i = l; i < r; i++) {
		if (s[i] == '(') { dep++; }
		if (s[i] == ')') { dep--; }
		if (dep == 1) {
			if (s[i] == '*') { return getSinriti(l + 1, i) & getSinriti(i + 1, r - 1); }
			if (s[i] == '^') { return getSinriti(l + 1, i) ^ getSinriti(i + 1, r - 1); }
		}
	}
	return 0;
}

vector<US> oneSinriti() {
	vector<US> ret;
	string s = "01abcd";
	for (int i = 0; i < 6; i++) ret.push_back(sinriti(s[i]));
	return ret;
}

void add(vector<US> &dst, vector<US> &src1, vector<US> &src2, char ope) {
	for (int i = 0; i < src1.size(); i++) {
		for (int j = 0; j < src2.size(); j++) {
			if (ope == '*') {
				dst.push_back(src1[i] & src2[j]);
			}
			else {
				dst.push_back(src1[i] ^ src2[j]);
			}
		}
	}
}

vector<US> memo[17];
vector<US> dfs(int length) {
	if (memo[length].size() > 0) return memo[length];
	if (length == 1) return oneSinriti();
	
	vector<US> ret;
	
	if (length >= 5) {
		for (int i = 1; i < length - 3; i++) {
			vector<US> res1 = dfs(i);
			vector<US> res2 = dfs(length - 3 - i);
			add(ret, res1, res2, '*');
			add(ret, res1, res2, '^');
		}
	}
	vector<US> res = dfs(length - 1);
	for (int i = 0; i < res.size(); i++) { ret.push_back(~res[i]); }
	
	sort(ret.begin(), ret.end());
	ret.erase(unique(ret.begin(), ret.end()), ret.end());
	return memo[length] = ret;
}

int main() {
	while (cin >> s) {
		if (s == ".") break;
		
		int type = getSinriti(0, s.length());
		
		int i, j;
		for (i = 1; i < s.length(); i++) {
			vector<US> res = dfs(i);
			for (j = 0; j < res.size(); j++) {
				if (res[j] == type) break;
			}
			if (j < res.size()) {
				break;
			}
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
import sys
from itertools import product

def main():
    input = sys.stdin.readline
    N, K = map(str, input().split())
    D = list(map(str, input().split()))

    nums = set([str(i) for i in range(10)])
    safe = sorted(list(nums - set(D)))
    min_safe = safe[0]
    if min_safe == '0':
        min_safe = safe[1]

    digit = len(str(N))
    safe_num = list(product(safe, repeat=digit))
    ans = 10**5
    for n in safe_num:
        m = int(''.join(n))
        l = int(min_safe + ''.join(n))
        if m >= int(N):
            ans = min(ans, m)

        if l >= int(N):
            ans = min(ans, l)


    return ans


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


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int c[26];
	fill(c, c+26, 0);

	for(int i=0; i<s.length(); i++){
		c[s.at(i)-'a']++;
	}

	int j=0;
	while(j<26){
		if(c[j] == 0){
			printf("%c\n", 'a'+j);
			return 0;
		}
		j++;
	}
	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
for x in T[::-1]:
    while 1:
        if len(D)==0:
            print('NO')
            exit()
        temp = D.pop()
        if temp==x:
            break
else:
    print('YES')


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) (int)x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(str) scanf("%s",str)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define NL printf("\n")
#define Max 505
#define INF 1e9
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())
#define mod 1000000007

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDD(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int setb(int n,int pos)
{
    return n=n | (1 << pos);
}
int resb(int n,int pos)
{
    return n=n & ~(1 << pos);
}
bool checkb(int n,int pos)
{
    return (bool)(n & (1 << pos));
}

LL bigmod(LL b,LL p,LL m)
{
    if( p == 0 ) return 1;
    LL ret = bigmod(b,p/2,m);
    ret = ( ret * ret ) % m;
    if( p & 1 ) ret = ( ret * b ) % m;
    return ret;
}

int main()
{
    //FI;
    int n,i,x,y,t;
    int curt = 0, curx = 0, cury = 0;
    int flag = 1;
    si(n);
    rep(i,n)
    {
        siii(t,x,y);
        int td = t - curt;
        int d = abs(curx - x) + abs(cury - y);
        if( d > td ) flag = 0;
        else
        {
            int my = abs(d - td);
            if( my & 1 ) flag = 0;
        }
        curx = x; cury = y; curt = t;
    }
    if( flag ) puts("Yes");
    else puts("No");
    return 0;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

vector<int> g[N];
vector<int> part[2];
int p[N];

void dfs(int v,int p,int d)
{
    part[d%2].push_back(v);
    for(int to:g[v])
        if(to!=p)
            dfs(to,v,d+1);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1,-1,0);
    if(part[0].size()>part[1].size())
        swap(part[0],part[1]);
    int cnt[3]={};
    for(int i=1;i<=n;i++)
        cnt[i%3]++;
    vector<int> ord;
    if(part[0].size()<=cnt[0])
    {
        for(int i=1;i<=n;i++)
            if(i%3==0)
                ord.push_back(i);
        for(int i=1;i<=n;i++)
            if(i%3!=0)
                ord.push_back(i);
    }
    else
    {
        for(int i=1;i<=n;i++)
            if(i%3==1)
                ord.push_back(i);
        for(int i=1;i<=n;i++)
            if(i%3==0)
                ord.push_back(i);
        for(int i=1;i<=n;i++)
            if(i%3==2)
                ord.push_back(i);
    }
    vector<int> vers=part[0];
    copy(part[1].begin(),part[1].end(),back_inserter(vers));
    for(int i=0;i<n;i++)
        p[vers[i]]=ord[i];
    for(int i=1;i<=n;i++)
        cout<<p[i]<<" ";
}


Measured memory_bytes: 25576
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a[s.size()];
  memset(a,0,sizeof(a));
  int b[s.size()]={0};
  int c[s.size()]={0};
  int count1=0,count2=0;
  for(int i=0;i<s.size();i++)
  {
  	if(s[i]=='W')
  		count1++;
  	b[i]=count1;
  	if(s[s.size()-1-i]=='E')
  		count2++;
  	c[s.size()-1-i]=count2;
  }
  int count;
  for(int i=0;i<s.size();i++)
  {
    if(i==0)
    	a[i]=c[i+1];
    else if(i==s.size()-1)
    	a[i]=b[i-1];
    else
    	a[i]=b[i-1]+c[i+1];
  }
  /*for(int i=0;i<s.size();i++)
  	cout<<a[i]<<" ";8*/
  sort(a,a+s.size());
  cout<<a[0]<<endl;
  return 0;
}

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

using namespace std;

int main(void)
{
  int N;
  string S,T;
  cin>>N>>S>>T;

  string R = "";
  for(int i=0;i<N;i++){
    R += S.at(i);
    R += T.at(i);
  }

  cout << R<<endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

template <typename ... Args>
string format(const string& fmt, Args ... args )
{
    size_t len = snprintf( nullptr, 0, fmt.c_str(), args ... );
    vector<char> buf(len + 1);
    snprintf(&buf[0], len + 1, fmt.c_str(), args ... );
    return string(&buf[0], &buf[0] + len);
}

int h,w,k;
int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    cin>>h>>w>>k;
    vector<vi> s(h,vi(w));
    vector<vi> cs(h+1,vi(w+2, 0));

    FOR(i,1,h+1) FOR(j,1,w+1){
        scanf("%1d", &s[i-1][j-1]);
        cs[i][j] = cs[i][j-1] + cs[i-1][j] + s[i-1][j-1] - cs[i-1][j-1];
    }


    ll ans = LINF;
    //行でチョコを割る全パターン走査
    REP(i, (1LL<<(h-1))){
        //DEBUG(i);
        int pw = -1;
        ll anstmp = 0;
        bool impossible = false;
        FOR(ww,0,w){
            int ph = -1;

            FOR(hh,0,h){
                if(hh < h-1 && !((i>>hh) & 1)) continue;

                //ll tmp = cs[hh+1][ww+1] - (cs[hh+1][pw+1] + cs[ph+1][ww+1]);
                ll tmp = (cs[hh+1][ww+1]-cs[hh+1][pw+1]) - (cs[ph+1][ww+1]-cs[ph+1][pw+1]);
                if(tmp > k){//アウト
                    pw = ww-1;
                    
                    tmp = (cs[hh+1][ww+1]-cs[hh+1][pw+1]) - (cs[ph+1][ww+1]-cs[ph+1][pw+1]);
                    if(tmp > k){
                        //可能な限り縦に分割したがkを上回る場合
                        impossible = true;
                    }
                    anstmp++;
                }

                if(hh < h-1){
                    ph = hh;
                    if(ww==0) anstmp++;
                }
            }

        }

        if(!impossible)
            chmin(ans, anstmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def mod_inv(a, m):
    return pow(a, m-2, m)


X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

if (X + Y) % 3:
    print(0)
    exit()

n = (X + Y) // 3
nx, ny = X - n, Y - n

if nx < 0 or ny < 0:
    print(0)
    exit()

ans = 1
for i in range(nx + 1, nx + ny + 1):
    ans = ans * i % MOD
for i in range(1, ny + 1):
    ans = ans * mod_inv(i, MOD) % MOD

print(ans)



Measured memory_bytes: 3188
#include <iostream>

using namespace std;
void print(int *a,int n)
{
	for(int i = 0; i <n-1 ; i++){
		cout <<a[i]  << " ";
	}
	cout << a[n-1];
	cout << endl;
	return;
}

void insertion(int *a,int n)
{
	for(int i = 0 ; i < n ; i ++){
		int key = a[i];
		int j = i-1;
		while(j >= 0 && key < a[j]){
			a[j+1] = a[j];
			j --;
		}
		a[j+1] = key;
		print(a,n);
	}
	return;
}


int main(int argc, char const *argv[])
{
	//input 
	int n = 0 ;
	cin >> n;
	int *a = new int[n];
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}

	//insertion sort
	insertion(a,n);
	return 0;
} 

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int n;
long long int a1[100010];
long long int a2[100010];
long long int sum_a1 = 0;
long long int sum_a2 = 0;
long long int a[300001];
priority_queue<int> que2;
priority_queue<int, vector<int>, greater<int>> que1;

int main()
{
    cin >> n;
    for (int i = 0; i < 3 * n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        que1.push(a[i]);
        sum_a1 += a[i];
        que2.push(a[3 * n - i - 1]);
        sum_a2 += a[3 * n - i - 1];
    }
    a1[0] = sum_a1;
    a2[n] = sum_a2;
    for (int i = n; i < 2 * n; i++)
    {
        que1.push(a[i]);
        sum_a1 += a[i];
        sum_a1 -= que1.top();
        que1.pop();
        que2.push(a[3 * n - i - 1]);
        sum_a2 += a[3 * n - i - 1];
        sum_a2 -= que2.top();
        que2.pop();
        a1[i - n + 1] = sum_a1;
        a2[2 * n - i - 1] = sum_a2;
    }
    long long int ans = -1000000000000000000;
    for (int i = 0; i <= n; i++)
    {
        ans = max(ans, a1[i] - a2[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5108
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a[100000] = {}, ans = 0;
map<ll, ll> m;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		m[a[i]]++;
	}
	rep(i, n) {
		if (m[a[i]] > a[i]) {
			ans += m[a[i]] - a[i];
		}
		else if (m[a[i]] < a[i]) {
			ans += m[a[i]];
		}
		m[a[i]] = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
string s[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    int count=1;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            ans+=count; 
            count++;
        }
        else{
            count=1;
        }
    }
    cout<<ans<<"\n";
}

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

int main(void) {
	int n;
	string s,t;
	cin >> n >> s >> t;
	int ans=s.length()+t.length();
	for(int i=1; i<=t.length(); i++){
		if(s.find(t.substr(0,i))==s.length()-i){
			ans=s.length()+t.length()-i;
		}
	}
	cout << max(n,ans) << endl;
	return 0;
}


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

int main() {
  string str;
  int m = 0;
  int n = 0;

  cin >> str;

  for(int i=0;i<str.size();i++) {
    if (str.at(i) == '1') {
      m += 1;
    } else {
      n += 1;
    }
  }

  if (m < n) {
    cout << m * 2 << endl;
  } else {
    cout << n * 2 << endl;
  }
}

Measured memory_bytes: 512
main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  print $ solve (xs!!0) (xs!!1)

limit :: Int
limit = 10^9 + 7

solve :: Int -> Int -> Int
solve n m
  | abs (n - m) > 1 = 0
  | abs (n - m) == 0 = iter n 1 * iter m 1 * 2 `mod` limit
  | otherwise = iter n 1 * iter m 1 `mod` limit

iter :: Int -> Int -> Int
iter 1 a = a
iter i a = iter (i-1) (mod (a * i) limit)


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

int main() {
	int N;
	cin >> N;
	int i = 0;
	string input;
	int acc = 0;
	int wac = 0;
	int tlec = 0;
	int rec = 0;
	while (i < N) {
		cin >> input;
		if (input == "AC") {
			++acc;
		}else if (input == "WA") {
			++wac;
		}else if (input == "TLE") {
			++tlec;
		}else {
			++rec;
		}
		++i;
	}
	cout << "AC x " << acc << endl;
	cout << "WA x " << wac << endl;
	cout << "TLE x " << tlec << endl;
	cout << "RE x " << rec << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;

  if(n%2==1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  n /= 2;
  while(n>0){
    n /= 5;
    ans += n;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256