akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string s, t; cin >> s >> t;

    rep(i, n){
        if(s.substr(i) == t.substr(0, n - i)){
            cout << 2 * n - (n - i) << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main()
{
  ll n, a, b;
  cin >> n >> a >> b;

  ll s = n / (a + b);
  ll t = s * (a + b);

  if (n - t < a) cout << s * a + n - t << endl;
  else cout << s * a + a << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque

n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = deque( )
for i in range( n ):
    name, time = input( ).split( " " )
    processes.append( ( name, int( time ) ) )
  
qsum = 0
output = []
while len( processes ):
    process = processes.popleft( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.append( ( process[0], process[1]- q ) )
        qsum += q
 
print( "\n".join( output ) )

Measured memory_bytes: 21232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N,T;
    cin>>N>>T;
    vector<ll> t(N);
    rep(i,N)cin>>t[i];
    ll ans = T;
    rep1(i,N){
        //水が流れている間にもう一度押す
        if(t[i]<t[i-1]+T){
            ans += t[i]-t[i-1];
        }
        else{
            ans += T;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n===0)break;
   var ary=arr.shift().split(" ").map(Number);
   var obj={};
   ary.forEach(function(v){
      if(obj.hasOwnProperty(v)==false)obj[v]=1;
      else obj[v]++;
   });
   var ans="NO COLOR";
   for(var k in obj){
      if(obj[k]>n/2)ans=k;
   }
   console.log(ans);
}

Measured memory_bytes: 182048
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    vector<int>suuzi(100000);

    for(int i = 1; i<= 100; i++){
        for(int j =1; j<= 100; j++){
            for(int k =1; k<=100; k++){
                int num = i*i + j*j + k*k + i*j + j*k + k*i;
                suuzi[num]++;
            }
        }
    }

    for(int i = 1; i<=N;i++){
        cout  <<suuzi[i] << endl;
    }

}

Measured memory_bytes: 3708
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int ans = 0;
	vector< int > B(N), C(N);
	rep(i, N) B[i] = A[i] + i;
	rep(i, N) C[i] = -(A[i] - i);
	map< int, int > m;
	rep(i, N) {
		ans += m[C[i]];
		m[B[i]]++;
	}
	//cout << B << C;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30612
n=int(input())
l=[list(map(int,input().split())) for _ in [0]*n]
l1=[]
l2=[]
l3=[]
l4=[]
for i in range(n):
    if l[i][0]==0:
        if l[i][1]>0:
            l1.append(l[i])
        else:
            l3.append(l[i])
    elif l[i][0]<0:
        l2.append(l[i])
    else:
        l4.append(l[i])
L=l1+sorted(l2,key=lambda x:x[1]/x[0])+l3+sorted(l4,key=lambda x:x[1]/x[0])
L=[[0,0]]+L*2
#print(L)
for i in range(1,n*2+1):
    L[i]=[L[i-1][0]+L[i][0],L[i-1][1]+L[i][1]]
ans=0
#print(L)
for i in range(n+1):
    for j in range(i,i+n+1):
        ans=max(ans,(L[j][0]-L[i][0])**2+(L[j][1]-L[i][1])**2)
print(ans**.5)

Measured memory_bytes: 3188
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        a: [i32; n],
    );
    let mut a:Vec<i32> = a;
    a.push(-1);
    let mut fi = n;
    let mut se = n;
    for i in 0..n {
        if a[fi] <= a[i] {
            se = fi;
            fi = i;
        }
        else if a[se] <= a[i] {
            se = i;
        }
    }
    for i in 0..n {
        if i == fi {
            println!("{}", a[se]);
        }
        else {
            println!("{}", a[fi]);
        }
    }
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {

	int a,b;
	
	for (int i = 0; i < 3000; i++) {
	    cin >> a >> b;
	    if (a == 0 && b == 0) break;
	    cout << min(a,b) << " " << max(a,b) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3012
#include <iostream>

int main() {
	int a[9];
	for (auto&& e: a)
		std::cin >> e;

	int n;
	std::cin >> n;

	bool hit[9] = {};
	for (int i = 0; i < n; ++i) {
		int b;
		std::cin >> b;

		for (int i = 0; i < 9; ++i)
			if (a[i] == b)
				hit[i] = true;
	}

	bool bingo = [&]() {
		for (int i = 0; i < 3; ++i) {
			bool f1 = true, f2 = true;
			for (int j = 0; j < 3; ++j) {
				f1 = f1 && hit[i * 3 + j];
				f2 = f2 && hit[i + j * 3];
			}

			if (f1 || f2)
				return true;
		}

		bool f3 = true, f4 = true;
		for (int i = 0; i < 3; ++i) {
			f3 = f3 && hit[i * 4];
			f4 = f4 && hit[2 + i * 2];
		}

		return f3 || f4;
	}();

	std::cout << (bingo ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
memo1 = (0..4000).map{|i| i<=1000 ? 1 : 0}
cum1 = Array.new(4001, 1)
(1..4000).each{|i| cum1[i] = cum1[i-1] + memo1[i]}
memo2 = (0..4000).map{|i| (i<=1000) ? (cum1[i]) : (cum1[i] - cum1[i-1001])}
cum2 = Array.new(4001, 1)
(1..4000).each{|i| cum2[i] = cum2[i-1] + memo2[i]}
memo3 = (0..4000).map{|i| (i<=1000) ? (cum2[i]) : (cum2[i] - cum2[i-1001])}
cum3 = Array.new(4001, 1)
(1..4000).each{|i| cum3[i] = cum3[i-1] + memo3[i]}
memo4 = (0..4000).map{|i| (i<=1000) ? (cum3[i]) : (cum3[i] - cum3[i-1001])}

while (ln = gets)
  n = ln.to_i
  p memo4[n]
end


Measured memory_bytes: 7108
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793

const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}


int main(){
  int n, m, k; cin >> n >> m >> k; ll ans = 0;
  COMinit();
  for(int i=0; i<=k; i++){
    ans+=COM(n-1, i)*m%mod*modpow(m-1, max(n-i-1, 0), mod)%mod;
    //cout << ans << endl;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 27044
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	x := -1
	y := -1
	z := -1
	c := b - a*1000
	for i := 0; i <= a && c-i*9000 >= 0; i++ {
		t := float64(c - i*9000)
		if (t/4000) == float64(int(t/4000)) && a-i-int(t/4000) >= 0 {
			x = i
			y = int(t / 4000)
			z = a - x - y
			break
		}
	}
	/*
		    x+y+z = a
			x*10000 + y*5000 + z*1000 = b
		    z = a - x - y
		    x*10000 + y*5000 + (a-x-y)*1000 = b
		    x*9000 + y*4000 = b - a*1000
		    y = (b-a*1000-x*9000)/4000
	*/

	fmt.Fprintf(writer, "%d %d %d", x, y, z)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

int main(){

	while(true){
		string stl1;
		string stl2;
		cin>>stl1;
		cin>>stl2;
	
		if(stl1=="0"&&stl2=="0")
			break;

		int h=0,b=0;
	
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(stl1[i]==stl2[j]){
					if(i==j){
						h++;
					}
					else{
						b++;
					}
				}
			}
		}
		cout<<h<<' '<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int a, b;

    scanf("%d %d", &a, &b);

    int mysum;
    if (a == b) {
        mysum = a * 2;
    } else if (a > b) {
        mysum = a + (a - 1);
    } else {
        mysum = b + (b - 1);
    }

    printf("%d", mysum);


    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long k;
int main() {
    cin >> k;
    vector<string> ans;
    for(int i = 1; i <= 9; ++i) {
        ans.push_back(to_string(i));
    }
    if(k < 10) {
        cout << ans.at(k-1) << endl;
    }else {
        int now = 0;
        for(int i = 10; i <= k;) {
            int nowlen = ans.at(now).length();
            int ss = ans.at(now).at(nowlen-1) - '0';
            for(int j = max(0, ss-1); j <= min(9, ss+1); ++j) {
                string aans = ans.at(now) + to_string(j);
                ans.push_back(aans);
            }
            now++;
            i += 2;
        }
        cout << ans.at(k-1) << endl;
    }

    /*for(int i = 0; i < ans.size(); ++i) {
        cout << ans.at(i) << endl;
    }*/
}

Measured memory_bytes: 8436
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
int main(){
	ll t1,t2,a1,a2,b1,b2;
	scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2);
	ll x=t1*(b1-a1), y=t2*(b2-a2);
	ll z= x+y;
	if( z==0 ){
		puts("infinity");
		return 0;
	}
	if( (z>0&&x>0) || (z<0&&x<0) ){
		puts("0");
		return 0;
	}
	x=abs(x), z=abs(z);
	ll ans= x/z*2+((x%z)?1:0);
	ptll(ans),pt('\n');
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




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






int main() {

    
    int H, W; cin >> H >> W;
    char c[H][W];
    rep(h,H) {
        rep(w,W) cin >> c[h][w];
    }

    rep(h,H) {
        rep(w,W) {
            if (c[h][w] == '.') {
                int num = 0;
                rep(dir, 8) {
                    int nh = h + dy[dir];
                    int nw = w + dx[dir];
                    if (nh < 0 || H - 1 < nh || nw < 0 || W - 1 < nw) continue;
                    if (c[nh][nw] == '#') ++num;
                }
                cout << num;
            }
            else cout << c[h][w];
        }
        cout << endl;
    }

    


    return 0;
}






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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;


int main(){
    int n,m;
    while(scanf("%d%d", &n, &m) && n){
        ll x[n+1], c[m], dp[n+2][256];
        rep(m) scanf("%lld", &c[i]);
        x[0] = 128;
        rep(n) scanf("%lld", &x[i+1]);

        fill(dp[0], dp[n+2], LLONG_MAX);
        dp[0][128] = 0LL;
        rep(n){
            repp(j, 256){
                if(dp[i][j] == LLONG_MAX) continue;
                repp(k, m){
                    ll jj = max(0LL, min(255LL, j+c[k]));
                    ll diff = jj - x[i+1];
                    dp[i+1][jj] = min(dp[i+1][jj], dp[i][j] + diff*diff);
                }
            }
        }

        ll ans = LLONG_MAX;
        repp(j, 256) ans = min(ans, dp[n][j]);
        printf("%lld\n", ans);
    }
}



Measured memory_bytes: 43368
// AOJ 1023: Amazing Graze
// 2017.8.20 bal4u@uu
// 2017.11.9 retry

#include <stdio.h>
#include <stdlib.h>

#define MAX 100000
typedef struct { int x, y, e; } T; 
T a[MAX+5];
int AN, BN, R;

int cmp(T *a, T *b) { return a->x - b->x; }

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int bsch(int x)
{
	int m, l = 0, r = AN;
    while (l < r) {
        m = (l + r) >> 1;
        if (a[m].x <= x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int x, y, i, j, r, r2, ans;

	while (fgets(p=buf, 30, stdin) && *p != '0') {
		AN = getint(), p++, BN = getint(), p++, R = getint();
		for (i = 0; i < AN; i++) {
			fgets(p=buf, 20, stdin);
			a[i].x = getint(), p++, a[i].y = getint(), a[i].e = 0;
		}
		qsort(a, AN, sizeof(T), cmp);
		r = R << 2, r2 = r*r;
		for (i = 0; i < BN; i++) {
			fgets(p=buf, 20, stdin);
			x = getint(), p++, y = getint();
			for (j = bsch(x-r-1); j < AN && a[j].x <= x+r; j++) {
				if ((a[j].x-x)*(a[j].x-x) + (a[j].y-y)*(a[j].y-y) <= r2) a[j].e++;
			}
		}
		for (ans = 0, i = AN; i--; ) ans += a[i].e;
		printf("%d\n", ans);
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  string half = s.substr(0,n/2);
  if(s == half+half){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327
#define NUM 1000000007
#define ss second
#define ff first
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int n, k;
	string s;
	cin >> n >> k;
	getline(cin >> ws, s);
	s[k - 1] = tolower(s[k - 1]);
	
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=998244353;
int INF=1e11;

void solve(){
	int n,k;
	cin>>n>>k;
	v<p<int,int>> r(k);
	rep(i,0,k){
		cin>>r[i].f>>r[i].s;
	}
	sort(all(r));
	vi dp(n,0);
	for(int i=0;i<n;i++){
		if(i==0){
			dp[i]=1;
		}
		else{
			for(int j=0;j<k;j++){
				if(r[j].f>i){
					break;
				}
				else if(r[j].f==i){
					dp[i]++;
					break;
				}
				int u=min(i,r[j].s);
				int l=r[j].f;
				if(i-1-u<0){
					dp[i]=(dp[i]+dp[i-l])%modF;
				}
				else{
					dp[i]=(dp[i]+dp[i-l]-dp[i-u-1]+modF)%modF;
				}
			}
			dp[i]=(dp[i]+dp[i-1])%modF;
		}
		// debug(dp[i])
	}
	cout<<(dp[n-1]-dp[n-2]+modF)%modF<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 4780
#include<stdio.h>
int main(void){
  int x,y,z,a,b,c;
  scanf("%d %d %d",&x,&y,&z);
  a=z;
  b=x;
  c=y;
  printf("%d %d %d\n",a,b,c);
  return 0;
}
  
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i ++)
 
int main(void){
    string str;
    int n;
    cin >> str;
    cin >> n;
    
    vector<string> dict(5, "zzzzzz");
    
    for(int len = 1; len <= 5; len ++){
        for(int j = 0; j + len <= str.size(); j ++){
            string sub = str.substr(j, len);
            for(int i = 0; i < 5; i ++){
                if(sub == dict[i]) break;
                if(sub < dict[i]){
                    dict.insert(dict.begin() + i, sub);
                    dict.pop_back();
                    break;
                }
            }
        }
    }
    
    cout << dict[n-1] << "\n";
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003,INF=10000;

int main(){
    
    int N;cin>>N;
    vector<pair<double,double>> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].first>>S[i].second;
    }
    
    for(int i=0;i<N;i++){
        double a1=0,a2=M_PI,b1=M_PI,b2=M_PI*2.0;
        double ans=0.0;
        for(int j=0;j<N;j++){
            if(i==j) continue;
            if(S[i].first==S[j].first){
                if(S[i].second<S[j].second){
                    a1=0.0;
                    a2=0.0;
                }else{
                    b1=M_PI*2.0;
                    b2=M_PI*2.0;
                }
            }else if(S[i].first>S[j].first){
                if(S[i].second==S[j].second){
                    a2=min(a2,M_PI/2.0);
                    b1=max(b1,M_PI*1.5);
                }else if(S[i].second>S[j].second){
                    double x=S[i].first-S[j].first,y=S[i].second-S[j].second;
                    double a=-x/y;
                    a2=min(a2,atan(a)+M_PI);
                    b1=max(b1,atan(a)+M_PI*2.0);
                }else if(S[i].second<S[j].second){
                    double x=S[i].first-S[j].first,y=S[i].second-S[j].second;
                    double a=-x/y;
                    a2=min(a2,atan(a));
                    b1=max(b1,atan(a)+M_PI);
                }
            }else if(S[i].first<S[j].first){
                if(S[i].second==S[j].second){
                    a1=max(a1,M_PI/2.0);
                    b2=min(b2,M_PI*1.5);
                }else if(S[i].second>S[j].second){
                    double x=S[i].first-S[j].first,y=S[i].second-S[j].second;
                    double a=-x/y;
                    a1=max(a1,atan(a));
                    b2=min(b2,atan(a)+M_PI);
                }else if(S[i].second<S[j].second){
                    double x=S[i].first-S[j].first,y=S[i].second-S[j].second;
                    double a=-x/y;
                    a1=max(a1,atan(a)+M_PI);
                    b2=min(b2,atan(a)+M_PI*2.0);
                }
            }
        }
        if(a1<a2) ans+=(a2-a1)/(M_PI*2.0);
        if(b1<b2) ans+=(b2-b1)/(M_PI*2.0);
        cout<<setprecision(15)<<ans<<endl;
    }
}


Measured memory_bytes: 768
function main( input )
{
  input = input.trim().split("\n");

  for( var i = 0; i < input.length; ++i )
  {
    var ln = input[i].split(" ");

    var a = parseInt(ln.shift());
    var b = parseInt(ln.shift());

    console.log( (a+b).toString().length );
  }
}

main( require("fs").readFileSync( "/dev/stdin", "utf8" ) );

Measured memory_bytes: 15972
from itertools import product
N, M = map(int, input().split(" "))
s = []
for i in range(M):
    s.append(list(map(int, input().split(" ")))[1:])

p = list(map(int, input().split(" ")))
ans = 0
for tup in product(range(2), repeat=N):
    for i in range(M):
        flg = True
        cnt = 0
        for d in s[i]:
            cnt += tup[d - 1]
        if cnt % 2 != p[i]:
            flg = False
            break

    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[H+1];
    rep(i, H) {
        cin >> S[i];
    }
    int ans[H][W] = {};
    rep(i, H) {
        rep(j ,W) {
            if (S[i][j+1] == '#') {
                ans[i][j]++;
            }
            if (j - 1 >= 0) {
                if (S[i][j-1] == '#') {
                ans[i][j]++;
                }
            }
            if (S[i+1][j] == '#') {
                ans[i][j]++;
            }
            if (i - 1 >= 0) {
                if (S[i-1][j] == '#') {
                    ans[i][j]++;
                }
            }
            if (S[i+1][j+1] == '#') {
                ans[i][j]++;
            }
            if (j - 1 >= 0 && i - 1 >= 0) {
                if (S[i-1][j-1] == '#') {
                    ans[i][j]++;
                }
            }
            if (i - 1 >= 0) {
                if (S[i-1][j+1] == '#') {
                    ans[i][j]++;
                }
            }
            if (j - 1 >= 0) {
                if (S[i+1][j-1] == '#') {
                    ans[i][j]++;
                }
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') {
                cout << "#"; 
            }
            else {
                cout << ans[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [0]
a += list(map(int, input().split()))
ans = [0]*(N+1)
for i in range(N, 0, -1):
    if i > N/2:
        ans[i] = a[i]
    elif i == 1:
        cnt = sum(ans)
        ans[i] = (a[i] + cnt) % 2
    else:
        num = N // i
        cnt = 0
        for j in range(2, num+1):
            cnt += ans[i * j]
        ans[i] = (a[i] + cnt) % 2

print(sum(ans))
s = ""
for i in range(N+1):
    if ans[i] == 1:
        s += str(i) + " "
print(s)

Measured memory_bytes: 9148
/**
2018/10/20/ 解説AC　理解はしたが自力で実装できるか怪しい
**/
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;
 
int N, M, a[51], b[51];
bool graph[51][51];
bool visited[51];
 
void dfs(int v){

    for(int i = 0; i < N; i++){
        if(graph[v][i] == true && visited[i] == false){
            visited[i] = true;
            dfs(i);
        }
    }

}
 
int main(){

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
 
    int ans = 0;
    for(int i = 0; i < M; i++){

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
 
        for(int j = 0; j < N; j++) visited[j] = false;

        visited[0] = true;
 
        dfs(0);

        for(int j = 1; j < N; j++){
            if(visited[j] == false){
                ans++;
                break;
            }
        }

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main()
{
	vector< pair<string,int> > v;
	pair<string,int> w;
	while(cin>>w.first>>w.second)
	{
		v.push_back(w);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(i==0)
		{
			cout<<v[i].first<<endl<<v[i].second;
		}
		else if(v[i].first!=v[i-1].first||i==0)
		{
			cout<<endl<<v[i].first<<endl<<v[i].second;
		}
		else
		{
			cout<<" "<<v[i].second;
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"

using namespace std;

enum FACE { TOP = 0, SOUTH = 1, EAST = 2, WEST = 3, NORTH = 4, BOTTOM = 5 };
class Dice {
 public:
  Dice(int top, int south, int east, int west, int north, int bot) {
    id[TOP] = top;
    id[SOUTH] = south;
    id[EAST] = east;
    id[WEST] = west;
    id[NORTH] = north;
    id[BOTTOM] = bot;
  }
  Dice(vector<int> fs) {
    assert((int)fs.size() == 6);
    for (int i = 0; i < 6; i++) {
      id[i] = fs[i];
    }
  }
  int& operator[](FACE f) { return id[f]; }
  const int& operator[](FACE f) const { return id[f]; }
  bool operator==(const Dice& b) const {
    const Dice& a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] && a[SOUTH] == b[SOUTH] &&
           a[NORTH] == b[NORTH] && a[WEST] == b[WEST] && a[EAST] == b[EAST];
  }
  // TOP -> SOUTH
  void roll_x() { roll(TOP, NORTH, BOTTOM, SOUTH); }
  // TOP -> EAST
  void roll_y() { roll(TOP, WEST, BOTTOM, EAST); }
  // SOUTH -> WEST
  void roll_z() { roll(SOUTH, EAST, NORTH, WEST); }
  vector<Dice> all_rolls() {
    vector<Dice> ret;
    for (int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), ++k)
      for (int i = 0; i < 4; roll_z(), ++i) ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const Dice& di) {
    for (int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), ++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }

 private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    auto tmp = id[a];
    id[a] = id[b];
    id[b] = id[c];
    id[c] = id[d];
    id[d] = tmp;
  }
  int id[6];
};

int main() {
  vector<int> v(6);
  for (int i = 0; i < 6; i++) cin >> v[i];
  Dice dc(v);
  string s;
  cin >> s;
  for (auto c : s) {
    if (c == 'S') dc.roll_x();
    if (c == 'N') {
      for (int i = 0; i < 3; i++) dc.roll_x();
    }
    if (c == 'E') dc.roll_y();
    if (c == 'W') {
      for (int i = 0; i < 3; i++) dc.roll_y();
    }
  }
  cout << dc[TOP] << endl;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
using namespace std;
 
 
#define all(x) (x).begin(),(x).end()
 
#define FOR(i,x,n)for(int i=(x);i<(n);i++)
#define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
#define REP(i, n) FOR(i, 0, n)
#define REP_R(i, n) FOR_R(i, 0, n)
 
using ll = long long;
typedef long long ll;
typedef long long int64;
typedef long long lint;
typedef long long lli;
 
 
 
//bit
 
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
 
 
 
//variables
 
int N=0;
int K=0;
 
const int INF = INT_MAX/2;
int ans=0;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
////////////////////////////////////////////////////////////////
	 
int main(){
 
	cin >> N >> K;
 
	vector<int> data(N);
	FOR(i,1,N+1) cin >> data[i];
 
  	int dp[N];
  	FOR(i,1,N+1)dp[i] = INF;
  	dp[1]=0;
  
  	FOR(i,1,N+1){FOR(j,1,K+1){
    	if(i - j >= 1)dp[i] = min(dp[i],dp[i-j]+abs(data[i]-data[i-j]));
      	//cout << dp[i] << endl;
    }}
	
	
	cout << dp[N] << endl;
	return 0; 
}

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

using namespace std;

char s[200005];

int main() {
    int n;
    scanf("%d%s", &n, s);

    int totw = 0;
    int totr = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') totw++;
        else totr++;
    }

    int curw = 0;
    int res = 1e9;

    for (int i = 0; i <= n; i++) {
        int curr = n - i - totw + curw;
        res = min(res, max(curw, curr));

        if (i != n && s[i] == 'W') curw++;
    }

    printf("%d\n", res);
}


Measured memory_bytes: 3940
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

vector<ll>ans;
void dfs(int i,int j,ll cur) {
    if(i==10) return;
    ans.push_back(cur);
    if(j>=1)dfs(i+1,j-1,cur*10+j-1);
    dfs(i+1,j,cur*10+j);
    if(j<=8)dfs(i+1,j+1,cur*10+j+1);
}

int main() {
    int k;
    cin >> k;
    for(ll i = 1;i<=9;i++) {
        dfs(0,i,i);
    }
    sort(ans.begin(),ans.end());
    cout << ans[k-1] << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int q; cin >> q;
    vector<int> b(q), c(q); rep(i,q) cin >> b[i] >> c[i];
    map<int,int> cnt;
    rep(i,n) cnt[a[i]]++;
    ll sum = 0;
    for(auto v : cnt) sum += (ll)v.first*v.second;
    rep(i,q) {
        if(cnt[b[i]]){
            int tmp = cnt[b[i]];
            cnt[c[i]] += tmp;
            cnt[b[i]] = 0;
            sum += (ll)(c[i] - b[i])*tmp;
        }
        cout << sum << endl;
    }
    return 0; 
}

Measured memory_bytes: 8640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    vector<string> str(3, "");
    for (int i = 0; i < 3; i++) {
        cin >> str[i]; reverse(str[i].begin(), str[i].end());
    }
    int now = 0, tmp = 0;
    while (true) {
        if (str[now].length() == 0) break;
        if (str[now][str[now].length() - 1] == 'a') {
            tmp = 0;
        };
        if (str[now][str[now].length() - 1] == 'b') {
            tmp = 1;
        };
        if (str[now][str[now].length() - 1] == 'c') {
            tmp = 2;
        };
        str[now].pop_back();
        now = tmp;
    }
    cout << (char)(now + 65) << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>

void color(std::vector<std::vector<int> > n) {
	std::vector<int> color(n.size(), 0);
	std::stack<int> s;

	int count = 1;
	for (size_t i = 0; i < n.size(); i++) {
		if (color[i] != 0) continue;
		color[i] = count;
		s.push(i);
		while (s.size() != 0) {
			int num = s.top(); s.pop();
			for (std::vector<int>::iterator it = n[num].begin(); it != n[num].end(); it++) {
				if (color[*it] == 0) {
					s.push(*it);
					color[*it] = count;
				}
			}
		}
		count++;
	}

	int question;
	std::cin >> question;
	for (int i = 0; i < question; i++) {
		int from, to;
		std::cin >> from >> to;
		if (color[from] == color[to]) {
			std::cout << "yes" << std::endl;
		} else {
			std::cout << "no" << std::endl;
		}
	}

}

int main() {
	int people, relation;

	std::cin >> people >> relation;

	std::vector<std::vector<int> > n(people);

	for (int i = 0; i < relation; i++) {
		int from, to;
		std::cin >> from >> to;
		n[from].push_back(to);
		n[to].push_back(from);
	}

	color(n);

	return 0;
}

Measured memory_bytes: 12356
package main

import (
	"fmt"
	"sort"
)

func main() {
	vs := make([]int, 3)
	fmt.Scan(&vs[0], &vs[1], &vs[2])
	sort.Ints(vs)

	res := vs[2] - vs[1] + vs[2] - vs[0]
	if res%2 == 0 {
		fmt.Println(res / 2)
	} else {
		fmt.Println((res + 3) / 2)
	}
}


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

using namespace std;
vector<int> v;
void dfs(int n,int s){
	if(n==9)return;
	v.push_back(10*s + 3);
	v.push_back(10*s + 5);
	v.push_back(10*s + 7);
	dfs(n+1,10*s + 3);
	dfs(n+1,10*s + 5);
	dfs(n+1,10*s + 7);
}
int main(void){
	int N;
	cin >> N;
	dfs(0,0);
	sort(v.begin(),v.end());
	int ans = 0;
	for(int i=0;i<v.size();i++){
		if(v[i]>N)break;
		bool flag[3]={0,0,0};
		string S = to_string(v[i]);
		for(int i=0;i<S.size();i++){
			if(S[i]=='3')flag[0]=1;
			if(S[i]=='5')flag[1]=1;
			if(S[i]=='7')flag[2]=1;
		}
		if(flag[0]&&flag[1]&&flag[2])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 10000
int se(int a,int A[],int b,int B[]);
int main(){
  int a,A[N];
  int b,B[N];
  int i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
  }
  printf("%d\n",se(a,A,b,B));
  return 0;
}




int se(int a,int A[],int b,int B[]){
  int i,j;
  int c=0;
  for(j=0;j<b;j++){
  for(i=0;i<a;i++) {
    if(A[i]==B[j]){
      c++;
      break;
    }
  }
 }
return c;

}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL s;
        cin>>s;
        if(s>=30) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> v;
vector<int> cnt;
int N, M, G;
double p[8][8] = {};
double memo[390626];
int pow5[8];
double dfs(const int S){
  if(memo[S] >= 0) return memo[S];
  if(S == G) return memo[S] = 1.0;
  vector<int> cur(N);
  int idx = 0;
  int TMPS = S;
  REP(i, N){
    cur[i] = TMPS % 5;
    idx += cur[i];
    TMPS /= 5;
  }
  if(idx == v.size()) return memo[S] = 0.0;
  int u = v[idx];
  memo[S] = 0;
  REP(v, N){
    if(cur[v] + 1 > cnt[v]) continue;
    int NS = S + pow5[v];
    memo[S] += p[u][v] * dfs(NS);
  }
  return memo[S];
}

int main(){
  pow5[0] = 1;
  for(int i = 1; i < 8; i++) pow5[i] = 5 * pow5[i - 1];
  int CASENUM = 1;
  while(cin >> N && N){
    printf("Case %d: ", CASENUM++);
    v.clear();
    cnt = vector<int>(N);
    G = 0;
    REP(i, 390626) memo[i] = -1.0;

    REP(i, N) REP(j, N) cin >> p[i][j];

    REP(i, N){
      int t; cin >> t;
      cnt[i] = t;
      REP(j, t) v.push_back(i);
      G += t * pow5[i];
    }

    M = v.size();

    double ans = dfs(0);
    if(ans == 0.0) cout << "-INFINITY" << endl;
    else printf("%.8lf\n", log(ans));
  }
  return 0;
}

Measured memory_bytes: 4396
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk)
{

var line = chunk.toString().trim().split(' ');

var a = Number(line[0]);
var b = Number(line[1]);
var c = Number(line[2]);

if (a < b && b < c){
 console.log("Yes");
} else{
 console.log("No");
}


});

Measured memory_bytes: 15508
using System;
class Program
{
	static void Main()
	{
    int howmany = 0;//差
    int multypleNum = 1;//交互にかける数。
    int a = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
    int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
//入力を受け取り、string[]型をint[]型に変換
	Array.Sort(nums);//小さい順にする
	Array.Reverse(nums);//逆順にする
      
      for(int i = 0;i<nums.Length;i++)
      {
        howmany += multypleNum * nums[i];
        multypleNum *= -1;//+-の交換
      }
      
	Console.WriteLine(howmany);//WriteLineをWriteとすると、改行なしで出力。
	}
  
}

Measured memory_bytes: 11220
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         ll n;cin>>n;
         if(n)cout<<"0";
         else cout<<"1";
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a[3][3] = {};
	bool f[3][3] = {};
	REP(i, 3) REP(j, 3) cin >> a[i][j];
	int n;
	cin >> n;
	REP(i, n){
		int b;
		cin >> b;
		REP(j, 3){
			REP(k, 3){
				if(a[j][k] == b){
					f[j][k] = true;
				}
			}
		}
	}
	bool ans = false;
	REP(i, 3){
		bool g = true;
		REP(j, 3){
			g &= f[i][j];
		}
		if(g) ans = true;
	}
	REP(j, 3){
		bool g = true;
		REP(i, 3){
			g &= f[i][j];
		}
		if(g) ans = true;
	}
	if(f[0][0] & f[1][1] & f[2][2]) ans = true;
	if(f[0][2] & f[1][1] & f[2][0]) ans = true;
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0]
#print(a)
for i in a:
    s.append((s[-1]+i)%k)
#print(s)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
    if s[i] in mp:
        mp[s[i]]+=1
    else:
        mp[s[i]]=1
    #print(i,ans)
print(ans)
#ans+=sum(list(map(lambda x: x==0,s)))
#print(ans)


Measured memory_bytes: 40612
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(b < n*a) {
        cout << b;
    }
    else {
        cout << n*a;
    }
    

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import numpy as np
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)]
e_from = [[] for _ in range(N+1)]
e_to = [[] for _ in range(N+1)]
for a, b in AB:
    e_from[a].append(b)
    e_to[b].append(a)


add = np.zeros(N+1, dtype=int)
rank = [-1]*(N+1)

# まず根を探す
for i in range(1, N+1):
    add[i] = len(e_to[i])
    if len(e_to[i]) == 0:
        root = i

# BFS
rank[root] = 0
node = deque([root])
while node:
    s = node.popleft()
    add[e_from[s]] -= 1
    for t in e_from[s]:
        if add[t] == 0:
            rank[t] = s
            node.append(t)

print(*rank[1:], sep="\n")


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

using namespace std;

using ll = long long;

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

typedef pair<int, int> P;

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

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

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, d;
	cin >> n >> m >> d;
	
	int cnt = 0;
	if (d == 0) {
		cnt = n;
	} else {
		FOR(i, 1, n + 1) {
			if (i + d <= n) cnt++;
			if (i - d >= 1) cnt++;
		}
	}
	
//	cout << cnt << endl;

//	cout << (double) ((cnt) * pow(n, (m - 1))) / pow(n, m) << endl;
//	cout << (double) (cnt) / n << endl;
//	if (d == 0) cnt = cnt / 2;
//	cout << ((long double) (m - 1) / (long double) n) * ((long double) cnt / (long double) n) << endl;
	printf("%.9f\n",((double) (m - 1) / (double) n) * ((double) cnt / (double) n));
	
	return 0;
}

Measured memory_bytes: 512