akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n;
int a[410];
long long int p[410];
long long int dp[410][410];

long long int rek(int x, int y) {
	if (x == y) return 0;
	if (x+1 == y) {
		return a[x] + a[y];
	}
	
	long long int &ret = dp[x][y];
	if (ret != -1) return ret;
	ret = 1e18;
	
	for (int i = x; i < y; i ++) {
		ret = min(ret, rek(x, i)+rek(i+1, y) + (p[i] - p[x-1]) + (p[y] - p[i]));
	}
	
	return ret;
}

int main () {
	
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		p[i] = a[i] + p[i-1];
	}
	memset(dp, -1, sizeof dp);
	cout << rek(1, n);
	
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll N,M;
  cin>>N>>M;
  if(N==1&&M==1){
    cout<<1<<endl;
  }
  else if(N==1){
    cout<<M-2<<endl;
  }
  else if(M==1){
    cout<<N-2<<endl;
  }
  else{
    //端っこは表
    cout<<M*N-2*(M-1)-2*(N-1)<<endl;
  }
  return 0;
}


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

char a[100][100];
int m, n;

int main() {
  cin>>n>>m;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      a[i][j] = '+';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin>>a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int q = 0;
      if (a[i][j] == '#') {
        cout<<'#';
        continue;
      }
      if (a[i+1][j] == '#') {
        q++;
      }
      if (a[i][j+1] == '#') {
        q++;
      }
      if (a[i-1][j] == '#') {
        q++;
      }
      if (a[i][j-1] == '#') {
        q++;
      }
      if (a[i+1][j-1] == '#') {
        q++;
      }
      if (a[i+1][j+1] == '#') {
        q++;
      }
      if (a[i-1][j+1] == '#') {
        q++;
      }
      if (a[i-1][j-1] == '#') {
        q++;
      }
      cout<<q;
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

if "AC" in S :
  print ("Yes")
else :
  print ("No")



Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;
int O[401][401];
bool seen[401][401];
int init(){
    for(int yi = 0; yi < 401; yi++){
        for(int xi = 0; xi < 401; xi++){
            O[yi][xi] = -1;
            seen[yi][xi] = true;
        }
    }
}
pair<ll,ll> solve(int yi,int xi,int sig){
    if(yi < 0 || xi < 0){
        return pair<ll,ll>(0,0);
    }
    if( seen[yi][xi] || O[yi][xi] != sig){
        return pair<ll,ll>(0,0);
    }
    seen[yi][xi] = true;
    pair<ll,ll> N = solve(yi + 1,xi,1-sig);
    pair<ll,ll> S = solve(yi - 1,xi,1-sig);
    pair<ll,ll> E = solve(yi ,xi + 1,1-sig);
    pair<ll,ll> W = solve(yi ,xi - 1,1-sig);
    pair<ll,ll> result = make_pair(0ll,0ll);
    result.first = N.first + S.first + E.first + W.first;
    result.second = N.second + S.second + E.second + W.second;
    if(O[yi][xi] == 0){
        result.first += 1;
    }
    if(O[yi][xi] == 1){
        result.second += 1;
    }

    return result;
}

int main() {
    ll H,W;
    cin >> H >>W;
    init();
    for(ll yi = 0; yi < H; yi++){
        string s;
        cin >> s;
        for(int xi = 0; xi < W; xi++){
            if(s[xi] == '#'){
                O[yi][xi] = 1;
            }else{
                O[yi][xi] = 0;
            }
            seen[yi][xi] = false;
        }
    }
    pair<ll,ll> bucket[H][W];
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            bucket[yi][xi] = solve(yi,xi,O[yi][xi]);
        }
    }
    ll sum = 0;
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            //cout << "(" << bucket[yi][xi].first << "," << bucket[yi][xi].second << ")";
            sum += bucket[yi][xi].first * bucket[yi][xi].second;
        }
        //cout << endl;
    }
    cout << sum << endl;

}


Measured memory_bytes: 18560
from collections import defaultdict as dd

N = int(input())
graph = dd(list)
seen = dd(int)
u = []
d, f = dd(int), dd(int)
ts = 1
for _ in range(N):
  info = list(map(int, input().split()))
  u.append(info[0])
  graph[info[0]] = info[2:]

def dfs(v):
  global ts
  d[v] = ts
  ts += 1
  
  seen[v] = 1
  for next_v in graph[v]:
    if seen[next_v]:
      continue
    dfs(next_v)
  
  f[v] = ts
  ts += 1

for key in u:
  if seen[key]:
    continue
  dfs(key)

for id in u:
  print("{} {} {}".format(id, d[id], f[id]))


Measured memory_bytes: 6064
#include <iostream>
#include <cstdio>
#include <set>
#include<cmath>
#include<math.h>
#include<math.h>
#include<map>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
long long int C[2005][2005],n,k,mod=1e9+7;
int main()
{
	C[0][0] = 1;
	for (int i = 1; i < 2005; i++)
	{
		C[i][0] = 1;
		C[i][i] = 1;
	}
	for(int i=1;i<2005;i++)
		for (int j = 1; j <= i; j++) 
		{
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	scanf("%lld%lld", &n, &k);
	for (int i = 1; i <= k; i++)
	{
		printf("%lld\n", C[n - k + 1][i] * C[k - 1][i - 1] % mod);
	}
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b&&b==c&&a%2==0)
    cout << -1 << endl;
  else{
    int i=0;
    while(a%2==0&&b%2==0&&c%2==0){
      int x=a/2;
      a=a/2+b/2;
      b=b/2+c/2;
      c=c/2+x;
      i++;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int c=b-a;
    if(c<(2*k)){
        for(int i=a;i<=b;i++){
            cout<<i<<endl;
        }
    }
    else{
        for(int i=a;i<=a+k-1;i++){
            cout<<i<<endl;
        }
        for(int i=b-k+1;i<=b;i++){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  int ans=N/11*2;
  N%=11;
  if(N>0)ans++,N-=6;
  if(N>0)ans++;
  cout<<ans<<endl;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int h[100100];
    for (int i = 0; i < N; i++) cin >> h[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (h[i] >= K) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n,A,B,C=map(int,input().split())
L=[int(input()) for _ in range(n)]

INF=10**9
def dfs(cur,a,b,c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF 
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+L[cur],b,c)+10
    ret2=dfs(cur+1,a,b+L[cur],c)+10
    ret3=dfs(cur+1,a,b,c+L[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

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

int main() {
  int W, a, b;
  scanf("%d%d%d", &W, &a, &b);
  if (abs(a - b) <= W) {
    printf("0");
  } else {
    printf("%d", abs(a - b) - W);
  }
  return 0;
}

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


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


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


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


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


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


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  double n,k,ans=0;
  cin>>n>>k;
  for(long long int i=1;i<=n;i++){
    long long int cnt=0,a=i;
    
    while(a<k){
      a*=2;
      cnt++;
    }
    ans+=(double)pow(0.5,cnt);
  }
  cout<<setprecision(10)<<ans*(1/n)<<endl;
}



Measured memory_bytes: 256
#include <iostream>

long long sum(long long N)
{
    return N * (N + 1) / 2;
}

int main()
{
    long long N;
    std::cin >> N;

    long long fizz = N / 3;
    long long buzz = N / 5;
    long long fizzbuzz = N / 15;

    std::cout << (sum(N) - 3 * sum(fizz) - 5 * sum(buzz) + 15 * sum(fizzbuzz));

    return 0;
}

Measured memory_bytes: 3188
a = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(0,a) :
  b = str(input())
  if b == "AC" :
    AC = AC + 1
  elif b == "WA" :
    WA = WA + 1
  elif b == "TLE" :
    TLE = TLE + 1
  else :
    RE = RE + 1

print("AC x",AC)
print("WA x",WA)
print("TLE x",TLE)
print("RE x",RE)

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 211111;

int fact[d5];
int modpow(int x, int n) {
    if (n == 0)return 1;
    int res = modpow(x * x % mod, n / 2);
    if (n & 1)res = res * x % mod;
    return res;
}
void makef() {
    fact[0] = 1;
    for (int i = 1; i < d5; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
}
int comb(int n, int k) {
    if(n<k)return 0;
    else{
        int ret = fact[n];
        ret *= modpow(fact[n - k], mod - 2);
        ret %= mod;
        ret *= modpow(fact[k], mod - 2);
        ret %= mod;
        return ret;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    makef();
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int res=0;
    for(int i=0;i<h-a;i++){
        if(i!=h-a-1){
            res+=comb(i+b,b)*comb(w-b-3+h-i,h-i-1);
            res%=mod;
        }
        else{
            res+=comb(h-a-1+b,b)*comb(w-b+a-1,a);
            res%=mod;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1920
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int dp[200005][3][2];
bool cdp[200005][3][2];
int a[200005];
int n;

int suri(int idx,int extra,bool prev)
{
	if(extra>=3)
		return -1e15;
	if(idx==n)
		return 0;
	int &ans=dp[idx][extra][prev];
	if(cdp[idx][extra][prev])
		return ans;
	cdp[idx][extra][prev]=true;
	if(prev)
	{
		ans=suri(idx+1,extra,0);
	}
	else
	{
		ans=a[idx]+suri(idx+1,extra,1);
		ans=max(ans,suri(idx+1,extra+1,0));
	}
	return ans;
}


int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int i;
		cin>>n;
		for(i=0;i<n;i++)
			cin>>a[i];
		cout<<suri(0,!(n&1),0);
		
	}

	return 0;
}

Measured memory_bytes: 31324
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

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

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

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

fn main() {
    let (N, R) = read!(usize, i64);

    let rate = if N >= 10 {
        R
    } else {
        R + 100 * (10 - N as i64)
    };

    println!("{}", rate)
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);
//        for (int i = 0; i < n; i++) {
////            System.out.print(array[i] + " ");
////        }

        System.out.println("\n" + (array[n/2] - array[n/2-1]));

    }
}


Measured memory_bytes: 49776
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  int K;
  cin>>S>>K;
  
  int N=S.size();
  vector<string> L;
  
  for(int i=1; i<=K; ++i){
    for(int j=0; j<=N-i; ++j){
      L.push_back(S.substr(j,i));
    }
  }
  
  SORT(L);
  L.erase(unique(L.begin(),L.end()),L.end());
  
  cout<<L.at(K-1)<<endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s << "\n";
    }
    else {
        reverse(s.begin(), s.end());
        cout << s << "\n";
    }
    return 0;
}


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



int main(){
	
	int N;
	cin>>N;
	long long ans  = 0;
	map<long long,long long> mp;
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		mp[A]++;
		ans += A;
	}
	
	int Q;
	cin>>Q;
	
	for(int i=0;i<Q;i++){
		long long B,C;
		cin>>B>>C;
		if(!mp.count(B)){
			cout<<ans<<endl;
			continue;
		}
		int t = mp[B];
		ans -= B * mp[B];
		mp.erase(B);
		ans += C * t;
		mp[C] += t;
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 7576
#include <iostream>

using namespace std;

int main()
{
    int d = 0;
    int c[26];
    int s[365][26];
    int t[365];
    int last[26] = {0};
    int score = 0;

    cin >> d;

    for(int i = 0; i < 26; i++)
    {
        cin >> c[i];
    }

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < d; i++)
    {
        cin >> t[i];
        t[i]--;
    }

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            if(t[i] == j)
            {
                last[j] = 0;
                score += s[i][j];
            }
            else
            {
                last[j]++;
                score -= c[j] * last[j];
            }
        }

        cout << score << endl;
    }

    return 0;
}

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

#define ll long long int
#define vi vector<int>

int main() {

    int N, K;
    cin >> N >> K;

    vi A(200, 0);
    int d, a;
    for (int i = 0; i < K; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            cin >> a;
            A[a]++;
        }
    }

    int count = 0;
    for (int i = 1; i <= N; ++i) {
        if (A[i] == 0) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    string S;
    cin>>S;
    bool C=true;
    if(S.at(3)!=S.at(2))C=false;
    if(S.at(4)!=S.at(5))C=false;
    Yes(C);
}



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

int main(){
    int n, l, sum;
    cin >> n >> l;
    sum = 0;
    if(l >= 0){
        for(int i=1; i<n; i++){
            sum+=l+i;
        }
    }else{
        if(n<=-l){
           for(int i=0; i<n-1; i++){
               sum+=l+i;
           }
        }else{
            for(int i=0; i<n; i++){
               sum+=l+i;
           }
        }
    }
    cout << sum <<endl;
  return 0;
}

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

using namespace std;

int noNum , x ;
int sol ;

int main(){


    scanf("%d",&noNum );

    for ( int i = 0 ; i < noNum ; i++ ){
        scanf("%d",&x);

        while ( x % 2 == 0 ){
            x/=2 ;

            sol++;

        }
    }

    printf("%d",sol);




    return 0;
}


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

int dp[502][2][10][500][3], m, len[2];
char S[2][550];
int solve(int o) {
	memset(dp, 0, sizeof(dp));
	dp[0][0][0][0][0] = 1;
	rep(i, len[o])rep(j, 2)rep(k, 10)rep(l, m)rep(d, 3) {
		if (dp[i][j][k][l][d] == 0)continue;
		int s, g, p = S[o][i] - '0';
		if (d == 1)s = k + 1, g = (j ? 9 : p);
		else if (d == 2)s = 0, g = (j ? k - 1 : min(k - 1, p));
		else s = 0, g = (j ? 9 : p);
		for (int x = s; x <= g; x++) {
			if (x&&k == x)continue;
			int y;
			if (d == 1)y = 2;
			else if (d == 2)y = 1;
			else {
				if (k == 0)y = 0;
				else if (x < k)y = 1;
				else y = 2;
			}
			(dp[i + 1][j || x < p][x][(l * 10 + x) % m][y] += dp[i][j][k][l][d]) %= MOD;
		}
	}
	int sum = 0;
	rep(i, 2)rep(j, 10)rep(t, 3) {
		if (!i && !o)continue;
		(sum += dp[len[o]][i][j][0][t]) %= MOD;
	}
	return sum;
}
int main() {
	scanf("%s%s%d", S[0], S[1], &m);
	rep(i, 2)len[i] = strlen(S[i]);
	printf("%d\n", (solve(1) + MOD - solve(0)) % MOD);
}

Measured memory_bytes: 62032
#include<stdio.h>
 
main()
{
    char buf[2000], *p = buf;
     
     
    scanf("%[^\n]",buf);
     
    while(*p != '\0'){
        if('A' <= *p && *p <= 'Z'){
            printf("%c",*p + ('a'-'A'));
        } else if('a'<=*p && *p <= 'z'){
            printf("%c",*p-('a'-'A'));
        } else {
            printf("%c",*p);
        }
        p++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define int long long 

signed main(void){
  
  int N; cin >> N;
  int SIZE = 1 << N;
  multiset<int> target; //これだけ作らなければならない
  
  for(int i = 0; i < SIZE; i++){ 
    int a; cin >> a;
    target.insert(a);
  }
  
  int M = *target.rbegin();
  vector<int> V;
  V.push_back(M);
  
  for(int i = 0; i < N; i++){ 
   
    int m = V.size();
    
    vector<int> stock;
    
    for(int j = 0; j < m; j++){
        // V[j]の子を作れないかどうか考える
      int p = V[j]; 
      auto itr = target.lower_bound(p);
      if( itr == target.begin() ){ cout << "No" <<  endl; return 0;}
      
      itr--;
      
      stock.push_back(*itr);
      
      target.erase(itr);
    }
    
    for(int j = 0; j < stock.size(); j++){
      V.push_back(stock[j]);
    }
    
   sort(V.rbegin(),V.rend());
    
    
  }
  
  //SIZE回無事に終わったらYes
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 15460
////////////////////////////////////
//          ,.                    //
//         (_|,.                  //
//        ,' /, )_______   _      //
//     __j o``-'        `.'-)'    //
//    (")                 \'      //
//     `-j                |       //
//        `-._(           /       //
//           |_\  |--^.  /        //
//          /_]'|_| /_)_/         //
//             /_]'  /_]'         //
//                                //
//           PIGMEISTER™          //
//                                //
////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define mod (ll)1000000007
#define sidha(i, x, n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i, x, n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mii map<ll, ll>
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define modInv(x) powah(x, mod-2)
#define test ll t;cin>>t;while(t--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
//ll powah(ll, ll);

vi dp(100005, -1), h;

ll minCost(ll n, ll k) {
    if (dp[n] > -1) return dp[n];

    if (n == 1)
        dp[n] = 0;
    else {
        ll miin = LLONG_MAX, limit = min(k+1, n);
        sidha (i, 1, limit)
            if (miin > minCost(n-i, k) + abs(h[n] - h[n-i]))
                miin = minCost(n-i, k) + abs(h[n] - h[n-i]);
        dp[n] = miin;
    }
    return dp[n];
}

int main()
{
    jaldi;
    
    ll n, k;
    cin >> n >> k;
    h.resize(n+1);
    sidha (i, 0, n)
        cin >> h[i+1];
    cout << minCost(n, k) << endl;
    
    return 0;
}

// ll powah(ll x, ll y) { 
//     ll res = 1;
//     x = x % mod;
//     while (y > 0) { 
//         if (y & 1) 
//             res = (res*x) % mod; 
//         y = y>>1;
//         x = (x*x) % mod; 
//     } 
//     return res; 
// }

Measured memory_bytes: 8064
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let m = get!();
    
    let ai = m / n;
    let rem = m % n;
    
    if rem == 0 {
    	println!("{}", ai);
        return;
    }
    
    let mut p = 2;
    let mut ans = 1;
    while p * p <= m || m / p >= n {
    	if m % p == 0 && m / p >= n {
        	ans = p;
        }
        p += 1;
    }
    
    println!("{}", ans);    
}


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    ll n;
    cin >> n;
    vector<int> A(n + 2);
    A[0] = n + 1;
    A[n + 1] = n + 2;
    for(int i = 1; i < n + 1; i++)
        cin >> A[i];
    vector<int> next(n + 2),
                nnext(n + 2, -1),
                prev(n + 2),
                nprev(n + 2, -1);
    stack<int> B;
    priority_queue< pair<int, int> > D;
    for(int i = 1; i < n + 2; i++) {
        while(D.size() > 0 && -D.top().first < A[i]) {
            nnext[D.top().second] = i;
            D.pop();
        }
        while(B.size() > 0 && A[B.top()] < A[i]) {
            next[B.top()] = i;
            D.push(make_pair(-A[B.top()], B.top()));
            B.pop();
        }
        B.push(i);
    }
    while(B.size()) B.pop();
    while(D.size()) D.pop();
    for(int i = n; i >= 0; i--) {
        while(D.size() > 0 && -D.top().first < A[i]) {
            nprev[D.top().second] = i;
            D.pop();
        }
        while(B.size() > 0 && A[B.top()] < A[i]) {
            prev[B.top()] = i;
            D.push(make_pair(-A[B.top()], B.top()));
            B.pop();
        }
        B.push(i);
    }

#if 0
    for(int i = 0; i < n + 2; i++)
        cout << A[i] << " \n"[i == n + 1];
    for(int i = 0; i < n + 2; i++)
        cout << next[i] << " \n"[i == n + 1];
    cout << "\n\n";
    for(int i = 0; i < n + 2; i++)
        cout << prev[i] << " \n"[i == n + 1];
    cout << "\n\n";
#endif

    ll result = 0;
    for(int i = 1; i < n + 1; i++) {
        if(nprev[i] != -1)
            result += (ll)A[i] * (prev[i] - nprev[i]) * (next[i] - i);
        if(nnext[i] != -1)
            result += (ll)A[i] * (nnext[i] - next[i]) * (i - prev[i]);
    }
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h> 

int main(void)
{
	int a,b,c,d;

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


	if(a > b)
	{
		d = a;
		a = b;
		b = d;
	}
	if(b > c)
	{
		d = b;
		b = c;
		c = d;
	}
	if(a > c)
	{
		d = a;
		a = c;
		c = d;
	}
	if(a > b)
	{
		d = a;
		a = b;
		b = d;
	}
	printf("%d %d %d\n",a,b,c);

	return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	int ac = 0, wa = 0, tle = 0, re = 0; 
  	rep(i, n){
    	string s;
      	cin >> s;
      
      	if(s == "AC") ac++;
      	if(s == "WA") wa++;
      	if(s == "TLE") tle++;
		if(s == "RE") re++;
    }

  	cout << "AC x " << ac << endl;
  	cout << "WA x " << wa << endl;
  	cout << "TLE x " << tle << endl;
  	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    int k;
    vector <ll> v;
    int tmp;
    for (ll i=0;i<5;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    cin >> k;
    if(v[4]-v[0] > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
 
int main(){
    int N;
    cin >> N;
    int S[N];
    for(int i = 0; i < N; i++)cin >> S[i];
 
    int M;
    cin >> M;
 
    int Q[M];
    for(int i = 0; i < M; i++)cin >> Q[i];
    sort(Q,Q+M);
 
    int left = 0,right,m,count = 0;
 
    for(int i = 0; i < M; i++){
        right = N-1;
        m = (left+right)/2;
 
        while(left <= right){
            if(S[m] == Q[i]){
                count++;
                left= m+1;
                break;
            }else if(S[m] > Q[i]){
                right = m-1;
            }else{ //S[m] < Q[i]
                left = m+1;
            }
            m = (left+right)/2;
        }
    }
    cout << count << endl; 
}


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

using namespace std;

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

	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	
	int ans = 0;
	ans += a[2] - a[1];
	a[0] += ans;

	if ((a[2] - a[0])%2 == 0) ans += (a[2] - a[0])/2;
	else ans += (a[2] - a[0] + 1)/2 + 1;

	cout << ans << endl;		

	return 0;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

def dfs(v, visited):
	all_visited = True
	
	for i in range(N):
		if visited[i] == False:
			all_visited = False
	
	if all_visited:
		return 1
	
	ret = 0
	
	for i in range(N):
		if graph[v][i] == False:
			continue
		if visited[i]:
			continue
		
		visited[i] = True
		ret += dfs(i, visited)
		visited[i] = False
	
	return ret

N, M = [int(x) for x in input().split()]
graph = [[False] * N for _ in range(N)]

for i in range(M):
	A, B = [int(x) for x in input().split()]
	graph[A-1][B-1] = graph[B-1][A-1] = True

visited = [False] * N

visited[0] = True
print(dfs(0, visited))

Measured memory_bytes: 3064
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

void dfs(int u, int prev, int *cnt, int *visited, int *prenum, int *lowest, int *parent, vector< vector<int> > &v){
  visited[u] = true;
  prenum[u] = lowest[u] = *cnt;
  REP(i, v[u].size()){
    int next = v[u][i];
    if(!visited[next]){
      parent[next] = u;
      ++(*cnt);
      dfs(next, u, cnt, visited, prenum, lowest, parent, v);
      lowest[u] = min(lowest[u], lowest[next]);
    } else if(next != prev)
      lowest[u] = min(lowest[u], prenum[next]);
  }
}

vector<int> articulation_points(int V, int E, vector< vector<int> > &v){
  int visited[V], prenum[V], lowest[V], parent[V];
  memset(visited, 0, sizeof(visited));
  parent[0] = -1;
  int tmp = 1;
  dfs(0, -1, &tmp, visited, prenum, lowest, parent, v);
  //cout <<"prenum" <<endl;
  //REP(i, V) cout <<i <<" : " <<prenum[i] <<endl;
  //cout <<"parent" <<endl;
  //REP(i, V) cout <<i <<" : " <<parent[i] <<endl;
  //cout <<"lowest" <<endl;
  //REP(i, V) cout <<i <<" : " <<lowest[i] <<endl;
  vector<int> ret;
  int cnt = 0, used[V];
  memset(used, 0, sizeof(used));
  FOR(i, 1, V){
    if(parent[i] == 0) ++cnt;
    if(parent[i] > 0 && !used[parent[i]] && prenum[parent[i]] <= lowest[i]){
      used[parent[i]] = true;
      ret.push_back(parent[i]);
    }
  }
  if(cnt >= 2) ret.push_back(0);
  return ret;
}

int main() {
  int V, E; cin >>V >>E;
  vector< vector<int> > es(V);
  REP(i, E){
    int f, t; cin >>f >>t;
    es[f].push_back(t);
    es[t].push_back(f);
  }
  vector<int> ans = articulation_points(V, E, es);
  SORT(ans);
  REP(i, ans.size()) cout <<ans[i] <<endl;
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;

int order(int n)
{
	int i = 0;
	while (n != 0)
	{
		n /= 10;
		i++;
	}
	return i;
}

int main()
{
	int n;
	int j = 0;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		if (order(i) % 2 == 1)
		{
			j++;
		}
	}
	cout << j << endl;

	return 0;
}

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

using namespace std;

int main(){

    int kids;
    int candy_max;
    int happy = 0;
    int pointer = 0;
    int num;

    cin >> kids >> candy_max;
    int candy = candy_max;
    vector<int> v(kids);

    for(int i=0; i<kids; i++){
        cin >> v[i];
    }

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

    //candyを小さいほうから割り当てる
    for(int i=0; i < kids; i++){
        candy -= v[i];
        if(candy == 0){
            happy++;
            cout << happy;
            return 0;
        } 
        if(candy <= 0){
            cout << happy;
            return 0;
        }
        happy++;
    }
    
    if(candy > 0 && candy != candy_max){
        happy--;
        cout << happy;
        return 0;
    }

    cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int s = n;
	int result = 0;
	while (s) {
		result += s % 10;
		s /= 10;
	}
	
	if (n % result == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
p=*0..gets.to_i
f=->a{a!=p[a]?p[a]=f[p[a]]:a}
p$<.map(&:split).transpose.map{|a|i=0
(x,i),*y=a.map{[_1.to_i,i+=1]}.sort
y.map{[-x+x=_1,i,i=_2]}}.flatten(1).sort.sum{(a=f[_2])!=(b=f[_3])?(p[b]=a
_1):0}

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

using namespace std;
int n,k;
int v[105],w[105];
long long dp[105][100005];

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<100005;i++){
        dp[n][i]=0;
    }
    long long res=0;
    for(int i=n-1;i>=0;i--){
        for(int j=k;j>=0;j--){
            long long ch2=dp[i+1][j],ch1=0;
            if(j-w[i]>=0) {
                ch1 = dp[i+1][j-w[i]]+v[i];
            }
            dp[i][j]=max(ch1,ch2);
            res=max(dp[i][j],res);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 82304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	if(m==1)cout<<0<<endl;
	else cout<<n-m<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

public static void main(String[] args){
Scanner obj=new Scanner(System.in);
int n=obj.nextInt();
String g=obj.next();
if(n%2!=0){
System.out.println("No");
}else{
int p=n/2;
int q=p;
int h=0;
boolean flag=true;

for(;h<p;h++,q++){

if(g.charAt(h)!=g.charAt(q)){
flag=false;
}

}

if(flag){

System.out.println("Yes");
}else{
System.out.println("No");
}
}

}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll sm = 0;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5 == 0) continue;
        sm += i;
    }
    cout << sm << endl;
}

Measured memory_bytes: 3672
#include <stdio.h>

void common(int a,int b){
	int c,k,res;
	if(a > b){
		k = b;
	}else{
		k = a;
	}
	for(c=1;c<=k;c++){
		if(a%c==0&&b%c==0){
			res = c;
		}
	}
	printf("%d\n",res);
}

int main(void){
	int x,y,c;
	int res=0;
	scanf("%d %d",&x,&y);
	if(x > y){
		common(y,x%y);
	}else if(x < y){
		common(x,y%x);
	}else{
		printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string w;
    cin >> w;
    sort(ALL(w));
    if(w.size() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < w.size(); i += 2){
        if(w[i] != w[i + 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main(){
    int a, b, c;
    int maxvalue = 0;
    int k;
    cin >> a >> b >> c >> k;
    maxvalue = max(max(a, b), c);
    int maxvalue0 = maxvalue;
    for(int i = 0; i < k; i++){
        maxvalue *= 2;
    }
    cout << a + b + c + maxvalue - maxvalue0 << endl;
    return 0;
}

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

int a[301][301];
pint pos[90002];
int dp[90001];
int main(){
    int h,w,d,q,ai;
    cin>>h>>w>>d;
    rep(i,h)rep(j,w){
        cin>>ai;
        a[i][j]=ai;
        pos[ai]={j,i};
    }
    cin>>q;
    memset(dp,-1,sizeof(dp));
    int l,r;
    ll sum=0;
    if(d<=100){
        rep(i,d){
        int cur=i;
        sum=0;
        dp[i]=0;
        while(cur<h*w){
            sum+=abs(pos[cur+d].first-pos[cur].first)+abs(pos[cur+d].second-pos[cur].second);
            cur+=d;dp[cur]=sum;
        }
        }
    }
    rep(i,q){
        sum=0;
        cin>>l>>r;
        int cur=l;
        while(cur!=r){
            if(dp[r]!=-1){
                sum=dp[r]-dp[cur];
                break;
            } 
            sum+=abs(pos[cur+d].first-pos[cur].first)+abs(pos[cur+d].second-pos[cur].second);
            cur+=d;
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#define Sort_len 3

using namespace std;

int main (void) {
    int num[Sort_len];
    for (int i = 0; i < Sort_len; i++)
    {
        cin >> num[i];
    }
    int* num_p = &num[0];
    sort(num_p, num_p+Sort_len);
    for (int i = 0; i < Sort_len; i++)
    {
        cout << num[i];
        if (i < 2) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3164
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF 99999999

typedef int Weight;
typedef vector<Weight> Array;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef unordered_map<int,Edges> Graph;

void shortestPath(Graph &g, int s,
    Array &dist, Array &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

int main(){
	int i,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d",&V);
		Graph g(V);
		for(i=0;i<V-1;i++)scanf("%d%d",&s,&t),g[s-1].push_back(Edge(s-1,t-1,1)),g[t-1].push_back(Edge(t-1,s-1,1));
		Array dist1(V),dist2(V),prev(V);
		shortestPath(g,0,dist1,prev);
		shortestPath(g,V-1,dist2,prev);
		int r=0;
		for(i=0;i<V;i++)r+=dist1[i]>dist2[i];
		puts(r>=V-r ? "Snuke" : "Fennec");
	//}
}


Measured memory_bytes: 11432
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mod 1000000007
ll binpow(ll a, ll b, ll m=mod) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll gcd (ll a,ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int x=0;x<n;x++)
        cin>>a[x]>>b[x];
    map<pair<ll,ll>,ll> ae;
    ll d=1;
    ll f=0;
    ll g=0;
    for(int x=0;x<n;x++)
    {     if(a[x]==0 && b[x]==0)
             {  ++g;
                continue;}
        ll r=gcd(abs(a[x]),abs(b[x]));
               a[x]/=r;
               b[x]/=r;
               if((a[x]<=0 && b[x]<=0) || (a[x]>=0 && b[x]>=0))
               {
                   a[x]=abs(a[x]);
                   b[x]=abs(b[x]);
               }
               else
               {
                   a[x]=-abs(a[x]);
                   b[x]=abs(b[x]);
               }
               ++ae[{a[x],b[x]}];
    }
    set<pair<ll,ll>> aw;
    for(auto it : ae)
    {   ll w;
        ll we;
        aw.insert(it.first);
        pair<ll,ll> r;
        if(it.first.first>0)
        r={-it.first.second,it.first.first};
        else
        {
           r={it.first.second,-it.first.first};
        }
        if(aw.count(r))
           continue;
         w=ae[r];
        we=binpow(2,it.second+w);
        we-=((((mod+binpow(2,it.second)-1)%mod)*((mod+binpow(2,w)-1)%mod))%mod)%mod;
        we=(2ll*mod+we)%mod;
        d*=we;
        d%=mod;
    }
    d%=mod;
    d=(mod+d-1ll+g)%mod;
    cout<<d<<"\n";
}


Measured memory_bytes: 50500
//============================================================================
// Name        : beginner079.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : atcorder ABC077 in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

inline int main001();
inline int main002();
inline int main003();
inline int main004();

#define TEST

int main() {

  main001();

  return 0;
}

inline int main001() {

	string input;

	cin >> input;

	if ((input[1] == input[2])
			&& ((input[2] == input[0]) || (input[2] == input[3]))) {
		cout << "Yes";
	} else {
		cout << "No";

	}

	return 0;

}


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

const long long MOD = 1000000007;

long long modpow(long long n, int p) {
  if (p == 0) return 1;
  else if (p % 2 == 0) {
    long long tmp = modpow(n, p / 2) % MOD;
    return (tmp * tmp) % MOD;
  } else {
    return (n * modpow(n, p - 1)) % MOD;
  }
}

void Main() {
  int n, m;
  cin >> n >> m;
  map<int, int> pn;
  for (int i = 2; i * i <= m; i++) {
    while (m % i == 0) {
      pn[i]++;
      m /= i;
    }
  }
  if (m > 1) pn[m]++;

  long long ans = 1;
  for (auto p: pn) {
    int b = p.second;
    for (int i = 0; i < b; i++) {
      ans = ans * (b + n - 1 - i) % MOD;
    }
    for (int i = 0; i < b; i++) {
      ans = ans * modpow((i + 1), MOD - 2) % MOD;
    }
  }
  cout << ans << endl;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int main(){
    int a, b, c, d, e, f;
    sc(a) sc(b) sc(c) sc(d) sc(e) sc(f)
    int water[2] = {100*a, 100*b},sugar[2] = {c, d};
    int tmpw, tmps;
    P ans = P(0, 0);
    for (int i = 0; i <= 3000; i++){
        tmpw = water[0]*i;
        if (tmpw > f) break;
        for (int j = 0; j <= 3000; j++){
            tmpw = water[0]*i + water[1]*j;
            if (tmpw > f) break;
            for (int x = 0; x <= 3000; x++){
                tmps = sugar[0]*x;
                if(tmpw + tmps > f) break;
                for (int y = 0; y <= 3000; y++){
                    tmps = sugar[0]*x + sugar[1]*y;
                    if (tmpw + tmps > f) break;
                    if (tmpw * e < tmps * 100) break;
                    if (ans.first == 0) ans = P(tmpw + tmps, tmps);
                    else if (ans.second*(tmpw+tmps) < \
                    tmps*ans.first) ans = P(tmpw + tmps, tmps);
                }
            }
        }
    }
    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	s=input().rstrip().decode()

	w=[0]*(n+1)
	r=[0]*(n+1)

	for i,ss in enumerate(s):
		if ss=="W":
			w[i+1]=w[i]+1
		else:
			w[i+1]=w[i]

	for i,ss in enumerate(reversed(s)):
		if ss=="R":
			r[i+1]=r[i]+1
		else:
			r[i+1]=r[i]

	#print(w,r)

	ans=0
	for i,j in zip(w[1:],reversed(r[1:])):
		ans=max(ans,min(i,j))
	print(ans)




if __name__ == "__main__":
	main()


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

int main()
{
    //入力
    long double a,b,th_deg;
    cin>>a>>b>>th_deg;

    //degをradに変換
    long double th_rad=th_deg*M_PI/180.0;

    //2辺の長さa,bとその間の角θが分かっているときの、3角形の面積
    long double s=1.0/2.0*a*b*sin(th_rad);

    //aを底辺としたときの高さh
    long double h=b*sin(th_rad);

    //三角形の周長L
    long double l=a+b+sqrt(b*sin(th_rad)*b*sin(th_rad)+(a-b*cos(th_rad))*(a-b*cos(th_rad)));

    //出力
    cout << fixed << setprecision(15) << s << endl;
    cout << fixed << setprecision(15) << l << endl;
    cout << fixed << setprecision(15) << h << endl;

    return 0;
}


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

int main() {
	char S[10];
	cin >> S;
	int X, gap, min;
	for (int i = 0; i < strlen(S)-2; i++) {
		X = ((S[i] - '0') * 100) + ((S[i+1] - '0') * 10) + (S[i+2] - '0');
		gap = abs(X - 753);
		if (i == 0) min = gap;
		else if (min > gap) min = gap;
	}
	cout << min << endl;
	
	return 0;
}

Measured memory_bytes: 256