akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, x, t; cin >> n >> x >> t;
    cout << (n+x-1)/x * t << endl;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

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

	int n,k;
	int a[100105],dp[100105];
	memset(a,0,sizeof(a));
	memset(dp,0x3f,sizeof(dp));
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0]=a[1];
	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(a[i]-a[i+j]));
		}
	}
	cout << dp[n] << "\n";
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll L, R;
int l, r, ans = INF;

void solve(){
    l = L%2019;
    r = R%2019;

    if(R-L>=2019){
        ans = 0;
    } else {
        if(r <= l) r += 2019;

        for(int i = l; i < r; ++i){
            for(int j = i+1; j <= r; ++j) {
                ans = min(ans, (i*j)%2019);
                // cout << i << " " << j << endl;
            }
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> L >> R;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

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

    int n;
    cin >> n;
    map<int, int> mp;
    int l = 0, r = 0;
    rep(i, n+1) {
        int a;
        cin >> a;
        a--;
        if (mp.count(a)) {
            l = mp[a];
            r = i;
        } else {
            mp[a] = i;
        }
    }
    int m = n - r;
    combination c(n+1);
    for (int i = 1; i <= n+1; ++i) {
        mint ans = c(n+1, i) - c(l+m, i-1);
        cout << ans << endl;
    }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if (x == 0) return 0;
  return counter(x >> 1) + (x&1);
}

int main () {
  cin >> n;
  rep(i,n) {
    cin >> a[i];
    rep(j,a[i]) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  rep(b,1<<n) {
    bool ok = true;
    rep(i,n) {
      if (!(b&(1<<i))) continue;
      // 正直者の証言が矛盾しないか確認
      rep(j,a[i]) {
        //if ((b&(1<<x[i][j])) ^ y[i][j]) ok = false;
        //b&(1<<x[i][j])は1より大きな値になりうり、xorの計算が狂うのでダメ

        if (((b>>x[i][j])&1) ^ y[i][j]) ok = false;

        //printf("b = %d, b&(1<<x[i][j]) = %d, y[i][j] = %d\n", b, b&(1<<x[i][j]), y[i][j]);
        //printf("b = %d, (b>>x[i][j])&1 = %d, y[i][j] = %d\n", b, (b>>x[i][j])&1, y[i][j]);
      }
    }
    if (ok) ans = max(ans, counter(b));
    //if (ok) debug(b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a0 = [0]+a+[0]
suma = 0
for i in range(n+1):
  suma += abs(a0[i+1]-a0[i])

for i in range(1, n+1):
  if (a0[i]-a0[i-1])*(a0[i+1]-a0[i]) >= 0:
    print(suma)
  else:
    print(suma-abs(a0[i]-a0[i-1])-abs(a0[i+1]-a0[i])+abs(a0[i+1]-a0[i-1]))

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[1]==s[2]) cout << "Yes" << endl;
  else if(s[1]==s[2]&&s[2]==s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

ll dp[20010][256];

int main(){
	int n, m;
	int nxt;
	while(cin>>n>>m && n && m){
		vi c(m), x(n);
		rep(i, m) cin>>c[i];
		rep(i, n) cin>>x[i];
		rep(i, 20010) rep(j, 256) dp[i][j] = LINF;

		for(int i = 0; i < m; i++){
			nxt = 128+c[i];
			nxt = max(nxt, 0);
			nxt = min(nxt, 255);
			dp[0][nxt]=min(dp[0][nxt], (ll)(x[0]-nxt)*(x[0]-nxt));
		}
		for(int i = 1; i < n; i++){
			for(int j = 0; j < 256; j++){
				for(int k = 0; k < m; k++){
					nxt = j + c[k];
					nxt = max(nxt, 0);
					nxt = min(nxt, 255);
					dp[i][nxt] = min(dp[i][nxt], dp[i-1][j]+(x[i]-nxt)*(x[i]-nxt));
				}
			}
		}
		ll ans = LINF;
		for(int i = 0; i < 256; i++){
			ans = min(dp[n-1][i], ans);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 41292
n,l = map(int,input().split())
a = 0
for i in range(n):
    a += l + i
t = 0
u = 0
z = 999
ans = 0
for i in range(n):
    t = a - (l+i)
    u = abs(a - t)
    if z > u:
        z = u
        ans = t
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 101010;
vi G[N];
bool vis[N];
int n, m, ans;
vi x, y;
int a[N];
void dfs(int u) {
	vis[u] = 1; x.pb(u), y.pb(a[u]);
	for(auto & v : G[u]) if(!vis[v]) dfs(v);
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i, 0, n) scanf("%d", a + i), a[i]--;
	rep(i, 0, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	rep(i, 0, n) if(!vis[i]) {
		x.clear(), y.clear();
		dfs(i);
		sort(all(x)); sort(all(y));
		for(int ai = 0, bi = 0; ai < sz(x) && bi < sz(y); ) {
			if(x[ai] > y[bi]) bi++;
			else if(x[ai] < y[bi]) ai++;
			else ans++, ai++, bi++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10156
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	string s;
	cin >> s;
	int time[26] = { };
	for(int i = 0; i < s.size(); i++){
		time[s[i] - 'a']++;
	}
	int ans = 1;
	for(int i = 0; i < 26; i++){
		if(time[i] % 2 != 0) ans = 0;
	}
	if(ans == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, Q = list(map(int, input().split()))
C = list(map(int, input().split()))

M = max(C) + 1
T = [0]*(M)
for v in C: T[v] = 1

L = [0]*(M)
m = 0

for i in range(M):
    L[i] = m
    if T[i] : m = i

for i in range(Q):
    q = int(input())
    maxv = 0
    cur = m
    while 0 < cur:
      p = cur % q
      maxv = max(maxv, p)
      if cur - p < 0:  break
      cur = L[cur - p]
    print(maxv)




Measured memory_bytes: 39980
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll n;
ll dat[800020];
void init(int n_){
n=1;
  while(n<n_)
    n*=2;
  }
void update(ll k,ll a){
k+=n-1;
  dat[k]=a;
  while(0<k){
  k=(k-1)/2;
    dat[k]=max(dat[2*k+1],dat[2*k+2]);
  }
}
ll query(ll a,ll b,ll k,ll l,ll r){
if(a<=l && r<=b)
  return dat[k];
  else if(b<=l || r<=a)
    return 0;
  else
    {
  ll val=query(a,b,2*k+1,l,(l+r)/2);
    ll var=query(a,b,2*k+2,(l+r)/2,r);
    return max(val,var);
  }
}
ll N;
int main(){
  cin>>N;
  vector<ll>h(N);
  vector<ll>a(N);
  for(int i=0;i<N;i++)
    cin>>h[i];
  for(int i=0;i<N;i++)
    cin>>a[i];
  init(200005);
  for(int i=0;i<N;i++){
  ll M=query(0,h[i],0,0,n);
    update(h[i],a[i]+M);
  }cout<<dat[0]<<endl;
  return 0;
}

Measured memory_bytes: 9668
import java.util.Scanner;

public class Main {
    public static class Solver {
        int n;
        int k;
        public Solver() {
            Scanner sc = new Scanner(System.in);

            n = sc.nextInt();
            k = sc.nextInt();

            for (int i = 0 ; i < n ; i ++) {
                sc.nextInt();
            }

            if (k >= n) {
                System.out.println(1);
            } else {
                int r = (int) Math.ceil(((n - k) / (double) (k - 1)) + 1);
                System.out.println(r);
            }
        }
    }

    public static void main(String[] args) {
        new Solver();
    }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

  ll n, W;
  cin >> n >> W;

  vl w(n), v(n);
  rep(i,0,n) cin >> w[i] >> v[i];

  vvl dp(W+1, vl(n+1, 0));

  rep(j,0,W+1) {
    rep(i,0,n) {
      if (j+w[i] <= W) ckmax(dp[j+w[i]][i+1], dp[j][i]+v[i]);
      ckmax(dp[j][i+1], dp[j][i]);
    }
  }

  ll ans = -1;
  rep(j,0,sz(dp)) ckmax(ans, *max_element(all(dp[j])));
  cout << ans << "\n";
}

Measured memory_bytes: 82304
process = []
n, q = [int(i) for i in input().split(" ")]
for i in range(n):
    name, time = input().split(" ")
    time = int(time)
    process.append([name, time])

time = 0
while len(process) > 0:
    p = process.pop(0)
    if p[1] <= q:
        time += p[1]
        print(p[0], time)
    else:
        p[1] -= q
        time += q
        process.append(p)



Measured memory_bytes: 13024
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int32_t main()
{
    speed
    for(int i=1;i<=5;i++)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


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

int main() {
    long x, y, ans = 0, temp;
    cin >> x >> y;
    temp = x;
    while(temp <= y) {
        ans++;
        temp *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math

N=int(input())

town=[]
result=0
count=0

for i in range(N):
    town.append([int(x) for x in input().split()])

tag=list(itertools.permutations(town))

for val in tag:
    #print(val)
    for i in range(0,len(val)-1):
        #print(val[i][0],val[i+1][0])
        #print(val[i][1],val[i+1][1])
        buf=pow(val[i][0]-val[i+1][0],2)
        tmp=pow(val[i][1]-val[i+1][1],2)
        #print("buf:",buf)
        #print("tmp:",tmp)
        result+=(math.sqrt(buf+tmp))

print(result/math.factorial(N))

Measured memory_bytes: 8100
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007 // prime
const int SIZE = 300100;
ll inv[SIZE],fac[SIZE],facinv[SIZE];
ll nCr(int n,int r)
{
	if(n<r)return -1;
	if(n<0||r<0)return -1;
	if(r==0)return 1ll;
	return ((fac[n]*facinv[r]%MOD)*facinv[n-r])%MOD;
}
int N,M,K;
int main()
{
	fac[0]=1;
	for(int i=1;i<=SIZE;i++)fac[i]=(fac[i-1]*i)%MOD;
	inv[1]=1;
	for(int i=2;i<=SIZE;i++)inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
	facinv[0]=1;
	for(int i=1;i<=SIZE;i++)facinv[i]=(facinv[i-1]*inv[i])%MOD;
	
	scanf("%d %d %d",&N,&M,&K);
	ll ans = 0ll;
	for(int i=0;i<=K;i++)
	{
		ll tate,yoko;
		ll All;
		int j = K-i;
		tate = (nCr(N+2*i,i)*(N+1))%MOD;
		tate = (tate*inv[N+i+1])%MOD;
		yoko = (nCr(M+2*j,j)*(M+1))%MOD;
		yoko = (yoko*inv[M+j+1])%MOD;
		if(i==0)tate = 1ll;
		if(j==0)yoko = 1ll;
		All = (tate*yoko)%MOD;
		All = (All*nCr(N+M+K*2,N+2*i))%MOD;
		//printf("%lld %lld %lld\n",tate,yoko,All);
		ans = (ans+All)%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8224
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	double a, b, c;
	cin >> a >> b;
	cout << a / b << endl;
	return 0;
}


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

int main(){
	int n,k,q,t;
	map <int,int> a;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		cin>>t;
		a[t-1]++;
	}
	for(int i=0;i<n;i++){
		if(k-q+a[i]>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
int main(void)
{
	int t,n,total=0;
	int i = 0;

	for(i = 0; i < 4; i++) {
		scanf("%d",&t); scanf("%d", &n);

		switch (t) {
			case 1: total = n * 6000;
				break;
			case 2: total = n * 4000;
				break;
			case 3: total = n * 3000;
				break;
			case 4: total = n * 2000;
				break;
		default: break;
		}

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

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

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

	int D,S,T;
	int i,k;
	int ans=0;
	int ctr=0;

	cin >> D >> S >> T;

	if(D<=S*T)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3604
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    # divisorsを使い回せるようにする。
    #   - 二度生成した場合にかかる時間が許容できない場合
    #   - エラトステネスの篩などで素数テーブルを既に持っている場合
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        # divisorsを引数で与えた場合のみ起こりうる
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))

print(len(small_factors.intersection(big_factors)) + 1)


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

int main() {
  map<char, int> alpha;
  string s;
  while (getline(cin, s)) {
    for (const auto &c : s) {
      if (!isalpha(c)) continue;
      alpha[tolower(c)]++;
    }
  }

  for (char c{'a'}; c <= 'z'; ++c) {
    cout << c << " : " << alpha[c] << endl;
  }

  return 0;
}



Measured memory_bytes: 3156
#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() {
  ll x;
  cin >> x;

  for (ll i = -200; i <= 200; i++) {
    for (ll j = -200; j <= 200; j++) {
      ll diff = (i * i * i * i * i) - (j * j * j * j * j);
      if (diff == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3568
n = int(input())
a_array = list(map(int, input().split()))
a_array.insert(0, 0)
x_sum = {}
x_dis = {}

for i in range(1, n+1):
    a_sum = i + a_array[i]
    if a_sum in x_sum:
        x_sum[a_sum].append(i)
    else:
        x_sum[a_sum] = [i]
    if not(a_sum in x_dis):
        x_dis[a_sum] = []

    a_dis = i - a_array[i]
    if a_dis > 0:
        if a_dis in x_dis:
            x_dis[a_dis].append(i)
        else:
            x_dis[a_dis] = [i]
        if not(a_dis in x_sum):
            x_sum[a_dis] = []

# print(x_sum)
# print(x_dis)
count = 0
for k in x_sum.keys():
    count += len(x_sum[k]) * len(x_dis[k])

print(count)


Measured memory_bytes: 86312
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

vl d(ll n){
	vl r;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			r.push_back(i);
			if((i*i)!=n)r.push_back(n/i);
		}
	}
	sort(all(r));
	return r;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	rep(i,n)cin>>v[i];
	ll sum=0;
	rep(i,n)sum+=v[i];
	vl dv=d(sum);
	ll ans=1;
	if(n==1){
		cout<<sum<<endl;
		return 0;
	}
	rep(j,dv.size()){
		vl r(n),l(n);
		rep(i,n){
			r[i]=v[i]%dv[j];
		}
		sort(all(r));
		rep(i,n)l[i]=(dv[j]-r[i])%dv[j];
		range(i,1,n)r[i]+=r[i-1];
		rrep(i,n-1)l[i]+=l[i+1];
		rep(i,n-1){
			if(r[i]==l[i+1]&&r[i]<=k)ans=dv[j];
		}
	}
	cout<<ans<<endl;
}


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

using ll = long long;
#define int ll

template<typename T> void max_self(T& a, T b)
{
	a = max(a,b);
}

bool first_row_or_column(pair<int,int> p)
{
	return p.first == 0 || p.second == 0;
}

const int INF = 1e18L + 5;

int32_t main()
{
	string a,b;
	cin>>a>>b;
	vector<vector<pair<int,pair<int,int>>>> dp(a.length() + 1,vector<pair<int,pair<int,int>>>(b.length() + 1,{-INF,{0,0}}));
	dp[0][0] = {0,{0,0}};
	for(int i=0;i<(int)a.length();i++)
	{
		for(int j=0;j<(int)b.length();j++)
		{
			if(a[i] == b[j])
			{
				max_self(dp[i+1][j+1],{dp[i][j].first + 1,{i,j}});
			}
			max_self(dp[i+1][j],{dp[i][j].first,{i,j}});
			max_self(dp[i][j+1],{dp[i][j].first,{i,j}});
		}
	}
	pair<int,pair<int,int>> answer = {0,{0,0}};
	for(int i=0;i<=(int)a.length();i++)
	{
		for(int j=0;j<=(int)b.length();j++)
		{
			max_self(answer,{dp[i][j].first,{i,j}});
		}
	}
	string s;
	pair<int,int> cur = answer.second;
	while(!first_row_or_column(cur))
	{
		int i = cur.first;
		int j = cur.second;
		pair<int,int> previous = dp[i][j].second;
		if(previous == make_pair(i-1,j-1))
		{
			assert(a[i-1] == b[j-1]);
			s+=a[i-1];
		}
		cur = previous;
	}
	reverse(s.begin(),s.end());
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 211456
N, W = map(int, input().split())
MOD = 10**9 + 7
ws = [int(input()) for i in range(N)]
ws.sort(reverse=1)
su = sum(ws)
dp = [0]*(W+1)
dp[0] = 1
ans = 0
if su <= W:
    ans += 1
for i in range(N):
    w = ws[i]
    su -= w
    ans += sum(dp[max(W+1-w-su, 0):max(W+1-su, 0)]) % MOD
    for j in range(W, w-1, -1):
        dp[j] += dp[j-w]
        dp[j] %= MOD
print(ans % MOD)



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

int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
	int n;
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    set<char> c;
    for (int i = 0; i < n; i++) {
        c.insert(s[i]);
    }
    if (n > c.size()) cout << "no" << endl;
    else cout << "yes" << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s.at(i).at(j); 
        }
    }
       
    vector<vector<pair<int, int>>> len(h, vector<pair<int, int>>(w));
    for (int i = 0; i < h; i++)
    {
        int cnt = 0;
        for (int j = 0; j < w; j++)
        { 
            if (s.at(i).at(j) == '.' && len.at(i).at(j).second != 0) continue; 
            
            if (s.at(i).at(j) != '#') cnt++;

            if (s.at(i).at(j) == '#') {
                int k = j - 1;
                if (k == -1) continue;
                while (s.at(i).at(k) == '.') {
                    len.at(i).at(k).first = cnt;
                    k--;

                    if (k == -1) break;
                }

                cnt = 0;
            }

            if (j == w - 1) {
                int k = j;
                while (s.at(i).at(k) == '.') {
                    len.at(i).at(k).first = cnt;
                    k--;

                    if (k == -1) break;
                }

                cnt = 0;
            }
        }
        
    }
    

    for (int i = 0; i < w; i++)
    {

        int cnt = 0;
        for (int j = 0; j < h; j++)
        { 
            if (s.at(j).at(i) == '.' && len.at(j).at(i).second != 0) continue; 
            
            if (s.at(j).at(i) != '#') cnt++;

            if (s.at(j).at(i) == '#') {
                int k = j - 1;
                if (k == -1) continue;
                while (s.at(k).at(i) == '.') {
                    len.at(k).at(i).second = cnt;
                    k--;

                    if (k == -1) break;
                }

                cnt = 0;
            }

            if (j == h - 1) {
                int k = j;
                while (s.at(k).at(i) == '.') {
                    len.at(k).at(i).second = cnt;
                    k--;

                    if (k == -1) break;
                }

                cnt = 0;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            ans = max(ans, len.at(i).at(j).first + len.at(i).at(j).second - 1);
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

int main() {

   int X;
   scanf("%d", &X);

   printf("%s\n", X >= 30 ? "Yes" : "No");

   return 0;
}

Measured memory_bytes: 1592
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        string x,y;
        cin>>x>>y;
        int c=0;
        for(int i=0;x[i];++i){
          if(x[i]!=y[i])++c;
        }
        printf("%d\n", c);

        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 3844
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (true) {
			int h = sc.nextInt(); int w = sc.nextInt();
			if (h==0 && w==0) return;
			
			for (int i=0; i<h; i++) {
				StringBuilder sb = new StringBuilder();
				for (int j=0; j<w; j++) {
					if (i%2==0) {
						if (j%2==0) sb.append("#");
						else sb.append(".");
					}
					else {
						if (j%2==0) sb.append(".");
						else sb.append("#");
					}
				}
				System.out.println(sb);
			}
			
			System.out.println();
		}
		
	}
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  
  vector<int> w(v.at(n - 1));
  for (int i = 0; i < n; i++) {
    w.at(v.at(i) - 1)++;
  }
  sort(w.begin(), w.end());
  reverse(w.begin(), w.end());
  
  int s = 0;
  if (k < w.size()) {
    for (int i = 0; i < k; i++) {
      s += w.at(i);
    }
  }
  else {
    for (int i = 0; i < w.size(); i++) {
      s += w.at(i);
    }
  }
  cout << n - s << endl;
}

Measured memory_bytes: 1792
fun main() {
    val l = readLine()!!.split(" ").map { it.toInt() }
    val n = l[0]
    val m = l[1]
    val x = l[2]
    val array = Array(n){Array(m+1){0}}
    for(i in 0..n-1){
        val a = readLine()!!.split(" ").map { it.toInt() }
        for(j in 0..m){
            array[i][j] = a[j]
        }
    }
    var result = Int.MAX_VALUE
    fun dfs(a:Array<Int>,price:Int,count:Int){
        if(count<n) {
            val aa = a.clone()
            dfs(aa, price, count + 1)
            for (i in 0..m - 1) {
                aa[i] = a[i] + array[count][i + 1]
            }
            dfs(aa, price + array[count][0], count + 1)
        }else {
            var flag = true
            for (i in 0..m - 1) {
                val num = a[i]
                if (num < x) {
                    flag = false
                    break;
                }
            }
            if (flag) {
                if (price < result) result = price
            }
        }
    }
    dfs(Array(m){0},0,0)
    if(result == Int.MAX_VALUE){
        println("-1")
    }else{
        println(result)
    }
}

Measured memory_bytes: 40304
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
int colors_now[3][30];
int color_graph[30][30];


ll calc_cost(int mod_type, int to)
{
    ll res = 0;
    rep(from, 0, 30)
        res += color_graph[from][to] * colors_now[mod_type][from];
    return res;
}

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

    rep(i, 0, c)
    rep(j, 0, c)
        cin >> color_graph[i][j];
    

    rep(i, 0, n)
    rep(j, 0, n)
    {
        int c;
        cin >> c;
        --c;
        colors_now[(i + j) % 3][c]++;
    }

    int best = 1000000000;
    rep(i, 0, c)
    rep(j, 0, c)
    if(i != j)
    {
        rep(k, 0, c)
        if (j != k and k != i)
        {
            int now = 0;
            now += calc_cost(0, i);
            now += calc_cost(1, j);
            now += calc_cost(2, k);
            best = min(best, now);
        }
    }

    // rep(c, 0, 3)
    // rep(i, 0, 30)
    //     cout << c << ' ' << i << ' ' << colors_now[c][i] << endl;
    cout << best << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	string s;
	bool f=true;
	while(cin >> s){
		if(!f)cout<<"\n";
		f=false;
		string soroban[8];
		int n[5]={0};
		for(int i=0;i<8;++i)soroban[i]="";
		for(int i=5-s.size();i<5;++i)if('0'<=s[i-(5-s.size())]&&s[i-(5-s.size())]<='9')n[i]=s[i-(5-s.size())]-'0';
		for(int i=0;i<5;++i){
			soroban[0]+=(n[i]/5)?' ':'*';
			soroban[1]+=(n[i]/5)?'*':' ';
			soroban[2]+='=';
			for(int j=0;j<5;++j) soroban[3+j]+=(n[i]%5==j)?' ':'*';
		}
		for(int i=0;i<8;++i)cout<<soroban[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
set<pair<string, pair<int, int> > > s;
int main(){
    int t;sc(t);
    fr(i, 1, t){
        string si;cin >>si;
        int x;sc(x);
        s.insert({si, {-x, i}});
    }
    for(auto u: s) {
        pr(u.se.se);n_l;
    }
    return 0;
}



Measured memory_bytes: 3720
//https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_c
//C - ThREE
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
	int blue_red=0; //0,青 1,赤
	bool visited=false;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif
	ll N; cin>>N;
	WeightedGraph<ll> graph(N+1);
	FOR(i,0,N-1){
		ll a,b; cin>>a>>b;
		graph.at(a).edges.emplace_back(a,b,1);
		graph.at(b).edges.emplace_back(b,a,1);
		assert(a<=N&&b<=N);
	}

	//1からbfsする
	stack<ll> que;
	que.push(1);
	graph.at(1).blue_red=1;
	graph.at(1).visited=true;
	while(not que.empty()){
        const auto&n = que.top();
        que.pop();
		const auto& cur_n=graph.at(n);
        for(const auto& e:cur_n.edges){
            auto& next_p = graph.at(e.to);
		 	if (next_p.visited) continue;	
		 	next_p.blue_red = (cur_n.blue_red+1)%2;
		 	next_p.visited=true;
		 	que.push(e.to);
        }
	}
	// cout<<-1<<endl;
	// return 0;

	//count blue
	vector<ll> numtbl[2];
	FOR(i,1,N+1){
		auto br = graph.at(i).blue_red;
		assert(br==0||br==1);
		numtbl[br].push_back(i);
	}
	vector<ll> ans(N+1);
	auto result_func = [&](const auto& tbl){
		//0に3いれ
		ll n3=3;
		for(const auto& n:tbl){
			ans[n]=n3;
			n3+=3;
		}
		ll v=1;
		FOR(i,1,N+1){
			auto&& a=ans[i];
			if(a>0)continue;
			if(v%3==0&&v<n3)++v;
			a=v++;
		}
	};
	if(numtbl[0].size()<=N/3){
		result_func(numtbl[0]);
	} else if(numtbl[1].size()<=N/3){
		//1に3いれ
		result_func(numtbl[1]);
	} else {
		//mod1,mo2をそれぞれつめて、のこりを3で
		FOR(i,0,2){
			ll n3=0;
			for(auto n:numtbl[i]){
				ll v=3*n3+1+i;
				if(v>N)break;
				ans[n]=v;
				++n3;
			}
		}
		ll n3=3;
		FOR(i,1,N+1){
			auto&& a=ans[i];
			if(a>0)continue;
			ans[i]=n3;
			n3+=3;
		}
	}

	FOR(i,1,N+1){
		if(i!=1)cout<<" ";
		cout<<ans.at(i);
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 23268
#include <iostream>

using namespace std;

int main()
{
    int H, W;

    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0)   break;

        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                if ((i+j) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;

}


Measured memory_bytes: 3096
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = list(input())
t = list(input())

ans = float("inf")

for i in range(len(s)-len(t)+1):
	tar = s[i:i+len(t)]
	ansk = 0
	for j in range(len(tar)):
		if t[j]!=tar[j]:
			ansk+=1
	ans = min(ans, ansk)

print(ans)

Measured memory_bytes: 68272
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int l = 0;
	int r = 0;
	int d = 0;
	scanf("%d", &l);
	scanf("%d", &r);
	scanf("%d", &d);
	
	int multiple_total = 0;
	int i = l;
	while (i <= r) {
		if (i % d == 0) {
			multiple_total++;
		}
		i++;
	}
	printf("%d\n", multiple_total);




	return 0; 
}

Measured memory_bytes: 1732
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin>>n;
    ll res = 1;
    fr(i,1,n)
    {
      res = res%mod * i%mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define size 3000
#define ll long long int
struct node
{
	int x;
	int y;
	char c;
	int length;
};
node dp[size+1][size+1];
int main()
{
	string s1,s2;
	cin>>s1;
	cin>>s2;
	for(int i=0;i<=s1.length();i++)
	{
		for(int j=0;j<=s2.length();j++)
		{
			if(i==0)
			{	//dp[i][j].append(s2,0,j);
				dp[i][j].length=0;
			}
			else if(j==0)
			{
				//dp[i][j].append(s1,0,i);
				dp[i][j].length=0;
			}                                                                                                                                                                                 
			else if(s1[i-1]==s2[j-1])
			{
				dp[i][j].c=s1[i-1];
				dp[i][j].x=i-1;
				dp[i][j].y=j-1;
				dp[i][j].length=dp[i-1][j-1].length+1;
			}
			else if(dp[i][j-1].length>dp[i-1][j].length)
			{
				dp[i][j].c='A';
				dp[i][j].x=i;
				dp[i][j].y=j-1;
				dp[i][j].length=dp[i][j-1].length;
			}
			else
			{
				dp[i][j].c='A';
				dp[i][j].x=i-1;
				dp[i][j].y=j;
				dp[i][j].length=dp[i-1][j].length;
			}
			//cout<<dp[i][j].c<<dp[i][j].length<<dp[i][j].x<<" "<<dp[i][j].y<<"     ";
		}
		//cout<<endl;
	}
	string ans;
	int i=s1.length();
	int j=s2.length();
	while(i>0 && j>0)
	{
		if(dp[i][j].c!='A')
		{
			ans.push_back(dp[i][j].c);
			//cout<<dp[i][j].c<<" i="<<i<<"  j="<<j<<endl;
		}
		int temp=i;
		i=dp[i][j].x;
		j=dp[temp][j].y;
		//cout<<"i= "<<i<<"j= "<<j<<endl;
	}
	reverse(ans.begin(), ans.end()); 
	cout<<ans<<endl;

}

Measured memory_bytes: 140928
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long[] a = new long[n+1];

		a[1]=1;
		for (int i=2; i<=n; i++){

			a[i]++;

			for (int j=i; j<=n; j+=i){
				a[j]++;
			}
		}
		long ans=0;

		for (int i=1; i<=n; i++){
			ans += i * a[i];
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 115968
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pu push_back
#define po pop_back
#define EPS (1e-7)
#define INF (1e9)
#define pi (acos(-1))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vec vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
//const int INF = 1001001001;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//gcd & lcm
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //FROM HERE//
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}
  

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>
using namespace std;

int main() {
    clock_t cTimeStart, cTimeEnd;
    cTimeStart = clock();           // 現在時刻
    float a,b,c,d,e,f ;
    float x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
    	x=(f*b-e*c)/(b*d-e*a);
       	y=(f*a-d*c)/(e*a-b*d);
       	if(x>-0.001&&x<=0)x=0.0;
       	if(y>-0.001&&y<=0)y=0.0;

       	printf("%.3f %.3f\n",x,y);
    }

    cTimeEnd = clock();           // 現在時刻
//    cout<< "処理時間:" <<(cTimeEnd - cTimeStart)/1000 << "[ms]" << endl;

	return 0;
}

Measured memory_bytes: 1244