akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int g(int x, int y, int z) {
  return (x + y) * (x + y) + (y + z) * (y + z) + (z + x) * (z + x);
}

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

  vector<set<multiset<int>>> trios(n);
  rep(in, n) {
    int sup = sqrt((in + 1) / 6);
    int x = 1, y = 1;
    int mint = sup;
    while (x <= sup) {
      int z = 1;
      while (g(x, y, z) <= 2 * (in + 1)) y++;
      while (y >= z) {
        y--;
        while (g(x, y, z) < 2 * (in + 1)) z++;
        if (g(x, y, z) == 2 * (in + 1)) {
          multiset<int> trio;
          trio.insert(x);
          trio.insert(y);
          trio.insert(z);
          trios[in].insert(trio);
          mint = min(mint, min(y, z));
          //cout << in + 1 << " : " << x << " " << y << " " << z << endl;
          //for (int r : trio) cout << r << " ";
          //cout << endl;
        }
      }
      x++;
      while (g(x, y, z) > 2 * (in + 1)) y--;
    }
  }
  rep(i, n) {
    int count = 0;
    for (auto t : trios[i]) {
      //auto it = t.begin();
      int x = *(t.begin());
      int y = *next(t.begin(), 1);
      int z = *next(t.begin(), 2);
      if (x == y && y == z)
        count += 1;
      else if (x == y || y == z || z == x)
        count += 3;
      else
        count += 6;
      //cout << i + 1 << " : " << x << " " << y << " " << z << endl;
    }
    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 13680
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("Ofast")
#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>
using namespace std;
using namespace __gnu_pbds;
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
#define mp make_pair
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int modpow(int n, int k, int MOD);

/**************** code starts here ****************/

void poppingfever() {
	map<int, int> mp;
	int x; 
	while (cin >> x) {
		mp[x]++;
	}
	for (auto u: mp) {
		if (u.second >= 3) {cout << "NO"; return;}
	}
	cout << "YES";
}

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
 
	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);
 
	int t = 1; //cin >> t;
	for (int i = 1; i <= t; i++) {
		poppingfever();
	}
 
	return 0;
}

int modpow(int n, int k, int MOD) {
	int ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans;
}

Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline().strip()

h, w, m = map(int, input().split())
dic_h = {}
dic_w = {}
s = set([])
for _ in range(m):
    i, j = map(int, input().split())
    s.add((i, j))
    try:
        dic_h[i] += 1
    except:
        dic_h[i] = 1
    try:
        dic_w[j] += 1
    except:
        dic_w[j] = 1

max_h = 0
lh = []
max_w = 0
lw = []
for i, j in dic_h.items():
    if max_h < j:
        max_h = j
        lh = [i]
    elif max_h == j:
        lh.append(i)
for i, j in dic_w.items():
    if max_w < j:
        max_w = j
        lw = [i]
    elif max_w == j:
        lw.append(i)

for i in lh:
    for j in lw:
        if (i, j) not in s:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)

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

int main() {
  int n,x;
  cin>>n;
  x=1;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    if(a.at(i)%2==0)x*=2;
  }
  x=pow(3,n)-x;
  cout<<x<<endl;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/c.in", "r", stdin);
//  freopen("../IO/c.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}



void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;

  vector<int> cnt(n + 1);
  for (int i = 2; i <= n; ++i) {
    int p;
    in >> p;
    cnt[p] += 1;
  }
  for (int i = 1; i <= n; ++i) {
    out << cnt[i] << '\n';
  }
}



Measured memory_bytes: 3996
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,x;
  cin >> N;
  x = 0;
  vector<int> value(N);
  vector<int> cost(N);
  for (int i = 0; i < N; i++) {
    cin >> value.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> cost.at(i);
  }
  for (int i = 0; i < N; i++) {
    if(value.at(i) > cost.at(i)){
        x = x + (value.at(i) - cost.at(i));
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.stream.DoubleStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      String[] lines;
      double[] s;
      while( !(line = br.readLine()).equals("0") ){

        int n = Integer.parseInt(line);
        lines = br.readLine().split(" ");

        s =
          Stream.of(lines)
            .mapToDouble(Double::parseDouble)
            .toArray();
        
        double dm =
          Arrays.stream(s)
            .average()
          .getAsDouble();

        double result =
        Arrays.stream(s)
          .map(d -> Math.pow((d-dm),2))
          .sum();
        result = Math.sqrt((result)/n);

        System.out.printf("%.8f\n" ,result);
      }
    }
  }
}


Measured memory_bytes: 31992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))
 
const long long MOD = 1e9 + 7;
 
int main() {
    ll n, k;
    cin >> n >> k;
    vll a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vll dp(k + 1,0), nx;
    dp[0] = 1;
    for (int person = 0; person < n; person++) {
        nx = vll(k + 2, 0);
        for (int candies = 0; candies <= k; candies++) {
            ll ways = dp[candies];
            nx[candies] += ways;
            nx[min(candies + a[person], k) + 1] -= ways;
        }
        for (int i = 0; i <= k; i++)
            dp[i] = (nx[i] + (i > 0 ? dp[i - 1] : 0) + MOD) % MOD;
    }
    cout << (dp[k]) << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 2e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=INF,a[100000000],b,c,cmp[100000000],data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
       }
       cmp[0]=a[0];
       cnt=n-1;
       rep(i,n-1){
           cmp[i+1]=cmp[i]+a[i+1];
       }
       rep(i,n-1){
           ans=min(Abs(cmp[i],cmp[cnt]-cmp[i]),ans);
       }
       Cout(ans);
return 0;
}


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

#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define INF 1e9 + 7

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;
    int hit = 0;
    REP(i, 3) {
        if (S[i] == T[i]) {
            ++hit;
        }
    }
    cout << hit << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	double x,h,c;
	while(1){
		scanf("%lf %lf",&x,&h);
		if(x == 0.0 && h == 0.0) break;
		c = (x/2.0)*(x/2.0) + h*h;
		c = sqrt(c);
		c = x*x + x*c/2.0*4.0;
		printf("%lf\n",c);
	}
	return 0;
}

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

signed main(){
  
  int N, A, B;
  cin>>N>>A>>B;
  
  int plus = min(A,N%(A+B));
    
  cout<<(N/(A+B))*A+plus<<endl;
  
  return 0;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define PH push
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int maxn = 105;
const int INF = 998244353;

int can[maxn];
string str;
unordered_map<string, int> f, g;

inline int dp(string str);

inline int fold(string str){
	if(g.find(str) != g.end())
		return g[str];
	int n = str.size();
	int &ret = g[str];
	if(n == 1){
		return 0;
	}
	FOR(i, 1, n) if(!(n % i)){
		ll res = 1;
		FOR(j, 0, i)
			can[j] = 1;
		FOR(j, 0, n)
			can[j % i] &= (str[j] - '0');
		string nxt = "";
		FOR(j, 0, i){
			nxt += can[j] + '0';
		}
		(ret += dp(nxt)) %= INF;
	}
//	cout << "str = " << str << " fold = " << ret << endl;
	return ret;
}

inline int dp(string str){
	if(f.find(str) != f.end())
		return f[str];
	int &ret = f[str];
	if(str.size() <= 1){
		if(!str.size())
			return (ret = 1);
		if(str == "0")
			return (ret = 1);
		return (ret = 2);
	}
	string cut = "", nxt = str;
	FOR(i, 0, str.size()){
		cut += str[i];
		nxt.erase(nxt.begin());
		if(i)
			(ret += 1ll * fold(cut) * dp(nxt) % INF) %= INF;
		else
			(ret += dp(nxt) * (str[i] - '0' + 1) % INF) %= INF;
//		printf("i = %d ret = %d\n", i, ret);
	}
//	cout << "str = " << str << " dp = " << ret << endl;
	return ret;
}

int main(){
	cin >> str;
	cout << dp(str) << endl;
	return 0;
}

Measured memory_bytes: 12952
def main():
    N = int(input())
    H = int(input())
    W = int(input())
    count = 0
    for i in range(N):
        for j in range(N):
            if (N - i) >= H and (N - j) >= W:
                count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n)i++)
typedef long long ll;
using namespace std;
int main(){
  int n = 0;
  cin >> n;
  vector<ll> lu(n+1,0);
  lu[0] = 2; lu[1] = 1;
  
  for(int i=2;i<n+1;i++){
    lu[i] = lu[i-1] + lu[i-2];
  }
  cout << lu[n] << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int H, W, i, k;
    while(1) {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++) {
            for(k = i; k < W + i; k++) {
                if(k % 2 == 0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll power(ll a,ll n)
{
	if(n==0)
	return 1;
	if(n%2==0)
	return power((a*a)%mod,n/2)%mod;
	return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
}


int main()
{
	int a;
  scf(a);
  cout<<a+a*a+a*a*a;
return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    
    int N, K; cin >> N >> K;
    vector<ll> P(N+1), C(N+1);
    
    for (int i=1; i<=N; ++i) cin >> P[i];
    for (int i=1; i<=N; ++i) cin >> C[i];
    
    vector<ll> scores(N+1);
    ll maxscore = -1e18;
    
    for (int i=1; i<=N; ++i) {
        int cur = P[i];
        ll score = C[cur];
        int cnt = 1;
        scores[cnt] = score;
        while (cur != i && cnt < K) {
            cnt++;
            cur = P[cur];
            score += C[cur];
            scores[cnt] = max(scores[cnt-1], score);
        }
        if (cnt == K) {
            maxscore = max(scores[cnt], maxscore);
        } else {
            if (score > 0) {
                maxscore = max((K/cnt-1)*score + scores[cnt],max((K/cnt)*score + scores[K%cnt], maxscore));
            } else {
                maxscore = max(scores[cnt], maxscore);
            }
        }
    }
    
    cout << maxscore;
}


Measured memory_bytes: 3784
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}
impl UnionFind {
    fn new(size: usize) -> UnionFind {
        let mut par = Vec::with_capacity(size);
        let mut rank = Vec::with_capacity(size);
        for i in 0..size {
            par.push(i);
            rank.push(0);
        }
        UnionFind {
            par: par,
            rank: rank,
        }
    }
    fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let par = self.par[x];
            let ppar = self.root(par);
            self.par[x] = ppar;
            ppar
        }
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        return self.root(x) == self.root(y);
    }
    fn unite(&mut self, x: usize, y: usize) {
        let px = self.root(x);
        let py = self.root(y);
        if px == py {
            return;
        }
        if self.rank[px] < self.rank[py] {
            self.par[px] = py;
        } else {
            self.par[py] = px;
            if self.rank[px] == self.rank[py] {
                self.rank[px] += 1;
            }
        }
    }
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut nv = get!([usize]);
    for i in nv.iter_mut() {
        *i -= 1;
    }
    let mut uf = UnionFind::new(n);
    for _ in 0..m {
        let (x, y) = get!(usize, usize);
        uf.unite(x - 1, y - 1);
    }
    let mut count = 0;
    for (i, x) in nv.iter().enumerate() {
        if uf.same(i, *x) {
            count += 1;
        }
    }
    println!("{}", count);
}


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

int main(){
	int H,W;
	while(cin >> H >> W){
		if(H==0&&W==0) break;	
		for(int i=0;i<H;i++){
			for(int j =0 ; j<W ; j++){
				if(i==0 || j==0 || j==W-1 ||i==H-1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}

Measured memory_bytes: 1120
#include <iostream>

using namespace std;

int main(){
    while(1){
        int n,m;
        cin>>m>>n;

        if(n==0&&m==0){
            return 0;
        }

        int a[m]={0};

        int owan=n;
        int now=0;
        
        for(int i=0;i<1000000;i++){
            now=i%m;

            if(owan==0){
                owan=a[now];
                a[now]=0;
            }else if(owan!=0){
                owan--;
                a[now]++;
            }

            // cout<<a[now]<<" "<<owan<<endl;
            if(a[now]==n){
                cout<<now<<endl;
                break;
            }   
        }
    }
}

Measured memory_bytes: 3048
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep (i, n) cin >> a[i];
	rep (i, m) cin >> b[i];

	vector<ll> sum(m + 1, 0);
	rep (i, m) sum[i+1] = sum[i] + b[i];

	ll now = 0;
	ll ans = (upper_bound(rng(sum), k) - sum.begin()) - 1;
	rep (i, n) {
		now += a[i];
		if (now > k) break;
		chmax(ans, (upper_bound(rng(sum), k - now) - sum.begin()) + (ll)i);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7984
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//ユークリッドの互除法
ll gcd(ll x,ll y){
    if(x > y) swap(x,y);
    if(x == 0) return y;
    return gcd(x,y%x);
};

int main(){
    int n;
    cin >> n;
    vector<int> f(n),b(n);
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    f[0] = a[0];
    b[n-1] = a[n-1];
    for(int i = 1; i < n; i++){
        f[i] = gcd(f[i-1],a[i]);
        b[n-i-1] = gcd(b[n-i],a[n-i-1]);
    }
    ll ans = b[1];
    for(int i = 1; i < n; i++){
        ans = max(ans,gcd(f[i-1],b[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n, i, j, k, t, temp;
    cin >> n>>k;
    LL h[n + k + 1], dp[n + k + 1];
    const LL INF = 100000000000000000;
    for (i = 1; i <= n; i++)
    {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[1] = 0;
    for (i = 1; i <= n; i++)
    {
        for (j = 1; i + j <= min(n,i+k); j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + (LL)fabs(h[i] - h[i + j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	static int[][] c;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		
		c = new int[h][w];
		
		if(d%2 == 0){
			paint(-2*d, -2*d, h, w, d, 0);
			paint(-d, -2*d, h, w, d, 1);
			paint(-d-d/2, -d-d/2, h, w, d, 2);
			paint(-d-d/2, -d+d/2, h, w, d, 3);
		}else{
			c[0][0] = 0;
			for(int i=1; i<h; i++){
				if(c[i-1][0] == 0) c[i][0] = 1;
				if(c[i-1][0] == 1) c[i][0] = 2;
				if(c[i-1][0] == 2) c[i][0] = 3;
				if(c[i-1][0] == 3) c[i][0] = 0;
			}
			for(int i=0; i<h; i++){
				for(int j=1; j<w; j++){
					if(c[i][j-1] == 0) c[i][j] = 1;
					if(c[i][j-1] == 1) c[i][j] = 2;
					if(c[i][j-1] == 2) c[i][j] = 3;
					if(c[i][j-1] == 3) c[i][j] = 0;
				}
			}
		}	
		
		for(int i=0; i<h; i++){
			String s = "";
			for(int j=0; j<w; j++){
				String ns = "";
				if(c[i][j] == 0) ns = "R";
				if(c[i][j] == 1) ns = "Y";
				if(c[i][j] == 2) ns = "G";
				if(c[i][j] == 3) ns = "B";
				s = s + ns;
			}
			System.out.println(s);
		}
	}
	
	public static void paint(int x0, int y0, int h, int w, int d, int color){
		for(int i=x0; i<w+d*3; i+=d*2){
			for(int j=y0; j<h+d*3; j+=d*2){
				paint2(i, j, h, w, d, color);
			}
		}
		for(int i=x0+d; i<w+d*3; i+=d*2){
			for(int j=y0+d; j<h+d*3; j+=d*2){
				paint2(i, j, h, w, d, color);
			}
		}
	}
	
	public static void paint2(int x0, int y0, int h, int w, int d, int color){
		for(int i=0; i<d/2; i++){
			for(int j=i; j<d-i; j++){
				paint3(x0+j, y0+i, h, w, color);
				paint3(x0+j, y0-i, h, w, color);
			}
		}
	}
	
	public static void paint3(int x, int y, int h, int w, int color){
		if(x>=0 && x<w && y>=0 && y<h){
			c[y][x] = color;
		}
	}
}


Measured memory_bytes: 149012
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long
struct dijkstra_normal{
    int V;
    long long int *d; 
    vector<pair<int,int> > *edges;
    priority_queue< pair<long long int,int> , vector< pair<long long int,int> >, greater< pair<long long int,int> > > q;
    dijkstra_normal(int N): V(N){
        d=new long long int[N];
        edges=new vector<pair<int,int> > [N];
        rep(i,N){
            d[i]=LLINF;
        }
    }
    void push(int a,int b, int c){
        edges[a].pb( mp(b,c) );
    }
    long long int *solve(int start){
        q.push(mp(0,start));
        while(!q.empty()){
            pair<long long int,int> p=q.top();q.pop();
            int now=p.second;long long int cost=p.first;
            if(d[now]<=cost)continue;
            d[now]=cost;
            rep(e,edges[now].size()){
                int to=edges[now][e].first;int cst=edges[now][e].second;
                if(d[to]>cost+cst){
                    d[to]>cost+cst;
                    q.push(mp(cost+cst,to));
                }
            }
        }
        return d;
    }
    vector<int> return_not_use(){
        delete[] edges;
        delete[] d;
    }
};

int main(void){
    int N,Q,K;
    scanf("%d",&N);
    dijkstra_normal dijk(N);
    rep(i,N-1){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        a--;b--;
        dijk.push(a,b,c);dijk.push(b,a,c);
    }
    scanf("%d %d",&Q,&K);
    long long int *ans=dijk.solve(K-1);
    rep(i,Q){
        int x,y;
        scanf("%d %d",&x,&y);x--;y--;
        printf("%lld\n",ans[x]+ans[y]);
    }
}
    


Measured memory_bytes: 10096
#include<stdio.h>
int main(void)
{
  double w,h,x,y;
  scanf("%lf%lf%lf%lf",&w,&h,&x,&y);

  printf("%f %d\n",(double)((h*w)/2),2*x==w&&2*y==h);
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
	public class Main {
		public static void main(String[] args) {
		// ?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			// a??¨b????????£???values??????????????????
			int x = values[a];
			values[a] = values[b];
			values[b] = x;
		}
		// values??????????????????
		for(int i=0; i<n; i++){
			System.out.println(values[i]);
		}
	}
}

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

int main() {
  int N, K, S;
  cin >> N >> K;
  S = 1;
  for(int i = 0; i < N; i++){
  if(S * 2 >= S + K){
    S += K;
  }
  else{
   S *= 2;
  }
  }
  cout << S << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<memory.h>
#include<string.h>

using namespace std;

int main()
{
    char ch[1300];
    int cnt[26];

    memset(cnt,0,sizeof(cnt));

    while(cin.getline(ch,1300,'\n'))
    {
        int len=strlen(ch);

        for(int i=0;i<len;i++)
        {
            if(ch[i]>='a'&&ch[i]<='z')
            {
                cnt[ch[i]-'a']++;
            }else if(ch[i]>='A'&&ch[i]<='Z')
            {
                cnt[ch[i]-'A']++;
            }
        }

    }



    for(int i=0;i<26;i++)
    {
        cout<<(char)('a'+i)<<" : "<<cnt[i]<<endl;
    }


    return 0;
}



Measured memory_bytes: 3072
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		
		char[] w = {'R', 'G', 'B'};

		int[][] sum = new int[N][3];
		for(int i=N-1; i>=0; i--) {
			for(int j=0; j<3; j++) {
				sum[i][j] = (i==N-1 ? 0 : sum[i+1][j]) + (s[i]==w[j] ? 1 : 0);
			}
		}
		
		long ans = 0;
		for(int i=0; i<N-2; i++) {
			for(int j=i+1; j<N-1; j++) {
				if(s[i]!=s[j]) {
					if((s[i]^s[j])==('R'^'G')) {
						ans += sum[j+1][2];
						if(j+(j-i) < N && s[j+(j-i)]=='B')
							ans--;
					}
					if((s[i]^s[j])==('G'^'B')) {
						ans += sum[j+1][0];
						if(j+(j-i) < N && s[j+(j-i)]=='R')
							ans--;
					}
					if((s[i]^s[j])==('B'^'R')) {
						ans += sum[j+1][1];
						if(j+(j-i) < N && s[j+(j-i)]=='G')
							ans--;
					}
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 28324
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int G[101][101];

int main () {
	int N, K;
    cin >> N >> K;
	if (K > (N-1)*(N-2)/2) {
		cout << -1 << endl;
		return 0;
	}
	vector<pii> ans;
	rep(i,N-1) ans.push_back(pii(i+1, N));
	vector<pii> edges;
	rep(i,N-1)
		rep(j,i)
			edges.push_back(pii(j+1,i+1));
	rep(i,(N-1)*(N-2)/2 - K) ans.push_back(edges[i]);
	cout << ans.size() << endl;
	rep (i,ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){cout << "Yes" << endl;}
  else{cout << "No" << endl;}

}       

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int n,L,q;
int a[MAXN],d[MAXN][25];
void Init()
{
	int l=1,r=1;
	while(l<=n&&r<=n)
	{
		while(r<n&&a[r+1]-a[l]<=L)
			r++;
		d[l][0]=r;
		l++;
	}
	for(int i=1;(1<<i)<=n;i++)
		for(int j=1;j<=n;j++)
			d[j][i]=d[d[j][i-1]][i-1];
}
bool check(int x,int s,int t)
{
	int now=s,jl=0;
	while(x)
	{
		if(x&1)
			now=d[now][jl];
		x>>=1;
		jl++;
	}
	if(now>=t)
		return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	scanf("%d",&L);
	Init();
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		int s,t;
		scanf("%d %d",&s,&t);
		if(s>t)
		swap(s,t);
		if(s==t)
		{
			printf("0\n");
			continue ;
		}
		int l=0,r=n;
		while(l<r)
		{
			int mid=(l+r)>>1;
			if(check(mid,s,t))
				r=mid;
			else
				l=mid+1;
		}
		printf("%d\n",r);
	}
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    vector<int> cnt;
    for(auto i = mp.begin(); i != mp.end(); ++i){
        cnt.push_back(i->second);
    }
    if((int)cnt.size() <= k){
        cout << 0 << endl;
    }else{
        sort(cnt.begin(), cnt.end());
        int ans = 0;
        rep(i, (int)cnt.size() - k){
            ans += cnt[i];
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 10748
import java.util.Scanner;

public 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){
                break;
            }
            for (int i = 0; i < H; i++){
                for (int j = 0; j < W; j++){
                    if (i % 2 == 0){
                        if (j % 2 == 0){
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    } else {
                        if (j % 2 == 0){
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 37540
import sys

sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
n, m = map(int, input().split())

pow_ = [0] * 31
divisor = 2
power = 0
while m % divisor == 0:
    m //= divisor
    power += 1
if power > 0:
    pow_[power] += 1

divisor = 3
while m > 1:
    power = 0
    while m % divisor == 0:
        m //= divisor
        power += 1
    if power > 0:
        pow_[power] += 1
    divisor += 2

# print(pow_)

ans = 1
t = 1
d = 1
for power, cnt in enumerate(pow_[1:], 1):
    # 1 <= power <= 30
    t = t * (n - 1 + power) % mod
    d = d * pow(power, mod - 2, mod) % mod
    # print(power, cnt, ans, t, d)
    for _ in range(cnt):
        ans = ans * t * d % mod
print(ans)


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    s += s.substr(0, 2);

    string ans = "-1";
    for (int i = 0; i < 4; i++) {
        string t;
        if (i == 0) {
            t = "SS";
        } else if (i == 1) {
            t = "SW";
        } else if (i == 2) {
            t = "WS";
        } else {
            t = "WW";
        }

        for (int i = 1; i <= n; i++) {
            if ((s[i] == 'o' and t[i] == 'S') or (s[i] == 'x' and t[i] == 'W')) {
                if (t[i - 1] == 'S') {
                    t += 'S';
                } else {
                    t += 'W';
                }
            } else {
                if (t[i - 1] == 'S') {
                    t += 'W';
                } else {
                    t += 'S';
                }
            }
        }

        if (t.substr(0, 2) == t.substr(n, 2)) {
            ans = t.substr(0, n);
            break;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 736
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll cnt[2019]={1ll};

int main(void){
	int n,c=1,t=0,i;
	std::string s;
	ll ans = 0ll;
	std::cin >> s;
	n = s.l_ength();
	std::reverse(s.begin(),s.end());
	for(i=0; i<n; ++i){
		t += c*(s[i]-'0')%2019;
		t %= 2019;
		ans += cnt[t];
		++cnt[t];
		c *= 10; c %= 2019;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
  int a, b, i;
  cin>>a>>b;
  string str1, str2;

  if(a<=b)
        for(i=0; i<b; i++)
            cout<<a;

  else
    for(i=0; i<a; i++)
            cout<<b;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int sum =0;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0;i<n;i++)
    cin >> v[i];
  for(int i=0;i<n;i++)
    cin >> c[i];
  
  for(int i=0;i<n;i++){
    if(v[i]-c[i]>0)
      sum += v[i]-c[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		if(C >= A && C <= B) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main() {
    int a=0,b=0,H[100],W[100];
    while (1) {
        cin >> H[a] >> W[a];
        if (H[a] == 0 && W[a] == 0) break;
        a++;
        
    }
    
    while (b<a) {

        for (int i = 0; i < H[b]; i++) {
            for (int j = 0; j < W[b]; j++) {
                printf("#");
            }
        printf("\n");
        }
        b++;
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2996
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int w,sengetu=4280;
  while(cin>>w){
    int ryokin=1150;
    if(w==-1) break;
    if(w>10) ryokin+=min(w-10,10)*125;
    if(w>20) ryokin+=min(w-20,10)*140;
    if(w>30) ryokin+=(w-30)*160;
    cout<<-(ryokin - sengetu)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}


static void ABC101C_Minimization();

#if 1
int main()
{
	ABC101C_Minimization();
	fflush(stdout);
	return 0;
}
#endif

static void ABC101C_Minimization()
{
	int N, K;
	get2int(N, K);
	
//	auto seqA = new int[N];
	int num, minPos = 0;
	for (int i = 0; i < N; i++) {
		get1int(num);
		if (num == 1) {
			minPos = i;
		}
	}
	int bfr = minPos;
	int aft = N - minPos - 1;
	if (bfr > aft) {
		tp_swap(bfr, aft);
	}

	int ope = 0;
	while(bfr > 0) {
		ope++;
		bfr -= (K - 1);
		if (bfr < 0) {
			aft += bfr;
		}
	}
	while(aft > 0) {
		ope++;
		aft -= (K - 1);
	}
	printf("%d\n", ope);
//	delete[] seqA;
}


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

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

    for (int i=0; i<25+1; i++){
        for (int j=0; j<15; j++){
            int temp = 4*i + 7*j;
            if (temp == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define BUG cout << "acdsfas" << endl
#define int long long

const int mod = 1e9 + 7;
const int inf = 2e6;
const int INF = 1e18;
const int N = 1e6 + 15;
int n, c, a[N], dp[N];

struct node {
    node *l, *r;
    int k, b;
    node() {
        l = r = NULL;
        k = b = -1;
    }
    node(int k, int b) : k(k), b(b) {
        l = r = NULL;
    }
    inline int val(int x) {
        return k * x + b;
    }
};

typedef node* pnode;

pnode root = NULL;

void update(pnode &t, int tl, int tr, pnode nw) { // v and nw - indexes
    if(tl > tr)
        return;
    if(!t) {
        t = nw;
        return;
    }
    int mid = tl + tr >> 1;
    if(nw->val(mid) < t->val(mid)) {
        swap(t->k, nw->k);
        swap(t->b, nw->b);
    }
    if(nw->val(tl) < t->val(tl))
        update(t->l, tl, mid - 1, nw);
    else
        update(t->r, mid + 1, tr, nw);
}

int get(pnode t, int tl, int tr, int x) {
    if(!t)
        return INF;
    int mid = tl + tr >> 1;
    if(x <= mid)
        return min(t->val(x), get(t->l, tl, mid - 1, x));
    return min(t->val(x), get(t->r, mid + 1, tr, x));
}

main() {
    cin >> n >> c;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    root = new node(-2 * a[1], a[1] * a[1]);
    for(int i = 2; i <= n; ++i) {
        dp[i] = get(root, 0, inf, a[i]) + c + a[i] * a[i];
        update(root, 0, inf, new node(-2 * a[i], a[i] * a[i] + dp[i]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 15360
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2018-7-21 21:04:17
# Powered by Visual Studio Code
#

n = gets.to_i
a = gets.chomp.split(" ").map{|i| i.to_i}
ans = 0
a.each{|it|
  ans += it - 1
}
puts ans


Measured memory_bytes: 1916
N = int(input())
ans = 0
for i in range(N + 1):
    if i % 2 == 0:
        continue
    c = 0
    for j in range(1, i + 1):
        if i % j == 0:
            c += 1
    if c == 8:
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int n, k, i, j, min, ans=0, leng=0, po=0;
    scanf("%lld", &n);
    long long int n2 = (long long int) sqrt((double) n);
    for(i=n2; i>0; i--){
        if(n%i==0){
            ans = i + n/i - 2;
            break;
        }
    }
    printf("%lld", ans);
    
}

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

int main() {
	long long a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	string ans;
	if(a==b){
		ans="YES";
		cout << ans << endl;
		return 0;
	}
	if(w>=v){
		ans="NO";
		cout << ans  << endl;
		return 0;
	}
	if(abs(a-b)<=(v-w)*t){
		cout << "YES" << endl;
	}
	else{
		cout <<"NO" <<endl;
	}
}


Measured memory_bytes: 3628
N,K=map(int,input().split())
p=list(map(int,input().split()))
P=([(1+i)/2 for i in p])
count=0
S=[0]
for i in range(N):
  S.append(S[i]+P[i])

ans=[]
for i in range(N-K+1):
  ans.append(S[K+i]-S[i])
print(max(ans))



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

string s;
int n;
int ans;
int main() {
    cin >> s;
    n = s.size();
    int num[26] = {0};
    rep(i,0,n){
        num[(int)(s[i]-'a')] += 1;
    }
    rep(i,0,26){
        if(num[i] == 0){
            ans = (char)(i + 'a');
            printf("%c\n",ans);
            return 0;
        }
    }
    printf("None\n");
    return 0;
    }


Measured memory_bytes: 512
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
tree = [[] for i in range(N)]
for i in range(N - 1):
	a, b, c = list(map(int, input().split()))
	a -= 1
	b -= 1
	tree[a].append((b, c))
	tree[b].append((a, c))

Q, K = list(map(int, input().split()))

que = deque([])
que.append(K - 1)
dist = [-1 for _ in range(N)]
dist[K - 1] = 0
while len(que) > 0:
	node = que.popleft()
	for edge in tree[node]:
		if dist[edge[0]] == -1:
			que.append(edge[0])
			dist[edge[0]] = dist[node] + edge[1]

for i in range(Q):
	a, b = list(map(int, input().split()))
	print(dist[a - 1] + dist[b - 1])

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll k,m;
  string S;
  cin >> S;
  m=0;
  k=0;
  REP(i,S.length()){
    if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
      k=k+1;
    }else{
      if(k>0 && k>m){
        m=k;
      }
      k=0;
    }
  }
  if(k!=0 && k>m){
    m=k;
  }
  cout << m<< endl;
  return 0;
}

Measured memory_bytes: 256
/***************************
 * Author  : dhakad_123  ***
 * Created : 26.07.2020  ***
 **************************/

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


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


	int x; 
	cin >> x;

	
	if(x >= 400 && x <= 599){
		cout << 8 << endl;
	}

	else if(x >= 600 && x <= 799){
		cout << 7 << endl;
	}

	else if(x >= 800 && x <= 999){
		cout << 6 << endl;
	}
	else if(x >= 1000 && x <= 1199){
		cout << 5 << endl;
	}

	else if(x >= 1200 && x <= 1399){
		cout << 4 << endl;
	}

	else if(x >= 1400 && x <= 1599){
		cout << 3 << endl;
	}
	else if(x >= 1600 && x <= 1799){
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}


	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long ll;
int main() {
    ll f,l;
    scanf("%lld %lld",&f,&l);

    if(f<=0&&l>=0)
        printf("Zero\n");
    else if(f<0&&l<0){
        (l-f+1)%2 ? printf("Negative\n") : printf("Positive\n");
    }else{
        printf("Positive\n");
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

template <class T>
void chmin(T& a, T b) {
  if (b < a) a = b;
}

int calcCost(const string& a, const string& b, int c) {
  int N = a.size();
  int res = 0;
  for (int i = c; i < N; i++) {
    if (a[i - c] == b[i]) ++res;
  }
  return res;
}

vec<int, 2> makeCostTable(const string& a, const string& b) {
  int N = a.size();
  vec<int, 2> cost = make_v(N + 1, N + 1, 0);
  for (int c = 0; c <= N; c++) {
    cost[c][0] = calcCost(a, b, c);
    cost[0][c] = calcCost(b, a, c);
  }
  for (int c1 = 1; c1 <= N; c1++) {
    for (int c2 = 1; c2 <= N; c2++) {
      cost[c1][c2] = cost[c1 - 1][c2 - 1] - (a[N - c1] == b[N - c2]);
    }
  }
  return cost;
}

int solve(const string& a, const string& b) {
  int N = a.size();
  auto cost = makeCostTable(a, b);
  vec<int, 2> dp = make_v(N + 1, N + 1, 1 << 29);
  dp[0][0] = 0;
  for (int c1 = 0; c1 <= N; c1++) {
    for (int c2 = 0; c2 <= N; c2++) {
      if (c1 + 1 <= N) {
        chmin(dp[c1 + 1][c2], dp[c1][c2] + cost[c1][c2]);
      }
      if (c2 + 1 <= N) {
        chmin(dp[c1][c2 + 1], dp[c1][c2] + cost[c1][c2]);
      }
    }
  }
  return dp[N][N];
}

int main() {
  int H, W;
  while (cin >> H >> W) {
    vector<string> grid(H);
    for (int i = 0; i < H; i++) cin >> grid[i];
    int res = 0;
    for (int j = 0; j + 1 < W; j++) {
      string a = "", b = "";
      for (int i = 0; i < H; i++) {
        a += grid[i][j];
        b += grid[i][j + 1];
      }
      res += solve(a, b);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1200
def fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
if m != 0:
  a = [int(input()) for i in range(m)]
  ans = fib(a[0])
  for j in range(1,m):
    if m == 1:
        continue
    elif a[j] == a[j-1]+1:
        ans = 0
    else:
        ans *= fib(a[j]-a[j-1]-1)
  ans *= fib(n-a[m-1])
else:
  ans = fib(n+1)
print(ans%1000000007)


Measured memory_bytes: 7080
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

int main() {
  int k;
  while(cin >> k){
  	int ans = 0;
  	for(int a = 1; a<=k; a++){
  		for(int b = 1; b<=k; b++){
  			for(int c = 1; c<=k; c++)
  				ans += __gcd(a, __gcd(b, c));
  		}
  	}
    cout << ans << endl;
  }
	return 0;
}

Measured memory_bytes: 3560