akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn num_to_array(mut n: u64) -> Vec<u64> {
    let mut v = Vec::new();
    let d = 10;
    while n != 0 {
        v.push(n % d);
        n /= d;
    }
    v.reverse();
    v
}

pub fn array_to_num(a: &[u64]) -> u64 {
    let mut n = 0;
    let mut d = u32::pow(10, (a.len() - 1) as u32) as u64;
    for i in a {
        n += i * d;
        d /= 10;
    }
    n
}

fn main() {
    input! {
        n: u64,
        k: usize,
        d: [u64;k]
    }
    for i in 0.. {
        let a = num_to_array(n + i);
        if a.iter().all(|x| !d.contains(x)) {
            println!("{}", array_to_num(&a));
            return;
        }
    }
}

Measured memory_bytes: 4352
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	c := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		v[i] = getInt()
	}
	for i := 0; i < N; i++ {
		c[i] = getInt()
	}
	n := 1 << uint(N)
	ans := -10001000100
	for i := 0; i < n; i++ {
		C := 0
		V := 0
		for j := 0; j < N; j++ {
			if (i>>uint(j))%2 == 1 {
				C += c[j]
				V += v[j]
			}
		}
		// fmt.Printf("%b %d %d\n", i, V, C)
		ans = max(ans, V-C)
	}
	out(ans)
}


Measured memory_bytes: 640
n = []
d = []
while True:
    n = [int(i) for i in input().split()]
    if n[0] == 0 and n[1] == 0:
        break
    else:
        n.sort()
        d.append(n)

for i in range(len(d)):
    print(" ".join(map(str, d[i])))



Measured memory_bytes: 5980
import sys

N = int(input())
A = list(map(int, input().split()))

# print(A)
ans = 1
MAX = 10 ** 18
if 0 in A:
    print(0)
    sys.exit()
for a in A:
    ans *= a
    if ans > MAX:
        print(-1)
        sys.exit()
print(ans)


Measured memory_bytes: 21600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, K; cin >> N  >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }       

    vector<ll> S(N+1);
    S[0] = 0;
    for (int i = 1; i <= N; i++) {
        S[i] = (K + S[i-1] + A[i-1] - 1) % K;
    }

    map<ll,ll> mp;
    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        ans += mp[S[i]];
        if(i >= K-1){
            mp[S[i-K+1]]--;
        }
        if(!mp.count(S[i])){
            mp[S[i]] = 0;
        }
        mp[S[i]]++;
    }
    printf("%lld\n", ans);



}


Measured memory_bytes: 15872
object Main extends App {
  val sc = new FastScanner(System.in)
  val r, c, k = sc.nextInt()
  val rcv = List.fill(k)((sc.nextInt()-1, sc.nextInt()-1, sc.nextLong()))

  def composev(x1: Int, x2: Int): Int = {
    x1 * c + x2
  }

  def compose2(x1: Int, x2: Int): Int = {
    x1 * 4 + x2
  }

  val v = Array.fill(r * c)(0L)
  for ((ri, ci, vi) <- rcv) {
    v(composev(ri, ci)) = vi
  }

  val dp = Array.fill(c * 4)(0L)
  def maxOfDp(x1: Int): Long = {
    dp(compose2(x1, 0)).max(
      dp(compose2(x1, 1))).max(
      dp(compose2(x1, 2))).max(
      dp(compose2(x1, 3)))
  }

  dp(compose2(0, 1)) = v(composev(0, 0))
  for {
    i <- 0 until r
    j <- 0 until c
    if !(i == 0 && j == 0)
  } {
    val max = maxOfDp(j)
    for (k <- 0 to 3) {
      var x = Long.MinValue
      if (k <= 1 && i != 0) {
        x = x.max(max + (if (k == 1) v(composev(i, j)) else 0))
      }

      if (j != 0) {
        x = x.max(dp(compose2(j-1, k)))
        if (k != 0) {
          x = x.max(dp(compose2(j-1, k-1)) + v(composev(i, j)))
        }
      }
      dp(compose2(j, k)) = x
    }
  }

  println(maxOfDp(c-1))
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


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

int main() {
  int64_t N;
  int64_t X=0;
  cin >>N;
  for(int i=0; i<N; i++){
    if((i+1)%3==0){
      continue;
    }
    else if((i+1)%5==0){
      continue;
    }
    else{
      X = X + (i+1);
    }
  }
  cout <<X  <<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll MOD = 1000000007;

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;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  COMinit();  
  int n;
  cin >> n;
  ll ans=0;
  rep(i,n){
    int j=i+1;
    ans+=COM(n-3*j+i,n-3*j);
    ans%=MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15576
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main() {
	int  N;
	long int T2, T1;
	long int A2, A1;

	scanf("%d",&N);
	scanf("%ld %ld", &T1, &A1);
	for (int i = 1; i < N; i++) {
		scanf("%ld %ld", &T2, &A2);
		
		long int m = MAX(T1 /T2 + (T1%T2 ? 1 : 0), A1 /A2 + (A1%A2 ? 1 : 0));
		
		T1 = T2 * m;
		A1 = A2 * m;
	}
	printf("%ld", T1 + A1);

	return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int ds(int x) {
    return x == 0 ? 0 : x % 10 + ds(x / 10);
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; cin >> n;
    int ans = 100000;
    for (int a = 1, b = n - 1; b >= 1; a++, b--) ans = min(ans, ds(a) + ds(b));
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = 0;
		int m = 0;

		int H1 = sc.nextInt();
		int M1 = sc.nextInt();
		int H2 = sc.nextInt();
		int M2 = sc.nextInt();
		int K = sc.nextInt();

		h = H2 - H1;
		if (M2 >= M1) {
			m = M2 - M1;
		} else {
			m = 60 - M1 + M2;
			h--;
		}

		System.out.println((h * 60) + m - K);

	}

}

Measured memory_bytes: 35828
//include
//------------------------------------------
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<algorithm>

using namespace std;

int main() {
	int n, p, cup;
	while (cin >> n >> p, n | p)
	{
		cup = p;
		vector<int> v(n, 0);
		int i = 0;
		while (true)
		{
			if (cup) {
				v[i]++;
				cup--;
			}else{
				cup = v[i];
				v[i] = 0;
			}
			if (v[i] == p)break;
			if (i++ == n - 1) i = 0;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
int main()
{
	int n,mins,maks;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int input;
		cin>>input;
		if(i==1)
			mins=input,maks=input;
		else
			mins=min(mins,input),maks=max(maks,input);
	}
	cout<<maks-mins<<endl;
}

Measured memory_bytes: 256
#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;

int N,n;
P p[300000],dat[1200000];
void init(int n){N=1;while(N<n)N<<=1;fill(dat,dat+2*N-1,P(0,0));}
void update(int k,int x){k+=N-1;dat[k]={x,k-N+1};while(k>0)k=(k-1)/2,dat[k]=max(dat[k*2+1],dat[k*2+2]);}
bool ok(int t){init(t);ll s=0,sum=0;for(int i=n-1;i>=n-t+1;i--)update(s++,p[i].second),sum+=p[i].second;if(p[n-t].first*(ll)t>=(ll)sum+p[n-t].second)return 1;for(int i=n-t;i>0;i--){if(dat[0].first>p[i].second)sum-=dat[0].first-p[i].second,update(dat[0].second,p[i].second);if(p[i-1].first*(ll)t>=(ll)sum+p[i-1].second)return 1;}return 0;}
int main() {
	scanf("%d",&n);
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);
		p[i]={b,a};
	}sort(p,p+n);
	int a=0,b=n;while(a!=b){int t=(a+b)/2;if(b-a==1)t=b;if(ok(t))a=t;else b=t-1;}
	printf("%d\n",a);
}

Measured memory_bytes: 13740
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,ans;
    ans=0;
    b=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(i%2==1){
            if(s[i]=='R')
            b=1;
        }
        if(i%2==0&&s[i]=='L')
        b=1;
    }
   if(b==1)
   cout<<"No"<<endl;
   else
   cout<<"Yes"<<endl;
    
}


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

int main() {
  int  A, B, C;
  cin >> A >> B >> C;

  for (int i = 1; i <= B; ++i) {
      if (A*i%B == C) {
          cout << "YES" << endl;
          return 0;
      }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin >> s;
  int a = 0;
  
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') a++;
  }
  cout << 700 + 100 * a << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
ll X[1010],Y[1010],Z[1010];
ll dp[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>X[i]>>Y[i]>>Z[i];
	
	ll ma=0;
	for(int mask=0;mask<8;mask++) {
		FOR(j,1010) dp[j]=-1LL<<60;
		dp[0]=0;
		FOR(i,N) {
			ll val=0;
			val += X[i]*((mask&1)?1:-1);
			val += Y[i]*((mask&2)?1:-1);
			val += Z[i]*((mask&4)?1:-1);
			
			for(j=N;j>=0;j--) dp[j+1]=max(dp[j+1],dp[j]+val);
		}
		ma=max(ma,dp[M]);
	}
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int ary[n];
  
  for (int i = 0; i < n; i++) {
    scanf("%d", &ary[i]);
  }

  int ans = 1;
  int min = ary[0];

  for (int i = 0; i < n-1; i++) {
    if (min > ary[i]) {
      min = ary[i];
    }  
     
    if (min > ary[i + 1]) {
      ans++;
    }
  }

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


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> cnt(N, 0);
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        cnt[a - 1]++;
    }

    sort(cnt.begin(), cnt.end());
    int ans = 0;
    for(int i=0;i<N-K;i++){
        ans += cnt[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<set>

using namespace std;
int main(){
int H,W;
cin >>H>>W;
int h,w;
cin >>h>>w;

  cout<<(H-h)*(W-w)<<endl;
}


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

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

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

	vector<int> h(n);
	for(auto &e : h) cin >> e;

	int max_up = 0, max_down = 0;
	for(int i = 0; i < n - 1; ++i) {
		chmax(max_up, h[i + 1] - h[i]);
		chmax(max_down, h[i] - h[i + 1]);
	}

	cout << max_up << " " << max_down << endl;
}

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

	int t;
	cin >> t;
	while(t--) solve();

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  bool flag = true;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    if (a % 2 == 1)
      flag = false;
  }
  if (flag)
    cout << "second" << endl;
  else
    cout << "first" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 200000

int main(){
  int n,num[N],i,max,min;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)scanf("%d",&num[i]);
  
  max=num[1]-num[0];
  min=num[0];
  for(i=1;i<n;i++){
    if(num[i]-min>max)max=num[i]-min;
    if(min>num[i])min=num[i];
  }
  
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int ch;

  while ( ( ch = getchar ( ) ) != EOF )
  {
    if ( ch == '@' )
    {
      int n;

      n = getchar ( ) - '0';
      ch = getchar ( );
      while ( n-- ) putchar ( ch );
    }
    else
    {
      putchar ( ch );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main(void) {
	std::string str;
	std::cin >> str;

	for (int i = 0; i < str.length(); ++i) {
		if (i % 2 == 0) {
			std::cout << str[i];
		}
	}
	return 0;
}


Measured memory_bytes: 512
/* competitive programming circle traP */
/* template */
#include <stdio.h>

int mp[8][8];

void bomb(int y,int x){
  mp[y][x] = 0;
  for(int d=-3;d<=3;d++){
    if(d==0)continue;
    // y + d
    if(0<=y+d && y+d<8){
      if(mp[y+d][x]==1)bomb(y+d,x);
    }
    // x + d
    if(0<=x+d && x+d<8){
      if(mp[y][x+d]==1)bomb(y,x+d);
    }
  }
}

int main(){
  int t;
  scanf("%d",&t);
  for(int no=0;no<t;no++){
    // input
    for(int i=0;i<8;i++){
      char s[10];
      scanf("%s",&s);
      for(int j=0;j<8;j++){
        mp[i][j] = (s[j]-'0');
      }
    }
    int x,y;
    scanf("%d%d",&x,&y);
    // calc(dfs)
    bomb(y-1,x-1);
    // output
    printf("Data %d:\n",no+1);
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++)printf("%d",mp[i][j]);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    for (ll i = 1; i<=3500;++i) {
        for (ll j = i; j<=3500 ; ++j) {
            ll left = 1, right = 3500;
            while (left <= right) {
                ll k = (left + right) / 2;

                ll a = 4ll*i*j*k;
                ll b = i*j + j*k + i*k;

                // cout << left << " " << right << endl;
                // cout << k << endl;
                // cout << N * b << endl;
                // cout << a << endl;
                // cout << i << " " << j << " " << k << endl;
                // cout << a << endl;
                // cout << b << endl;
                // cout << a%b << endl;
                // cout << a/b << endl;

                if (a%b == 0 && a/b == N) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }

                if (N * b > a) {
                    left = k + 1;
                } else {
                    right = k - 1;
                }
            }

            // for (ll k=j; k<=3500 ; ++k) {
            //     ll a = 4ll*i*j*k;
            //     ll b = i*j + j*k + i*k;
            //     // cout << i << " " << j << " " << k << endl;
            //     // cout << a << endl;
            //     // cout << b << endl;
            //     // cout << a%b << endl;
            //     // cout << a/b << endl;
            //     if (a%b == 0 && a/b == N) {
            //         cout << i << " " << j << " " << k << endl;
            //         return 0;
            //     }
            // }
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){

int f,s;
int a,b,c;

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

if(a==5){
f++;
}else if(a==7){
s++;
}

if(b==5){
f++;
}else if(b==7){
s++;
}

if(c==5){
f++;
}else if(c==7){
s++;
}

if(f==2 && s==1){

printf("YES\n");

}else{

printf("NO\n");

return 0;

}

}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
Ns = list(map(int,input().split()))

num1 = 0
num4 = 0
num7 = 0
num9 = 0

for n in Ns:
    if n == 1:
        num1 +=1
    if n == 4:
        num4 +=1
    if n == 7:
        num7 +=1
    if n == 9:
        num9 +=1
    
if num1 == 1 and num4 == 1 and num7 == 1 and num9 == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main(void) {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	map<int,int> al;
	priority_queue<int, vector<int>, greater<int>> pq;
	REP(i, n) {
		scanf("%d", &a[i]);
		al[a[i]]++;
	}
	int cs = al.size();
	for (auto itr : al) {
		pq.push(itr.second);
	}

	int ans = 0;

	while(cs > k) {
		ans += pq.top();
		pq.pop();
		cs--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11516
#include <stdio.h>
int main(void){
	
	int W,H,x,y,r;
	
	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	
	if((x+r)<=W && (x-r)>=0 && (y+r)<=H && (y-r)>=0){
					
	printf("Yes\n");
	}
	
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0); 

    string s;
    cin>>s;
    if (s[s.size()-1]=='s')
    {
    	cout<<s;
    	cout<<"es"<<endl;
    }   	
   else{
   	cout<<s<<"s"<<endl;
   }
   	return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int main(void){
	int H, W, i, j;
	while(1){
		//数値を2つ入力
		scanf("%d %d", &H, &W);
		//2つの数値が0なら終了
		if(H == 0 && W == 0){
			break;
		}
		//チェック柄の四角形を出力
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if((i % 2) == 0){
					if((j % 2) == 0 && j == (W - 1)){
						printf("#\n");
					}else if((j % 2) == 1 && j == (W - 1)){
						printf(".\n");
					}else if((j % 2) == 1){
						printf(".");
					}else{
						printf("#");
					}
				}else{
					if((j % 2) == 0 && j == (W - 1)){
						printf(".\n");
					}else if((j % 2) == 1 && j == (W - 1)){
						printf("#\n");
					}else if((j % 2) == 1){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int N;
  cin >> N;
  mint ans = 1;
  rep(i,N) {
    ans *= i+1;
  }
  cout << ans.x << endl;
  return 0;
}

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

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

    int n,k;
    cin >> n >> k;
    int a[n],b[n];
    for(int i=0;i<n;i++)cin >> a[i];

    b[0]=0;

    for(int i=1;i<n;i++)
    {
        b[i]=2147483647;
        for(int j=1;j<=k;j++)
            if(i>=j)b[i]=min(b[i-j]+abs(a[i-j]-a[i]),b[i]);
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <list>
#include <stack>

using namespace std;
long long gcd(long long a, long long b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
long long a[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long x = a[0];
	for (int i = 1; i < n; i++) {
		x = gcd(a[i], x);
	}
	cout << x << '\n';


}


Measured memory_bytes: 1024
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll q, n, x, y, sum;
ll cnt[MXN];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> x, cnt[x] ++, sum += x;
    cin >> q;
    while(q --){
        cin >> x >> y;
        sum -= cnt[x] * x;
        sum += cnt[x] * y;
        cnt[y] += cnt[x], cnt[x] = 0;
        cout << sum << '\n';
    }
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 4404
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    //エラトステネスの篩
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        //最小素因数がかかれるようにしている
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  //素因数列挙
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //頻度を集計したもの
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      //小さい順に出てくるので前回と同じなら足す作業でmapが作れる
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
  Sieve sieve(1e6);
  vector<ll> res(1e6);
  ll cnt = 0;
  for(ll i = 2; i < 1e6; i++){
    if(sieve.isPrime(i) and sieve.isPrime((i + 1) / 2)){
      cnt++;
    }
    res[i] = cnt;
  }

  ll N; cin >> N;
  vector<ll> ans;
  rep(i, N){
    ll a, b; cin >> a >> b;
    ans.pb(res[b] - res[a - 1]);
  }
  rep(i,N) cout << ans[i] << endl;
}


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

int main() {
  int M, D;
  cin >> M >> D;

  int cnt = 0;
  for(int k = 1; k <= M; k++) {
  for(int i = 2; i<= 9; i++) {
    for(int j = 2; j<= 9; j++) {
      if (i*10+j <= D && i*j == k) cnt++;
    }
  }
  }
  cout << cnt;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s, w = map(int, input().split())

    if s <= w:
        print("unsafe")
    else:
        print("safe")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 61668
import re
# input process
inputData = input()

uniq_str_list = list(set(inputData))
if len(uniq_str_list) != 2:
    print("No")
    exit()
if len(re.findall(uniq_str_list[0], inputData)) != 2:
    print("No")
    exit()

if len(re.findall(uniq_str_list[1], inputData)) != 2:
    print("No")
    exit()

print("Yes ")

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

public class Main {

    class Reader {
        BufferedReader in;

        Reader() {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        StringTokenizer tok = new StringTokenizer("");

        String next() throws IOException {
            if (!tok.hasMoreTokens()) {
                tok = new StringTokenizer(in.readLine());
            }
            return tok.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(in.readLine());
        }

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

    class Writer {
        PrintWriter out;

        Writer() {
            out = new PrintWriter(System.out);
        }

        StringBuilder str = new StringBuilder();

        void print(Object o) {
            str.append(o);
        }

        void close() {
            out.write(str.toString());
            out.close();
        }
    }

    void slave() throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        String S = in.next();
        long k = in.nextInt();
        long ans = 0;
        int i = 0;
        while (i + 1 < S.length() && S.charAt(i) == S.charAt(i + 1)) {
            i++;
        }
        int n = S.length();
        while (n > 0 && S.charAt(n - 1) == S.charAt(0)) {
            n--;
        }
        if (i >= n) {
            ans = S.length() * k;
            ans = (ans - ans % 2) / 2;
        } else {
            long st = i + 1;
            long end = S.length() - n;
            ans += (st - st % 2) / 2;
            ans += (end - end % 2) / 2;
            long count = 0;
            for (i = i + 1; i < n; i++) {
                int j = i;
                while (j + 1 < n && S.charAt(j) == S.charAt(j + 1)) {
                    j++;
                }
                long len = j - i + 1;
                count += (len - len % 2) / 2;
                i = j;
            }
            ans += count * k;
            ans += (((st + end) - (st + end) % 2) / 2) * (k - 1);
        }
        out.print(ans);
        out.close();
    }

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

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int a[N];
  vector<bool> Taro(K+1);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= K; i++) {
    for (int j = 0; j < N; j++) {
      if (i-a[j] >= 0 && !Taro[i-a[j]]) {
        Taro[i] = true;
        break;
      }
    }
  }
  if (Taro.back()) {
    cout << "First";
  } else {
    cout << "Second";
  }
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  cin >> n;
  string u;
  double x,ans = 0;
  rep(i,n){
    cin >> x >> u;
    if(u == "JPY"){
      ans += x;
    }else{
      ans += x * 380000;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
#define dbg(x) cerr << "[" #x << " : " << x << "]\n";
const int mod = (int)1e9+7;

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    int p[210000];
    for(int i = 0; i < n; i++) scanf("%d", &p[i]);
    double ans = 0;
    double s = 0;
    int mx = 0;
    for(int i = 0; i < k; i++) s += (p[i]+1)/2.0;
    ans = s;
    for(int i = k; i < n; i++ ) {
        s -= (p[i-k]+1)/2.0;
        s += (p[i]+1)/2.0;
        ans = max(ans, s);
    }
    printf("%lf\n", ans);
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	string s ;
	cin>>s ;
	map<string , int>ans ;
	ans["SAT"] = 1 ;
	ans["FRI"] = 2 ;
	ans["THU"] = 3 ;
	ans["WED"] = 4 ;
	ans["TUE"] = 5 ;
	ans["MON"] = 6 ;
	ans["SUN"] = 7 ;
	return cout<<ans[s]<<"\n" , 0 ;
	return 0 ;
}		

Measured memory_bytes: 764
#include<cstdio>
#include<vector>
using namespace std;

const int MAX_N = 1000;

long long a[MAX_N];
bool use[MAX_N];

int main() {
	int n;
	scanf("%d", &n);
	long long sum[2] = {0, 0};
	int count[2] = {0, 0};
	bool corner = true;
	int max_i = 0;
	for(int i=0;i<n;i++) {
		scanf("%lld", &a[i]);
		if(a[i] > 0){
			sum[i%2] += a[i];
			count[i%2]++;
			corner = false;
		}
		if(a[i] > a[max_i]) max_i = i;
	}
	long long s;
	vector<int> v;
	if(corner) {
		s = a[max_i];
		for(int i=0;i<n;i++) use[i] = false;
		use[max_i] = true;
	} else {
		int parity = sum[0] > sum[1] ? 0 : 1;
		s = sum[parity];
		for(int i=0;i<n;i++) {
			use[i] = i%2 == parity && a[i] > 0;
		}
	}
	int i = n - 1;
	while(!use[i]) {
		v.push_back(i+1);
		i--;
	}
	i--;
	while(i >= 0) {
		if(i == 0) {
			v.push_back(1);
			break;
		} else {
			if(use[i-1]) {
				v.push_back(i+1);
			} else {
				if(i >= 2) {
					v.push_back(i);
				} else {
					v.push_back(1);
					v.push_back(1);
					break;
				}
				
			}
			i -= 2;
		}
	}
	printf("%lld\n", s);
	printf("%d\n", v.size());
	for(int i=0;i<v.size();i++) printf("%d\n", v[i]);
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		scan.close();
		String[] inputs = input.split(" ");
		Deque<Integer> stack = new ArrayDeque<>();
		for(String s : inputs) {
			if(s.equals("+")) {
				stack.push((stack.pop() + stack.pop()));
			}else if(s.equals("-")) {
				stack.push((-1 * stack.pop() + stack.pop()));
			}else if(s.equals("*")) {
				stack.push((stack.pop() * stack.pop()));
			} else {
				stack.push(Integer.parseInt(s));
			}
		}
		System.out.println(stack.pop());
	}

}



Measured memory_bytes: 26228
from math import gcd
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        L = gcd(i,j)
        for k in range(j,K+1):
            M = gcd(L,k)
            if i == j == k:
                ans += M
            elif i == j or j == k:
                ans += M*3
            else:
                ans += M*6
print(ans)


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> G(h);
  for(int i = 0; i < h; i++) cin >> G.at(i);
  
  int ans = 0;
  // 行のboolを考える 2のｈ乗通り
  for(int i = 0; i < (1 << h); i++) {
    //列のbooiを考える 2のw乗通り
    for(int j = 0; j < (1 << w); j++) {
      int cnt = 0;
      //行を取り出してその行のboolを考える
      for(int a = 0; a < h; a++) {
        //塗られている行
        if((i >> a) & 1) continue;
        //列
        for(int b = 0; b < w; b++) {
          if((j >> b) & 1) continue;
          //ここまで来るのは塗られていない行列
          if(G.at(a).at(b) == '#') cnt++;
        }
      }
      if(cnt == k) ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    // 冪剰余 a^n mod MOD
    const auto& modpow = [](unsigned long a, unsigned long n) -> unsigned long {
        unsigned long r{1};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    
    unsigned long N, K;
    cin >> N >> K;

    vector<unsigned long> v(K + 1);
    // v[i] = floor(K/i)^N で初期化
    for(unsigned long i{1}; i <= K; ++i)v[i] = modpow(K / i, N);
    // 正しい v[i] を i の大きい方から求めます
    for(unsigned long i{K}; i > 0; --i){
        // v[i] = floor(K/i)^N - Σv[ij]
        for(unsigned long j{i * 2}; j <= K; j += i)v[i] += MOD - v[j];
        v[i] %= MOD;
    }

    // ans = Σ i v[i]
    unsigned long ans{0};
    for(unsigned long i{0}; i <= K; ++i)ans += i * v[i];
    cout << ans % MOD << endl;
    
    return 0;
}

Measured memory_bytes: 4008
from collections import Counter
n = int(input())
s = list(input() for _ in range(n))

s = dict(Counter(s))

print("AC x " + str(s.get("AC", 0)))
print("WA x " + str(s.get("WA", 0)))
print("TLE x " + str(s.get("TLE", 0)))
print("RE x " + str(s.get("RE", 0)))


Measured memory_bytes: 78824
/* ~/lib/template.cを引用 */
#include<stdio.h>
#include<stdlib.h>
// #inclide<math.h>

int main(int argc, char *argv[]){

  int a, b;

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

  if(a < 1 || 100 < b){
    exit(0);
  }

  printf("%d %d\n",a*b, 2*a + 2*b );


  return 0;
}



Measured memory_bytes: 2044
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;


int factorial(int N){
  int ans = 1;
  for (int i=N;i>0;i--) ans *=i;
  return ans;
}

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);

  REP(n,N) cin >> P[n];
  REP(n,N) cin >> Q[n];

  vector<int> nums(N);
  REP(n,N) nums.at(n) = n;

  int a = 0, b = 0;
  int count = 0;
  bool flagP = false, flagQ=false;
  do {
    flagP = true;
    flagQ = true;
    REP(n,N){
      int current = nums.at(n)+1;
      if (current != P.at(n)) flagP = false;
      if (current != Q.at(n)) flagQ = false;
    }

    if (flagP == true) a = count;
    if (flagQ == true) b = count;
    count +=1;
  } while (next_permutation(nums.begin(), nums.end()));

  int ans = abs(b-a);
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

string S;
int N;

typedef pair<int, int> pii;
pii judge(int code) {
	vector<int> A(N + 1, 0);
	vector<int> AA(N + 1, INT_MAX);
	for (int n = 1; n <= N; n++) {
		if (S[n-1] == code)A[n] += 1;
	}
	for (int n = 2; n <= N; n++) {
		A[n] += A[n - 1];
	}
	for (int n = 1; n <= N; n++) {
		A[n] = 2 * A[n] - n;
	}
	AA[0] = A[0];
	for (int n = 1; n <= N; n++)AA[n] = min(AA[n - 1], A[n]);
	for (int n = 2; n <= N; n++) {
		if (AA[n - 1] >= A[n])continue;
		int s = -1, e = n;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (AA[m] >= A[n])s = m;
			else e = m;
		}
		if (n-e >= 2) {
			return pii(e + 1, n);
		}
	}
	return pii(-1, -1);
}

int main() {
	cin >> S;
	N = S.size();
	for (int code = 'a'; code <= 'z'; code++) {
		pii res = judge(code);
		if (res != pii(-1, -1)) {
			cout << res.first << " " << res.second << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

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

string S;

int main() {
    cin >> S;

    string ans = "";
    ans += S[0];
    ans += to_string(S.length() - 2);
    ans += S[S.length() - 1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let V = read![[i32]];

    let mut kv = vec![];

    for p in 0..2 {
        let mut m = BTreeMap::new();

        for i in 0..N {
            if i % 2 != p {
                continue;
            }

            *m.entry(V[i]).or_insert(0) += 1;
        }

        let mut v = m.into_iter().map(|(k, v)| (v, k)).vec();

        v.push((0, 1_000_000));
        v.push((0, 1_000_001));
        v.sort();
        v.reverse();
        kv.push(v);
    }

    let s = N - max(
        kv[0][0].0
            + kv[1]
                .iter()
                .filter(|&&(_, k)| k != kv[0][0].1)
                .max()
                .unwrap()
                .0,
        kv[1][0].0
            + kv[0]
                .iter()
                .filter(|&&(_, k)| k != kv[1][0].1)
                .max()
                .unwrap()
                .0,
    );

    println!("{}", s)
}


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

int main() {
	int N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		lint k;
		cin >> k;
		cout << upper(A, k - 1) - A.begin() << endl;
	}
}




Measured memory_bytes: 3620
//#pragma GCC optimize(3)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod=1e9+7;
const int N=1e5+5;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    string s,t="",e="";
    int tag=0;
    cin>>s>>k;
    ll ans=0,res=0;
    int n=s.size();
    int pos=1,pot=n-2;
    while(pos<n&&s[pos]==s[pos-1]) pos++,t+=s[pos-1];
    t+=s[0];
    ans+=t.size()/2;
    if(t.size()==n) tag=1;
    while(pot>=0&&s[pot]==s[pot+1]) pot--,e+=s[pot+1];
    e+=s[n-1];
    ans+=e.size()/2;
    //cout<<ans<<endl;
    reverse(e.begin(),e.end());
    e+=t;
    for(int i=pos;i<=pot;i++)
    {
        int siz=0;
        for(int j=i;j<=pot;j++)
        {
            if(s[j]!=s[i]) break;
            i=j;
            siz++;
        }
        res+=siz/2;
    }
    //cout<<res<<endl;
    ans+=res*k;
    res=0;
    n=e.size();
    for(int i=0;i<n;i++)
    {
        int siz=0;
        for(int j=i;j<n;j++)
        {
            if(e[j]!=e[i]) break;
            i=j;
            siz++;
        }
        res+=siz/2;
    }
    //cout<<res<<endl;
    ans+=res*(k-1);
    if(tag) cout<<ans/2<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256