akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

long long N;
vector<long long> A, X;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=1; i<=N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	long long x0 = 0;
	for(int i=0; i<N; i++){
		if(i % 2 == 0){
			x0 += A[i];
		}
		else{
			x0 -= A[i];
		}
	}
	x0 /= 2;
	X.push_back(x0);
	printf("%lld", X[0]*2);
	long long x = X[0];
	for(int i=1; i<N; i++){
		x = A[i-1] - X[i-1];
		printf(" %lld", x*2);
		X.push_back(x);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb(a) push_back(a)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using vP = vector<P>;

int main(){
    int n; cin>>n;
    vv sh(n, vi (n,-1));//証言なし: -1
    
    int a,x,y;
    
    rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>x>>y;
            x--;
            sh[i][x] = y;//正直: 1, 不定: 0
        }
    }
    
    int ans = 0, count;
    
    rep(i, 1<<n){
        
        count = 0;
        bool ok = true;
        
        rep(j,n){
            if(!(i&1<<j))continue;
            count++;
            
            rep(k, sh[j].size()){
                if((i&1<<k) && sh[j][k]==0){
                    ok = false;
                    break;
                }else if(!(i&1<<k) && sh[j][k]==1){
                    ok = false;
                    break;
                }
            }
            
            if(!ok)break;
        }
        
        if(ok)ans = max(ans, count);
    }
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#coding: UTF-8
import math
N=int(input())
def prime_list(k):
    lis=[True for i in range(1,k+1)]
    lis[0]=False
    for i in range(2,k+1):
        j=2
        while j*j<=i:
            if i%j==0:
                lis[i-1]=False
                break
            else:
                j+=1
    return lis
#    print(lis)
def p_fact(k,N):
    plist=prime_list(k)
    lis=[0]*N
    for i in range(0,k):
        n=0
        if plist[i]:
            while k%(i+1)==0:
                n+=1
                k=k/(i+1)
        lis[i]=n
    return lis
out_lis=[0]*N
for i in range(1,N+1):
    input_lis=p_fact(i,N)
    out_lis=[out_lis[j]+input_lis[j] for j in range(0,N)]
#print(out_lis)
out=1
for i in range(0,N):
    out=out*(out_lis[i]+1)
print(out%1000000007)

Measured memory_bytes: 3188
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n = in();
  vector<int> a(n);
  cin >> a;
  int q = in();
  while (q--) {
    int t = in();
    cout << lower_bound(all(a), t) - a.begin() << " " << upper_bound(all(a), t) - a.begin() << endl;
  }
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, string> pp;

const int MAXN = 21, MAXM = 30, MAXD = 30;

int disp[MAXN][MAXD], p[MAXN], num[MAXD];
string s[MAXN];

int main()
{
    int n, m, d;
    while(cin >> n && n)
    {
        memset(disp, 0, sizeof(disp));
        memset(num, 0, sizeof(num));
        memset(p, 0, sizeof(p));

        REP(n){ cin >> s[i] >> m; rep(j,m){cin >> d; disp[i][d] = 1; num[d]++;}}

        rep(j,MAXD)
            if(num[j]>0)REP(n)if(disp[i][j]) p[i] += n + 1 - num[j];

        vector<pp> ans;
        REP(n) ans.push_back(pp( p[i], s[i]));

        sort(all(ans));
        cout << ans[0].first << " " << ans[0].second << endl;
        
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli knapSack(lli W, lli wt[], lli val[], lli n) 
{ 
   lli i, w; 
   lli K[n+1][W+1]; 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
int main()
{
  lli n,w;
  cin>>n>>w;
  lli wt[n];
  lli val[n];
  for(lli i=0;i<n;i++)
    cin>>wt[i]>>val[i];
  lli m=knapSack(w,wt,val,n);
  cout<<m<<"\n";
  return 0;
}
  
  

Measured memory_bytes: 79104
N = int(input())

pool = []
for _ in range(10):
    pool.append([0] * 10)

for n in range(1, 1 + N):
    i = int(str(n)[0])
    j = n % 10
    pool[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += pool[i][j] * pool[j][i]
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll a,b,n;
  cin>>a>>b>>n;
  cout << (a*min(n,b-1))/b << endl;
  return 0;
}


Measured memory_bytes: 3692
#include<iostream>
using namespace std;
main()
{
    string s;
    cin>>s;
    int count=0;
    int n=s.size();
    for(int i=0; i<n-1; i++)

        {
            if(s[i]=='S' and s[i+1]=='u' and s[i+2]=='n' and s[i+3]=='n' and s[i+4]=='y')
           cout<<"Cloudy"<<endl;

        else if (s[i]=='C' and s[i+1]=='l' and s[i+2]=='o' and s[i+3]=='u' and s[i+4]=='d' and s[i+5]=='y')
            cout<<"Rainy"<<endl;
            else if (s[i]=='R' and s[i+1]=='a' and s[i+2]=='i' and s[i+3]=='n' and s[i+4]=='y')
            cout<<"Sunny"<<endl;
}

    }

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#define B 4
#define F 3
#define R 10

int main() {
	int d[B][F][R] = { 0 };
	int b, f, r, v;
	int n, i, j, k;

	scanf("%d", &n);
	for (i=0;i<n;i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		d[b - 1][f - 1][r-1] += v;
	}
	for (i=0;i<B;i++) {
		for (j=0;j<F;j++) {
			for (k=0;k<R;k++)printf(" %d", d[i][j][k]);
			putchar('\n');
		}
		if(i!=3)
		puts("####################");
	}
	return 0;
}

Measured memory_bytes: 2760
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int main()
{
	int n,i,j,t,sum=0;
	int a[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]); 
	qsort(a,n,sizeof(a[0]),cmp);
	for(i=(a[(n/2)-1]+1);i<=a[n/2] ;i++ )
		sum++;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int a[n+1], ans = 0;
	FOR(i,1,n+1){
		cin >> a[i];
		if(i&1 && a[i]&1) ++ans;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
ll gcd(ll a, ll b){
    return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, z, w, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll x[n], y[n], h[n];
        ll g[3] = {-1, -1, -1};
    	rep(i, n){
    		cin >> x[i] >> y[i] >> h[i];
    		if(h[i] >= 1){
                g[0] = x[i], g[1] = y[i], g[2] = h[i];
            }
    	}
    	rep(i, 101){
    		rep(j, 101){
                bool flag = true;
                cnt = g[2] + abs(g[0] - i) + abs(g[1] - j);
                maxs(cnt, 0LL);
    			rep(k, n){
    				ll cnt2 = cnt - abs(x[k] - i) - abs(y[k] - j);
                    maxs(cnt2, 0LL);
    				if(h[k] != cnt2){
                        flag = false;
                        break;
                    }
    			}
    			if(flag){
                    print(i << " " << j << " " << cnt);
                    return 0;
                }
    		}
    	}
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}

void chmin(int &a, int &b){if (a>b){a = b; return;}return;}
void chmax(int &a, int &b){if (a<b){a = b; return;}return;}


const ll MOD = 1000000007;
const ll INF = 9999999999;

int win(char x){
  // 相手がグーチョキパーならパーグーチョキが価値
  if (x == 'r') return 2;
  else if(x == 's') return 0;
  else return 1;
}

int main() {
  int N,K; cin >>N >>K;
  int R,S,P; cin >>R >>S >>P;
  string t; cin >>t;
  vector<vector<int>> dp(N, vector<int>(3, 0)); // dp[i][j]: i回目にjを出した時の最大得点
  vector<int> score = {R, S, P};
  int ans = 0;

  // Kで割った余りで場合分け
  for (int i=0; i<K; i++){
    int j=0;
    while (i + j*K < N){
      int turn = i + j*K;
      int preturn = i + (j-1)*K;
      int winner = win(t.at(turn));
      if (j == 0){
        for (int ii = 0; ii<3; ii++){
          dp.at(turn).at(ii) = 0;
        }
        dp.at(turn).at(winner) += score.at(winner);
        j++; continue;
      }
      for (int ii = 0; ii<3; ii++){
        if (ii == winner){
          chmax(dp.at(turn).at(ii), dp.at(preturn).at((ii+1)%3) + score.at(winner));
          chmax(dp.at(turn).at(ii), dp.at(preturn).at((ii+2)%3) + score.at(winner));
        }else{
          chmax(dp.at(turn).at(ii), dp.at(preturn).at((ii+1)%3));
          chmax(dp.at(turn).at(ii), dp.at(preturn).at((ii+2)%3));
        }
      }
      j++;
    }
    int a = dp.at(i+(j-1)*K).at(0);
    int b = dp.at(i+(j-1)*K).at(1);
    int c = dp.at(i+(j-1)*K).at(2);

    ans += max(a, max(b,c));
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;


namespace ConsoleApp40 {
    class Program {
        //これまでに訪れた頂点の数
        static int num_visited = 0;
        //答え
        static int ans;
        //訪問済みかどうかを調べるためのリスト
        static List<int> visited;

        static int N;
        static int M;

        //グラフデータを保持しておくためのN個のリスト
        static List<int>[] G;

        static void Main(string[] args) {
            int[] X = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            N = X[0];
            M = X[1];

            G = new List<int>[N];
            for (int i = 0; i < N; i++) {
                G[i] = new List<int>();
            }

            //グラフデータをリストに入れていく
            for (int i = 0; i < M; i++) {
                var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int a = ab[0];
                int b = ab[1];
                //0-indexにする
                a--;
                b--;

                G[a].Add(b);
                G[b].Add(a);
            }

            visited = Enumerable.Repeat(0, N).ToList();

            //頂点番号0からスタートして、DFSを始める
            dfs(0);

            Console.WriteLine(ans);
        }

        static void dfs(int now) {
            visited[now] = 1;  //訪問済みにする
            num_visited++;

            //全ての頂点を訪れたら
            if (num_visited == N) {
                ans++;
            }

            for (int i = 0; i < G[now].Count(); i++) {
                //次の移動先となる候補
                int next = G[now][i];
                //もし未訪問なら
                if (visited[next] == 0) {
                    dfs(next);  //再帰で次の経路を探す
                } else {
                    //もし訪問済みなら何もせずループを抜ける
                }
            }

            //再帰を抜けるタイミングで、今いる頂点を未訪問に戻す
            visited[now] = 0;
            num_visited--;
        }
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	FOR(b, 1, n + 1) {


		int c = n % b;
		int d = min(b - 1, k - 1);
		ans += d;
		if (c <= d) {
			ans += (n / b)*(c + 1);
			ans += (n / b - 1)*(d - c);
		}
		else {
			ans += (n / b)*(d + 1);
		}

	}
	cout << n * n - ans << endl;

}


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

int a[101], dp[10010];
int main(){
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d", &a[i]);
		ans += a[i];
	}
	
	int mx = ans;
	dp[0] = 1;
	for(int i = 0;i <= mx;i++){
		for(int j = 0;j < n;j++){
			if(0 > i-a[j])continue;
			dp[i] = max(dp[i], dp[i-a[j]]);
		}
	}
	for(int i = 1;i <= mx;i++){
		if(ans%10 != 0)break;
		if(i%10 == 0)continue;
		if(dp[i] == 1){
			ans -= i;
			break;
		}
	}
	if(ans%10 == 0)printf("%d\n", 0);
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())

memo = [[] for _ in range(N)]
ans = 0

for i in range(N):
    A = int(input())
    for _ in range(A):
        #配列が0始まりなので、xは-1して使用する
        x, y = map(int, input().split())
        memo[i].append((x,y))

# print(memo)
for i in range(2**N):
    # print(i)#test
    flag = True
    for j in range(N):
        # bitが1の人の証言を確認していく。
        if i >> j & 1:
            for evidence in memo[j]:
                check_evidence = int(bin(i >> (evidence[0]-1))[-1])
                if check_evidence != evidence[1]:
                    # print(check_evidence==evidence[1])
                    flag = False
                    break
        if not flag:
            break
    if flag:
        bin_i = bin(i)
        ans = max(ans, bin_i.count("1"))

print(ans)


Measured memory_bytes: 3064
#include <algorithm> // min
#include <cmath> // abs
#include <iostream>
using namespace std;
int main(){
	string S;
	cin >> S;
	int N=S.size();
	int num,ans=999,c[10];

	for(int i=0;i<=N-3;i++){
		num = (S[i]-'0')*100 + (S[i+1]-'0')*10 + S[i+2]-'0';
		ans = min(ans, abs(num-753));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = int(input())
nums = set()
a = [0] * 1000001

a[0] = s
nums.add(s)
for i in range(1, 1000002):
    if a[i - 1] % 2 == 0:
        a[i] = a[i - 1] // 2
    else:
        a[i] = a[i - 1] * 3 + 1
    if a[i] in nums:
        ans = i + 1
        print(ans)
        break
    else:
        nums.add(a[i])


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

int A, V, B, W, T;

bool solve() {
  if (V <= W) return false;


  return abs(A - B) <= (long long)T * (V - W);
}

int main() {
  scanf("%d %d %d %d %d", &A, &V, &B, &W, &T);

  if (solve()) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

vector <int> res;

int main(){
    string st;
    cin>>st;
    if (st == "SAT"){
        cout<<1<<endl;
    }
    else if (st == "SUN"){
        cout<<7<<endl;
    }
    else if (st == "MON"){
        cout<<6<<endl;
    }
    else if (st == "FRI"){
        cout<<2<<endl;
    }
    else if (st == "THU"){
        cout<<3<<endl;
    }
    else if (st =="WED"){
        cout<<4<<endl;
    }
    else if (st == "TUE"){
        cout<<5<<endl;
    }

}


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


int main()
{
	
	int m,n,N;
	cin >> m >> n >> N;
	int z = max(m, n);
	int x = (N + z - 1) / z;
	cout << x << endl;
}

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

int main(){
	int n,k ,b;
	cin >> n >> k ;
	for(int i=0 ;i < n ; i++){
		cin >> b ;
	}
	cout << ( (n-1) / (k-1)) + ( (n-1 )%( k-1 )!= 0) ;
}


Measured memory_bytes: 384
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
    
memo = {}

def nap(i, j):
    if i == N:
        return 0
    
    if (i, j) in memo:
        return memo[i, j]
    elif j < w[i]:
        temp = nap(i+1, j)
    else:
        temp = max(nap(i+1, j), nap(i+1, j-w[i]) + v[i])
    
    memo[i,j] = temp
    
    return memo[i,j]

print(nap(0, W))

Measured memory_bytes: 20760
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int nSum = 0;
		for (int i = 1; i <= String.valueOf(n).length(); i++) {
			nSum += getDigit(n, i);
		}
		if (n % nSum == 0) {
			System.out.println("Yes");		
		} else {
			System.out.println("No");
		}
	}

	public static int getDigit(int n, int i) {
		int a = n / (int)Math.pow(10, i);
		a = a * (int)Math.pow(10, i);
		n = n - a;
		n = n / (int)Math.pow(10, i - 1);
		return n;
	}
}

Measured memory_bytes: 21844
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  for (int r = 0; r * R <= N; ++r) {
    for (int g = 0; g * G <= N; ++g) {
      int num = N - r*R - g*G;
      if (num < 0) continue;
      if (num % B == 0) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[][] a = new int[3][n + 1];
        for (int i = 1; i <= n; i++) {
            a[0][i] = in.nextInt();
            a[1][i] = in.nextInt();
            a[2][i] = in.nextInt();
        }

        int[][] dp = new int[3][n + 1];
        dp[0][1] = a[0][1];
        dp[1][1] = a[1][1];
        dp[2][1] = a[2][1];

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }
                    
                    if (dp[j][i] + a[k][i + 1] > dp[k][i + 1]) {
                        dp[k][i + 1] = dp[j][i] + a[k][i + 1];
                    }
                }
            }
        }

        out.println(Math.max(dp[0][n], Math.max(dp[1][n], dp[2][n])));
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 48440
#include<bits/stdc++.h>
using namespace std;
#define ll      long long
#define f(i,a,b)    for(ll i=a;i<b;i++)
#define jatin   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb      push_back
#define v       vector<ll>
#define mi       map<ll,ll>
#define mp      make_pair<ll,ll>
#define F       first
#define S       second
#define set     set<ll>
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);
}
ll factorial(ll n) 
{ 
    ll res = 1, i; 
    for (i = 2; i <= n; i++) 
        res = (res*i)%1000000009; 
    return res; 
}
/*ll pascal(ll i,ll j){
    if(j==1 || i==j)
        return 1;
    return pascal(i-1,j-1) + pascal(i-1,j);
}*/\

int main(){
    jatin
    ll n,k;
    cin>>n>>k;
    ll a[100000];
    f(i,0,n){
        cin>>a[i];
    }  
    ll b[100000];
    b[0]=0;
    f(i,1,k){
        b[i] = abs(a[i]-a[0]);
    }
    f(i,k,n){
        ll count = INT32_MAX;
        f(j,i-k,i){
            if(count>(b[j]+abs(a[i]-a[j]))){
                count = b[j]+abs(a[i]-a[j]);
            }
        }
        b[i] = count;
    }
    cout<<b[n-1];
}

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

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

    int c=1;
    int x;
    cin>>x;
    while(x!=0){
        cout<<"Case "<<c<<": "<<x<<endl;
        c++;
        cin>>x;
    }
    return 0;
}


Measured memory_bytes: 3228
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int solve(int c0, int c1, int c2) {
	if (c2 == 0) {
		if (c0 > 0) return 0;
		return 1;
	}
	if (c0 - 1 == c2) {
		return c1 == 0;
	}
	if (c0 - 1 > c2) {
		return 0;
	}
	return 1;
}
int main()
{
	int c0 = 0, c1 = 0, c2 = 0;
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		if (a % 4 == 0) c2++;
		else if (a % 2 == 0) c1++;
		else c0++;
	}

	if (solve(c0, c1, c2)) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define minus djsf
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b){
	return (a.second < b.second);
}

int process(vector<pair<int, int> > v) {
	int n = v.size();
	int ans = 0;
	vector<pair<int, int> > pref(n+1), suff(n+1);
	pref[0] = {-1e9, 1e9};
	for (int i=0;i<n;++i){
		pref[i+1] = {max(pref[i].first, v[i].first), min(pref[i].second, v[i].second)};
	}
	suff[n] = {-1e9, 1e9};
	for (int i=n-1; i >= 0; i--){
		suff[i] = {max(suff[i+1].first, v[i].first), min(suff[i+1].second, v[i].second)};
	}

	for (int i=0;i<n;++i){
		int L = max(pref[i].first, suff[i+1].first);
		int R = min(pref[i].second, suff[i+1].second);
		ans = max(ans, max(R-L+1, 0) + v[i].second-v[i].first + 1);
	}

	return ans;

}
 
signed main()
{
#ifdef LOCAL
	freopen("N_input.txt", "r", stdin);
	//freopen("P_output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<pair<int, int> > v;
    int ans = 0;
    for (int i=0;i<n;++i){
    	int x, y;
    	cin >> x >> y;
    	v.push_back({x, y});
    }

    int right = -1;
    for (int i=0;i<n;++i){
    	right = max(right, v[i].first);
    }

    sort(v.begin(), v.end(), cmp);
    int L = -1e9, R = 1e9;

    for (int i=0; i < n-1; ++i){
    	L = max(L, v[i].first);
    	R = min(R, v[i].second);
    	//cout << "==== " << L << " " << R << " " << right << " " << v[i+1].second << endl;
    	ans = max(ans, max(R-L+1, 0) + max(v[i+1].second - right + 1, 0));
    }

    ans = max(ans, process(v));

    cout << ans;
	
}

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

#define NN 1000000007

bool ipn(long long int x){
  if(x==2||x==3)return true;
  if(x%2==0||x%3==0||x <= 4)return false;
  for(int i = 6; (i-1)*(i-1)<= x; i+=6)
    if(x%(i-1)==0||x%(i+1)==0)return false;
  return true;
}

int main(){
  long long int N,ans = 1, temp[1010] = {}, count;

  cin>>N;

  for(int i = N; i >= 2;i--){
    int k = i;
    //int count = 1;
    if(ipn(i)){temp[i]++;temp[i]%=NN;k=1;}
    for(int j = 2; j <= N; j++){
      if(k==1)break;
      while(k%j==0){
	k/=j;
	temp[j]++;
	temp[j]%= NN;
	//count++;
      }
    }
    //ans *= count;
    //ans %= NN;
  }
  //for(int i = 0; i <= 5; i++)cout<<i<<" "<<temp[i]<<endl;
  for(int i = 2; i <= 1000; i++){
    if(temp[i]){
      ans *= (temp[i]+1);
      ans %= NN;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//C - Back and Forth:
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int sx, sy, tx, ty, up, right;
    string ans = "";
    cin >> sx >> sy >> tx >> ty;
    right = tx - sx;
    up = ty - sy;
    loop(i, 0, up) ans += 'U';
    loop(i, 0, right) ans += 'R';
    loop(i, 0, up) ans += 'D';
    loop(i, 0, right) ans += 'L';

    ans += 'L';
    loop(i, 0, up+1) ans += 'U';
    loop(i, 0, right+1) ans += 'R';
    ans += 'D'; ans += 'R';
    loop(i, 0, up+1) ans += 'D';
    loop(i, 0, right+1) ans += 'L';
    ans += 'U';

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

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  int ans = 4000000;
  for(int i = -100; i <= 100; i++){
    int sum = 0;
    for(int j = 0; j < N; j++){
      sum += (i - vec.at(j)) * (i - vec.at(j));
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


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

int main() {
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    } else if(a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    } else {
        for(int i = 0; i < a.size(); i++) {
            if(a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if(a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        string t = sc.Next();

        Dictionary<char, char> dic = new Dictionary<char, char>();

        bool ok = true;

        for (int i = 0; i < s.Length; i++)
        {
            char cs = s[i];
            char ts = t[i];

            if (dic.ContainsKey(cs))
            {
                if (dic[cs] != ts)
                {
                    ok = false;
                    break;
                }
            }
            else
            {
                if (dic.ContainsValue(ts))
                {
                    ok = false;
                    break;
                }
                dic.Add(cs, ts);
            }
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);

    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int k;
string s;

int32_t main()
{
	IOS;
	cin >> k >> s;
	if(s.size() <= k)
		cout << s;
	else
		cout << s.substr(0, k) << "...";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

int ggcd(int a, int b){
    int c = a % b;
    while (c > 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    ll d; cin >> d;
    int ans = 0;
    rep(i,n){
        ll a, b; cin >> a >> b;
        if (a * a + b * b <= d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::cout<<n*(n-1)/2<<'\n';
}


Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

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

        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" " , n);
        int[] array = new int[n];
        
        for(int i = 0; i < n; i++){
            array[i] = Integer.parseInt(input[i]);
        }

        insertionSort(array);
    }

    static void printArray(int[] A){
    	StringBuilder sb = new StringBuilder();
        for(int k : A){
            sb.append(k + " ");
        }
        System.out.println(sb.toString().substring(0 , sb.length() - 1));
    }

    static void insertionSort(int[] A){
    	int count=0;
        for(int i=0; i<A.length; i++){
        	for(int j=A.length-1; j>i; j--){
        		if(A[j]<A[j-1]){
        			int k = A[j];
        			A[j] = A[j-1];
        			A[j-1] = k;
        			count++;
        		}
        	}
        }
        printArray(A);
        System.out.println(count);
    }
}



Measured memory_bytes: 24420
#include<iostream>
#include <stdio.h>
using namespace std;

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }

    return ans;

}

int main()
{
    int a,b;
    cin >> a >> b;

    int s=0;

    if(a<=b){
        for(int i=0;i<b;i++){
            s += a * pow(i);
        }        
    }else{
        for(int i=0;i<a;i++){
            s += b * pow(i);
        }   
    }
    cout << s << endl;

    return 0;

}

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>x(n);
  for(int i=0;i<n;i++) cin>>x[i];
  int ans=1000000000;
  for(int i=0;i<n-k+1;i++){
    int left=x[i];
    int right=x[i+k-1];
    int answer=min(abs(left)+right-left,abs(right)+right-left);
    ans=min(ans,answer);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#template
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(i) for i in input().split()]
#template
A,B,M = inputlist()
a = inputlist()
b = inputlist()
ma = sorted(a)[0]
mb = sorted(b)[0]
mc = ma+mb
for i in range(M):
    x,y,c = inputlist()
    x -=1
    y -=1
    mc = min(mc,a[x]+b[y]-c)
print(mc)

Measured memory_bytes: 18864
#include <algorithm>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){
 ll A,B,C,K;
 cin>>A>>B>>C>>K;
 if(K<=A) cout<<K<<endl;
 else if(A<K&&K<=A+B) cout<<A<<endl;
 else cout<<A-(K-A-B)<<endl;
}

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

#include <math.h>
#include <stdlib.h>


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


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vector<vector<int>> a(n);
    for(int i = 0; i < n-1; i++) {
        a[i].push_back(i+1);
        a[i+1].push_back(i);
    }

    a[x].push_back(y);
    a[y].push_back(x);

    vector<int> ans(n);

    for(int i = 0; i < n; i++){
        vector<int> dist(n, -1);
        dist[i] = 0;

        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(int j : a[cur]){
                if(dist[j] != -1) continue;
                dist[j] = dist[cur]+1;
                ans[dist[j]]++;
                q.push(j);
            }
        }
    }

    for(int i = 1; i < n; i++) cout << ans[i]/2 << endl;

    return 0;
}


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    int n, m;
    cin >> n >> m;
    int cnt[26]; fill(cnt, cnt + 26, 0);
    rep(i, 0, n)
        rep(j, 0, m)
        {
            char c;
            cin >> c;
            cnt[c - 'a']++;
        }
    int c = 0, sum = 0;
    rep(i, 0, 26)
    {
        if (cnt[i] % 2 == 1)
            c++;
        sum += cnt[i] % 4;
    }
    if (n % 2 == 0 || m % 2 == 0)
    {
        int x;
        if (n % 2 == 1)
            x = m;
        else if (m % 2 == 1)
            x = n;
        else
            x = 0;
        if (c > 0 || sum > x)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    else
    {
        if (c > 1 || sum - 1 > n - 1 + m - 1)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    return 0;
}


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

const long long INF = 1LL << 60;

int N, W;
int w[110], v[110];

long long dp[110][100010];

int main() {
    cin >> N >> W;
    for(int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    for(int i = 0; i < 110; i++)
        for(int j = 0; j < 100010; j++)
            dp[i][j] = INF;

    dp[0][0] = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= 100000; j++) {
            if(j >= v[i])
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    int res = 0;
    for(int j = 0; j <= 100000; j++)
        if(dp[N][j] <= W) res = j;

    cout << res << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


ll d[] = {-1,0,1};
ll h,w,K;
vector<vector<ll>> v(10,vector<ll>(3,0));
map<P,ll> mp;
ll dfs(int dep,int pos){
  if(dep >= h && pos != K)return 0;
  if(dep >= h)return 1;
  if(mp.count(make_pair(dep,pos)))return mp[make_pair(dep,pos)];
  ll res = 0;
  rep(i,3){
    if(pos+d[i] < 0 || pos+d[i] >= w)continue;
    res = (res+v[pos][i]*dfs(dep+1,pos+d[i]))%MOD;
  }
  return mp[make_pair(dep,pos)] = res;
}


int main(){
  
  cin >> h >> w >> K;
  K--;
  if(w == 1){
    cout << 1 << endl;
    return 0;
  }
  for(int bit = 0;bit < (1 << (w-1));bit++){
    if(bit & (bit >> 1))continue;
    rep(i,w-1){
      if(bit >> i & 1){
        v[i][2]++;
        v[i+1][0]++;
      }
    }
    rep(i,w){
      if(i == 0){
        if(!(bit >> i & 1))v[i][1]++;
      }else if(i == w-1){
        if(!(bit >> (i-1) & 1))v[i][1]++;
      }else if(!(bit >> i & 1) && !(bit >> (i-1) & 1))v[i][1]++;
    }
  }
  cout << dfs(0,0) << endl;






  return 0;
}

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

int gcd(int x, int y) {
  if (x < y) {
    return gcd(y, x);
  } else {
    if (x % y == 0) {
      return y;
    } else {
      return gcd(y, x % y);
    }
  }
}

int main() {
  int x, y;
  cin >> x >> y;
  int ans = gcd(x, y);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3092
import java.util.*;

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 = (a+b)/2;
    int d = (a+b)%2;
    if(d == 0){
      System.out.println(c);
    }else{
      System.out.println(c+1);
    }

  }
}


Measured memory_bytes: 23764
n=int(input())

#base=["357","375","537","573","735","753"]
arr=["3","5","7"]
for i in range(9):
    t_arr=[]
    for i in arr:
        t_arr.append("3"+i)
        t_arr.append("5"+i)
        t_arr.append("7"+i)
    arr.extend(t_arr)
#print(len(arr))

count=0
for i in set(arr):
    if n>=int(i) and "3" in i and "5" in i and "7" in i:
        count+=1
        #print(i)
print(count)


Measured memory_bytes: 69608