akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto bs = new int[][](K*2, K*2);
    auto ws = new int[][](K*2, K*2);
    foreach (_; 0..N) {
        auto xyc = readln.split;
        auto x = xyc[0].to!int % (K*2);
        auto y = xyc[1].to!int % (K*2);
        if (xyc[2] == "B") {
            bs[y][x] += 1;
        } else {
            ws[y][x] += 1;
        }
    }
    foreach (i; 0..K*2) {
        foreach (j; 0..K*2) {
            if (i > 0) {
                bs[i][j] += bs[i-1][j];
                ws[i][j] += ws[i-1][j];
            }
            if (j > 0) {
                bs[i][j] += bs[i][j-1];
                ws[i][j] += ws[i][j-1];
            }
            if (i > 0 && j > 0) {
                bs[i][j] -= bs[i-1][j-1];
                ws[i][j] -= ws[i-1][j-1];
            }
        }
    }

    int r;
    auto m = K*2-1;
    foreach (i; 0..K) {
        foreach (j; 0..K) {
            r = max(r,
                bs[m][m] - bs[K+i][m] - bs[m][K+j] + bs[K+i][K+j]
                + bs[K+i][K+j] - bs[i][K+j] - bs[K+i][j] + bs[i][j]
                + bs[i][m] - bs[i][K+j]
                + bs[m][j] - bs[K+i][j]
                + bs[i][j]
                + ws[K+i][m] - ws[K+i][K+j] - ws[i][m] + ws[i][K+j]
                + ws[m][K+j] - ws[K+i][K+j] - ws[m][j] + ws[K+i][j]
                + ws[i][K+j] - ws[i][j]
                + ws[K+i][j] - ws[i][j]
            );
            r = max(r,
                ws[m][m] - ws[K+i][m] - ws[m][K+j] + ws[K+i][K+j]
                + ws[K+i][K+j] - ws[i][K+j] - ws[K+i][j] + ws[i][j]
                + ws[i][m] - ws[i][K+j]
                + ws[m][j] - ws[K+i][j]
                + ws[i][j]
                + bs[K+i][m] - bs[K+i][K+j] - bs[i][m] + bs[i][K+j]
                + bs[m][K+j] - bs[K+i][K+j] - bs[m][j] + bs[K+i][j]
                + bs[i][K+j] - bs[i][j]
                + bs[K+i][j] - bs[i][j]
            );
        }
    }
    writeln(r);
} 

Measured memory_bytes: 34684
N, L = $stdin.read.chomp.split(" ").map(&:to_i)

sum = (2 * L + N - 1) * N / 2

if L < 0
  if L + N - 1 >= 0
    puts sum
  else
    puts sum - (L + N - 1)
  end
else
  puts sum - L
end


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll sa = 0, sb = 0, n, cnt = 0, cnta = 0, cntb = 0;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i], sa += a[i];
  rep(i, n) cin >> b[i], sb += b[i];

  rep(i, n) {
    if (a[i] > b[i])
      cnta += (a[i] - b[i]);
    else if (a[i] < b[i])
      cntb += (b[i] - a[i]) / 2;
  }

  cout << (cnta <= cntb ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 512
def resolve():
    N = int(input())
    AC=0;WA=0;TLE=0;RE=0
    for i in range(N):
        S = input()
        if S=="AC":
            AC+=1
        elif S=="WA":
            WA+=1
        elif S=="TLE":
            TLE+=1
        elif S=="RE":
            RE+=1

    print("AC x "+str(AC))        
    print("WA x "+str(WA))        
    print("TLE x "+str(TLE))        
    print("RE x "+str(RE))    

resolve()

Measured memory_bytes: 9212
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
//ll ss[2][(1<<22)+10];
       int main()
       
       {
        fast
    
         
        string s;
        cin>>s;
        sort(all(s));
        if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
        {
            Yes
        }
    else
    {
        No
    }
    
    
    
    
    
    
    
        
       
          re
}


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

// マクロ //
#define rep(i,N) for(long long int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// 定数 //
#define pi acos(-1)
// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    lint N;   
    cin >> N;

    vli vec(N);
	lint p;
	rep(i, N) {
		cin >> p;
		vec[i] = p;
	}
    vli suvec = vec;

    sort(suvec);
    suvec.push_back(-1);

    lint conseq = 1LL;
    vli memo(N + 1);

    rep(i, N) {
        if (suvec[i] == suvec[i + 1]) {
            conseq++;
        }
        else {
            memo[suvec[i]] = conseq;
            conseq = 1LL;
        }
    }
    lint sum = 0;
    rep(i, N + 1) {
        sum += (memo[i] * (memo[i] - 1LL) / 2LL);
    }
    rep(i, N) {
        cou(sum - (memo[vec[i]] * (memo[vec[i]] - 1LL)) / 2LL + ((memo[vec[i]] - 1) * (memo[vec[i]] - 2LL)) / 2LL);
    }

}

Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int pos=0;
  for(auto c:s) {
    if(pos==0&&c=='C')pos++;
    if(pos==1&&c=='F')pos++;
  }
  if(pos==2)puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int r,d,x;
	cin >> r>> d>> x;
    fr(i,10){
      x = r*x-d;
      cout << x << endl;
    }
}


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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
  
  int n, m; cin >> n >> m;
  int ms[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<pi> v;

  rep(i, m){
    int a; cin >> a;
    v.pb(mp(ms[a - 1], a));
  }

  sort(all(v));
  vector<string> dp(n + 1, "");
  dp[0] += '0';
  vi digit(9, 0);

  for(int i = 2; i <= n; i++){
    rep(j, v.size()){
      int pos = i - v[j].first;
      if(pos >= 0 and dp[pos] != ""){

        string s = dp[pos] + to_string(v[j].second);
        //cout << i << ' ' << s << endl;
 
        if(dp[i].length() <= s.length()){
          sort(s.rbegin(), s.rend());
          chmax(dp[i], s);
        }

      }
    }
  }

  string ans = dp[n].substr(0, dp[n].length() - 1);
  pr(ans);

  return 0;
}


Measured memory_bytes: 25600
n,m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  A[i].pop(0)
 
ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
 
print(ans)

Measured memory_bytes: 3064
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long a = Long.parseLong(sc.next());
	long b = Long.parseLong(sc.next());
	long x = Long.parseLong(sc.next());

	if(x==1) {
	    System.out.println(b-a+1);
	    return;
	}

	long ans = b/x - a/x;
	if(a%x==0) ans++;
	System.out.println(ans);

    }
}

Measured memory_bytes: 23760
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def isqrt(n):
    if n > 0:
        x = 1 << (n.bit_length() + 1) // 2
        y = (x + n // x) // 2
        while y < x:
            x = y
            y = (x + n // x) // 2
        return x
    elif n == 0:
        return 0
    else:
        raise ValueError("isqrt() argument must be nonnegative")


def main():
    N = int(readline())
    n = (isqrt(8 * N + 1) - 1) // 2
    if N != n * (n + 1) // 2:
        print('No')
        return

    it = iter(range(1, N + 1))
    G = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(i + 1):
            G[i][j] = G[j][i] = next(it)

    G.append([G[i][i] for i in range(n)])
    ans = ["{} {}".format(n, ' '.join(map(str, row))) for row in G]
    print('Yes')
    print(n + 1)
    print('\n'.join(ans))
    return


if __name__ == '__main__':
    main()


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

int main() {
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) cout << 'F';
        else if (m + f >= 80) cout << 'A';
        else if (m + f >= 65) cout << 'B';
        else if (m + f >= 50 || (m + f >= 30 && r >= 50)) cout << 'C';
        else if (m + f >= 30) cout << 'D';
        else cout << 'F';
        cout << endl;
    }
}

Measured memory_bytes: 1152
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


N, M = [int(n) for n in input().split()]
X = [0]*M
Y = [0]*M
Z = [0]*M
UF = UnionFind(N)
adj = [[0, []] for _ in range(N)]
for i in range(M):
    X[i], Y[i], Z[i] = [int(n) for n in input().split()]
    Z[i] %= 2
    X[i] -= 1
    Y[i] -= 1
    UF.union(X[i], Y[i])
s = set([UF.find(0)])
ans = 1

for i in range(1, N):
    tmp = UF.find(i)
    if not(tmp in s):
        ans += 1
        s.add(tmp)
print(ans)


Measured memory_bytes: 91168
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;


lli rep_pow(lli x, lli p, lli m = 1000000007)
{
	if (p == 1) return x % m;
	lli b = rep_pow(x, p / 2, m) % m;
	if (p % 2 == 0) { return (b * b) % m; }
	else { return (x * ((b * b) % m)) % m; }
}
void solve()
{
	lli H, W, A, B;
	cin >> H >> W >> A >> B;
	//階乗
	vector<lli> fa(200010);
	fa[0] = fa[1] = 1;
	for (lli i = 2; i <= 200000; i++) {
		fa[i] = (fa[i - 1] * i) % inf;
	}
	//逆元
	vector<lli> re(200010);
	re[0] = re[1] = 1;
	for (lli i = 2; i <= 200000; i++) {
		re[i] = rep_pow(fa[i], inf - 2, inf) % inf;
	}
	lli ans = 0;
	for (lli b = B + 1; b <= W; b++) {
		//上側(H-A)(x)の経路数
		lli half = fa[H - A + b - 2] * re[H - A - 1] % inf * re[b - 1] % inf;
		//下側(A)(W-x+1)の経路数
		lli _half = fa[A - 1 + W - b] * re[A - 1] % inf * re[W - b] % inf;
		ans += half % inf * _half % inf;
		ans %= inf;
		/*cout << b << " : " << H - A - 1 << " " << _half << endl;
		cout << b << " : " << half << " " << _half << endl;*/
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return 0;
}

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

using namespace std;
int n;
int a[1005];
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int t=1;
    for(int i=1;i<=n;i++)
    {
        t=t*a[i]/gcd(t,a[i]);
    }
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum=sum+t/a[i];
    }
    double ans=1.0*t/sum;
    printf("%.10f",ans);
    return 0;
}


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

int main() {
    int M = 1 << 18 + 1;
    int N;
    cin >> N;
    vector<int> A(N), a(N), ord(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        a[i] = A[i];
    }

    sort(a.begin(), a.end());
    for ( int i = 0; i < N; i++ ) {
        ord[i] = lower_bound(a.begin(), a.end(), A[i]) - a.begin();
    }

    ll ans = 0;
    vector<int> bit(M);
    int k,sum;
    for ( int i = 0; i < N; i++ ) {
        // add
        k = ord[i] + 1;
        while ( k <= M ) {
            bit[k]++;
            k += k & -k;
        }
        // sum
        sum = 0;
        k = ord[i] + 1;
        while ( k > 0 ) {
            sum += bit[k];
            k -= k & -k;
        }
        
        ans += i + 1 - sum;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7344
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int MOD=1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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;
  }

  // for prime mod
  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;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> c0(60,0);
	vector<ll> c1(60,0);
	rep(i,n){
		cin>>a[i];
		rep(j,60){
			if (a[i]>>j & 1) c1[j]++;
			else c0[j]++;
		}
	}

	ll ans=0;
	ll cnt=1;
	rep(i,60){
		ll temp=c1[i]*c0[i];
		temp%=mod;
		ans+=temp*cnt;
		cnt=(cnt*2)%mod;
		ans%=mod;
//		cout<<temp<<'t'<<i<<'i'<<endl;

	}
	cout<<ans;


}


Measured memory_bytes: 2560
#include<stdio.h>//２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラム

int main(void){

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

	if(a<b)
		printf("a < b\n");
	else if(a>b)
		printf("a > b\n");
	else 
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = java.lang.Long.parseLong(sc.next());
		sc.close();
		String ans = "";

		while( n > 0) {
			n -= 1;
			ans += (char)('a' + n % 26);
			n /= 26;
		}
		
		for(int i = 0; i < ans.length(); i++) {
			System.out.print(ans.charAt(ans.length() - 1 - i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 27036
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 2e6 + 5, MX = 1e9;
char a[N];
int rev(int n){
    int ret = 0;
    while (n) {
        ret = ret * 10 + n % 10;
        n /= 10;
    }
    return ret;
}
int main(){
    int a = D(), b = D(), ans = 0;
    for(int i = a; i <= b; ++i){
        ans += rev(i) == i;
    }
    printf("%d", ans);
    return 0;
}


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

ll f(ll n){
    return n*(n+1)/2;
}

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

    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=f(n/i)*i;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

Measured memory_bytes: 596
#include<stdio.h>

int Zeller(int,int,int);

int main(void){
  int i,j,sum,a,b;
  
  while(1){
    sum=0;
    scanf("%d %d",&a,&b);
    if(a==0 && b==0)break;

    switch(Zeller(2004,a,b)){
    case 0:
      printf("Sunday\n");
      break;
    case 1:
      printf("Monday\n");
      break;
    case 2:
      printf("Tuesday\n");
      break;
    case 3:
      printf("Wednesday\n");
      break;
    case 4:
      printf("Thursday\n");
      break;
    case 5:
      printf("Friday\n");
      break;
    case 6:
      printf("Saturday\n");
      break;
    }
  }
  return 0;
}

int Zeller(int year, int month, int day){
    if (month == 1 || month == 2) {
        year--;
        month += 12;
    }
    return (year + year/4 - year/100 + year/400
            + (13*month+8)/5 + day) % 7;
}

Measured memory_bytes: 584
#include<stdio.h>
int R=1,C=1,H[2000020],N[2000020];
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
void prls(int v,int *ta,int *to,int *nt){
  int i,j;
  for(i=1;i<=v;i++){
    printf("%d:",i);
    for(j=ta[i];j+1;j=nt[j])printf("%d ",to[j]);
    printf("\n");
  }
  printf("\n");
}
int CO[100010];
void dijk(int v,int e,const int *fr,int *to,const int *co,int mi){
  int i,id[100010],ta[100010],nt[200010],f[100010]={0};
  for(i=1;i<=v;i++)ta[i]=-1;
  for(i=1;i<=v;i++)CO[i]=1010000000;
  for(i=CO[mi]=0;i<e;i++){
    nt[i]=ta[fr[i]];
    ta[fr[i]]=i;
  }
  //prls(v,ta,to,nt);
  while(f[mi]-1){
    f[mi]=1;
    for(i=ta[mi];i+1;i=nt[i]){
      if(CO[mi]>co[i])continue;//printf("to%d\n",to[i]);
      if(CO[to[i]]>co[i])hin(CO[id[R]=to[i]]=co[i]);//,printf("to%d\n",to[i]);
    }//printf("%d\n",mi);
    //for(i=0;i<v;i++)printf("%d ",CO[i+1]);printf("\n");
    while(f[mi]&&C-1)mi=id[hout()];
  }
}
int main(){
  int i,max,n,m,a[200010],b[200010],c[200010];
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  dijk(n,m,a,b,c,1);
  max=-1;
  //for(i=0;i<n;i++)printf("%d\n",CO[i+1]);
  for(i=0;i<m;i++){//printf("%d %d\n",i,CO[i]);
    if(b[i]-n||CO[a[i]]>c[i])continue;
    if(max<c[i])max=c[i];
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 9560
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

ll gcd(ll a, ll b){
  if(b == 0) return a;

  return gcd(b, a%b);
}

/*

 */
int a,b,c;

int main(){
  cin>>a>>b>>c;
  if(c%gcd(a,b) == 0)
    cout << "YES\n";
  else
    cout<<"NO\n";

  return 0;
}


Measured memory_bytes: 256
let change n m d =
  let t = Array.make (n + 1) max_int in
  t.(0) <- 0;
  let rec doit i x =
    if i = m then t.(n)
    else
      let v = x + d.(i) in
      if v > n then doit (i + 1) 0
      else begin
        t.(v) <- min t.(v) (t.(x) + 1);
        doit i (x + 1)
      end in
  doit 0 0

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> (n, m)) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  change n m d |> Printf.printf "%d\n"

Measured memory_bytes: 2808
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
  
int main() {
  int N;
  cin >> N;
  
  cout << N*(N+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
const int N=1e5+5;
char str[N];

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
	scanf("%s",str+1);
	int ans=0;
	for(int i=strlen(str+1); i>1; --i){
		ans+=str[i]!=str[i-1];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
def gcd(a, b)
  a, b = b, a if a < b
  return a if b == 0
  gcd(b, a % b)
end

def lcm(a, b)
  return a * b / gcd(a, b)
end

n = gets.chomp.split(' ').map(&:to_i)[0]
t = []
n.times {|n| t[n] = gets.chomp.split(' ').map(&:to_i)[0] }
m = 1
d = t[0]
t.each { |t| m = lcm(m, t) }
puts m

Measured memory_bytes: 1916
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (N, M) = rd.readIntArray()
    val eg = edge<Int>(N)
    for (i in 0 until M) {
        val (a, b) = rd.readIntArray().map{ it-1 }
        eg[a].add(b)
        eg[b].add(a)
    }

    var ans = 0
    val vis = BooleanArray(N) { false }

    fun dfs(x: Int) {
        vis[x] = true
        if (vis.count{it} >= N) {
            ans++
            vis[x] = false
            return
        }

        for (nx in eg[x]) {
            if (vis[nx]) continue
            dfs(nx)
        }

        vis[x] = false
    }

    dfs(0)

    println(ans)
}


//val rd = debug.Reader("abc", "054", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 38332
#include<stdio.h>
int main()
{

int n,k,i;
scanf("%d%d",&n,&k);
char S[n];
scanf("%s",S);
for(i=0;i<n;i++)
{
    if(i+1==k)
        S[i]=S[i]+32;
}

printf("%s",S);

return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x)
{
    if(x==2)return true;
    if(!(x&1))return false;
    for(int i=2;i*i<=x;i++)
        if(x%i==0)return false;
    return true;
}
int main()
{
    int n;cin>>n;
    for(int i=n;i<=200000;i++)
    {
        if(isprime(i)){cout<<i<<endl;return 0;}
    }
}


Measured memory_bytes: 256
using System;

class ABC_136_C
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] H = new int[N];
        int[] B = new int[N];
        for (int i = 0; i < N; i++)
        {
            H[i] = int.Parse(input[i]);
        }

        for (int i = 0; i < N-1; i++)
        {
            if (H[i] > H[i + 1])
            {
                H[i] -= 1;
                B[i] = 1;
                for(int j=i; j>0; j--)
                {
                    if (H[j - 1] > H[j] && B[j - 1] == 0)
                    {
                        H[j - 1] -= 1;
                        B[j - 1] = 1;
                    }
                    else break;
                }
            }
        }

        for (int i = 0; i < N - 1; i++)
        {
            if (H[i] > H[i + 1])
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll B,W,inv[200005],f[200005],p[200005],w[200005],b[200005];
ll C(ll n,ll m)
{
    ll ans=f[n]*inv[n-m]%mod*inv[m]%mod;
    return ans;
}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%lld%lld",&B,&W);
    f[0]=1;inv[0]=1;
    for(int i=1;i<=B+W;i++)
        f[i]=f[i-1]*i%mod,inv[i]=qpow(f[i],mod-2);
    p[0]=1;
    for(int i=1;i<=B+W;i++)
        p[i]=p[i-1]*(mod-mod/2)%mod;
    for(int i=B;i<B+W;i++)
        b[i]=p[i]*C(i-1,B-1)%mod;
    for(int i=W;i<B+W;i++)
        w[i]=p[i]*C(i-1,W-1)%mod;
    for(int i=1;i<=B+W;i++)
    {
        w[i]=(w[i]+w[i-1])%mod;
        b[i]=(b[i]+b[i-1])%mod;
    }
    for(int i=1;i<=B+W;i++)
    {
        ll ans=w[i-1]+(1-w[i-1]-b[i-1])*(i==B+W?1:(mod-mod/2))%mod;
        printf("%lld\n",(ans%mod+mod)%mod);
    }
}


Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            List<int>[] tonari = new List<int>[n];
            for(int i=0;i<n;i++){
                tonari[i] = new List<int>();
            }
            for(int i=0;i<n-1;i++){
                string[] hoge = Console.ReadLine().Split();
                int a = int.Parse(hoge[0])-1;
                int b = int.Parse(hoge[1])-1;
                tonari[a].Add(b);
                tonari[b].Add(a);
            }
            string[] cst = Console.ReadLine().Split();
            int[] c = new int[n];
            int maxind = 0;
            for(int i=0;i<n;i++){
                c[i] = int.Parse(cst[i]);
            }
            Array.Sort(c);

            int ans = 0;
            int[] ans2 = new int[n];

            Queue<int> q = new Queue<int>();
            q.Enqueue(0);

            bool[] moumita = new bool[n];
            for(int i=0;i<n;i++){
                moumita[i] = false;
            }
            moumita[0]=true;
            int imac = n-1;

            while(q.Count>0){
                int ima = q.Dequeue();
                foreach(int i in tonari[ima]){
                    if(!moumita[i]){
                        q.Enqueue(i);
                        
                    }
                }
                moumita[ima] = true;
                ans2[ima] = c[imac];
                        imac --;
            }
            for(int i=0;i<n;i++){
                if(c[maxind]<c[i])maxind = i;
            }
            for(int i=0;i<n;i++){
                if(!(maxind==i)){
                    ans += c[i];
                }
            }

            Console.WriteLine(ans);

            for(int i=0;i<n-1;i++){
                Console.Write(ans2[i]);
                Console.Write(" ");
            }
            Console.WriteLine(ans2[n-1]);
        }
    }
}

Measured memory_bytes: 15968
fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (aStr, bStr) = line.split(" ").map {it}

    val aIchi = aStr.indexOf(".")
    val aWari = if (aIchi >= aStr.length - 3) {
        Math.pow(10.0, (aStr.length - aIchi  - 1).toDouble()).toLong()
    } else {
        1L
    }

    val bIchi = bStr.indexOf(".")
    val bWari = if (bIchi >= bStr.length - 3) {
        Math.pow(10.0, (bStr.length - bIchi  - 1).toDouble()).toLong()
    } else {
        1L
    }

    val aLong = aStr.replace(".", "").toLong()
    val bLong = bStr.replace(".", "").toLong()

    val result: Long = aLong * bLong / (aWari * bWari)

    println("${result}")
}

Measured memory_bytes: 39808
#include<bits/stdc++.h>
using namespace std;
int m,d,ans;
int main(void){
	scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++){
		for(int sw=22;sw<=d;sw++){
			int g=sw%10;
			int s=sw/10;
			if(g>=2&&s>=2&&s*g==i)
				ans++;
		}
	} 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int x, y;
    cin >> x >> y;
    if(x >= y){
        if(x % y == 0){
            COUT("-1");
            return 0;
     
        }
    }

    COUT(x);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
  char S[4], T[4];
  int i;
  int a = 0;

  scanf ("%s", S);
  scanf ("%s", T);

  for (i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      a++;
    }
  }

  printf ("%d", a);
}

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

int main() {
  int n;
  cin >> n;
  vector<string> ss(n);
  for (auto &&s : ss) {
    cin >> s;
  }
  
  for (auto &&s : ss) {
    sort(s.begin(), s.end());
  }
  
  unordered_map<string, int64_t> ump;
  
  int64_t ans = 0;
  
  for (auto &&s : ss) {
    ans += ump[s]++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(void){
	string s;
	cin >> s;
	int n = 700;
	if(s[0] =='o')n += 100;
	if(s[1] =='o')n += 100;
	if(s[2] =='o')n += 100;
	 cout <<n<<endl;;
	
	return 0;
}

Measured memory_bytes: 256
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

# def printA(A):
#     for i, n in enumerate(A):
#         print(n, end='')
#         if i != N-1:
#             print(' ', end='')
#     print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d


x, y = [int(x) for x in input().split()]

print(mymath.gcd(x, y))




Measured memory_bytes: 5684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 079
	// https://atcoder.jp/contests/abc079/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int yen = sc.nextInt();
		
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				for (int k = 0; k <= n - i - j; k++) {
					if ((10000 * i + 5000 * j + 1000 * k) == yen && (i + j + k) == n) {
						System.out.println("" + i + " " + j + " " + k);
						System.exit(0);
					}
				}
			}
		}
		
		System.out.println("-1 -1 -1");
	}
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N;
    map<string,int>m;
    string s[N];
    for(int i=0;i<N;i++){
        cin>>s[i];
    }
    for(int i=0;i<N;i++){
        m[s[i]]++;
    }
    cin>>M;
    string t[M];
    for(int i=0;i<M;i++){
        cin>>t[i];
    }
    for(int i=0;i<M;i++){
        m[t[i]]--;
    }
    int ma=-200;
    for(int i=0;i<N;i++){
        ma=max(m[s[i]],ma);
    }
    for(int i=0;i<M;i++){
        ma=max(m[t[i]],ma);
    }
    cout<<(ma<0?0:ma)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int b[110000];
int ret[110000];
int p[110000];
int q[110000];
int nx[20][110000];
int main(){
    int a;scanf("%d",&a);
    for(int i=0;i<a;i++)scanf("%d",b+i);
     
    int c;scanf("%d",&c);
    int d;scanf("%d",&d);
    for(int i=0;i<d;i++)scanf("%d%d",p+i,q+i);
    for(int i=0;i<d;i++){
        p[i]--;q[i]--;
    }
    for(int i=0;i<a;i++){
        nx[0][i]=upper_bound(b,b+a,b[i]+c)-b-1;
    }
    for(int i=1;i<20;i++){
        for(int j=0;j<a;j++){
            nx[i][j]=nx[i-1][nx[i-1][j]];
        }
    }
    for(int i=0;i<d;i++){
        if(p[i]>q[i])swap(p[i],q[i]);
        int at=p[i];
        for(int j=19;j>=0;j--){
            if(nx[j][at]<q[i]){
                at=nx[j][at];
                ret[i]+=(1<<j);
            }
        }
        ret[i]++;
    }
    for(int i=0;i<d;i++)printf("%d\n",ret[i]);
}

Measured memory_bytes: 10880
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();//頂点数
		int[][] E = new int[V+1][V+1];//a→cに向かうかどうか 1なら向かう
		for(int i = 1; i <= V; i++) {
			int a = sc.nextInt();//頂点番号
			int b = sc.nextInt();//出次数
			for(int k = 0; k < b; k++) {
				int c = sc.nextInt();//出次している番号
				E[a][c] = 1; //a→cに向かうかどうか 1なら向かう
			}
		}
		int[] D = bfs(V, E);
		
		for(int i = 1; i <= V; i++) {
			System.out.println(i + " " + (D[i] -1));
		}
		sc.close();
	}
	
	int[] bfs(int V, int[][] E) { //V:頂点数, E[a][b]:a→bに向かうなら1、そうでないなら0
		Queue<Integer> Q = new ArrayDeque<>();
		Q.add(1);//ノード1から始める
		int D[] = new int[V+1];
		D[1] = 1; //D[a] : ノードaの深さ（D[a]=0ならまだ通過していない）
		while(Q.size() > 0) {//キューに値が入っている間
			int cur = Q.poll();	//cur : 今考えている点
			for(int d = 1; d <= V; d++) { //d : 次向かう点
				if(E[cur][d] == 1 & D[d] == 0) { //E[cur][d]cur→dに向かうかどうか 1なら次向かう
					D[d] = D[cur]+1; //Dに深さを格納
					Q.add(d);//キューに値追加
				}
			}
		}
		return D; //各ノードの深さを返す
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


Measured memory_bytes: 28712
using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            Console.WriteLine(a*b + " " +2*(a+b));
        }
    }
}


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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9


int a[10][10];

int main() {
	
	int f=0;
	
	for(int i=0;i<3;i++) {
		for(int j=0;j<3;j++) {
			scanf("%d",&a[i][j]);
		}
	}
	
	for(int i=0;i<3;i++) {
		for(int j=0;j<2;j++) {
			a[i][j]=a[i][j+1]-a[i][j];
		}
	}
	
	for(int i=0;i<2;i++) {
		for(int j=0;j<2;j++) {
			if(a[i][j]!=a[i+1][j]) {
				f=1;
				break;
			}
		}
	}
	
	if(f==1) puts("No");
	else     puts("Yes");
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define ll long long 
#define mp make_pair 
#define pb push_back 

using namespace std;

void test(){
	ll n,k;
	cin>>n>>k;
	ll m = n%k;
	ll ans = min(n,min(m,k-m));
	cout<<ans<<"\n";
}

int main(){
//	std::ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

int main(){
    std::vector<std::vector<int>> a(3, std::vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            std::cin >> a[i][j];
        }        
    }
    int n;
    std::cin >> n;
    std::vector<std::vector<bool>> flag(3, std::vector<bool>(3));
    
    for (int i = 0; i < n; i++)
    {
        int b;
        std::cin >> b;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (a[i][j] == b)
                {
                    flag[i][j] = true;
                }
            }
        }
    }
    
    for (int i = 0; i < 3; i++)
    {
        if (flag[i][0] && flag[i][1] && flag[i][2])
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    for (int j = 0; j < 3; j++)
    {
        if (flag[0][j] && flag[1][j] && flag[2][j])
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    if ((flag[0][0] && flag[1][1] && flag[2][2]) || (flag[2][0] && flag[1][1] && flag[0][2]))
    {
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    int ans=1;
    int sub=1;
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      if(A[i]%2==0){
        sub=sub*2;
      }
      ans=ans*3;
    }
    System.out.println(ans-sub);
  }
    


  
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define INF 0
typedef long long int ll;

typedef struct ST{ 
	vector<ll> a;
	int n;
	void init(vector<ll> &b){
		int size= b.size();
		n=1;
		while(n<size) n*=2;
		a =vector<ll> (2*n-1,INF);
		for(int i=0;i<size;i++)	a[i+n-1] = b[i];
		for(int i=n-2;i>=0;i--) a[i] = max(a[i*2+1],a[i*2+2]); //RMQ
	}
	void update(int k,ll val){
		k+=n-1;
		a[k] = val;
		while(k>0){
			k = (k-1)/2;
			a[k] = max(a[k*2+1],a[k*2+2]);//RMQ
		}
	}
	// [aa,b)の最大値
	// kは節点番号l,rはその節点が[l,r)に対応
	// get(aa,b,0,0,n)
	ll get(int aa,int b,int k,int l,int r){
		//[aa,b)に完全に[l,r)が含んでいる場合 この節点
		if(aa<=l && r<=b) return a[k];
		
		//[aa,b)と[l,r)が交差しなければ INF
		if(r<=aa || b<=l) return INF;
		ll vl = get(aa,b,k*2+1,l,(l+r)/2);
		ll vr = get(aa,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
	ll find(int aa,int b){
		return get(aa,b,0,0,n);
	}	
}ST;



int main(){
	int n;
	cin>>n;
	vector<ll> b(n+2,0);
	ST seg;
	seg.init(b);
	vector<ll> a(n),h(n);
	for(int i=0;i<n;i++) cin>>h[i];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
	    ll M  = seg.find(0,h[i]);
	    seg.update(h[i], M + a[i] ) ;
	}
	cout<<seg.find(0,n+1)<<endl;

	return 0;
}

Measured memory_bytes: 9088
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	int ans=0;
	for(int i=10;i<=1000000;i=i*100){
		if(n>=i){
			ans+=9*i/10;
		} 
		else if(n>=i/10){
			ans+=n-i/10+1;
			break;
		}
		else{
			break;
		}
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
import math
N = int(input())
xlist = []
dist = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    x,y = map(int, input().split())
    xlist.append([x,y])
ans = 0

for j in range(N):
    x1 = xlist[j][0]
    y1 = xlist[j][1]
    for k in range(j+1,N):
        x2 = xlist[k][0]
        y2 = xlist[k][1]
        di = math.sqrt((x1-x2)**2 + (y1-y2)**2)
        dist[j][k] = di

ans = 0


for i in range(N):
    ans += sum(dist[i])

ans = 2 *ans /N 

print(ans)
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
int main() {
	int a, b, c,res=0;
	int n;
	cin >> n;
	for (a = 1; a <= n; a++) {
		for (b = 1; a * b <= n; b++) {
			if (a * b < n) {
				res++;
			}
		}
	}
	cout << res;
}

Measured memory_bytes: 3632
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (10 ** 9 + 7)

if __name__ == '__main__':
    # ------ 入力 ------#
    nk = list(map(int, input().split()))     # スペース区切り連続数字

    x = nk[1]
    dList = list(map(int, input().split()))     # スペース区切り連続数字

    # ------ 処理 ------#
    f = 0
    n = nk[0]
    while f == 0:
        nList = [int(c) for c in str(n)]  # 数字→単数字リスト変換
        b = 1
        for i in nList:
            for j in dList:
                if i == j:
                    b = 0
                    break
        if b == 1:
            break
        else:
            n += 1

    # ------ 出力 ------#
    print("{}".format(n))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")


Measured memory_bytes: 9076