akhauriyash/Code-Regression huggingface dataset:
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp
?????????: Red and Black
?????°
19:08:06 ??¶?´???????????????§Haskell??§??????????????????
19:17:53 ??¨??????????????????????????¨?????´??°??????bar???????£?????????????
19:32:19 ????????????
19:34:02 ??????fmap???????????????
-}
import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
 [w,h] <- (map read . words) `fmap` getLine
 when ((w,h) /= (0,0)) $ do
  arr <- replicateM h getLine
  print $ foo arr
  main

type Stat = (Integer, [[Char]])

foo :: [[Char]] -> Integer
foo arr = fst $ repetitive bar (1,arr)

repetitive :: Eq t => (t -> t) -> t -> t --??????????????????????????§?????¨????????????????±???????
repetitive f s = if f s == s then s else repetitive f (f s)

bar :: Stat -> Stat -- "@"????????????"."???"@"?????????
bar = f . f
 where f = fmap transpose . bar1 ".@" . bar1 "@."

bar1 :: String -> Stat -> Stat -- replace all `bef` with "@@", while counting the num
bar1 bef (num, dat) = (num + sum(map fst d'), map snd d')
 where 
  d' = map f dat
  f :: String -> (Integer,String)
  f str
   | null str = (0,"")
   | bef `isPrefixOf` str = count $ ("@@" ++) `fmap` f(drop 2 str)
   | otherwise = (head str :) `fmap` f (tail str)

count :: (Integer,a) -> (Integer,a)
count(a,b)=(a+1,b)

Measured memory_bytes: 5520
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void solve(void)
{

  int N,M;
  cin>>N>>M;
  if(M == 1)
  {
    cout<<"1 2"<<endl;
    return;
  }

  int i1 = 1;
  int i2 = M + 2;
  for (int i = M; i >= 1; i--) 
  {
      cout<<i1<<" "<<i1+i<<endl;
      i1++;
      swap(i1,i2);
  }

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
q = [(1,0)]
while q:
    x,parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)


Measured memory_bytes: 124236
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(int(A[k-1]))

Measured memory_bytes: 3060
from collections import defaultdict

N = int(input())

colors = [0] * (N+1)
vertices = defaultdict(bool)
edges = defaultdict(dict)
for i in range(1, N):
    u, v, w = map(int, input().split())
    edges[u][v] = w % 2 == 0
    edges[v][u] = w % 2 == 0
    vertices[u] = False
    vertices[v] = False

queue = []
for v in edges[u].keys():
    queue.append((u, v))
vertices[u] = True

while len(queue) > 0:
    u, v = queue.pop(0)
    if vertices[v]:
        continue
    vertices[v] = True
    if colors[u] == colors[v]:
        if not edges[u][v]:
            colors[v] = 1 - colors[u]
    else:
        if edges[u][v]:
            colors[v] = colors[u]

    for nv in edges[v].keys():
        if not vertices[nv]:
            queue.append((v, nv))

for i in range(1, N+1):
    print(colors[i])

Measured memory_bytes: 53620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

vector<P> cake;
vector<int> ans;

P getCake(int index){
  P tmp = cake[index];
  //cout << "d = " << tmp.first << " w = " << tmp.second << endl;
  cake.erase(cake.begin() + index);
  return tmp;
}

bool compare(P cake1, P cake2){
  int s1 = cake1.first * cake1.second;
  int s2 = cake2.first * cake2.second;
  return s1 < s2;
}

void CutCake(int s, int index){
  P cake_part = getCake(index);
  int count = 0;
  while(s > 0){
	if(count % 2 == 0){
	  s -= cake_part.second;
	}
	else if(count % 2 == 1){
	  s -= cake_part.first;
	}
	count++;
  }

  if((count - 1) % 2 == 0){
	s += cake_part.second;
	P cake1 = P(cake_part.first, s);
	P cake2 = P(cake_part.first, cake_part.second - s);
	if(compare(cake1, cake2)){
	  cake.push_back(cake1);
	  cake.push_back(cake2);
	}
	else{
	  cake.push_back(cake2);
	  cake.push_back(cake1);
	}
  }
  else if((count - 1) % 2 == 1){
	s += cake_part.first;
	P cake1 = P(s, cake_part.second);
	P cake2 = P(cake_part.first - s, cake_part.second);
	if(compare(cake1, cake2)){
	  cake.push_back(cake1);
	  cake.push_back(cake2);
	}
	else{
	  cake.push_back(cake2);
	  cake.push_back(cake1);
	}
  }
	
}

void getAns(){
  for(unsigned long i = 0; i < cake.size(); i++){
	int s = cake[i].first * cake[i].second;
	ans.push_back(s);
  }
  sort(ans.begin(), ans.end());
}

void showAns(){
  for(unsigned long i = 0; i < ans.size(); i++){
	if(i == 0) cout << ans[i];
	else cout << " " << ans[i];
  }
  cout << endl;
}

void init(){
  cake.clear();
  ans.clear();
}

int main(){
  int n = 0, w = 0, d = 0;
  while(1){
	cin >> n >> w >> d;
	if(n == 0 && w == 0 && d == 0) break;
	init();
	cake.push_back(P(d, w));
	for(int i = 0; i < n; i++){
	  int p = 0, s = 0;
	  cin >> p >> s;
	  CutCake(s, p - 1);
	}
	getAns();
	showAns();
  }
  return 0;
}

Measured memory_bytes: 3148
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    char a,b;
    cin>>a>>b;
    if(a==b) cout<<'H';
    else cout<<'D';
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++){
	    	if(i*j>=n)
	    	    break;
		    sum++;
	    }
	cout<<sum;
}

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

const int INF = 1e9;

int main() {
  string s;
  cin>>s;
  int cnt = 0;
  for (int i=1; i<s.length(); i++) {
    if (s[i-1] != s[i]) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 512
from math import sin, cos, pi
def koch(px, py, qx, qy, n):
    if n == 0:
        return True
    sx = (2 * px + qx) / 3
    sy = (2 * py + qy) / 3
    tx = (px + 2 * qx) / 3
    ty = (py + 2 * qy) / 3
    ux = sx + (tx - sx) * cos(pi / 3) - (ty - sy) * sin(pi / 3)
    uy = sy + (tx - sx) * sin(pi / 3) + (ty - sy) * cos(pi / 3)
    koch(px, py, sx, sy, n - 1)
    print("{:.8f} {:.8f}".format(sx, sy))
    koch(sx, sy, ux, uy, n - 1)
    print("{:.8f} {:.8f}".format(ux, uy))
    koch(ux, uy, tx, ty, n - 1)
    print("{:.8f} {:.8f}".format(tx, ty))
    koch(tx, ty, qx, qy, n - 1)
n = int(input())
print("{:.8f} {:.8f}".format(0, 0))
koch(0, 0, 100, 0, n)
print("{:.8f} {:.8f}".format(100, 0))


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < k; i++) {
    bool all_n = true;
    vector<int> d(n + 1);
    for (int j = 0; j < n; j++) {
      d.at(max(0, j - a.at(j)))++;
      d.at(min(n, j + a.at(j) + 1))--;
    }
    a.at(0) = d.at(0);
    if (a.at(0) != n) all_n = false;
    for (int j = 1; j < n; j++) {
      a.at(j) = a.at(j - 1) + d.at(j);
      if (a.at(j) != n) all_n = false;
    }
    assert(a.at(n - 1) + d.at(n) == 0);
    if (all_n) break;
  }
  for (int i = 0; i < n; i++) {
    cout << a.at(i);
    if (i < n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}


Measured memory_bytes: 4848
n = input()
amd = [i+1 for i in range(n)]

m = input()

for i in range(m):
    a,b = map(int, raw_input().split(','))
    amd[a-1],amd[b-1] = amd[b-1],amd[a-1]

for am in amd :
    print am

Measured memory_bytes: 4220
n = int(input())
_map = [list(map(int, input().split())), list(map(int, input().split()))]
_max = 0
# n通りを全探索
for i in range(n):
    total = _map[0][0]
    # どこで下の段に降りるかを i <= j のタイミングとし、経路をたどって数字を足していく
    for j in range(n):
        row = 1 if i <= j else 0
        col = j if row == 1 else j + 1
        total += _map[row][col]
    if _max < total:
        _max = total
print(_max)

Measured memory_bytes: 39280
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        int n = in.nextInt();
        int a = in.nextInt();

        int[] x = new int[n+1];
        for(int i=1;i<=n;i++){
            x[i] = in.nextInt();
        }

        long[][] dp = new long[51][2551];

        dp[0][0]=1;
        int tot =0;
        for (int i=1;i<=n;i++){
            for(int j = i-1;j>=0;j--){
                for(int k = tot;k>=0;k--){
                    dp[j+1][k+x[i]]+=dp[j][k];
                }
            }
            tot+=x[i];
        }
        long cnt =0;
        for(int i=1;i<=n;i++){
            cnt+=dp[i][a*i];
        }
        out.print(cnt);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }

    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a-b*d;
	f=d+1.0*r/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}



Measured memory_bytes: 2108
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lp(i,n)   for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
const ll M  = 1e9+7 ;
//const int N = 111;
const int inf = 2e9+7;
const double EPS = 1e-9;
//////////////////////    Hi    ^_^  hack me if you can :P
string ys = "YES\n";
string no = "NO\n" ;


int main()
{
    speed;
    string s;
    cin >> s;
    cout << s[0] ;
    cout << sz(s)-2 ;
    cout << s[sz(s)-1] ;

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
Ts = [0] + gets.split.map(&:to_i)
M = gets.to_i
PXs = readlines.map{|l| l.split.map(&:to_i)}

sum = Ts.inject(:+)
PXs.each do |p, x|
  puts sum - Ts[p] + x
end


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

struct PBDS
{
	tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> t;
	int timer;
	
	PBDS(){timer = 0;}
	void insert(int x)
	{
		t.insert(mp(x, timer));
		timer++;
	}
	
	int lower(int x)
	{
		return t.order_of_key(ii(x, -1));
	}
	
	void del(int x) //make sure x exists
	{
		ii tmp = (*t.find_by_order(lower(x)));
		t.erase(tmp);
	}
	
	int higher(int x)
	{
		int tmp = lower(x+1);
		return (int(t.size()) - tmp);
	}
};

int ans[111111];
int L[111111];
vi d[111111];
vi add[111111];
vi rem[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	for(int i = 2; i <= 100000; i++)
	{
		for(int j = i; j <= 100000; j+=i)
		{
			d[j].pb(i);
		}
	}
	int n, m; cin>>n>>m;
	for(int i = 0; i < n; i++)
	{
		int l, r; cin>>l>>r;
		L[1]++;
		L[r-l+2]--;
		add[l].pb(r-l+2); //at least r-l+2 to count
		rem[r+1].pb(r-l+2);
	}
	PBDS t;
	for(int i = 1; i <= m; i++)
	{
		for(int j = 0; j < add[i].size(); j++) t.insert(add[i][j]);
		for(int j = 0; j < rem[i].size(); j++) t.del(rem[i][j]);
		for(int j = 0; j < d[i].size(); j++)
		{
			int D = d[i][j];
			int cnt = t.lower(D+1);
			ans[D]+=cnt;
		}
	}
	for(int i = 1; i <= m; i++)
	{
		L[i]+=L[i-1];
		ans[i]+=L[i];
	}
	for(int i = 0; i < m; i++)
	{
		cout<<ans[i+1]<<'\n';
	}
}


Measured memory_bytes: 38656
while(True):
    try:
        n = int(input())
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        extra = []
        loss = 0
        ans = 0
        for i in range(n):
            dif = a[i] - b[i]
            extra.append(dif)
            loss += min(0, dif)
            if dif < 0:
                ans += 1
        extra.sort(reverse=True)
        for num in extra:
            if loss < 0:
                loss += num
                ans += 1
            else:
                print(ans)
                exit()
        print(-1)
    except EOFError:
        exit()



Measured memory_bytes: 18524
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (C > A - B) {
            System.out.println(C - A + B);
        } else {
            System.out.println(0);
        }
        
    }
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int,input().split()))

ans = 0
while any([a>N-1 for a in A]):
    A.sort()
    d = A[-1] - (N-1)
    k = -(-d//N)
    ans += k
    A[-1] -= k*N
    for i in range(N-1):
        A[i] += k
print(ans)

Measured memory_bytes: 3064
N = input()
A, B, C, D = [int(i) for i in N]

def judge(a, b, c, d):
  if a + b + c + d == 7:
    return '{}+{}+{}+{}=7'.format(a, b, c, d)
  elif a - b - c - d == 7:
    return '{}-{}-{}-{}=7'.format(a, b, c, d)
  elif a + b - c - d == 7:
    return '{}+{}-{}-{}=7'.format(a, b, c, d)
  elif a - b + c - d == 7:
    return '{}-{}+{}-{}=7'.format(a, b, c, d)
  elif a - b - c + d == 7:
    return '{}-{}-{}+{}=7'.format(a, b, c, d)
  elif a - b + c + d == 7:
    return '{}-{}+{}+{}=7'.format(a, b, c, d)
  elif a + b + c - d == 7:
    return '{}+{}+{}-{}=7'.format(a, b, c, d)
  elif a + b - c + d == 7:
    return '{}+{}-{}+{}=7'.format(a, b, c, d)

print(judge(A, B, C, D))

Measured memory_bytes: 3064
fun main(args: Array<String>) {

    val n = readLine()!!.toLong()

    var result = Int.MAX_VALUE

    loop@ for (i in 1..n) {

        val b = n / i
        if (i > b) {
            break@loop
        }

        if (n % i == 0L) {
            // 約数でこのときのiと商をペアの配列として確保
            val ilen = cntDigits(i)
            val blen = cntDigits(b)

            val fResult = if (ilen < blen) blen else ilen
            // kotlinのデータ型変換はtoXXXで良いのか???
            if (result > fResult) result = fResult
        }
    }

    println(result)
}

// toString.lengthで桁数を求めてみたが、性能が間に合わず???
// kotlinでメソッドの引数を変更したときどうする???
// 桁数算出メソッドを作成したが -> NG 実行時間ほぼ同じ
fun cntDigits(num: Long): Int {

    var digits = 0
    var target = num

    while (target > 0) {
        target /= 10
        digits++
    }
    return digits
}

Measured memory_bytes: 34560
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    Queue<Long> que = new ArrayDeque<>();
    long k = sc.nextLong();
      long num = 0;
      for(long i = 1 ; i <= 9 ; i++){
        que.add(i);
      }
    while(k > 0){
    long i = que.poll();
      num = i;
      k--;
      if(i % 10 != 0)
        que.add(i * 10 + i % 10 - 1);
      que.add(i * 10 + i % 10);
      if(i % 10 != 9)
        que.add(i * 10 + i % 10 + 1);
    }
      System.out.println(num);
	}
}

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

int main() {
   string s;
   cin >> s;

   sort(s.begin(), s.end());

   if (s == "abc") {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M,K = map(int,input().split())

def mCn(m,n):
    return math.factorial(m)//(math.factorial(n)*math.factorial(m-n)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N1 = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(1,M):
    ans += (M-i)*N**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

for i in range(1,N):
    ans += (N-i)*M**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

print(ans)


Measured memory_bytes: 126276
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3656
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  998244353
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll x,y;
    cin >> x >> y;
    for(ll i=1;i*x<=1e18 && i<=1e6;i++)
    {
        ll temp = i*x;
        if(temp%x==0 && temp%y!=0)  
        {
            cout<<temp;
            return;
        }
    }
    cout<<-1;
}


int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
string res;
int main() {
  cin >> s;
  res = "";
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != 'B') {
      res += s[i];
    } else if (res.length() != 0) {
      res.pop_back();
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main() {
    int n;
    string s;
    cin>>n;
    cin>>s;
    int l=s.size();
	char cae[l];
	rep(i,l){
	    cae[i]=s[i];
	}
	rep(j,n){
	    rep(k,l){
	        if(cae[k]!='Z')cae[k]++;
	        else cae[k]='A';
	    }
	}
	rep(p,l)cout<<cae[p];
	return 0;
}


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

const int N=1e2 +3;
int a[N];

int main(){

    int n;
    scanf("%d", &n);
    for(int i=0; i<n; ++i){
        scanf("%d", a+i);
    }

    sort(a, a+n);

    int cnt=1;
    for(int i=1; i<n; ++i){
        if(a[i]!=a[i-1])
            ++cnt;
    }

    printf("%d", cnt);




    return 0;
}


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

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=1e5+10, M=(ll)1e6+10 ;
const int mod = 998244353  ;

// vl compute(string s){
//         vl has(s.length());
//         ll i;

//         for(i=0;i<s.length();i++){
//             if(i==0){
//                 has[i]=((s[i]-'a'+1))%mod;
//             }
//             else
//                 has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
//         }
//         return has;
// }
vl a(N),b(N),col(N,0),vis(N,0);
ll n,m;
vl g[N];
void dfs(ll u){
    vis[u]=1;
    for(auto &it:g[u]){
        if(!vis[it]){
            dfs(it);
        }
    }
}
int main(){
 ios_base::sync_with_stdio(0);
  ll i,n,k;
  cin >> n >> k;
  for(i=0;i<k;i++){
      ll u,v,z;
      cin >> u >> v >> z;
      g[u].pb(v);
      g[v].pb(u);
  }
  ll ans=0;
  for(i=1;i<=n;i++){
      if(!vis[i]){
          dfs(i);
          ans++;
      }
  }
  cout << ans;
 return 0;
}

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

void Main() {
    // todo
    int a, b, c = 1, r = 0; cin >> a >> b;
    while (c < b) {
        c += a - 1;
        r++;
    }
    cout << r << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(void){
  int n, k, q, a;
  cin >> n >> k >> q;
  vector<int> answers(n);
  for(int i = 0; i < q; i++){
    cin >> a;
    answers[a-1]++;
  }
  for(int i = 0; i < n; i++){
    if(k-q+answers[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


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

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

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

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

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

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	//int n, l; cin >> n >> l;
	string S; cin >> S;
	vector<string> s(S.size());
	for (int i = 0; i < S.size(); i++) {
		s[i] = S[i];
	}
	
	string ans;
	for (int i = 0; i < S.size(); i++) {
		if (s[i] == "0") ans =ans+ "0";
		if (s[i] == "1") ans = ans + "1";
		if (ans.size() > 0 && (s[i] == "B")) ans.pop_back();
	}
	cout << ans;

	cout << endl;
	return 0;
}

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

bool is_bingo(vector<vector<int> >A)
{
	bool ans = false;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			if (A.at(i).at(j) != -1) break;
			if (j == 2)	ans = true;
		}
		if (ans) break;
	}
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			if (A.at(j).at(i) != -1) break;
			if (j == 2) ans = true;
		}
		if (ans) break;
	}
	for (int i = 0; i < 3; i++){
		if (A.at(i).at(i) != -1) break;
		if (i == 2) ans = true;
	}
	for (int i = 0; i < 3; i++){
		if (A.at(i).at(2-i) != -1) break;
		if (i == 2) ans = true;
	}
	return ans;
}

int main()
{
	vector<vector<int> > A(3, vector<int>(3));
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++) cin >> A.at(i).at(j);
	}
	int N;
	cin >> N;
	vector<int> B(N);
	for (int i = 0; i < N; i++){
		cin >> B.at(i);
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (A.at(j).at(k) == B.at(i)) A.at(j).at(k) = -1;
			}
		}
	}
	if (is_bingo(A)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int allocation(int *,int,int);
int check(int *,int,int,int);
int main(){
  int i,n,k,w[100000];
  int ans;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&w[i]);
  ans=allocation(w,n,k);
  printf("%d\n",ans);
  return 0;
}

int allocation(int *w,int n,int k){
  int left=0,right=1000000000,v;
  int mid;
  while(right-left>1){
    mid=(right+left)/2;
    v=check(w,n,k,mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}
int check(int *w,int n,int k,int P){
  int i,j=0,x;
  for(i=0;i<k;i++){
    x=0;
    while(x+w[j]<=P){
      x+=w[j];
      j++;
      if(n==j)return n;
    }
  }
  return j;
}



Measured memory_bytes: 2184
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int i, m;
	cin >> m;

	for(i=0; i<m; i++){

	int a[3];

	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);

	if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1]){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a);
    vector<int> B(b);
    rep(i, a) cin >> A[i];
    rep(i, b) cin >> B[i];
    int mincost;
    rep (i, m) {
        int x, y, c;
        cin >> x >> y >> c;
        if (i == 0) mincost = A[x - 1] + B[y - 1] - c;
        else mincost = min(mincost, A[x - 1] + B[y - 1] - c);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    mincost = min(A[0] + B[0], mincost);
    cout << mincost << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, K, A, B, C;
map<ll, ll> D;
vector<ll> S;

int main() {
    cin >> N >> K;
    S.resize(N+1, 0);
    FOR(i, 1, N) {
        cin >> A;
        S[i] = (S[i-1]+A)%K;
    }
    ll ans = 0, j;
    FOR(i, 0, N) {
        B = (S[i]-i)%K;        
        if(B < 0) B += K;
        if(D.find(B)==D.end()) D[B]=0;
        D[B]++;
        if (i >= K) {
            j = i-K;
            C = (S[j]-j)%K;
            if (C < 0) C += K;
            D[C]--;
        }
        // for(auto p : D) cerr << p.first << " " << p.second << "\n";
        // cerr << "\n";
        ans += D[B];
    }
    cout << ans - (N + 1) << endl;
	return 0;
}

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

int main(void)
{
    int N;
    char S[2000];

    scanf("%s",S);
    N = strlen(S);



    if(S[N-1] == 's'){
        printf("%ses\n",S);
    } else {
        printf("%ss\n",S);
    }


    return 0;
}

Measured memory_bytes: 1732
//
//AtCoder Beginner Contest 166
//B - Trick or Treat
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    int n, k;

    cin >> n >> k;

    int f[n];
    rep(i, n) f[i] = 0;

    int d[k];
    int a[k][n];

    rep(i, k){
        cin >> d[i];
        rep(j, d[i]){
            cin >> a[i][j];
            f[a[i][j]-1] = 1;
        }
    }

    int ans = 0;

    rep(i, n){
        if (f[i] == 0) ans++;
    }

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


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main() {
  ll i, j, k;
  
  string N;
  cin >> N;
  
  if(N[0]=='7'||N[1]=='7'||N[2]=='7') pt("Yes");
  else pt("No");
  
}




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

int main()
{
    int n,m,i;
    while(~scanf("%d",&n))
    {
        if(n==1)
        {
            printf("Hello World\n");
        }
        else
        {
            scanf("%d%d",&m,&i);
            printf("%d\n",m+i);
        }
    }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void) {
	int num, all, k, miss = 0, ok = 0;
	char kekka[3];
	int result[100000][2] = { 0 };
	scanf("%d %d", &num, &all);
	for (int i = 0; i < all; i++) {
		scanf("%d %s", &k, kekka);
		if (strcmp(kekka, "WA") == 0 && result[k - 1][0] == 0) {
			result[k - 1][1]++;
		}
		if (strcmp(kekka, "AC") == 0 && result[k - 1][0] == 0) {
			result[k - 1][0]++;
			ok++;
			miss += result[k - 1][1];
		}
		
	}
	printf("%d %d\n", ok, miss);

	return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;

int N, W, v[100], w[100], dp[10001], INF = 1000000000;

int main() {
  scanf("%d%d", &N, &W);
  for (int i = 0; i < N; i++) scanf("%d%d", &v[i], &w[i]);
  for (int i = 0; i < N; i++) for (int j = w[i]; j <= W; j++) {
    dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
  }
  printf("%d\n", dp[W]);
}



Measured memory_bytes: 2772
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder();
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = Math.max(n,m);
    int y = Math.min(n,m);
    for(int i=1;i<=x;i++){
      sb.append(y);
    }
    System.out.println(sb);
  }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <inttypes.h>

#define MOD_BY 998244353

int add(int a, int b) {
	return a + b - (a + b >= MOD_BY ? MOD_BY : 0);
}

int mul(int a, int b) {
	return (int)(((int64_t)a * b) % MOD_BY);
}

int pou(int a, int b) {
	int r = 1;
	while (b > 0) {
		if (b & 1) r = mul(r, a);
		a = mul(a, a);
		b >>= 1;
	}
	return r;
}

int inv(int a) {
	return pou(a, MOD_BY - 2);
}

int gotiusa[312345], kinnmoza[312345];

int nCr(int n, int r) {
	if (r < 0 || n < r) return 0;
	return mul(mul(gotiusa[n], kinnmoza[n - r]), kinnmoza[r]);
}

int main(void) {
	int N, A, B;
	int64_t K;
	int i;
	int mareitaso = 0;
	if (scanf("%d%d%d%" SCNd64, &N, &A, &B, &K) != 4) return 1;
	gotiusa[0] = kinnmoza[0] = 1;
	for (i = 1; i < 312345; i++) {
		gotiusa[i] = mul(gotiusa[i - 1], i);
		kinnmoza[i] = inv(gotiusa[i]);
	}
	for (i = 0; i <= N; i++) {
		int64_t hayaminn = K - (int64_t)A * i;
		int64_t mikisinn = hayaminn / B;
		if (hayaminn < 0 || hayaminn % B != 0 || mikisinn > N) continue;
		mareitaso = add(mareitaso, mul(nCr(N, i), nCr(N, (int)mikisinn)));
	}
	printf("%d\n", mareitaso);
	return 0;
}

/*

「緑色」のかわりに仮に「赤と青を混ぜた色」に塗るとすると、
「混ぜた色」の得点は「赤」+「青」の得点なので、
「赤」と「青」を独立に考えられる。

あとはつるかめ算の要領で全探索すればよい。

*/


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

int main(void) {
	char a[50],b[50],c[100];
	int i,j=0;
	cin >> a >>b;

	for(i = 0; i <=100; i++) {
	if(i%2 == 0){
	c[i] = a[j];
	}else{
	c[i] = b[j];
	j++;
	}
	}
	cout << c <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    vi t(n,-2);//マスの行き先 -1:ループ
    rep(i,n)if(t[i] == -2){
        if(a[i] == 0)t[i] = i;
        else{
            map<int,int> ma;
            int now = i;
            bool c = true;
            while(a[now]){
            //    cerr << "!" << now << endl;
                if(ma.find(now) != ma.end()){
                    c = false;
                    break;
                }
                ma[now]++;
                now = now + a[now];
                //cerr << "?" << now << endl;
            }
            for(auto itr = ma.begin(); itr != ma.end(); itr++){
                int ind = itr->first;
                //cerr << "!" << ind << endl;
                if(c)t[ind] = now;
                else t[ind] = -1;
            }
        }
    }
    //rep(i,n)cout << " " << i << " " << a[i] << " " << t[i] << endl;
    vi dp(n,INF);//dp[i]:= iに到達できる最小回数
    dp[0] = 0;
    queue<int> q;
    q.push(0);
    while(q.size()){
        int i = q.front();
        q.pop();
        if(t[i] < 0 || dp[i] == INF)continue;
        //cout << i << " " << dp[i] << endl;
        loop(j,1,7){
            if(i+j >= n)continue;
            //cerr << "!" << i+j << endl;
            int ne = t[i+j];
            if(ne == -1)continue;
            //cout << " " << i+j << " " << ne << endl;
            if(dp[ne] > dp[i]+1){
                dp[ne] = dp[i]+1;
                //cout << " " << ne << endl;
                q.push(ne);
            }
        }
    }

    cout << dp[n-1] << endl;
}



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

using namespace std;

int main(void)
{
    string S;
    cin >> S;

    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
    {
        cout << "Bad" << endl;
    }

    else
    {
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define mod        1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

int k,n;
int sh(int a,int b)
{
    return min(abs(a-b),k-max(a,b)+min(a,b));
}
void solve()
{
 
cin >> k>> n;

vii ar;
int el;
map<int,int>mp;
forf(j,0,n) 
{
    cin >> el;
    if(mp[el])continue;
    ar.pb(el);
    mp[el]=1;
}

sort(ar.begin(),ar.end());

int an = big;

for(int i=0;i<sz(ar);i++)
{
    int nx = i+1,pr=i-1;
    if(nx == sz(ar)) nx=0;
    if(pr < 0 ) pr=sz(ar)-1;
    
    an = min(an ,k-sh(ar[i],ar[pr]));
    an = min(an, k-sh(ar[i],ar[nx]));
    
}
 
 cout<<an<<endl;
 
}

int32_t main()
{
  //pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


Measured memory_bytes: 14320
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
using ll=long long;

int main(){
    const ll INF=LLONG_MAX/2;
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ret=0;
    if(n%2==0){
        vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(2,vector<ll>(2,-INF)));
        dp[0][0][0]=0;
        dp[0][1][1]=a[0];
        for(int i=1;i<n;i++){
            if(i%2==0){
                dp[i][0][0]=max(dp[i-1][0][1],dp[i-1][1][1]);
                dp[i][0][1]=-INF;
                dp[i][1][0]=-INF;
                dp[i][1][1]=dp[i-1][0][1]+a[i];
            }else{
                dp[i][0][0]=-INF;
                dp[i][0][1]=dp[i-1][1][1];
                dp[i][1][0]=-INF;
                dp[i][1][1]=dp[i-1][0][0]+a[i];
            }
        }
        ret=max(dp[n-1][0][1],dp[n-1][1][1]);
    }else{
        vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(2,vector<ll>(2,-INF)));
        dp[0][0][0]=0;
        dp[0][1][1]=a[0];
        for(int i=1;i<n;i++){
            if(i%2==0){
                dp[i][0][0]=max(dp[i-1][0][1],dp[i-1][1][1]);
                dp[i][0][1]=-INF;
                dp[i][1][0]=dp[i-1][0][0]+a[i];
                dp[i][1][1]=dp[i-1][0][1]+a[i];
            }else{
                dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0]);
                dp[i][0][1]=max(dp[i-1][0][1],dp[i-1][1][1]);
                dp[i][1][0]=-INF;
                dp[i][1][1]=dp[i-1][0][0]+a[i];
            }
        }
        ret=max(dp[n-1][0][0],dp[n-1][1][0]);
    }
    cout<<ret<<endl;
}


Measured memory_bytes: 33624
from sys import stdin, stdout # only need for big input

def solve():
    s = input() 
    left = 0
    right = len(s) - 1
    count = 0
    while left < right:
        count += (s[left] != s[right])
        left += 1
        right -= 1
    print(count)

def main():
    solve()


if __name__ == "__main__":
    main()

Measured memory_bytes: 9044
<?php
fscanf(STDIN, "%d %d", $h, $w);
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$x = $y = 0;
for ($i = 0; $i < $n; $i++) {
	$p = $i + 1;
	while ($a[$i]--) {
		$c[$x][$y] = $p;
		if ($y == $w - 1) {
			$x++;
			$y = 0;
		} else {
			$y++;
		}
	}
}
for ($i = 0; $i < $h; $i++) {
	if ($i % 2) krsort($c[$i]);
	$ans[] = implode(' ', $c[$i]);
}
echo implode("\n", $ans);

Measured memory_bytes: 6776