akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

ll s=1;
vector<ll> d, a, l;
set<ll> pq;
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    ll n,x;cin>>n>>x;
    d.resize(n+1,0);
    l.resize(n+1,0);
    a.resize(n+1,0);
    l[0]=x;
    repA(i,1,n){
        cin>>d[i];
        l[i]=min(l[i-1], abs(l[i-1]-d[i]) );
    }
    
    a[n]=1;
    repD(i,n-1,1){
        if(2*a[i+1]<=d[i+1]) a[i]=a[i+1];
        else a[i]=a[i+1]+d[i+1];
    }

    ll Q;cin>>Q;
    rep(i,Q){
        ll y;cin>>y;
        if(a[y]<=l[y-1]) cout<<"YES\n";
        else cout<<"NO\n";
    }

	return 0;
}
 



Measured memory_bytes: 13696
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    ll n;
    cin>>n;
    vector <ll> a(n+1);
    for(ll i=0;i<n+1;i++){
        cin>>a[i];
    }
    
    vector <ll> b(n);
    for(ll i=0;i<n;i++){
        cin>>b[i];
    }
    ll ans=0;
     for(ll i=0;i<n;i++){
        ll first=min(a[i], b[i]);
        b[i]-=first;
        ans+=first;
        ll second=min(b[i], a[i+1]);
        a[i+1]-=second;
        ans+=second;
    }
   
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
void solve(int n){
    int in,i,j,nn;
    vector<vector<int>> v;
    v=vector<vector<int>>(30,vector<int>(0));
    for(i=0;i<n;i++){
        cin>>nn;
        for(j=0;j<nn;j++){
            cin>>in;
            v[in-1].push_back(i);
        }
    }
    for(i=0;i<30;i++){
        set<int> s;
        for(int x:v[i]){
            s.insert(x);
        }
        if(s.size()==n){
            cout<<i+1<<endl;
            return;
        }
        for(int j=i-1;j>=0;j--){
            bool sw=false;
            for(int x:v[j]){
                if(s.find(x)!=s.end())sw=true;
            }
            if(sw){
                for(int x:v[j]){
                    s.insert(x);
                }
            }
            if(s.size()==n){
                cout<<i+1<<endl;
                return;
            }
        }
    }
    cout<<"-1"<<endl;
}


int main(void){
    int n;
    while(cin>>n,n){
        solve(n);
    }
}

Measured memory_bytes: 3024
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datH, datW) = readLine.split(" ").map(_.toInt)
    val board = for(i <- 1 to datH) yield readLine.split("").filterNot(_ == "").map(_(0))

    def searchGrid(x: Int, y: Int): Boolean = {
      if (board(y)(x) == '.') true
      else {
        val checkN = if (y <= 0       ) false else (board(y - 1)(x    ) == '#')
        val checkS = if (y >= datH - 1) false else (board(y + 1)(x    ) == '#')
        val checkW = if (x <= 0       ) false else (board(y    )(x - 1) == '#')
        val checkE = if (x >= datW - 1) false else (board(y    )(x + 1) == '#')
        (checkN || checkS || checkW || checkE)
      }
    }
    val checker = for(x <- 0 until datW; y <- 0 until datH) yield searchGrid(x, y)
    //checker.grouped( datW ).foreach(a => println (a.mkString))
    val ans = checker.forall(a => a)
    println(if (ans) "Yes" else "No")
  }
}


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

int main()
{
    int n,k;
    long z;
    scanf("%d %d",&n,&k);
    if(k%2==1){
        z=pow(n/k,3);
    }else if(n%k>=k/2){
        z=pow(n/k,3)+pow(n/k+1,3);
    }else{
        z=2*pow(n/k,3);
    }
    printf("%ld",z);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool choco[10][10];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int rdx[] = {1,0,-1,0};
int rdy[] = {0,-1,0,1};
int w,h;
int now;
int num;
bool visited[10][10];

bool dfs(int x, int y, int sx, int sy) {
  now++;
  //cout << now << " " <<  x << " " << y << " " << sx << " " << sy << endl;
  if (now * 2 == num) {
    return 1;
  }
  visited[y][x] = 1;
  visited[sy][sx] = 1;
  REP(i, 4) {
    int xx = x+dx[i], yy = y+dy[i];
    int sxx = sx+rdx[i], syy = sy+rdy[i];
    //cout << " " << xx << "," << yy << " " << sxx << "," << syy << endl;
    if (xx<0||xx>=w||yy<0||yy>=h||sxx<0||sxx>=w||syy<0||syy>=h) continue;
    if (yy==syy&&xx==sxx) continue;
    if (!choco[yy][xx] || !choco[syy][sxx]) continue;
    if (visited[yy][xx] || visited[syy][sxx]) continue;
    if (dfs(xx,yy,sxx,syy)) return 1;
  }
  return 0;
}

int main() {
  while(cin>>w>>h, w||h) {
    memset(choco,0,sizeof(choco));
    int x,y;
    num = 0;
    REP(i, h) REP(j, w) {
      cin >> choco[i][j];
      if (choco[i][j]) num++;
    }
    REP(i,2) { 
      REP(d,4) {
        REP(y,h) {
          REP(x,w) {
            if (choco[y][x] == 0) continue;
            REP(sy,h) {
              REP(sx,w) {
                if (sy==y&&sx==x) continue;
                if (choco[sy][sx] == 0) continue;
                now = 0;
                memset(visited,0,sizeof(visited));
                if (dfs(x,y,sx,sy)) {
                  //cout << x << " " << y << " " << sx << " " << sy << " " << d << endl;
                  goto ok;
                }
              }
            }
          }
        }
        rotate(dx,dx+1,dx+4);
        rotate(dy,dy+1,dy+4);
        // rotate(rdx,rdx+1,rdx+4);
        // rotate(rdy,rdy+1,rdy+4);
      }
      swap(rdx[0], rdx[2]);
      swap(rdy[0], rdy[2]);
    }
    cout << "NO" << endl;
    continue;
  ok:;
    cout << "YES" << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> all(N,0);
    vector<int> shain;
    for(int i = 0; i < N -1; i++){
        int n;
        cin >> n;
        shain.push_back(n);
    }
    
    for(int i = 0; i < shain.size(); i++){
        all.at(shain.at(i) - 1) += 1;
    }
    
    for(int i = 0; i < all.size(); i++){
        cout << all.at(i) << endl;
    }
    
}

Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {

	int R[MAX], n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;

}



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

int i,j,k;

int main(){
    string in;
    int len;
    int op;
    cin >> in >> op;
    len = in.length();
    char out[len + 1];
    for(i = 0; i < len; i++){
        char tmp = in[i];
        int diff = (26 - (tmp - 'a')) % 26;
        if(i == len-1){
            char alp = (op + (tmp - 'a')) % 26 + 'a';
            out[i] = alp;
            out[i + 1] = '\0';
        }
        else{
            if(op >= diff){
                out[i] = 'a';
                op = op - diff;
            }
            else {
                out[i] = tmp;
                continue;
            }
        }
    }
    for(i = 0; i < len; i++) cout << out[i];
}


Measured memory_bytes: 768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });
  sort(begin(A), end(A));
  ll ans = 0;
  for (ll i = 0; i < K; i++) {
    ans += A[i];
  }

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




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
  string str;
  cin>>str;
  int l,res=0;
  l=str.size();
  for(int i=0,j=l-1 ; i<l/2 ; i++,j--){
    if(str[i]!=str[j]) res++;
  }
  cout<<res;


  return 0 ;
}


Measured memory_bytes: 256
from itertools import combinations

def dist(ax, ay, bx, by):
    return ((ax - bx)**2 + (ay - by)**2)**0.5

n = int(input())
XY = [tuple(int(x) for x in input().split()) for _ in range(n)]
if n == 2:
    (ax, ay), (bx, by) = XY[0], XY[1]
    print(dist(ax, ay, bx, by) / 2)
    exit()

ans = 0
for (ax, ay), (bx, by), (cx, cy) in combinations(XY, 3):
    a, b, c = sorted([dist(ax, ay, bx, by), dist(bx, by, cx, cy), dist(cx, cy, ax, ay)])
    cosC = (a**2 + b**2 - c**2) / (2 * a * b)
    if cosC < 0:
        ans = max(ans, c / 2)
    else:
        sinC = (1 - cosC**2)**0.5
        ans = max(ans, c / (2 * sinC))
print(ans)


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

#define ll long long
#define inf (1LL<<60)

ll dp[3001][3001];
ll sum[3001][3001];

void preprocess(vector<int> &v, int n){

    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            sum[i][j] = v[j] + ((j == i) ? 0 : sum[i][j-1]);
        }
    }
}

ll solve(vector<int> &v, int i, int j){

    if(i==j)
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    ll mincost = inf;

    for(int k=i;k<j;k++){
        mincost = min(mincost,sum[i][j] + solve(v,i,k) + solve(v,k+1,j));
    }

    return dp[i][j] = mincost;
}

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

    vector<int> v(n+1);
    memset(dp,-1,sizeof dp);

    for(int i=1;i<=n;i++)
        cin>>v[i];

    preprocess(v,n);
    cout<<solve(v,1,n);

    return 0;
}


Measured memory_bytes: 76188
using System;

namespace AtCoderAbc160
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var p = new Problem1();
            Console.WriteLine(p.GetAnswer(s));
        }
    }

    public class Problem1
    {
        public string GetAnswer(string s)
        {
            var same = s[2] == s[3] && s[4] == s[5];
            return same ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 11092
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 100500;

ll a, b, c, x, y;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    ll by_self = min(a + b, 2 * c);
    while (min(x, y))
    {
        x--, y--;
        ans += by_self;
    }
    while (x--)
    {
        ans += min(a, 2 * c);
    }
    while (y--)
    {
        ans += min(b, 2 * c);
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 3648
m, d = map(int, input().split())

ans = 0
for mi in range(1, m+1):
    for di in range(1, d+1):
        if di % 10 >= 2 and di // 10 >= 2 and mi == (di // 10) * (di % 10):
            ans += 1

print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        std::size_t Index = FArray.size();
        FArray.push_back(Value);
        while(Index > 1){
            std::size_t Parent = Index / 2;
            if(FArray[Index] < FArray[Parent]) return;
            std::swap(FArray[Index], FArray[Parent]);
            Index = Parent;
        }
    }
    void pop()
    {
        FArray[1] = FArray.back();
        FArray.pop_back();

        std::size_t Size = FArray.size();
        std::size_t Index = 1;
        while(Index < Size){
            std::size_t Left = Index * 2;
            std::size_t Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size ? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6268
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  int a,b;
  cin >> a >> b;
  if( a == 1 ) a = 14;
  if( b == 1 ) b = 14;
  if( a == b ) puts("Draw");
  else puts((a<b)?"Bob":"Alice");
  return 0;
}


Measured memory_bytes: 256
n = int(input())
*v, = map(int, input().split())
v = v[:n]

for i in range(n):
    k = v[i]
    j = i-1
    while j >= 0 and v[j] > k:
        v[j+1] = v[j]
        j -= 1
    v[j+1] = k
    print(" ".join([str(_v) for _v in v]))



Measured memory_bytes: 5608
#include<stdio.h>

int main()
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if (w >= x + r && h >= y + r && r <= x && r <= y && x >= 0 && y >= 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  int least = *min_element(A.begin(), A.end());
  int ans = 0;
  for (int i = 0, cnt = 0; i < N; ++i) {
    if (A[i] != least) {
      if (++cnt == (K - 1) or (cnt > 0 and i == N - 1)) {
        ++ans;
        cnt = 0;
      }
    }
    else if (i == N - 1 and cnt > 0) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 3005;
int n;
//string a[maxn];
ld dp[maxn][maxn];
ld p[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    dp[0][0] = 1.0;
    for(int i = 1 ; i <= n; ++i)
    {
        cin >> p[i];
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for(int j = 1 ; j <= i ; ++j)
        {
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
//            cout << dp[i][j] << endl;
        }
    }
    ld res = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        if(i > (n - i))res += dp[n][i];
    }
    cout << fixed << setprecision(9) << res;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

int main() {
    cin >> n;

    VVi edges(n);
    REP(i, n) {
        int u, k;
        cin >> u >> k;
        u--;
        REP(j, k) {
            int v; cin >> v;
            v--;
            edges[u].push_back(v);
        }
    }

    Vi find(n, -1), end(n, -1);
    stack<int> s;
    s.push(0);
    int time = 1;
    while (true) {
        while (!s.empty()) {
            int node = s.top();
            if (find[node] == -1) {
                find[node] = time;
                time++;
            } else {
                if (end[node] == -1) {
                    end[node] = time;
                    time++;
                }
                s.pop();
                continue;
            }
            RREP(i, edges[node].size()-1, 0) {
                int v = edges[node][i];
                if (find[v] == -1) {
                    s.push(v);
                }
            }
        }
        int idx = -1;
        REP(i, n) if (find[i] == -1) {
            idx = i;
            break;
        }
        if (idx == -1) {
            break;
        }
        s.push(idx);
    }

    REP(i, n) {
        printf("%d %d %d\n", i+1, find[i], end[i]);
    }

    return 0;
}



Measured memory_bytes: 3344
#include <stdio.h>

#define MAX 1000000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P)
{
	int i =0;
	for(int j=0; j<k; j++){
		llong s = 0;
		while(s + T[i] <= P){
			s += T[i];
			i++;
			if(i == n) return n;
		}
	}
	return i;
}


int solve()
{
	int v;
	llong left = 0;
	llong right = 100000 * 100000;
	llong mid;
	while(right - left > 1){
		mid = (left + right) / 2;
		v = check(mid);
		if(v >= n){right = mid; }
		else {left = mid;}
	}
	return right;
}


int main(void)
{
	scanf("%d", &n);
	scanf("%d", &k);
	
	llong ans;
	for(int i=0; i<n; i++){
		scanf("%d", &T[i]);
	}
	ans = solve();
	printf("%d\n", ans);
	
	return 0;
}



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

int sort(const void *a,const void *b){
    return *(int*)b-*(int *)a;
}


int main(){
    int top[4]={0};
    int i;
    for(i=0;i<10;i++){
        scanf("%d",&top[3]);
        qsort(top,4,sizeof(int),sort);
    }
    for(i=0;i<3;i++){
        printf("%d\n",top[i]);
    }
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N, K, S;
  cin >> N >> K >> S;

  int a = S-1;
  if(a == 0) a = 10000;
  REP(i, N){
    if(i < K) cout << S << " ";
    else cout << a << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>

int main() {
    std::string line;
    std::cin >> line;

    int line_length = (int)line.size();
    int result = 0;
    for (int i = 0; i < line_length/2; i++) {
        if (line[i] != line[line_length-1-i]) result++;
    }
    std::cout << result << std::endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	int ans=753;
	for(int i=2;i<s.size();++i){
		string t=s.substr(i-2,3);
		int a=abs(stoi(t)-753);
		ans=min(ans,a);
	}
	cout<<ans<<"\n"s;
}

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

signed main(void){
  
  int q; cin >> q;
  while(q--){
    string s,t; cin >> s >> t;
    int n = s.size(); int m = t.size();
    
    vector<vector<int>> dp(n+10,vector<int>(m+10,0));
    vector<vector<int>> M(n+10,vector<int>(m+10,0));
    
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){ 
        
        if(s[i] == t[j] ){ 
          dp[i+1][j+1] = max(dp[i][j]+1,max(dp[i][j+1],dp[i+1][j]));
        }
        else{
          dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
        
      }
    }
    
    cout << dp[n][m] << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 18952
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    ll A;
    long double B;
    cin >> A >> B;
    cout << (ll)(A * B) << endl;
    return 0; 
}

Measured memory_bytes: 3760
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, C, B[20];
    cin >> N >> M >> C;
    REP(i, M) {
        cin >> B[i];
    }
    int res = 0;
    REP(i, N) {
        int sum = 0;
        REP(j, M) {
            int A;
            cin >> A;
            sum += A * B[j];
        }
        if (sum + C > 0) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var A = RLongs();
        long ans = 0;
        long max = 0;
        for (int i = 0; i <N; i++)
        {
            if (A[i] > max)
            {
                max = A[i];
            }
            else
            {
                ans += max - A[i];
            }
        }
        WriteLine(ans);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 47072
fun main(args: Array<String>) {
    val (A, B, C, D) = readLine()!!.split(" ").map { it.toLong() }
    println((B - A + 1) - (f(B, C, D) - f(A - 1, C, D)))
}

fun f(x: Long, a: Long, b: Long): Long {
    return x / a + x / b - x / lcm(a, b)
}

fun lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

tailrec fun gcd(a: Long, b: Long): Long = when {
    a < b -> gcd(b, a)
    b == 0L -> a
    else -> gcd(b, a % b)
}

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

std::vector<long> memo(100, -1);

long lucas(int n) {
  if (n == 0)
    return 2;
  if (n == 1)
    return 1;
  if (memo.at(n) == -1)
    memo.at(n) = lucas(n - 1) + lucas(n - 2);
  return memo.at(n);
}

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::cout << lucas(n) << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] box = new int[n];
        for (int i = 0; i < n; i++) {
        	box[i] = sc.nextInt();
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
        	int diff = Math.abs(box[i] - box[i+k-1]);
            int tmp = diff + Math.min(Math.abs(box[i]), Math.abs(box[i + k - 1]));
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;

lint dp[max_n];

int main () {
	make2(n, W);
	dp[0] = 0;
	FOR(i,1,1e5+1) dp[i] = W+1;
	FOR(i,0,n) {
		make2(w, v);
		FORD(j,1e5+1-v,0) {
			dp[j+v] = min(dp[j+v], dp[j]+w);
		}
	}
	lint ans = 0;
	FOR(i,0,1e5+1) {
		if (dp[i]<=W) 
			ans = i;
	}
	printf("%lld\n", ans);
}	





Measured memory_bytes: 1024
#!/usr/bin/python3
# -*- coding: utf-8 -*-



N,L = map(int, input().split())
An = [L+i-1 for i in range(1,N+1)]

eat = 0
for i,a in enumerate(An):
  if abs(An[eat]) > abs(a):
    eat = i

print(sum(An)-An[eat])


Measured memory_bytes: 38384
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
const long long mod = 998244353;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int s = A + B;
	int d = A - B;
	int p = A * B;
	if (s < d) {
		if (d < p)printf("%d", p);
		else printf("%d", d);
	}
	else {
		if (s < p)printf("%d", p);
		else printf("%d", s);
	}
	return 0;
}

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

int main() {
  double N;
  int a=0,b=0;
  cin >> N;
  
  for (double i = N; i > 0; i--) {
    int c = i*1.08;
    if(c==N){
      a=i;
      b=1;
      break;
    }
      
  }
 if(b==1) cout << a << endl;
 else cout << ":(" << endl;
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 998244353
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,m);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact,ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {
            fact[i+1] = fact[i]*(i+1) % M;
            ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;
        }
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b] * ifact[b] % M;
        return tmp * fact[a] % M;
    }
};

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

    ll N,M,K;
    cin >> N >> M >> K;
    
    ll ans = 0;
    
    combination C(N+1);
    
    for (ll k = 0; k <= K; k++) {
        ll kk = modpow<ll>(M-1,N-1-k,mod);
        ll kkk = C.com(N-1,k);
        ans += kk*kkk%mod;
        ans %= mod;
    }
    ans *= M;
    ans %= mod;
    
    
    cout << ans << endl;
    
    
    
    
    

    return 0;
}


Measured memory_bytes: 6260
import java.util.*;
                   
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] R = new int[t];
        int i, min, bnf;
        for(i=0; i<t; i++) R[i] = sc.nextInt();
        min = R[0];
        bnf = Integer.MIN_VALUE;
        for(i=1; i<t; i++){
            bnf = Math.max(bnf, R[i]-min);
            min = Math.min(min, R[i]);
        }
                    
        System.out.println(bnf);
    }
}

Measured memory_bytes: 101152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define MAX 1000000
bool is_prime[MAX+1];
vector<int> prime;
void init() {
    memset(is_prime, 1, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= MAX; i++) 
        if (is_prime[i]) {
            prime.push_back(i);
            for (int j = i + i; j <= MAX; j += i) 
                is_prime[j] = false;
        }
}

int cnt(int p, int m) {
    typedef vector<int>::iterator vi;
    vi u = lower_bound(prime.begin(), prime.end(), p+m+1);
    vi l = lower_bound(prime.begin(), prime.end(), p-m);
    return u - l;
}

int main() {
    int n, p, m;
    init();
    while (cin >> n, n) {
        int sum = 0;
        while (n--) {
            cin >> p >> m;
            int prize = cnt(p, m) - 1;
            sum += prize;
        }
        cout << sum << endl;
    }
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    const int INF = 1e6;
    vector<int> dp(N+1, INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}


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

int main(){
  int n,res=0,count;
  int a=0,b=0,c=0,d=0;
  
  
  while( scanf("%d",&n) != EOF){
     
     for( a = 0 ; a < 10 ; a++){
       //if( (a+b+c+d) == n)res++;

       for( b = 0 ; b < 10 ; b++){
	 //if( (a+b+c+d) == n)res++;
	 for( c = 0 ; c < 10 ; c++){
	   //if( (a+b+c+d) == n)res++;
	   for( d = 0 ; d < 10 ; d++){
	     if( (a+b+c+d) == n)res++;
	     //cout << res <<endl;
	   }

	 }
	 

       }

     }
     // count = a;
     //if(count > 9)break;
     cout << res<<endl;
     res =0;
   }

  
  return 0;
}

Measured memory_bytes: 1208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ATakahashikunTheStrider {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int x; cin >> x;
      cout << 360/gcd(x, 360) << endl;
      return;

      vector<int> cnt(180);
      cnt[x]++;
      int now = x;
      bool flag = true;
      rep(i, 180) {
        if (cnt[i] != 0) {
          flag = false;
        }
      }
      int ret = 1;
      while(!flag) {
        now += x;
        now %= 360;
        if (now >= 180) {
          cnt[now-180]--;
        } else {
          cnt[now]++;
        }
        flag = true;
        rep(i, 180) {
          if (cnt[i] != 0) {
            debug(ret, i, cnt[i]);
            flag = false;
          }
        }
        ret++;
      }
      cout << ret<< endl;


    }
};

signed main() {
  ATakahashikunTheStrider solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3636
/*
Hanit Banga
Problem: 
*/

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 2e5 + 5, INF = 1e9;

vector <int> g[N][2];
int ans[N], comp[N][2];
bool seen[N][2] = {0};
p3 cities[N];

void findComponents(int start, int c, int j);

int main()
{
	int n, k[2], u, v;
	cin >> n >> k[0] >> k[1];

	for (int j = 0; j < 2; ++j)
	{
		for (int i = 0; i < k[j]; ++i)
		{
			cin >> u >> v;
			g[u][j].pb(v);
			g[v][j].pb(u);
		}
	}

	for (int j = 0; j < 2; ++j)
	{
		for (int i = 1; i <= n; ++i)
		{
			if (!seen[i][j])
			{
				findComponents(i, i, j);
			}
		}
	}

	for (int i = 1; i <= n; ++i)
	{
		cities[i] = {{comp[i][0], comp[i][1]}, i};	
	}

	sort(cities + 1, cities + n + 1);
	cities[n+1] = {{INF, INF}, INF};

	// for (int i = 1; i <= n; ++i)
	// {
	// 	cout << cities[i].second << ' ' << cities[i].first.first << ' ' << cities[i].first.second << endl;
	// }

	int st = 1, ctr = 1;


	for (int i = 2; i <= n+1; ++i)
	{
		if (cities[i].first == cities[i-1].first)
			++ctr;

		else
		{
			for (int j = st; j < i; ++j)
				ans[cities[j].second] = ctr;

			st = i;
			ctr = 1;
		}
	}

	for (int i = 1; i <= n; ++i)
		cout << ans[i] << ' ';
}

void findComponents(int start, int c, int j)
{
	seen[start][j] = true;
	comp[start][j] = c;

	for (auto i : g[start][j])
	{
		if (!seen[i][j])
			findComponents(i, c, j);
	}
}

Measured memory_bytes: 21248
#include <cstdio>
#define loop_input(fmt,...) while(~scanf(fmt,__VA_ARGS__))

int main() {
    int W, H, x, y, r;
    loop_input("%d%d%d%d%d", &W, &H, &x, &y, &r) {
        if ((r <= x && x <= W-r) && (r <= y && y <= H-r)) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2624
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut v: Vec<u32> =(0..n).map(|_| sc.cin()).collect();
    v.sort();
    put!(v[n-1]-v[0]);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

long long int h, n;

int main() {
  cin >> h >> n;
  long long int a;
  rep(i, n) {
    cin >> a;
    h = h -a;
  }
  if(h>0) cout << "No";
  else cout << "Yes";

}


Measured memory_bytes: 256
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline

n,k = map(int,input().split())
v = list(map(int,input().split()))
ans = 0
for i in range(k+1):
        for j in range(k-i+1):
                x = v[:i]
                if n< i+j:
                        continue
                if i+j > k:
                        continue
                if j > 0:
                        x = x + v[-j:]
                x.sort(key=lambda x : -x)
                kai = i+ j
                while kai < k and x and x[-1] < 0:
                        x.pop()
                        kai+=1
                ans = max(ans,sum(x))
print(ans)

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

char encode(char x,int a,int b){
	return ( ( a * (x-'a') + b) % 26 ) + 'a';
}

char decode(char x, int a, int b){
	int t = ( x - 'a') - b;
	while( (t%a) != 0 ) t += 26;
	return (t/a) % 26 + 'a';
}

string encode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = encode( s[i] , a , b );
	return s;
}

string decode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = decode( s[i] , a , b );
	return s;
}

int main(){
	int n=1;
	int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
	
	string str, s;
	cin >> n;
	getline( cin , str );
	
	for(int i=0 ; i<n ; ++i){
		bool flag = false;
		getline( cin , str );

		for(int i=0 ; i<12 ; ++i){
			for(int j=0 ; j<26 ; j++){
				s = decode( str , a[i] , j );
				if( s.find("this") != string::npos || s.find("that") != string::npos ){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		cout << s << endl;
	} 
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,r;
	while(cin>>n>>r){
		if(n==0 && r==0){
			break;
		}
		int d[100],cp[100];
		for(int i=1;i<=n;i++){
			d[i]=n-i+1;
			cp[i]=n-i+1;
		}
		int p,c;
		for(int i=0;i<r;i++){
			cin>>p>>c;
		for(int i=0;i<c;i++){
			cp[i+1]=d[p+i];
		}
		for(int i=0;i<p-1;i++){
			cp[c+1+i]=d[i+1];
		}
		for(int i=0;i<=100;i++){
			d[i]=cp[i];
		}
		}
		cout<<d[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160