akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    rep(i, H) {
        string S;
        cin >> S;
        grid[i] = S;
    }
    ll ans = INF;
    rep(k, 1 << (H - 1)) {
        ll cnt = 0;
        vector<ll> yoko;
        yoko.push_back(0);
        rep(i, H) {
            if (k & (1 << i)) yoko.push_back(i + 1);
        }
        yoko.push_back(H);

        cnt += yoko.size() - 2;
        vector<ll> count(yoko.size() - 1, 0);
        rep(j, W) {
            rep(i, yoko.size() - 1) {
                ll start = yoko[i];
                ll end = yoko[i + 1];
                ll now = 0;
                rep2(d, start, end) {
                    if (grid[d][j] == '1') now++;
                }
                if (now + count[i] > K) {
                    cnt++;
                    if (now > K) {
                        cnt += 10000;
                    }
                    rep(x, yoko.size() - 1) {
                        count[x] = 0;
                    }
                    if (j != 0) {
                        rep(i2, i + 1) {
                            ll start2 = yoko[i2];
                            ll end2 = yoko[i2 + 1];
                            rep2(d, start2, end2) {
                                if (grid[d][j] == '1') count[i2]++;
                            }
                        }
                    } else {
                        cnt += 1000;
                    }

                } else {
                    count[i] += now;
                }
            }
        }
        // print(cnt);
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


void myfind(int x, int y);
void myupdate(int x, int y);

int* A;

int main()
{
	int i;
	int n, q;
	int (*dataset)[3];
	
	scanf("%d %d", &n, &q);
	
	/** A??????????蔵???????2^32-1??則????????? **/
	A = (int *)malloc(sizeof(int) * n);
	if(A == NULL){
		puts("###A malloc error");
		return 1;
	}
	
	for(i=0; i<n; i++) {
		A[i] = INT_MAX;
	}
	
	/** ????????????????????即??????????蔵???? **/
	dataset = malloc(sizeof(*dataset) * q);
	if(A == NULL){
		puts("###dataset malloc error");
		return 1;
	}
	/** ???????????????????????\??? **/
	for(i=0; i<q; i++) {
		scanf("%d %d %d", dataset[i]+0, dataset[i]+1, dataset[i]+2);
	}
	
	
	/** ??????????則? **/
	for(i=0; i<q; i++) {
		switch (dataset[i][0]) {
			case 0:
				myupdate(dataset[i][1], dataset[i][2]);
				break;
				
			case 1:
				myfind(dataset[i][1], dataset[i][2]);
				break;
		}
	}
	
	return 0;
}


void myupdate(int x, int y)
{
	A[x] = y;
}

void myfind(int x, int y)
{
	if(x != y) {
		int i;
		int min = INT_MAX;
		for(i=x; i<=y; i++) {
			if(A[i] < min) {
				min = A[i];
			}
		}
		printf("%d\n",min);
	}
	else {
		printf("%d\n",A[x]);
	}
}

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

int main() {
  char b;
  cin >> b;
  char c;
  if (b=='A') {c='T';}
  else if (b=='T') {c='A';}
  else if (b=='C') {c='G';}
  else if (b=='G') {c='C';}
  cout << c << endl;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
/*
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> s(3,""); int efctnum = 3;
  RPT(i,0,3) cin >> s[i];
  sort(s.begin(), s.end() );
  if(s[0]==s[1] && s[0]==s[2]) {efctnum=1; cout << s[0].size() << endl ; return 0;}
  if(s[0]==s[1] ) {efctnum=2; s[1]=s[2];}
  if(s[0]==s[2] || s[1]==s[2]) efctnum=2;
}
*/

int main(){
  int n; cin >> n;
  queue<pair<string,int>> Q[15]; 
  Q[1].push( {"a",1});
  for(int i=2; i <= n; ++i){
    while( !Q[i-1].empty() ){
      pair<string,int> s = Q[i-1].front();
      for(int j=0; j<s.second+1; ++j){
        Q[i].push( pair<string,int>((s.first+(char)('a'+j)),max(j+1,s.second)) );
      }
      Q[i-1].pop();
    }
  }
  while(!Q[n].empty() ){
    pair<string,int> s;
    s = Q[n].front();
    printf("%s\n",s.first.c_str());
    Q[n].pop();
  }
}



Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X,N;
    cin >> X >> N;
    
    map<int,int> mapAll;
    for (int i=0;i<102;i++) {
        mapAll[i]=abs(X-i);
    }
    
    vector<int> P(N);
    for (int i=0;i<N;i++) {
        cin >> P[i]; 
        mapAll.erase(P[i]);
    }
   
    int A =100;
    int ans;
    for (auto p:mapAll) {
        auto v = p.second;
        if(A>v){
            A=v;
            ans=p.first;
        }
        
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll m, d; cin >> m >> d;

    ll ans = 0;
    RANGE(mo, 1, m) {
        RANGE(da, 1, d) {
            ll d1 = da % 10;
            ll d2 = da / 10 % 10;
            if (d1 >= 2 && d2 >= 2 && d1 * d2 == mo) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int K, N;
	int max;
	cin >> K >> N;

	int temp1, temp2, n1;
	cin >> temp1;
	n1 = temp1;
	for (int i = 0; i < N - 1; i++)
	{
		temp2 = temp1;
		cin >> temp1;
		max = max < (temp1 - temp2)?(temp1 - temp2):max;
	}
		max = max < (K - temp1 + n1)?(K - temp1 + n1):max;

	cout << K - max << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n >> k;
    set <ll> s;
    for(i = 0; i < k; i++){
        cin >> x;
        for(j = 0; j < x; j++){
            cin >> y;
            s.insert(y);
        }
    }
    cout << n - s.size();

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>


static const int N =1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main()
{
  int n, i, j, swap, count = 0;
  int A[N];
  scanf("%d", &n);

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

  for(i = 0; i <= n-1; i++){
    for(j = n-1; j >= i+1; j--){
    if( A[j] < A[j-1]){
      swap = A[j];
      A[j] = A[j -1];
      A[j - 1] = swap;
	count++;
    }
    }
  }
  trace(A, n);
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 608
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int gcd(int, int);
int main() {
	int x,y,tmp;
	scanf("%d%d", &x,&y);
	/*
	while (x%y) {
		if (x < y) { tmp = x; x = y; y = tmp; }
		 x %= y;
	}
	printf("%d\n",y);
	*/
	printf("%d\n", gcd(x,y));
	return 0;
}

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

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	int n;
	cin >> n;
	cin >> s;
	int t = s.size();
	rep(i, t) {
		s[i] = (((char)(s[i] + n-'A')) % 26) + 'A';
	}
	cout << s << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
from fractions import gcd
n=int(input())
a=list(map(int,input().split()));g=a[-1]
b=deque([a[0]])
for num in reversed(a[1:]):
	g=gcd(g,num)
	b.appendleft(g)
m=b[0];gg=a[0]
for i,j in enumerate(a[:n-1]):
	gg=gcd(gg,j)
	m=max(m,gcd(gg,b[i+1]))
print(m)

Measured memory_bytes: 16148
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
#include<set>
using namespace std;
//#pragma warning(disable:4996)
#define INF 2147483647 
#define ll long long 
int main(int argc, char** argv)

{
	vector<int> a;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		//string str;
		//getline(cin, str);//需要多一次getline 吃第一行2后的空东西
		//if (str[0] == '0') {
		//	a.push_back(str[2] - 48);	
		//}
		//else if (str[0] == '2')a.pop_back();
		//else if (str[0] == '1')cout << a[str[2]-48] << endl;

		int aa; cin >> aa;
		if (aa == 0) { int b; cin >> b; a.push_back(b); }
		if (aa == 2)a.pop_back();
		if (aa == 1) { int b; cin >> b; cout << a[b] << endl; }
	}
	return 0;
}


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

int main()
{
  int r, i, n, rmin, dmax;
  char buf[16];
  buf[15]='\0';
  buf[14]='\n';
  fgets(buf, 16, stdin);
  n = atoi(buf);
  fgets(buf, 16, stdin);
  rmin = atoi(buf);
  fgets(buf, 16, stdin);
  r = atoi(buf);
  dmax = r-rmin;
  if (rmin>r) rmin=r;
  for (i=0; i<n-2; i++) {
    fgets(buf, 16, stdin);
    char *p = buf;
    for (r=0; *p>='0'; p++) r = r * 10 + *p - '0';
    if (dmax < r-rmin) dmax = r-rmin;
    if (rmin>r) rmin=r;
  }
  if (dmax==0) {
    fputs("0\n", stdout);
  } else {
    int sign=0;
    if (dmax<0) {
      sign=1;
      dmax=-dmax;
    }
    for (i=13; dmax>0; i--, dmax/=10)   buf[i] = '0' + (dmax%10);
    if (sign) buf[i--]='-';
    fputs(buf+i+1, stdout);
  }
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    read(a);
    V<ll> c(100010);
    ll res = 0;
    for (int i = 0; i < n; i++) {
        c[a[i]]++;
        res += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int b, d;
        cin >> b >> d;
        res -= c[b] * b;
        res += c[b] * d;
        c[d] += c[b];
        c[b] = 0;
        cout << res << newl;
    }
}

Measured memory_bytes: 4780
N, M = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars
T = gets.chomp.chars

def gcd(a, b)
  if (a < b)
    # swap(a, b)
    tmp = a
    a = b
    b = tmp
  end

  if (b == 0)
    return a
  end

  gcd(b, a % b)
end

L = N * M / gcd(N, M)

X = {}
LN = L/N
LM = L/M
0.upto(N-1).each do |i|
  X[i * LN] = S[i]
end

def solve
  ans = true
  0.upto(M-1).each do |i|
    if (X[i * LM] == nil) || (X[i * LM] == T[i])
      # OK
    else
      ans = false
      break
    end
  end
  
  if ans
    p L
  else
    p -1
  end
end

solve

Measured memory_bytes: 15868
class Node:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        self.p = None
        
        
def insert(root, add):
    parent = None
    pCandidate = root
    while pCandidate is not None:
        parent = pCandidate
        if add.key < pCandidate.key:
            pCandidate = pCandidate.left
        else:
            pCandidate = pCandidate.right
    add.p = parent
    
    if parent is None:
        root = add
    elif add.key < parent.key:
        parent.left = add
    else:
        parent.right = add
    return root

def inorderTreeWalk(node):
    if node.left is not None:
        inorderTreeWalk(node.left)
    print(" {0}".format(node.key), end="")
    if node.right is not None:
        inorderTreeWalk(node.right)
        
def preorderTreeWalk(node):
    print(" {0}".format(node.key), end="")
    if node.left is not None:
        preorderTreeWalk(node.left)
    if node.right is not None:
        preorderTreeWalk(node.right)

n = int(input())
root = None
for i in range(n):
    line = input().split()
    if line[0] == "insert":
        root = insert(root, Node(int(line[1])))
    else:
        inorderTreeWalk(root)
        print()
        preorderTreeWalk(root)
        print()

Measured memory_bytes: 153768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;

using Graph = vector<vector<char>>;

int main() {
  ll n;
  cin >> n;
  ll dp[50];
  dp[0]=1;
  dp[1]=1;
  for(int i=2; i<=n; i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 3068
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s; cin >> s;
    int one=0,zero=0;
    for (int i=0;i<sz(s);i++){
        if (s[i]=='1') one++;
        else zero++;
    } 
    cout << min(zero,one)*2 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

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

    rep(i, min(n+1, y/10000+1)) {
        rep(j, min(n+1-i, (y-10000*i)/5000+1)) {
            int k = n - (i+j);
            if (10000*i + 5000*j + 1000*k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
	cout << "-1 -1 -1" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String n=sc.next();
		while(!n.equals("0")){
			System.out.println(sum(n));
			n=sc.next();
		}
	}
	
	private static int sum(String s){
		int r=0;
		if(s.length()==1){
			r=Integer.parseInt(s);
		}else{
			r=Integer.parseInt(s.substring(0,1))+sum(s.substring(1));
		}
		return r;
	}
}

Measured memory_bytes: 17332
#include<bits/stdc++.h>
#define pb  push_back
using namespace std;
typedef long long ll;
const int nax = 1e5+10;
vector<int> v[nax];
bool vis[nax];
int d1[nax], d2[nax];
int n;
void dfs(int s, int p, int d[]){
	d[s] = d[p] + 1;
	for(auto i : v[s]){
		if(i != p){
			dfs(i,s,d);
		}
	}
}
int main(){
	
   cin >> n;
   int m = n-1;
   
   for(int i=0;i<m;i++){
   	 int a,b;
     cin >> a >> b;
	 v[a].pb(b);
	 v[b].pb(a);   	
   }
    
    d1[0] = -1;
    d2[0] = -1;
	
    dfs(1,0,d1);
    dfs(n,0,d2);
    
    int ans = 0;
    
    // why ?
    for(int i=1;i<=n;i++){
    	if(d1[i] <= d2[i]) ans++;
    	else ans--;
    }
    
    if(ans > 0) cout <<"Fennec";
    else cout <<"Snuke";
    
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    string s; cin >> s;
    int ans = 0;
    REP(i,s.length()) ans += (s[i]=='1');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = a * b;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35656
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int participants = sc.nextInt();
		int days = sc.nextInt();
		int amari = sc.nextInt();
		int[] aida = new int[participants];
		for (int i = 0; i < participants; i++) {
			aida[i] = sc.nextInt();
		}

		int total = amari;
		for (int j = 0; j < participants; j++) {
			int sum = 0;
			for (int k = 0; k < days; ) {
				sum = sum + 1;
				k = k + aida[j];
			}
			total = total+sum;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <math.h>
double pi=3.14159265358979;
struct point{
  double x;
  double y;
};
void print_point(struct point p){
  printf("%.8f %.8f\n",p.x,p.y);
}
void koch(int n,struct point p1,struct point p2){
  if(n==0) return ;
  struct point s,t,u;
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(pi/3)-(t.y-s.y)*sin(pi/3)+s.x;
  u.y=(t.x-s.x)*sin(pi/3)+(t.y-s.y)*cos(pi/3)+s.y;
  koch(n-1,p1,s);
  print_point(s);
  koch(n-1,s,u);
  print_point(u);
  koch(n-1,u,t);
  print_point(t);			\
  koch(n-1,t,p2);
  return ;
}
int main(){
  int n;
  struct point p1,p2;
  p1.x=0;p1.y=0;
  p2.x=100;p2.y=0;
  scanf("%d",&n);
  print_point(p1);
  koch(n,p1,p2);
  print_point(p2);
  return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a, b, c;
	a = n / 1000;
	n -= a * 1000;
	b = n / 100;
	n -= b * 100;
	c = n / 10;
	n -= c * 10;
	if ((a == b&&b == c) || (b == c&&c == n))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main()
{
  int n; cin >> n;
  vector<int> t(n);
  int sum = 0;
  rep(i, n) {
    cin >> t[i];
    t[i] *= 2;
    sum += t[i];
  }
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  vector<double> maxv(sum+1, 1001001001.0);
  maxv[0] = 0;
  maxv[sum] = 0;
  int ti = 1;
  rep(i, n) {
    ti--;
    rep(j, t[i]+1) {
      maxv[ti] = min(maxv[ti], v[i]);
      ti++;
    }
  }

  for (int i=1; i<sum; i++) {
    maxv[i] = min(maxv[i], maxv[i-1]+0.5);
  }
  for (int i=sum-1; i>=0; i--) {
    maxv[i] = min(maxv[i], maxv[i+1]+0.5);
  }
  double ans = 0;
  for (int i=1; i<=sum; i++) {
    ans += (maxv[i-1]+maxv[i])/4;
  }
  printf("%.10lf\n", ans);

  return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
    int n;
    cin>>n;
    vl a(n);
    fi(n)cin>>a[i];
    sort(all(a));
    ll sum = a.back();
    a.pop_back();
    int c = n-2;
    while(c)
    {
        if(c==1)
        {
            sum+=a.back();
            break;
        }
        else
        {
            sum+=2*a.back();
            a.pop_back();
            c-=2;
        }
    }
    cout<<sum<<endl;
}

int main()
{
	fastio;
    // int T;
    // cin>>T;
    // while(T--)
        solve();
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const LL MOD = 998244353LL;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
  int N;
  cin >> N;
  VLL a(N);
  int all_sum = 0;
  REP(i, N) {
    cin >> a[i];
    all_sum += a[i];
  }

  VLL dp(all_sum+1, 0);
  dp[0] = 1;
  REP(i, N) RREP(j, all_sum) {
    if(dp[j] != 0) {
      dp[j + a[i]] += dp[j];
      dp[j + a[i]] %= MOD;
      dp[j] *= 2;
      dp[j] %= MOD;
    }
  }
  
  LL ans = 1LL;
  REP(i, N) {
    ans *= 3;
    ans %= MOD;
  }
  int half = (all_sum + 1) / 2;
  REP2(i, half, all_sum+1) {
    ans += MOD;
    ans -= dp[i] * 3;
    ans %= MOD;
  }
  
  if(all_sum % 2 == 0) {
    VLL dp2(half+1, 0);
    dp2[0] = 1;
    REP(i, N) RREP(j, half) {
      if(dp2[j] != 0) {
        if(j + a[i] <= half) {
          dp2[j + a[i]] += dp2[j];
          dp2[j + a[i]] %= MOD;
        }
      }
  	}
    
    ans += dp2[half] * 3;
    ans %= MOD;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1280
"use strict";

function compareFunc(a, b) {
  return a - b;
}
const main = arg => {
  const input = arg.trim().split("\n");
  const A = input[0];
  if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(A) >= 0)  {
    console.log("A");
  } else {
    console.log("a");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29520
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
  std::string s;
  std::cin >> s;
  int ans1 = 0;
  int ans2 = 0;
  for (auto i = 0u; i < s.size(); ++i) {
    if ((i % 2 && s[i] == '0') || (i % 2 == 0 && s[i] == '1')) { ++ans1; }
    if ((i % 2 && s[i] == '1') || (i % 2 == 0 && s[i] == '0')) { ++ans2; }
  }
  std::cout << std::min(ans1, ans2) << std::endl;
  return 0;
}

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

int arrsum(int *arr, int start, int end) {
  int sum = 0;
  for (int i = start; i <= end; i++) {
    sum += arr[i];
  }
  return sum;
}

int main(int argc, const char *argv[])
{
  int n;
  int arr[100] = {0};
  int min = 2147483647;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = 1; i < n ; i++) {
    int left = arrsum(arr, 0, i - 1);
    int right = arrsum(arr, i, n);
    int gap = abs(abs(left) - abs(right));
    // printf(" gap = %d\n", gap);
    if (min > gap) {
      min = gap;
    }
  }
  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 128
import numpy as np

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]

for i in range(N):
    person = np.asarray(ab[i])
    shortest = 10**18
    for j in range(M):
        point = np.asarray(cd[j])
        diflist = person - point
        dif = abs(diflist[0])+abs(diflist[1])
        if dif < shortest:
            shortest = dif
            count = j+1
    print(count)


Measured memory_bytes: 12452
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

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

int main() {

	long long int a, v, b, w, i = 0, j = 0, t;
	cin >> a >> v >> b >> w >> t;
	
	rep(i, t+1) {
		if (a < b) {
			if (a + v * i >= b + w * i) {

				cout << "YES" << endl;
				return 0;
			}
		}
		else {
			if (a - v * i <= b - w * i) {

				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll lcd(ll x,ll y){
    return x*y/__gcd(x,y);
}

int main(){
    int n;ll m;cin>>n>>m;
    vin a(n);
    cin>>a[0];a[0]/=2;
    int tmp=a[0];int res=0;
    while(tmp%2==0){
        tmp/=2;
        res++;
    }
    bool twonum=true;int tmp2,res2;
    rep2(i,1,n){
        cin>>a[i];a[i]/=2;
        if(twonum){
            tmp2=a[i];res2=0;
            while(tmp2%2==0){
                tmp2/=2;
                res2++;
            }
            if(res2!=res)twonum=false;
        }
    }
    if(!twonum){
        cout<<0<<endl;
        return 0;
    }
    ll l=(ll)a[0];
    rep2(i,1,n){
        l=lcd(l,(ll)a[i]);
        if(l>m){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<(m+l)/(2*l)<<endl;
}

Measured memory_bytes: 640
#loud game
h,w,n=map(int,input().split())
sr,sc=map(int,input().split())
s=input()
t=input()

sr_deque=[]
sc_deque=[]

for i in range(n):
    p=s[i]
    if p=="U":
        #(X,people)=いくつ進めるか、どちらの人間か
        sr_deque.append((-1,1))
    elif p=="D":
        sr_deque.append((1,1))
    q=t[i]
    if q=="U":
        #(X,people)=いくつ進めるか、どちらの人間か
        sr_deque.append((-1,2))
    elif q=="D":
        sr_deque.append((1,2))      

for i in range(n):
    p=s[i]
    if p=="R":
        #(X,people)=いくつ進めるか、どちらの人間か
        sc_deque.append((1,1))
    elif p=="L":
        sc_deque.append((-1,1))
    q=t[i]
    if q=="R":
        #(X,people)=いくつ進めるか、どちらの人間か
        sc_deque.append((1,2))
    elif q=="L":
        sc_deque.append((-1,2)) 
        
sr_deque=sr_deque[::-1]
sc_deque=sc_deque[::-1]

def judge(start_node,width,deque):
    safe_left=1
    safe_right=width
    flags=True
    for que in deque:
        if que[1]==1:
            #消してしまいたい
            if que[0]==1:
                if safe_right>0:
                    safe_right-=1
           
            elif que[0]==-1:
                if safe_left<width+1:
                    safe_left+=1 
            
        if que[1]==2:
            #残しておきたい
            if que[0]==1:
                if safe_left>1:
                    safe_left-=1
                
                
            elif que[0]==-1:
                if safe_right<width:
                    safe_right+=1
 
        #境界条件
        if safe_left>safe_right:
            return False
    return safe_left<=start_node<=safe_right
  
def safe():
    return judge(sr,h,sr_deque) and judge(sc,w,sc_deque)
if safe():
    print("YES")
else:
    print("NO")



Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=2e5+10;
const LL inf=1e18;
typedef pair<LL,int> P;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='7'){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

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

    vector<vector<int>> A(n, vector<int>(m, 0));
    vector<int> b(m, 0);

    // A 読み込み
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            cin >> A[i][j];
        }
    }

    // b 読み込み
    for(int i=0; i<m; ++i) cin >> b[i];

    vector<int> ans(n, 0);
    
    // 行列計算
    for(int i=0; i<n; ++i) {
        int sum = 0;
        for(int j=0; j<m; ++j) {
            sum += (A[i][j] * b[j]);
        }
        ans[i] = sum;
    }

    // 結果表示
    for(int i=0; i<ans.size(); ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int w[100];
    for (int i = 0; i < n; i++) {
        std::cin >> w[i];
        if(i>0){
        w[i]+=w[i-1];
        }
    }
    int sum=w[n-1];
    int min=100000;
    for (int i = 0; i < n-1; i++) {
        if(abs(sum-w[i]-w[i])<min){
            min=abs(sum-w[i]-w[i]);
        }
    }
    std::cout << min << std::endl;
 
}


Measured memory_bytes: 256
// ABC070B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if (A >= C) {
		if (D < A) {
			cout << 0 << endl;
		} else {
			cout << min(B, D) - A << endl;
		}
	} else {
		if (B < C) {
			cout << 0 << endl;
		} else {
			cout << min(B, D) - C << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        
        
        int K = in.nextInt();
        in.nextLine();
        int A = in.nextInt();
        int B = in.nextInt();
        

        boolean isDone = false;
        
        for(int i = A; i <= B; i++) {
            if(i%K == 0) {
                isDone = true;
                System.out.println("OK");
                break;
            }
        }
        
        if(!isDone) System.out.println("NG");
    }
    

        
}


Measured memory_bytes: 35836
#include<iostream>
using namespace std;
 
int main(){
	int n, p[20], i, ans = 0;
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> p[i];
	}
	for (i = 1; i < n - 1; i++){
		if (p[i - 1] < p[i]){
			if (p[i] < p[i + 1]){
				ans++;
			}
		}
		else if (p[i - 1] > p[i]){
			if (p[i] > p[i + 1]){
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;



int main(){
	long long int N, M, K;
	cin >> N >> M >> K;
	bool f = false;
	for( int i = 0; i <= N; i++ ){
		for( int j = 0; j <= M; j++ ){
			if( i*(M-j)+j*(N-i) == K ){
				f = true;
			}
		}
	}
	if( f ){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}



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

int main() {
    int n, m;
    cin >> n >> m;
    int nm = n + m;
    vector<int> out[n + 1];
    unordered_set<int> in[n + 1];
    int parent[n + 1];

    for (int i = 1; i < nm; i++) {
        int a, b;
        cin >> a >> b;
        out[a].push_back(b);
        in[b].insert(a);
    }

    queue<int> que;
    for (int i = 1; i <= n; i++) {
        if (in[i].empty()) {
            que.push(i);
            parent[i] = 0;
            break;
        }
    }

    while (!que.empty()) {
        int x = que.front();
        que.pop();
        for (int y: out[x]) {
            in[y].erase(x);
            if (in[y].empty()) {
                que.push(y);
                parent[y] = x;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << parent[i] << endl;
    }
    return 0;
}


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

long long n,p=1000000007,ans;
char ch1[100],ch2[100];

int main()
{
	scanf("%lld",&n);
	scanf("%s",ch1+1);
	scanf("%s",ch2+1);
	if(ch1[1]==ch2[1])ans=3;
	else ans=6;
	for(int i=2;i<=n;i++){
		if(ch1[i]==ch1[i-1])continue;
		if(ch1[i-1]==ch2[i-1]){
   			ans=ans*2%p;
		}else{
			if(ch1[i]!=ch2[i]){
				ans=ans*3%p;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  100005;  
const int M = 101;
#define V first
#define W second
#define MAX_LOG_V 32
typedef pair<int, int>pii;
int mod = 1000000007;

vector<pair<int, int> >g[N];
ll sum[N];
void dfs(int u, int pre, ll all)
{
   sum[u] = all;
   for (int i = 0; i < g[u].size(); i++)
   {
      int v = g[u][i].V;
      if (v != pre)
         dfs(v, u, all + g[u][i].W);
   }
}

int main()  
{  

   // ios::sync_with_stdio(0);
   int  n, q, k;
   scanf("%d", &n);
   for (int i = 1; i < n; i++)
   {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      g[u].push_back(make_pair(v, w));
      g[v].push_back(make_pair(u, w));
   }
   scanf("%d%d", &q, &k);
   
   dfs(k, -1, 0);
   while (q--)
   {
      int x, y;
      scanf("%d%d", &x, &y);
      printf("%lld\n", sum[x] + sum[y]);
   }
   

   return 0;
}  

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll; 
#define rep(i, n) for(int i = 0; i < n; i++)

#define MAX_M 1000

ll a[105];

ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	gcd(y, x % y);
}

int main() {
	int n;
	cin >> n;
	ll rep = 0;
	rep(i, n) {
		cin >> a[i];
		if (i == 0) rep = a[0];
		else if (i == 1) rep = a[0] / gcd(a[0], a[1]) * a[1];
		else rep = rep / gcd(rep, a[i]) * a[i];
	}

	cout << rep << endl;

	return 0;
}


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

vi v;
vll memo;

ll dp(int n, int k) {
	if(n == 0) return 0;
	ll& ans = memo[n];
	if(ans != -1) return ans;
	ans = 1e12;
	for (int i = 1; i <= k and i <= n; ++i) {
		ans = min(ans, dp(n - i, k) + abs(v[n - i] - v[n]));
	}
	return ans;
}

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n, k;
	while (cin >> n >> k) {
		v = vi(n);
		for (int i = 0; i < n; ++i) cin >> v[i];
		memo = vll(n, -1);
		cout << dp(n-1, k) << '\n';
	}
}




Measured memory_bytes: 7680
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


a, b, c, d = map(int, input().split())
t0 = b//c - a//c + (a%c==0)
t1 = b//d - a//d + (a%d==0)
z = c*d//xgcd(c,d)
t2 = b//z - a//z + (a%z==0)

print(b-a+1-t0-t1+t2)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(void){
    int N;
    string S[110];
    int P[110];
    cin >> N;
    vector<pair<pair<string,int>,int>> ans(N);
    rep(i,N){
        cin >> S[i];
        cin >> P[i];
        ans[i] = make_pair(make_pair(S[i],-P[i]),i);
    }
    sort (ans.begin(),ans.end());
    rep(i,N) cout << ans[i].second + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	if(n>=30)
	cout<<"Yes";
	else cout<<"No";
	
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

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

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];

    if (vec[0] == vec[1] && vec[1] == vec[2]) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 3612
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/lazysegtree>
#include <atcoder/modint>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using mint = atcoder::modint998244353;
typedef std::pair<mint, mint> P;

P op(P a, P b) {
    return {a.first + b.first, a.second + b.second};
}
P e() {return {mint(0), mint(0)};}
P mapping(int x, P y) {
    if(x == -1) return y;
    y.first = y.second * x;
    return y;
}
int compostion (int x, int y) {
    if(x == -1) return y;
    return x;
}
int id(){return -1;}

using namespace std;

int main() {
    int n, q; cin >> n >> q;
    vector<P> da(n);
    da[n-1] = {mint(1), 1};
    for(int i = n-2; i> -1; i--) {
        da[i] = {da[i+1].first*10, da[i+1].first*10};
    }
    atcoder::lazy_segtree<P, op, e, int, mapping, compostion, id> lst(da);
    vector<P> ans(q);
    rip(i,q,0) {
        int l, r, q; cin >> l >> r >> q;
        --l;
        lst.apply(l, r, q);
        ans[i] = lst.all_prod();
    }
    rip(i,q,0) cout << ans[i].first.val() << endl;
}


Measured memory_bytes: 11352
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n = int(input())
    p = []
    m = []

    zz = 0

    for _ in range(n):
        a, b = map(int, input().split())
        if a != 0 and b != 0:
            g = gcd(a, b)
            f = b / a
            if b / a < 0:
                m.append(str(abs(a // g)) + ':' + str(abs(b // g)))
            elif f > 0:
                p.append(str(abs((b // g))) + ':' + str(abs((a // g))))
        elif a == 0 and b == 0:
            zz += 1
        elif a == 0:
            m.append(0)
        elif b == 0:
            p.append(0)

    g_p = {}
    for k in p:
        if k in g_p:
            g_p[k] += 1
        else:
            g_p[k] = 1
    g_m = {}
    for k in m:
        if k in g_m:
            g_m[k] += 1
        else:
            g_m[k] = 1

    ans = 1

    for k in g_p:
        if k in g_m:
            ans *= (2 ** g_p[k] + 2 ** g_m[k] - 1)
        else:
            ans *= 2 ** g_p[k]
        ans %= mod
    for k in g_m:
        if not (k in g_p):
            ans *= 2 ** g_m[k]
            ans %= mod
    print((ans + zz - 1) % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 136620