akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans;
  if(N < 10) ans = N;
  else if(N >= 10 && N < 100) ans = 9;
  else if(N >= 100 && N < 1000) ans = 9 + (N - 99);
  else if(N >= 1000 && N < 10000) ans = 909;
  else if(N >= 10000 && N < 100000) ans = 909 + (N - 9999);
  else if(N == 100000) ans = 90909;
  cout << ans << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 100 * a + 10 * b + c;
  if (ans % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll X;
    cin >>X;
    rep(i,200){
        rep(j,200){
            if(i*i*i*i*i-j*j*j*j*j == X){
                cout<<i<<" "<<j<<endl;
                return 0;
            }else if(i*i*i*i*i+j*j*j*j*j == X){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }



    return 0;
    

}

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

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

    int A, B;
    cin >> A >> B;
    int lo, hi;
    lo = min(A, B);
    hi = max(A, B);
    for(int i = 0; i < hi; i++){
        cout << (char)('0' + lo);
    }
    cout << endl;
    return 0;
}

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

int main() {
	int a, b, c, d, e, q, w;
	cin >> a >> b >> c >> d >> e;
	q = b / d;
	if (b%d != 0) q = q+1;
	w = c / e;
	if (c%e != 0) w = w+1;
	cout << a - max({ q,w }) << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 1e18;

void solve()
 {
  string s;
  cin>>s;
  int n = s.size();
  loop(i,0,n)
   cout<<'x';
  
 }  
signed main()
 {   
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0); 
   /*int t;
   cin>>t;
   loop(i,1,t+1)*/
      solve();
      
  //cerr<<END<<1.0*clock();
  return 0;
} 


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

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

  int k = 0;
  rep(i, N) {
    int A; cin >> A;
    if (k + 1 == A)
      ++k;
  }
  if (k == 0) cout << "-1\n";
  else cout << N-k << "\n";

  return 0;
}


Measured memory_bytes: 256
#n,k,*a=map(int,open(0).read().split())
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
mod=10**9+7
ans=1
i=0
j=-1
kk=k
while kk>1:
    if a[i]*a[i+1]>a[j]*a[j-1]:
        ans=ans*a[i]*a[i+1]%mod
        i+=2
        kk-=2
    else:
        ans=ans*a[j]%mod
        j-=1
        kk-=1
if kk==1:
    ans=ans*a[j]%mod

if a[-1]<0 and k%2==1:
    ans=1
    for i in a[n-k:]:
        ans=ans*i%mod
print(ans)


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

bool isPrime[100010];
int Like2017[100010];

void Eratosthenes(int N = 100000)
{
    memset(isPrime, true, sizeof(isPrime));
    isPrime[0] = false;
    isPrime[1] = false;
    
    for(int i = 2; i <= sqrt(N); i++)
    {
        if(isPrime[i])
        {
            for(int j = i * 2; j <= N; j += i)
            {
                isPrime[j] = false;
            }
        }
    }
}


int main()
{
    Eratosthenes();
    
    REP(i, 2, 100010)
    {
        if(isPrime[i] && isPrime[(i + 1) / 2])
            Like2017[i] = true;
    }
    
    REP(i, 1, 100010)
    {
        Like2017[i] += Like2017[i - 1];
    }
    
    int Q;
    cin >> Q;
    
    rep(i, Q)
    {
        int l, r;
        cin >> l >> r;
        
        cout << Like2017[r] - Like2017[--l] << endl;
    }
    
    return 0;
}











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

int main(){
    int a,b;
    cin >> a >> b;
    if(a < b) cout << "a < b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
}



Measured memory_bytes: 3116
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
m = a.sort! 
al,bo = 0,0
i = n - 1

loop do
    al += m[i]
    i -= 1
    break if i < 0
    bo += m[i]
    i -= 1
    break if i < 0
end

z = al - bo

puts z


Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	dp := make([]int, N)
	pre2 := nextInt()
	pre1 := nextInt()
	dp[1] = abs(pre1 - pre2)

	for i := 2; i < N; i++ {
		h := nextInt()
		dp[i] = min(dp[i-2]+abs(pre2-h), dp[i-1]+abs(pre1-h))
		pre2, pre1 = pre1, h
	}
	fmt.Println(dp[N-1])
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
// ll mod=1e9+7;
ll mod2=998244353;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll n,k;
ll dp[MAXN];
ll tree[4*MAXN];
vector<ii> v;

void build(ll node, ll l, ll r){
    if(l>r){
        return;
    }
    if(l==r){
        tree[node]=dp[l]%mod2;
        return;
    }
 
    ll m = (l+r)/2;
    build((2*node)+1, l, m);
    build((2*node)+2, m+1, r);
    tree[node] = (tree[(2*node)+1] + tree[(2*node)+2])%mod2;
}
 
void update(ll node, ll l, ll r, ll val, ll pos){
    if((l>r) || (r<pos) || (l>pos)){
        return;
    }
    if(l==r){
        dp[pos]+=val%mod2;
        tree[node]+=val%mod2;
        return;
    }
    ll m = (l+r)/2;
    update((2*node)+1, l, m, val, pos);
    update((2*node)+2, m+1, r, val, pos);
    tree[node] = (tree[(2*node)+1] + tree[(2*node)+2])%mod2;
}
 
ll query(ll node, ll start, ll end, ll l, ll r){
    if((l>r) || (r<start) || (l>end)){
        return 0;
    }
    if((l>=start) && (r<=end)){
        return tree[node]%mod2;
    }
 
    ll m = (l+r)/2;
    ll z1 = query((2*node)+1, start, end, l, m);
    ll z2 = query((2*node)+2, start, end, m+1, r);
    return (z1+z2)%mod2;
}


int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    cin>>n>>k;
    for (int i = 0; i < k; ++i)
    {
        ll a,b;
        cin>>a>>b;
        v.push_back({a, b});
    }
    sort(v.begin(), v.end());

    for (int i = 0; i < n; ++i)
    {
        dp[i]=0;
    }
    dp[0]=1;
    build(0, 0, n-1);

    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < v.size(); ++j)
        {
            // segement tree on segement
            ll st=v[j].F;
            ll en=-1;
            if(i>=v[j].S){
                en=v[j].S;
            }
            else if(i>=v[j].F){
                en=i;
            }
            if(en!=-1){
                ll x = query(0, i-en, i-st, 0, n-1);
                update(0, 0, n-1, x, i);
            }
        }
    }

    cout<<dp[n-1]%mod2;

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;

ll f[N]={1};
ll rf[N]={1};
ll w[N];
vector<ll> vect[N];
ll p[N];
vector<ll>g[N];
ll cnt[N];
int pos[N];
ll c[N];
ll same,notsame,n;


inline bool cmp(int x, int y)
{
	return w[x]<w[y];
}

int get(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=get(p[x]);
}

inline void uni(int x, int y)
{
	x=get(x);
	y=get(y);
	if(rand()&1)
		p[x]=y;
	else
		p[y]=x;
}

ll bin(ll x, ll k)
{
	ll res=1;
	while(k)
	{
		if(k&1)
			res=res*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>same>>notsame;
	fo(i,n)
	{
		p[i]=i;
		cin>>c[i]>>w[i];
		g[c[i]].pb(i);
	}
	fo(i,n)
		f[i]=f[i-1]*i%mod;
	rf[n]=bin(f[n],mod-2);
	for(int i=n-1;i>=1;--i)
		rf[i]=rf[i+1]*(i+1)%mod;
	multiset<pii> allw;
	fo(i,n)
	{
		sort(g[i].begin(),g[i].end(),cmp);  
		allw.insert(mp(w[i],i));
	}
	fo(i,n)
	{
		if(g[i].size()>0)
		{
			int cur=pos[i];
			int st=g[i][0];
			while(pos[i]<g[i].size())
			{
				int x=g[i][pos[i]];
				int y=st;
				if(w[x]+w[y]<=same)
					++pos[i];
				else
					break;
			}
		}
	}
	fo(i,n)
	{
		if(g[i].size()>0)
		{
			for(int e:g[i])
				allw.erase(mp(w[e],e));
			int y=g[i][0];
			int x=allw.begin()->S;
			if(w[x]+w[y]<=notsame)
				uni(c[x],c[y]);
			if(!allw.empty())
			{
	        	int x=allw.begin()->S;
	        	while(pos[i]<g[i].size())
	        	{
	        		int y=g[i][pos[i]];
	        		if(w[x]+w[y]<=notsame)
	        			uni(c[x],c[y]), ++pos[i];
	        		else
	        			break;
	        	}
	        }
			for(int e:g[i])
				allw.insert(mp(w[e],e));
		}
	}
	ll ans=1;
	fo(i,n)
	{
		int x=get(i);
		vect[x].pb(i);
	}
	for(int i=1;i<=n;++i)
	{
		ll sum=0;
		for(int j=0;j<vect[i].size();++j)
		{
			int y=vect[i][j];
			sum+=pos[y];
		}
		ans=(ans*f[sum])%mod;
		for(int j=0;j<vect[i].size();++j)
		{
			int y=vect[i][j];
			ans=(ans*rf[pos[y]])%mod;
		}
	}
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 39680
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
int n, m;
ll k, s;
V<ll> va={0};
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  FOR(i, 0, n){
    ll a;
    cin >> a;
    s += a;
    va.pb(s);
  }

  int ans = (upper_bound(all(va), k)-va.begin()) - 1;
  s = 0;
  FOR(i, 0, m){
    ll b;
    cin >> b;
    s += b;
    if(s <= k) maxs(ans, int(upper_bound(all(va), k-s) - va.begin())+i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5316
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    println!("{}", 6 - a - b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
	#define infl 		9223372036854775807
	#define int		long long
const int NN=3005;
int ans[NN][NN]={}, a[NN]={};

int minimax(int l, int r, bool ismax){
	//cout<<l<<" "<<r<<" "<<ismax<<endl;
	if(ans[l][r]!=infl)
		{return ans[l][r];}

	if(l > r)
		return ans[l][r] = 0;
	if(r==l){
		if(ismax) return (ans[l][r] = a[l]); else return (ans[l][r] = -a[l]);
	}

	if(ismax)
	{
		return ans[l][r] = max(a[l] + minimax(l+1, r, false), a[r] + minimax(l, r-1, false));
	}
	else
	{
		return ans[l][r] = min(-a[l] + minimax(l+1, r, true), -a[r] + minimax(l, r-1, true));
	}

}

signed main()
{
	int n;
	cin>>n;
	for(int i=0; i<NN; ++i)for(int j=0; j<NN; ++j)ans[i][j]=infl;
	for(int i=0; i<n; ++i){
		cin>>a[i];
	}
	minimax(0, n-1, true);
	/*for(int i=0; i<n; ++i)
	{
		for(int j=0; j<n; ++j)
		{
			if(i>j)
				cout<<"* ";
			else cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<ans[0][n-1];
	return 0;
}

Measured memory_bytes: 74340
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;

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

  int x = 7 % k;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x*10+7)%k;
    i++;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 50516
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  // Place A blue balls at the end of the row.
  // place B red balls at the end of the row
  // How many blue balls will there be among the first N balls in the row?

  // n = 8
  // a = 3
  // b = 4
  // BBB RRRR BBB
  //          ^

  // len_seq = 7
  // n = 8
  // n_seq = 1

  if (a == 0) {
    cout << "0" << endl;
    return 0;
  }
  long long len_seq = a + b;
  long long n_seq = n / len_seq;
  long long balls_left = n - len_seq * n_seq;
  long long ret = a * n_seq + (min(a, balls_left));

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3636
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    t = read_int_list()
    m = read_int()
    p = [0] * m
    x = [0] * m
    for i in range(m):
        p[i], x[i] = read_int_list()
        p[i] -= 1

    for i in range(m):
        res = 0
        for j in range(n):
            if j == p[i]:
                time = x[i]
            else:
                time = t[j]
            res += time
        print(res)


main()


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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 done[100][100];

char next_(int *i, int *j, char dire, int H, int W){
    if(dire=='u'){
        if(*i-1>=0 && done[*i-1][*j]==0){*i-=1; done[*i][*j]=1; return 'u';}
        else{*j+=1; done[*i][*j]=1; return 'r';}
    } else if(dire=='r'){
        if(*j+1<W && done[*i][*j+1]==0){*j+=1; done[*i][*j]=1; return 'r';}
        else{*i+=1; done[*i][*j]=1; return 'd';}
    } else if(dire=='d'){
        if(*i+1<H && done[*i+1][*j]==0){*i+=1; done[*i][*j]=1; return 'd';}
        else{*j-=1; done[*i][*j]=1; return 'l';}
    } else {
        if(*j-1>=0 && done[*i][*j-1]==0){*j-=1; done[*i][*j]=1; return 'l';}
        else{*i-=1; done[*i][*j]=1; return 'u';}
    }
}
int main(void){
    int H,W,N; cin >> H >> W >> N;
    int a[N]; REP(i,N) cin >> a[i];
    REP(i,H)REP(j,W) done[i][j] = 0;
    done[0][0] = 1;
    int c[H][W];

    int ptr=0;
    int i=0,j=0;
    char dire='r';
    REP(k,H*W){
        c[i][j] = ptr+1;
        a[ptr]--;
        if(a[ptr] == 0) ptr++;
        dire = next_(&i, &j, dire, H, W);
    }

    REP(i,H){
        REP(j,W){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
A = [[int(i) for i in input().split()] for _ in range(3)]
B = [[False, False, False], [False, False, False], [False, False, False]]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==b:
                B[j][k]=True
for r in B:
    if all(r):
        print("Yes")
        quit()

for c in zip(*B):
    if all(c):
        print("Yes")
        quit()
# print(B)
if (B[0][0] and B[1][1] and B[2][2]) or (B[0][2] and B[1][1] and B[2][0]):
    print("Yes")
    quit()

print("No")

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

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	int arr[n],s=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		s+=arr[i];
	}

	int c=0,ans=1e18;
	for(int i=0;i<n;i++)
	{
		c+=arr[i];
		ans=min(ans,abs(s-2*c));
	}
	cout<<ans<<endl;
}

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

int main()
{
    int n,m;
    std::cin >> n >> m;
    
    std::vector<std::vector<int> > mat(n,std::vector<int>(m));
    std::vector<int> b(m);
    std::vector<int> ans(n);
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            std::cin >> mat[i][j];
    
    for(int i=0;i<m;i++)
        std::cin >> b[i];
        
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            ans[i] += mat[i][j]*b[j];
    
    for(int i=0;i<n;i++)
        std::cout << ans[i] << std::endl;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
double dp[305][305][305];
int n;
vector<int> a;
void f(int i, int j, int k) {
    double nn0 = n-i-j-k;
    double bun = 1.0-(double)(nn0/(double)n);
    if(bun==0) dp[i][j][k]=0;
    else dp[i][j][k] =1.0/bun;
     
    if(i>0){
        if(dp[i-1][j][k]==-1) f(i-1,j,k);
        dp[i][j][k] += dp[i-1][j][k]*(i)/n/bun;
    }
    if(j>0){
        if(dp[i+1][j-1][k]==-1) f(i+1,j-1,k);
        dp[i][j][k] += dp[i+1][j-1][k]*(j)/n/bun;
    }
    if(k>0){
        if(dp[i][j+1][k-1]==-1) f(i,j+1,k-1);
        dp[i][j][k] += dp[i][j+1][k-1]*(k)/n/bun;
    }
}
signed main() {
    cin >> n;
    a.resize(n);
    int n1 = 0;
    int n2 = 0;
    int n3 = 0;
    rep(i,n) {
        cin >> a[i];
        if(a[i]==1) n1++;
        else if(a[i]==2) n2++;
        else if(a[i]==3) n3++;
    }
    rep(i,305)rep(j,305)rep(k,305) dp[i][j][k]=-1;
    f(n1,n2,n3);
    cout << setprecision(20)<<dp[n1][n2][n3] << endl;




  return 0;
}



Measured memory_bytes: 225516
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

#define keta setprecision(15) //15桁表示

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

	int n;
	cin >> n;
	vector<int> a(n);
	vector<vector<int>> x(n), y(n);
	rep(i, n)
	{
		cin >> a[i];
		rep(j, a[i])
		{
			int tmp;
			cin >> tmp;
			x[i].push_back(tmp);
			cin >> tmp;
			y[i].push_back(tmp);
		}
	}

	ll bit = pow(2, n) - 1;
	ll num = 0;
	bool lai = false;
	ll sum,ans=0;
	
	while (bit>=0)
	{
		sum = 0;
		num = 0;
		ll tmp = bit;
		while (tmp!=0)
		{
			if (tmp & 1)
			{
				for (int i = 0; i < x[num].size(); i++)
				{
					if ((bit >> (x[num][i] - 1) & 1) == y[num][i])
					{
						continue;
					}
					else
					{
						lai = true;
						break;
					}
				}
				if (!lai)
					sum++;
				else
				{
					sum = 0;
					lai = true;
					break;
				}
			}
			if (lai)
				break;

			num++;
			tmp = (tmp >> 1);
		}
		lai = false;
		ans = max(ans, sum);
		bit--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
int a[N];
vector<int> tree[N];
int n, q;

void dfs(int u = 1, int p = 0) {
    a[u] += a[p];
    rall(v, tree[u]) {
        if(v != p) {
            dfs(v, u);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    rep(i, 1, n - 1) {
        int u, v;
        cin >> u >> v;
        tree[u].pb(v);
        tree[v].pb(u);
    }
    while(q--) {
        int u, x;
        cin >> u >> x;
        a[u] += x;
    }
    dfs();
    rep(i, 1, n) {
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


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

using namespace std;


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

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};


const int nmax = 50;

int n, m;
int a[nmax], b[nmax];

bool graph[nmax][nmax];
bool visited[nmax];

void dfs(int v){
    visited[v] = true;
    for(int w = 0; w < n; ++w){
        if(!graph[v][w]) continue;
        if(visited[w]) continue;
        dfs(w);
    }

}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int ans = 0;

    cin >> n >> m;

    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

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

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j = 0; j < n; ++j){
            visited[j] = false;
        }

        dfs(1);

        bool bridge = false;
        for(int j = 0; j < n; ++j){
            if(!visited[j]) bridge = true;
        }

        if(bridge) ++ans;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))

wa=[0]
temp=0
for i in a:
  temp+=i
  wa.append(temp%m)

from collections import Counter
c=Counter(wa) #各余りが何種類あるか分析したよ。

ans=0
from operator import mul
from functools import reduce

def cmb(n,r):
    if n<r: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in c.values():
  ans+=cmb(i,2)
print(ans)

Measured memory_bytes: 16556
#include <stdio.h>

#define MAX 100000

int n, k;
int A[MAX];

void exchange(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int *A, int p, int r) {
  int x = A[r];
  int i = p - 1, j;

  for (j = p; j <= r-1; j++) {
    if (A[j] <= x) {
      i++;
      exchange(&A[i], &A[j]);
    }
  }
  exchange(&A[i+1], &A[j]);

  return i+1;
}

int main() {
  int i, q;

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

  q = partition(A, 0, n-1);
  for (i = 0; i < n; i++) {
    if (i == n-1) {
      printf("%d\n", A[i]);
      break;
    } if (i == q) {
      printf("[%d] ", A[i]);
      continue;
    }
    printf("%d ", A[i]);
  }

  return 0;
}

Measured memory_bytes: 988
n,m = map(int,input().split())
s = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    s.append(tmp[1:])
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
    if check:
        ans += 1
print(ans)

Measured memory_bytes: 9156
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n,score[1000];
    double ave,bigsum,doublesa,answer;

    while(1){
        cin>>n;
        if(n==0) break;
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>score[i];
            sum+=score[i];
        }
        ave=1.0*sum/n;
        double shosum=0;
        for(int j=0;j<n;j++){
            doublesa=pow(score[j]-ave,2);
            shosum+=doublesa;
        }
    bigsum=1.0*shosum/n;
    answer=sqrt(bigsum);
    printf("%1f\n",answer);
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll x;
  cin>>x;

  for(ll a=0; a<=1000; a++){
    for(ll b=-1000; b<=1000; b++){
      if(pow(a,5)-pow(b,5)==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
}



Measured memory_bytes: 4116
#include <stdio.h>

typedef enum {false, true} bool;


bool trace(long long xy[][2], long long basis, long long xor_basis, int N, int num, int ctr, int index)
{
    int i, j;
    static int record[15];
    static bool flag;
    
    
    if(num == ctr)
    {
        flag = true;
        xor_basis = xor_basis ^ basis;
        
        for(i=0; i<num; i++)
        {
            if((xy[record[i]][1] & basis) != basis || ((xy[record[i]][0] ^ xor_basis) & xor_basis) != xor_basis)
            {
                flag = false;
                
                break;
            }
        }
    }
    else
    {
        for(j=index; j<=N-(num-ctr); j++)
        {
            if(ctr == 0)
                basis = 0;
            
            record[ctr] = j;
            
            if(trace(xy, basis | 1<<(N-j-1), xor_basis, N, num, ctr+1, j+1))
                return true;
        }
    }
    
    if(flag)
        return true;
    else
        return false;
}

int main(void)
{
    char c;
    int N;
    int A, x, y;
    
    long long xy[15][2], temp;
    
    int i, j;
    
    
    scanf("%d%c", &N, &c);
    
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &A, &c);
        
        xy[i][0] = 1<<(N-i-1);
        
        xy[i][1] = 1;
        for(j=1; j<N; j++)
            xy[i][1] = xy[i][1]<<1 | 1;
        
        temp = xy[i][1];
        
        for(j=0; j<A; j++)
        {
            scanf("%d%c%d%c", &x, &c, &y, &c);
            
            if(y == 0)
                xy[i][1] &= temp ^ 1<<(N-x);
            
            if(y == 1)
                xy[i][0] |= 1<<(N-x);
        }
    }
    
    for(i=N; i>0; i--)
    {
        if(trace(xy, 0, temp, N, i, 0, 0))
            break;
    }
    
    
    printf("%d\n", i);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 128
def find_ans(N,K):
    # K==0ならN^2が答え
    if K==0:
        return N**2
    
    # そうでなければK+1～Nについて一般式
    else:
        ans = 0
        for i in range(K+1,N+1):
            ans += (N//i)*(i-K) + max(N%i-(K-1), 0)
            
        return ans
    
N,K = map(int, input().split())
print(find_ans(N,K))

Measured memory_bytes: 3060
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int N;
long long int X[20], Y[20], P[20];

long long int dp[1 << 17][20];

long long int INF = (long long int) 1e18-1;

long long int val[1 << 17]; // 集合Sを決めたときの最小値

int s_val[16000000], t_val[16000000];

int used_X[20], used_Y[20];


int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> P[i];
	}

	for (int i = 0; i < (1 << N); i++) {
		for (int k = 0; k <= N; k++) {
			dp[i][k] = INF;
		}
	}

	int M = pow(3, N);

	for (int k = 0; k < M; k++) {
		int tmp = k;
		int b = 0;
		//vector<long long int> VX, VY;
		for (int i = 1; i <= N; i++) { used_X[i] = 0; used_Y[i] = 0; }

		long long int sum = 0;

		int pos = 1;
		for (int i = 1; i <=N; i++) {
			b *= 2;
			if (tmp % 3 == 1) {/* VX.push_back(pos);*/ sum += abs(X[i])*P[i]; b++; }
			else if (tmp % 3 == 2) { /*VY.push_back(pos);*/ sum += abs(Y[i])*P[i]; b++; }
			tmp /= 3; pos++;
		}
			
			/*for (auto u : VX) {  sum += abs(X[u])*P[u]; }
			for (auto u : VY) { sum += abs(Y[u])*P[u]; }*/
			dp[b][0] = min(dp[b][0], sum);
	}

	

	for (int k = 0; k < (1 << N); k++) {
		val[k] = INF;
	}

	for (int k = 0; k < (1 << N); k++) {
		for (int u = 1; u <= N; u++) {
			long long int tmp = 0;
			for (int i = 1; i <= N; i++) {
				if (k & (1<<(N-i))) {
					tmp += abs(X[i] - X[u])*P[i];
				}
			}
			val[k] = min(val[k], tmp);
		}
		for (int u = 1; u <= N; u++) {
			long long int tmp = 0;
			for (int i = 1; i <= N; i++) {
				if (k& (1<<(N-i))) {
					tmp += abs(Y[i] - Y[u])*P[i];
				}
			}
			val[k] = min(val[k], tmp);
		}
	}

	
	

	for (int m = 0; m < M; m++) {
		int tmp = m;
		int tmp_s = 0; int tmp_t = 0;
		for (int i = 1; i <= N; i++) {
			tmp_s *= 2; tmp_t *= 2;
			if (tmp % 3 == 1) { tmp_s++; }
			else if (tmp % 3 == 2) { tmp_t++; }
			tmp /= 3;
		}
		s_val[m] = tmp_s; t_val[m] = tmp_t;
	}


	for (int k = 1; k <=  N; k++) {
		for (int m = 0; m < M; m++) {
			int s = s_val[m]; int t = t_val[m];
			dp[s | t][k] = min(dp[s | t][k], dp[s][k - 1] + val[t]);

		}
	}

	
	for (int k = 0; k <= N; k++) {
		cout << dp[(1 << N) - 1][k] << endl;
	}

	return 0;
}

Measured memory_bytes: 121436
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    vector<int> cnt(200010, 0);
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        A.emplace_back(tmp);
        cnt[tmp] += 1;
    }

    long long sum = 0;
    for (int x : cnt){
        sum += ((long long)x * ((long long)x - 1)) / 2;
    }

    long long ans;
    for (int i = 0; i < N; i++)
    {
        ans = sum - 2 * (cnt[A[i]] - 1) / 2;
        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;

#define ll64 long long

int main()
{
    set<int> S;
    map<int, int> IDX;
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        int x;
        scanf("%d", &x);
        IDX[x] = i;
    }
    S.insert(0);
    S.insert(N + 1);
    ll64 ans = 0;
    for(int i = 1; i <= N; i++){
        int m = IDX[i];
        auto it = S.upper_bound(m);
        ll64 y = *it;
        it--;
        ll64 x = *it;
        ans += (m - x) * (y - m) * i;
        S.insert(m);
        //printf("%d %d %d\n", x, m, y);
    }
    printf("%lld\n", ans);
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  cout << 3 * n * n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 200005

void solve()
{
	lli a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;

	if(w >= v)
	{
		cout<<"NO"<<endl;
		return ;
	}

	lli vel = v-w;
	lli t1 = t*(v-w);

	if(t1 >= abs(a-b)) cout<<"YES";
	else cout<<"NO";
}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    	solve();
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include<math.h>
#include<map>
#include<vector>
#include <tuple>
using namespace std;
int main() {
  int S;
  cin >> S;
  int sq = S/1000;
  int hq = S/100 - 10 * (S/1000);
  int jq = S/10 - 10 * (S/100);
  int r = S%10;
  if(sq == hq || hq == jq || jq == r){
    cout << "Bad" << endl;
    return 0;
  }
  else{
    cout << "Good" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ARC080
{
    class C
    {
        static void Main(string[] args)
        {
            /*
            方針：
            N%4 == 0 となる値が N/2 個以上あるかどうか。
            2が2個あることで4の倍数になるので、2の数も数える。
            2が2個で4の倍数1個と同じ

            メモ：2は隣り合っている間は4の倍数になる。奇数偶数に依らない

            新方針：
            2の数をNから引いて、残りの値にたいして4の倍数でジャッジする
            　→2の数だけではだめ。2の倍数同士でも4の倍数にできるので、2の倍数から4の倍数を引いた数で計算するべき
            */

            //入力
            long N = long.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            //N%4 == 0 となる値を格納する変数
            int count = 0;
            //2の数
            int secondcount = 0;

            //aを最初からチェックする。4の倍数のときcount++する
            for (int i = 0; i < N; i++)
            {
                if (a[i] % 4 == 0) { count++; }
                if (a[i] % 2 == 0) { secondcount++; }
            }

            secondcount -= count;

            //2の数が2以上の時、Nから引く。
            if (2 <= secondcount)
            {
                N -= secondcount;
                //Nが奇数になった場合、N / 2に1を足す
                //Nが偶数のときはそのまま
                if (N % 2 != 0)
                {
                    if ((N / 2) + 1 <= count) { Console.WriteLine("Yes"); }
                    else Console.WriteLine("No");
                    return;
                }
                else if (N / 2 <= count) { Console.WriteLine("Yes"); }
                else Console.WriteLine("No");
            }
            else
            {
                if (N / 2 <= count) { Console.WriteLine("Yes"); }
                else Console.WriteLine("No");
            }
        }
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n,k;cin>>n>>k;
  int i;
  ll ans=n;
  n%=k;
  ans=min(ans,n);
  rep(i,4)
  {
    n=abs(n-k);
    ans=min(ans,n);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(void){
    int A, B, K;

    cin >> A >> B >> K;
    vector<int> v;
    
    for(int i = 1; i <= 100; ++i){
        if(A % i == 0 && B % i == 0){
            v.push_back(i);
        }
    }
    sort(v.begin(), v.end(), greater<int>());
    
    cout << v[K - 1] <<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,x;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0)break;
        int ans = 0;
        for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)for(int k=j+1;k<=n;k++){
            if(i+j+k==x)ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll a, b, x, c, d;
  cin>>a>>b>>x;
  a = a - 1;
  if(a>=0) c = a/x + 1;
  else c = 0;

  if(b>=0) d = b/x + 1;
  else d = 0;
   cout<<d - c<<endl;

  return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

const int max_n = 8100;
bool pos_x[max_n][max_n*2];
bool pos_y[max_n][max_n*2];
signed main()
{
    gearup;
    string s; cin >> s;
    ll x,y; cin >> x >> y;

    vl dist;
    ll dif = 0;
    rep(i,s.size()){
        if(s[i] == 'T'){
            if(dif!=0)dist.push_back(dif);
            dist.push_back(0);
            dif = 0;
        }
        else{
            dif++;
            if(i == s.size() -1)dist.push_back(dif);
        }
    }
    ll dif_x = 0;
    if(dist[0] != 0){
        dif_x = dist[0];
        dist.erase(dist.begin());
    }
    pos_x[0][max_n + dif_x] = true;
    pos_y[0][max_n] = true;
    int idx_x = 0,idx_y = 0;
    bool is_dir_x = true;

    int m = dist.size();
    rep(i,m){
        if(dist[i] == 0)is_dir_x = !is_dir_x;
        else if(is_dir_x){
            idx_x++;
            rep(j,max_n*2){
                if(pos_x[idx_x-1][j]){
                    pos_x[idx_x][j+dist[i]] = true;
                    pos_x[idx_x][j-dist[i]]=true;
                }
            }
        }
        else{
            idx_y++;
            rep(j,max_n*2){
                if(pos_y[idx_y-1][j]){
                    pos_y[idx_y][j+dist[i]] = true;
                    pos_y[idx_y][j-dist[i]] = true;
                }
            }
        }
    }
    if(pos_x[idx_x][max_n + x] && pos_y[idx_y][max_n + y])out("Yes");
    else out("No");
}

Measured memory_bytes: 27576
#include<iostream>
#include<vector>
using namespace std;
int N;
int c[2<<17];
vector<int>G[2<<17];
int cnt[2<<17];
long ans[2<<17];
int dfs(int u,int p)
{
	int ret=1;
	int sto=cnt[c[u]];
	int pre=sto;
	for(int v:G[u])if(v!=p)
	{
		int t=dfs(v,u);
		ret+=t;
		long k=t-(cnt[c[u]]-sto);
		ans[c[u]]-=k*(k+1)/2;
		sto=cnt[c[u]];
	}
	cnt[c[u]]=pre+ret;
	return ret;
}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>c[i];
		c[i]--;
	}
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1);
	for(int i=0;i<N;i++)
	{
		ans[i]+=(long)N*(N+1)/2;
		if(i!=c[0])
		{
			long k=N-cnt[i];
			ans[i]-=k*(k+1)/2;
		}
		cout<<ans[i]<<endl;
	}
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int number = 1;
  for(int i = 0; i < n; i++){
    if(number * 2 < number + k){
      number = number * 2;
    }
    else{
      number = number + k;
    }
  }
  cout << number << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var dic = new Dictionary<string,int>();
		int ans = 0;
		for(var i=0;i<N;i++){
			string s = Console.ReadLine();
			if(!dic.ContainsKey(s)){
				dic[s] = 1;
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 45488