akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,K=map(int,input().split())
    
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N*M,MOD)
    
    def COM(n, k, MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    ans=0
    for a,b in [(N,M),(M,N)]:
        for i in range(1,a):
            ans+=(i*(a-i)*b**2)
            ans%=MOD
    ans*=COM(N*M-2,K-2,MOD)
    ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43504
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct Cond {
	vector<int>more;
	vector<int>less;
	Cond(const int _num) :more(_num, 0), less(_num, 200) {

	}
};
int main() {
	int M, N; cin >> M >> N;
	vector<Cond>conds;
	for (int i = 0; i < M; ++i) {
		Cond acond(N);
		int K; cin >> K;
		while (K--) {
			int s, t;string  st; cin >> s >> st >> t;
			s--;
			if (st == "<=") {
				acond.less[s] = min(acond.less[s], t);
			}
			else {
				acond.more[s] = max(acond.more[s], t);
			}
		}
		conds.push_back(acond);
	}
	{
		bool ok = true;
		for (int i = 0; i < M; ++i) {
			for (int skill = 0; skill < N; ++skill) {
				if (conds[i].less[skill]<conds[i].more[skill])ok = false;
			}
		}
		if (!ok) {
			cout << "No" << endl;
			return 0;
		}
	}
	vector<vector<int>>edges(M);
	vector<int>toedgesnums(M);
	for (int i = 0; i < M; ++i) {
		for (int j = i+1; j < M; ++j) {
			if (i == j)continue;
			bool itoj = false;
			for (int skill = 0; skill < N; ++skill) {
				if (conds[i].less[skill] < conds[j].more[skill])itoj = true;
			}
			bool jtoi = false;
			for (int skill = 0; skill < N; ++skill) {
				if (conds[j].less[skill] < conds[i].more[skill])jtoi = true;
			}
			if (itoj&&jtoi) {
				cout << "No" << endl;
				return 0;
			}
			if (itoj) {
				edges[i].push_back(j);
				toedgesnums[j]++;
			}
			else if (jtoi) {
				edges[j].push_back(i);
				toedgesnums[i]++;
			}
		}
	}
	queue<int>canget;
	for (int i = 0; i < M; ++i) {
		if (!toedgesnums[i]) {
			canget.emplace(i);
		}
	}
	int getnum = 0;
	while (!canget.empty()) {
		getnum++;
		const int atop(canget.front());
		canget.pop();
		
		for (auto e : edges[atop]) {
			toedgesnums[e]--;
			if (!toedgesnums[e]) {
				canget.emplace(e);
			}
		}
	}
	if (getnum == M) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3320
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> a(n),ans(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(ll i=1;i<=1e9+10;i*=2){
    ll btc=0;
    for(int j=0;j<n;j++){
      if(i&a[j]){
        btc++;
      }
    }
    for(int j=0;j<n;j++){
      if(btc%2==0){
        if(i&a[j]){
          ans[j] += i;
        }
      }else{
        if((i&a[j])==0){
          ans[j] += i;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << ans[i]<<" ";
  }
  cout << endl;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int o = 1;
  while (a > 0 && c > 0) {
    if (o)
      c -= b;
    else
      a -= d;
    o = !o;
  }
  if (a <= 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll N;
    cin>>N;
    vector<int> v(9);
    rep(i,N){
        ll n;
        cin>>n;
        if(1<=n&&n<=399){
          v[0]=1;
        }
        else if(400<=n&&n<=799){
          v[1]=1;
        }
        else if(800<=n&&n<=1199){
          v[2]=1;
        }
        else if(1200<=n&&n<=1599){
          v[3]=1;
        }
        else if(1600<=n&&n<=1999){
          v[4]=1;
        }
        else if(2000<=n&&n<=2399){
          v[5]=1;
        }
        else if(2400<=n&&n<=2799){
          v[6]=1;
        }
        else if(2800<=n&&n<=3199){
          v[7]=1;
        }
        else{
          v[8]++;
        }
    }
    int m,M;
    M=accumulate(v.begin(), v.end(),0);
    m=M-v[8];
    if(m == 0){
      m = 1;
    }
    cout << m <<' '<< M << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;
bool prime[1000010];
void sieve(ll n) { 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) { 
        if (prime[p] == true) {  
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
   
} 
int main(){
	IOS;
	sieve(1000000);
	ll n;
	cin >> n;
	ll ans = 0;
	loop(i, 2, 1000010){
		if(prime[i]){
			ll cnt = 0;
			while(n % i == 0){
				n /= i;
				cnt++;
			}
			//debug(i, cnt);
			ll value = 0, start = 0;
			while( ( start *(start + 1) ) / 2 <= cnt){
				start++;
			}
			ans += (start - 1);
		}		
	}
	if(n != 1)
		ans++;
	cout << ans << endl;
}

Measured memory_bytes: 4576
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m;
  cin>>n>>m;
  vi a(n,0);
  int ca=0,cw=0;
  vi c(n,0);
  rep(i,m){
    int p;
    cin>>p;
    p--;
    string s;
    cin>>s;
    if(s[0]=='A'){
      if(a[p]) continue;
      a[p]++;
      ca++;
      cw+=c[p];
    }
    else{
      if(a[p]) continue;
      c[p]++;
    }
  }
  cout<<ca<<' '<<cw<<endl;

}

Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
  res = [None] * n
  for i in range(n):
    res[i] = II()
  return res
def LIR(n):
  res = [None] * n
  for i in range(n):
    res[i] = LI()
  return res
def FR(n):
  res = [None] * n
  for i in range(n):
    res[i] = IF()
  return res
def LIR(n):
  res = [None] * n
  for i in range(n):
    res[i] = IF()
  return res
def LIR_(n):
  res = [None] * n
  for i in range(n):
    res[i] = LI_()
  return res
def SR(n):
  res = [None] * n
  for i in range(n):
    res[i] = S()
  return res
def LSR(n):
  res = [None] * n
  for i in range(n):
    res[i] = LS()
  return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
  def f(n, c):
    tmp = n % c
    t = tmp
    b = 0
    while tmp:
      if tmp & 1:
        b += 1
      tmp //= 2
    if t:
      return f(t, b) + 1
    else:
      return 1
  n = II()
  a = S()
  b = 0
  for ai in a:
    if ai == "1":
      b += 1
  a = a[::-1]
  bp = 0
  bm = 0
  if b != 1:
    for i, ai in enumerate(a):
      if ai == "1":
        bp += pow(2, i, b + 1)
        bm += pow(2, i, b - 1)
        bp %= b + 1
        bm %= b - 1
    ans = []
    for i, ai in enumerate(a):
      if ai == "1":
        tmpbm = bm - pow(2, i, b - 1)
        tmpbm %= b - 1
        ans.append(f(tmpbm, b - 1))
      else:
        tmpbp = bp + pow(2, i, b + 1)
        tmpbp %= b + 1
        ans.append(f(tmpbp, b + 1))
    for ai in ans[::-1]:
      print(ai)
    return
  else:
    for i, ai in enumerate(a):
      if ai == "1":
        bp += pow(2, i, b + 1)
        bp %= b + 1
    ans = []
    for i, ai in enumerate(a):
      if ai == "1":
        ans.append(0)
      else:
        tmpbp = bp + pow(2, i, b + 1)
        tmpbp %= b + 1
        ans.append(f(tmpbp, b + 1))
    for ai in ans[::-1]:
      print(ai)
    return


#main
if __name__ == '__main__':
  solve()


Measured memory_bytes: 92208
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define int long long
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int s[N];
int dp[N];
int n,k;

int pw(int n, int k)
{
    if (!k) return 1;
    int res = pw(n, k >> 1);
    res = res * res % mod;
    if (k & 1) return n * res % mod;
    return res;
}

void add(int &a, int b)
{
    a += b;
    if (a >= mod) a -= mod;
}

void sub(int &a, int b)
{
    a -= b;
    if (a < 0) a += mod;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
    {
        add(s[i], s[i - 1]);
        dp[i] = (pw(i, n) - s[i] + mod) % mod;
        for (int j = 2; i * j <= k; j++)
        {
            add(s[i * j], dp[i]);
            if ((i + 1) * j <= k) sub(s[(i + 1) * j], dp[i]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        add(ans, i * dp[k / i] % mod);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

struct Coord {
    Int x;
    Int y;
};
double CalcDist(Coord first, Coord second);
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId);
Int Factorial(Int n);

/*
// 引数に関数オブジェクトを渡さない場合
void PermutationLoop(Int n, vector<Coord>& coords) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }

    //double (*const calcDistSum[])(vector<Coord>&, vector<Int>&) = {CalcDistSum}; // 関数ポインタ
    // 関数オブジェクト(ラムダ式使用) ver.1
    // auto calcDistSum = [&coords, &v]() {
    //     return CalcDistSum(coords, v);
    // };
    // 関数オブジェクト(ラムダ式使用) ver.2
    // auto calcDistSum = [&v](vector<Coord>& coords) {
    //     return CalcDistSum(coords, v);
    // };

    double sum = 0;
    do {
        //sum += calcDistSum[0](coords, v); // 関数ポインタ
        //sum += calcDistSum(); // 関数オブジェクト ver.1
        sum += calcDistSum(coords); // 関数オブジェクト ver.2
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return;
}

*/
// 引数に関数オブジェクトを渡す場合
template <typename Func>
void PermutationLoop(Int n, Func func) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }
    double sum = 0;
    do {
        sum += func(v); // 関数オブジェクト ver.3
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return;
}


int main(void) {
    Int n;
    cin >> n;
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cin >> coords[i].x >> coords[i].y;
    }
    // 関数オブジェクト(ラムダ式使用) ver.3: 引数で渡す
    auto calcDistSum = [&coords](vector<Int>& v) {
        return CalcDistSum(coords, v);
    };

    PermutationLoop(n, calcDistSum);
    return 0;
}

double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}



Measured memory_bytes: 3840
#include<stdio.h>
int main()
{
    int x,a,b,z,n,l;
   while(scanf("%d %d %d",&x,&a,&b)!=EOF)
    {
    z=x-a;
    n=z/b;
    l=z-(n*b);
    printf("%d\n",l);
    }

    return 0;
}


Measured memory_bytes: 128
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  int x , y , z;
  scanf("%d %d %d",&x,&y,&z);
  printf("%d %d %d",z,x,y);
return 0 ;
}


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

int main() {
  string s;
  cin >> s;
  int bans = 0;
  int wans = 0;
  for (int i=0; i<s.size(); i++) {
    if (i%2 == 0){
      if (s.at(i) == '1') bans++;
    }
    else {
      if (s.at(i) == '0') bans++;
    }
  }
  for (int i=0; i<s.size(); i++) {
    if (i%2 == 0){
      if (s.at(i) == '0') wans++;
    }
    else {
      if (s.at(i) == '1') wans++;
    }
  }
  cout << min(bans, wans) << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	rep(i, n) {
		int r, t;
		cin >> r >> t;

		int a = r / 100 + (t / 30) * 5;
		int b = r / 100 + (t / 30) * 5 + 1;
		int c = r / 100 + (t / 30) * 5 + 5;
		int d = r / 100 + 1 + (t / 30) * 5 + 5;

		if (r % 100 == 0 && t % 30 == 0) cout <<a<< endl;
		else if (r % 100 == 0 || t % 30 == 0) {
			if (r % 100 == 0)cout <<a<< " " << c << endl;
			else if (t % 30 == 0) cout <<a << " " <<b << endl;
		}
		else  cout << a << " " << b << " " << c << " " << d << endl;
	}
	return 0; 
}

Measured memory_bytes: 3112
import java.util.Scanner;

public final class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);

        String s = stdIn.next();
        char[] cs = s.toCharArray();
        if(cs[0]==cs[1] || cs[1]==cs[2] || cs[2]== cs[3]){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,ans = 0; cin >> N;
  map<string, int> mp;
  rep(i,N){
    string key;
    cin >> key;
    mp[key]++;
    if(ans < mp[key]) ans = mp[key];
  }
  for (auto const& entry: mp){
    int tmp = entry.second;
    if(ans == tmp) cout << entry.first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
	cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
	cout << endl;
 	return 0;
}



Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] numberInfo = new int[100000 +1];
		long total = 0;
		for(int i =0;i < n;i++) {
			int tmp = sc.nextInt();
			numberInfo[tmp]++;
			total+= tmp;

		}
		int q = sc.nextInt();
		for(int i = 0; i < q; i++) {
			int b = sc.nextInt();
			int c = sc.nextInt();
			total += (c -b) * numberInfo[b];
			System.out.println(total);
			numberInfo[c] += numberInfo[b];
			numberInfo[b] = 0;
		}
	}
}


Measured memory_bytes: 60232
#include "bits/stdc++.h"
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define out(ans) cout << ans << endl
long long dp[100010];

int main(){

  int n;cin>>n;
  dp[0]=0;
  for(int i=1;i<=n;i++){
    dp[i]=dp[i-1]+1;
    for(int j=6;j<=i;j*=6)chmin(dp[i],dp[i-j]+1);
    for(int j=9;j<=i;j*=9)chmin(dp[i],dp[i-j]+1);
  }

  out(dp[n]);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	int n;
	int ans = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
		if(i%2 == 0 && a[i]%2 == 1){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
# include <iostream>

using namespace std;

//https://atcoder.jp/contests/abc088/tasks/abc088_a

int main(){
    int N,A;

    cin >> N >> A;

    if(N % 500 <= A ){
    cout << "Yes" << endl;
    } 
    else if(N % 500 >= A ){
    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val W = sc.nextInt
    val H = sc.nextInt
    val x = sc.nextInt
    val y = sc.nextInt
    val r = sc.nextInt

    val square =
      List((x + r, y), (x, y + r), (x - r, y), (x, y - r),
        (x + r, y + r), (x + r, y - r), (x - r, y + r), (x - r, y - r))
    val safe = square.map {
      case (t, u) =>
        t >= 0 && t <= W && u >= 0 && u <= H
      case _ => false
    }.reduce((l, r) => l && r)

    if (safe) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 45132
#include <stdio.h>


int main(void)
{
	//変数の宣言
	int x,a,b;
	int ans;
	
	//データの読み込み
	scanf("%d",&x);
	scanf("%d",&a);
	scanf("%d",&b);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans = (x-a)%b;
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
// ------------------------------------
// Date:2018/ 2/23
// Problem:ABC 046 AtCoDeerAndPaintCans a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

#define MOD 1000000007

int main()
{
  int t = -1,ans = 0;
  vector<int> n(3);
  REP(i,3) cin >> n[i];
  sort(ALL(n));
  REP(i,3) {
    if (t != n[i]) ++ans;
    t = n[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
  //int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int n,a,b;
  scanf("%d %d", &a, &b);
  int ans = a - 1;
  if(b >= a) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "algorithm"
using namespace std;
int main() {
    int N;
    cin >> N;
    long long int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A,A+N);

    long long int res = A[N-1];
    int number = 2;
    for (int i = N-2; number<N ; i-- ) {
        if(number+2<=N) {
            res = res + 2 * A[i];
            number+=2;
        }else{
            res = res + A[i];
            number++;
        }
    }
    cout << res;
    return 0;

}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll x, n;
    cin >> x >> n;
    if (n == 0) {
        print(x);
        return 0;
    }
    vi p(n);
    rep(i, n) cin >> p[i];
    ll i = 0;
    while (true) {
        if (find(all(p), x - i) == p.end()) {
            print(x - i);
            break;
        }
        else if (find(all(p), x + i) == p.end()) {
            print(x + i);
            break;
        }
        ++i;
    }
}

Measured memory_bytes: 3648
a,b,h,m = gets.chomp.split.map &:to_i

def rad(deg)
  deg * Math::PI / 180
end


long_rag = rad(m / 60.0 * 360)
short_rag = rad( (60 * h + m) / 720.0 * 360)

long = [b * Math.cos(long_rag), b * Math.sin(long_rag)]
short = [a * Math.cos(short_rag), a * Math.sin(short_rag)]

def len(a,b)
  return  Math.sqrt( (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 )
end

puts len(long, short)


Measured memory_bytes: 14808
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
/* calculate n^p mod M. O(log(p)) */ long long modpow(long long n, long long p,
                                                      long long M) {
  long long ans = 1;
  while (p > 0) {
    if (p & 1) ans = (ans * n) % M;
    n = (n * n) % M;
    p >>= 1;
  }
  return ans;
}
LL M = 998244353;

int main() {
  LL N;
  cin >> N;
  VEC<LL> D(N);
  VEC<LL> C(N, 0);
  REP(i, 0, N) {
    cin >> D[i];
    C[D[i]]++;
  }
  // int tmpcnt = 0;
  // REP(i, 0, N) {
  //   if (C[i] == 0) break;
  //   tmpcnt += C[i];
  // }
  // if (tmpcnt != N || C[0]!=1) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  DUMP(C);
  if (D[0] != 0 || C[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  LL ans = 1;
  REP(i, 1, N) {
    ans = (ans * modpow(C[i - 1], C[i], M)) % M;
    DUMP(ans);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

void solve(int n, int *a)
{
    for(int i = 0; i < n; i++) {
        for (int j = i+1; j< n; j++) {
            if(abs(a[i]-a[j])%(n-1) == 0) {
                cout << a[i] << " " << a[j] << endl;
                return;
            }
        }
    }
    return;
}

int main()
{
    int N;
    int a[1000];
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    solve(N, a);

    return 0;
}


Measured memory_bytes: 3140
import sys
input = sys.stdin.readline
MOD = 10**6+3
q = int(input())

fact = [1]*(MOD+1)
for i in range(1, MOD+1):
    fact[i] = fact[i-1]*i%MOD

for _ in range(q):
    x, d, n = map(int, input().split())
    if d == 0:
        ans = pow(x, n, MOD)
    else:
        x_div = x*pow(d, MOD-2, MOD)%MOD
        if x_div+n-1 > MOD:
            ans = 0
        else:

            if x_div+n-1 >= MOD:
                ans = 0
            else:
                f = fact[x_div+n-1]
                fi = pow(fact[x_div-1], MOD-2, MOD)
                ans = f*fi%MOD*pow(d, n, MOD)%MOD
    print(ans)

Measured memory_bytes: 45388
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<vi> graph(N);
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v, u--, v--;

        graph[u].pb(v);
        graph[v].pb(u);
    }

//
//    priority_queue<Pin> q;
//    q.emplace(0, 0);
//
//    vector<ll> dist(N, inf), prev(N);
//    dist[0] = 0;
//    while(!q.empty()) {
//        auto p = q.top(); q.pop();
//
//        ll d = p.fi + 1;
//        for (auto e: graph[p.se]) {
//            if (dist[e] <= d) continue;
//
//            dist[e] = d;
//            prev[e] = p.se;
//            q.emplace(d, e);
//        }
//    }

    vi ans(N);

    vector<bool> used(N, false);
    auto dfs = [&] (auto &&f, int from, int cur, vll& dp) -> void {
        if (used[cur]) return;
        used[cur] = true;

        // update dp table
        int op, idx, value;
        auto it = lower_bound(ALL(dp), A[cur]);
        if (it == dp.end()) {
            dp.pb(A[cur]);
            op = 0;
        } else {
            value = *it;
            idx = it - dp.begin();
            op = 1;
            *it = A[cur];
        }

        ans[cur] = dp.size();

        // go to next nodes
        for(auto e: graph[cur]) {
//            if (prev[e] != cur) continue;
            f(f, cur, e, dp);
        }

        // revert
        if (op == 0) {
            dp.pop_back();
        } else {
            dp[idx] = value;
        }
    };

    vll dp{A[0]};
    dfs(dfs, -1, 0, dp);

    REP(i, N) {
        print(ans[i]);
    }
    
}


Measured memory_bytes: 30728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y, int m) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y, int m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, m, q;
string s[2010];
int cum1[2010][2010], cum2[2010][2010], cum3[2010][2010];

signed main() {
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++)cin >> s[i];
	for (int i = 0; i < n; i++)for (int j = 0; j < m; j++) {
		if (s[i][j] == '1')cum1[i][j]++;
		if (i)cum1[i][j] += cum1[i - 1][j];
		if (j)cum1[i][j] += cum1[i][j - 1];
		if (i&&j)cum1[i][j] -= cum1[i - 1][j - 1];
	}
	for (int i = 0; i < n - 1; i++)for (int j = 0; j < m; j++) {
		if (s[i][j] == '1'&&s[i + 1][j] == '1')cum2[i + 1][j]++;
	}
	for (int i = 0; i < n; i++)for (int j = 0; j < m - 1; j++) {
		if (s[i][j] == '1'&&s[i][j + 1] == '1')cum3[i][j + 1]++;
	}
	for (int i = 0; i < n; i++)for (int j = 0; j < m; j++) {
		if (i)cum2[i][j] += cum2[i - 1][j];
		if (j)cum2[i][j] += cum2[i][j - 1];
		if (i&&j)cum2[i][j] -= cum2[i - 1][j - 1];
		if (i)cum3[i][j] += cum3[i - 1][j];
		if (j)cum3[i][j] += cum3[i][j - 1];
		if (i&&j)cum3[i][j] -= cum3[i - 1][j - 1];
	}
	for (int i = 0; i < q; i++) {
		int x, y, xx, yy; cin >> x >> y >> xx >> yy; x--; y--; xx--; yy--;
		int p = cum1[xx][yy];
		if (x)p -= cum1[x - 1][yy];
		if (y)p -= cum1[xx][y - 1];
		if (x&&y)p += cum1[x - 1][y - 1];
		int q = cum2[xx][yy] - cum2[x][yy] + cum3[xx][yy] - cum3[xx][y];
		if (y)q -= cum2[xx][y - 1];
		if (y)q += cum2[x][y - 1];
		if (x)q -= cum3[x - 1][yy];
		if (x)q += cum3[x - 1][y];
		cout << p - q << endl;
	}
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void grade(int m, int f, int r) {
	char res;
	int sum = m + f;
	if (m == -1 or f == -1) {
		res = 'F';
	} else if (80 <= sum) {
		res = 'A';
	} else if (65<= sum and sum < 80) {
		res = 'B';
	} else if (50<= sum and sum < 65) {
		res = 'C';
	} else if (30<= sum and sum < 50) {
		if (50 <= r) {
			res = 'C';
		} else {
			res = 'D';
		}
	} else {
		res = 'F';
	}
	cout << res << endl;
}

int main() {
	while (1) {
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 and f == -1 and r == -1) {
			break;
		}
		grade(m, f, r);
	}
	return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int N,M;
    int p[MAXN];
    int fa[MAXN];
    void init(){
        for(int u=0;u<MAXN;u++)fa[u]=u;
    }
    int tfind(int root){
        if(fa[root]==root)return root;
        int x=tfind(fa[root]);
        fa[root]=x;
        return x;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>M;
        init();
        for(int u=1;u<=N;u++)cin>>p[u];
        for(int u=1;u<=M;u++){
            int x,y;
            cin>>x>>y;
            if(x>y)swap(x,y);
            int rx=tfind(x)
            ,ry=tfind(y);
            if(rx!=ry)fa[ry]=rx;
        }
        for(int u=1;u<=N;u++){
            tfind(u);
        }
        map<int,set<int>>mp;
        for(int u=1;u<=N;u++){
            mp[fa[u]].insert(u);
        }
        int ans=0;
        for(const auto &pr:mp){
            set<int>tmp=pr.second;
            for(const auto &v:tmp){
                if(pr.second.count(p[v]))ans++;
            }
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 15104
#include<stdio.h>
void DFS(int);
void DFSvisit(int);
int a[105][105],color[105],count,time,d[105],f[105],p[105],n;
int main(){
  int i,j,b[105],c,k;
  for(i=0;i<=100;i++){
    d[i]=0;
    f[i]=0;
    for(j=0;j<=100;j++){
      a[i][j]=0;
      
    }
  }
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&b[i]);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&c);
      a[b[i]][c]=1;
    }
  }

DFS(n);
      for(i=1;i<=n;i++){
	printf("%d %d %d\n",i,d[i],f[i]);
      }
return 0;
}
void DFS(int u){
  int i;
  for(i=1;i<=u;i++){
    color[i]=0;
    p[i]=i;
    }
      time=0;
  for(i=1;i<=u;i++){
    if(color[i]==0){
      DFSvisit(i);
    }
  }
}
void DFSvisit(int u)
 {
   int i;
   color[u]=2;
   d[u]= ++time;
   for(i=1;i<=n;i++){
     if(color[i]==0 && a[u][i]==1){
       DFSvisit(i);
     }
   }
   color[u]=1;
   f[u] = ++time;
 }

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,count,ans;cin >> n;
  count=ans=0;
  string s;cin >> s;
  for (int i=0;i<n;i++) {
    if (s[i]=='R') count++;
  }
  for (int i=0;i<count;i++) {
    if (s[i]=='W') ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3716
import std.stdio; // readln
import std.array; // split
import std.conv; // to
import std.typecons;
import std.range;
import std.algorithm;

void main(){
	string s = readln();

	int cnt = 0;
	foreach (elem; s) {
		if(elem == '1') cnt++;
	}
	writeln(cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++) cin >> l[i];
  sort(l.begin(), l.end());
  ll ans {};
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans += distance(l.begin() + j, lower_bound(l.begin(), l.end(), l[i] + l[j])) -1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
//*INDENT-OFF*
#include<bits/stdc++.h>
using namespace std;
template<typename V>
bool tomin(V&x,V y){if(y<x){x=y;return true;}return false;}
template<typename V>
bool tomax(V&x,V y){if(x<y){x=y;return true;}return false;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
#pragma GCC optimize(3)
#define lowbit(x) ((x)&-(x))
//*INDENT-ON*
int main(){
    ll a;
    cin>>a;
    cout<<a*a*3<<endl;
    return 0;
    }

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

const int INF=1e9;
vector<int> dp(100100,INF);

int main(){
    int N,K; cin >> N >> K;
    int h[N];
    for(int i=0;i<N;i++) cin >> h[i];
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	static class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES": "NO");

		static void Main(string[] args)
		{
			var N = RI;
			var A = RIs;
			long[] a = new long[A.Length];
			a[0] = A[0];
			long ans = (a[0] == 0) ? 1 : 0;
			for (int i = 1;i < N;i++)
			{
				a[i] = a[i - 1] + A[i];
				if (a[i] == 0) ans++;
			}
			var gg = a.NumberCount();
			foreach(var item in gg)
			{
				if(item.Value > 1)ans += f(item.Value - 1);
			}
			Out(ans);
		}

		public static long f(int a)
		{
			return (long)a * (a + 1) / 2;
		}

		public static Dictionary<T, int> NumberCount<T>(this IEnumerable<T> items)
		{
			return items.GroupBy(s => s).Select(s => new { Item = s.Key, Count = s.Count() }).ToDictionary(g => g.Item, g => g.Count);
		}
	}
}


Measured memory_bytes: 54192
s = input()
t = input()

ls = len(s)
lt = len(t)
Ans = []
for i in range(ls - lt + 1):
    ss = s[i:i+lt]
    lss = len(ss)
    cnt = 0
    for j in range(lss):
        if s[i + j] == '?' or t[j] == ss[j]:
            cnt += 1
        else:
            break
    else:
        if cnt == lss:
            ans = ''
            for j in range(i):
                if s[j] == '?':
                    ans += 'a'
                else:
                    ans += s[j]
            ans += t
            for j in range(i + lt, ls):
                if s[j] == '?':
                   ans += 'a'
                else:
                    ans += s[j]
            else:
                Ans.append(ans)
if len(Ans) == 0:
    print('UNRESTORABLE')
else:
    print(sorted(Ans)[0])

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    L, R, d = mi()
    cnt = 0
    for i in range(L, R+1):
        if i%d==0:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61956
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,x,y;
    cin>>n>>x>>y;
	int ans[n]={0};
	rep(i,1,n+1){
		rep(j,i+1,n+1){
			int cur=min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(y-i)+abs(j-x)+1));
//			cout<<i<<" "<<j<<" "<<cur<<endl;
			ans[cur]++;
		}
	}
	rep(i,1,n)cout<<ans[i]<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int n,m,ans=0;
  scanf("%lld %lld",&n,&m);
  if(m >= 2*n)
    {
      m = m - 2*n;
      ans += (n + (m/4));
    }
  else
    {
      ans += m / 2;
    }
  printf("%lld",ans);
  return 0;
}
      

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int a[5000000],n,b,c[2],d;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    while(1){
        if(d==2)break;
        if(a[b]==a[b+1]){c[d]=a[b];d++;b++;}
        b++;
    }
    cout<<c[0]*c[1]<<endl;

}


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

int main() {
  int D ; cin >>D;
  string str;
  if(D==25)str="Christmas";
  if(D==24)str="Christmas Eve";
  if(D==23)str="Christmas Eve Eve";
  if(D==22)str="Christmas Eve Eve Eve";
  
  //出力
  cout <<str;
}


Measured memory_bytes: 768
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	REP(i,n-1){
		cin >> a[i];
		b[a[i]-1]++;
	}
	REP(i,n){
		cout << b[i] <<endl;
	}
}



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

int main(int argc, char const *argv[])
{
  char input;
  cin >> input;
  switch (input) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      cout << "vowel";
      break;
    default:
      cout << "consonant";
      break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string w,t;
	int n=0;
	cin >> w;

	while(1){
		cin >> t;
		if( t == "END_OF_TEXT" ) break;

		for( int i=0; i<t.size(); i++ ){ // size()??§????´???°???????????????
			t[i] = tolower(t[i]); //?°?????????§??????
		}

		if( w==t ) n++;
	}

	cout << n << "\n";
	return 0;
}

Measured memory_bytes: 1192
//#include <bits/stdc++.h>
#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>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  int n, k, y, x;
  cin >> n >> k >> x >> y;

  if(n < k) cout << x*n << endl;
  else cout << x*k + y*(n-k) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

const int N = 101;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, l;
    std::cin >> n >> l;
    std::string str[N];
    for (int i = 0; i < n; ++i) {
        std::cin >> str[i];
    }
    std::sort(str, str + n);
    for (int i = 0; i < n; ++i) {
        std::cout << str[i];
    }
    std::cout << '\n';
    return 0;
}


Measured memory_bytes: 256