akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    while(true){
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) { break; }

        int count = 0;
        for (int i = 1; i <= n - 2; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
            Scanner scanner = new Scanner(System.in);

            String b = scanner.nextLine();

            if (b.matches("A")) {
            	 System.out.println("T");
            } else if (b.matches("T")) {
               System.out.println("A");
            } else if (b.matches("G")) {
               System.out.println("C");
            } else if (b.matches("C")) {
              System.out.println("G");
            }
            scanner.close();
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
ll n, m;
ll ans = 0;
void dfs(vector<vector<ll>>& graph, ll v, vector<ll> visited){
    visited.push_back(v);
    if(visited.size()==n){
        ans++;
        return;
    }
    for(auto next:graph[v]){
        bool flag = false;
        for(auto i:visited){
            if(i==next)flag = true;
        }
            if(flag)continue;
        dfs(graph, next, visited);
    }
}
void solve(){
    cin >> n >> m;
    vector<vector<ll>> adj(n);
    for (ll i = 0; i < m;i++){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    vector<ll> visited;
    dfs(adj, 0, visited);
    cout << ans << endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    n = int(input())
    R = {}
    for i in range(1, n+1):
        s, p = input().split()
        p = int(p)
        if not s in R.keys():
            R[s] = [(i, p)]
        else:
            R[s].append((i, p))
    index = sorted(R)
    for idx in index:
        ids = R[idx]
        ids.sort(key=lambda x: x[1])
        for i in reversed(ids):
            print(i[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<queue>
#include<list>

using namespace std;

typedef list<int> Path;
/*
n m
a1 b1
...
aM bM

n: vertex
m: edge
*/

int n, m;
int main(){
  scanf("%d %d", &n, &m);

  bool connected[n+1][n+1];
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++)
      connected[i][j] = false;
  
  for(int i = 0; i < m; i++){
    int a,b;
    scanf("%d %d", &a, &b);
    connected[a][b] = true;
    connected[b][a] = true;    
  }

  queue<Path> que;
  Path ini;
  ini.push_front(1);
  que.push(ini);

  int ans = 0;
  while(!que.empty()){
    Path path = que.front();
    que.pop();

    if(path.size() >= n){
      ans++;
      continue;
    }

    int back = path.back();
    //printf("back = %d\n", back);

    for(int i = 1; i <= n; i++){
      // i in path -> continue
      if(find(path.begin(), path.end(), i) != path.end()) continue;

      //printf("i = %d\n", i);

      if(connected[back][i]){
        Path path1 = path;
        path1.push_back(i);
        que.push(path1);
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 1536
# AOJ 1611 ダルマ落とし
# 貰うdp

import sys


def main():
    while True:
        N = int(input())
        if N == 0:
            break
        w = list(map(int, sys.stdin.readline().strip().split()))

        # dp 初期化 -------------------------------------------------
        dp = [[0] * N for _ in range(N)]

        for i in range(N - 1):
            if abs(w[i] - w[i + 1]) <= 1:
                dp[i][i + 1] = 2

        # dp 更新 ------------------------------------------------------
        for l in range(2, N):
            for i in range(N - l):
                j = i + l

                if l % 2 == 1:
                    if dp[i + 1][j - 1] == l - 1 and (abs(w[i] - w[j]) <= 1):
                        dp[i][j] = l + 1
                        continue

                for k in range(i, j):
                    if dp[i][j] < dp[i][k] + dp[k + 1][j]:
                        dp[i][j] = dp[i][k] + dp[k + 1][j]
                        if dp[i][j] == l:
                            break

        # for i in range(len(dp)):
        #     print(dp[i])

        print(dp[0][-1])


if __name__ == '__main__':
    main()



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

int main() {
  vector<int> v(5);
  for(int i = 0; i < 5; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < 5; ++i) {
    if(i) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

int main(void){
	int n, x;
	int num1, num2, num3;

	for (;;){
		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0){
			break;
		}
		else{
			int count = 0;
			for (num3 = 3; num3 <= n; num3++){
				for (num2 = 2; num2 < num3; num2++){
					for (num1 = 1; num1 < num2; num1++)
					{
						if (num1 + num2 + num3 == x){
							count += 1;
						}
					}
				}
			}
			printf("%d\n", count);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

long long int MOD = 1e9+7;

int main(){

  // read problem
  long long int N, tmp;
  std::vector<long long int> A;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }

  // solve problem
  std::vector<long long int> tmp_state(N);
  tmp_state[0] = 3;
  long long int ans = 1;
  for(long long int i = 0; i < N; i++){
    if(tmp_state[A[i]] > 0){
      // update answer
      ans *= tmp_state[A[i]];
      ans = (ans + MOD)%MOD;
      // update state
      tmp_state[A[i]]--;
      tmp_state[A[i]+1]++;
    }
    else{
      ans = 0;
      break;
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
        int N;
        cin >> N;
        int a[] = {105, 135, 165, 189, 195};
        int ans = 0;
        rep(i, 5)
        {
                if (a[i] <= N)
                {
                        ans++;
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> r(3);
    REP(i, 3) cin >> r[i];
    sort(r.begin(), r.end());
    cout << r[0] + r[1] << '\n';
    return 0;
}


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

typedef long long ll;

const long double PI = (acos(-1));


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

  string s;
  cin >> s;

  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//2018年  3月 21日 水曜日 21:38:44 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int H, W;
int G[11][11];

void solve() {
	cin >> H >> W;
	rep(i, 0, 10) {
		rep(j, 0, 10) cin >> G[i][j];
	}
	rep(k, 0, 10) {
		rep(i, 0, 10) {
			rep(j, 0, 10) {
				MIN(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	int res = 0;
	rep(i, 0, H) {
		rep(j, 0, W) {
			int a; cin >> a;
			if(a == -1) continue;
			res += G[a][1];
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	bool ans = true;
	int n;
	cin >> n;
	vector<string> w(n);
	rep(i,n) cin >> w[i];

	rep(i,n-1){
		if(w[i].back() != w[i+1][0]) ans = false;
	}

	rep(i,n){
		size_t cnt = count(w.begin(), w.end(), w[i]);
		if(cnt >= 2) ans = false;
	}

	if(ans) cout << "Yes" <<endl;
	else cout << "No" <<endl;
	return 0;
}


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

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int A[100];
int B[100];

int main()
{
  int cnt;
  int64 N;
  int64 i;
  int64 result = 0;

  get_N(&N);

  for (i=0; i<(N-1); i++){
    cnt = scanf("%d", &B[i]);
    A[i] = -1;
  }
  A[N-1] = -1;

  for (i=0; i<(N-1); i++) {
    if (A[i] == -1) {
      A[i] = B[i];
    }
    if (A[i] > B[i]) {
      A[i] = B[i];
    }
    if (A[i+1] == -1) {
      A[i+1] = B[i];
    }
    if (A[i+1] > B[i]) {
      A[i+1] = B[i];
    }
  }
// A 0 0   10 10 10 23
// B 0 153 10 10 23

  for (i=0; i<N; i++) {
    result += A[i];
  }

  printf("%lld", result);

  return 0;
}



Measured memory_bytes: 128
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

int n,m;
int r,s,t,u;
int dis[1001][1001];

char a[1001][1001];

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

bool valid(int x,int y){
	if (x<0 || y<0 || y>m-1 || x>n-1)
		return false;
	if (a[x][y]=='#')
		return false;
	return true;
}


signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	cin>>n>>m;
   	cin>>r>>s;
   	cin>>t>>u;
   	r-=1;
   	s-=1;
   	t-=1;
   	u-=1;
  	memset(dis,mod,sizeof(dis));
   	for (int i=0;i<n;++i){
   		for (int j=0;j<m;++j)
   			cin>>a[i][j];
   	}
	dis[r][s] = 0;
	deque<array<int,2>> q;
	q.push_front({r,s});
	while (!q.empty()) {
	    int x = q.front()[0];
	    int y = q.front()[1];
	    q.pop_front();
	    for (int i=0;i<4;++i){
	    	int nx = dx[i]+x;
		    int ny = dy[i]+y;
		    if (!valid(nx,ny))
		      	continue;
		    if (dis[x][y]<dis[nx][ny] ) {
		        dis[nx][ny] = dis[x][y];
		        q.push_front({nx,ny});
	    	}		
	    }
	    for (int nx=x-2;nx<=x+2;++nx) {
	    	for (int ny=y-2;ny<=y+2;++ny){
		        if (!valid(nx,ny))
		        	continue;
		        if (dis[x][y] + 1< dis[nx][ny] ) {
		            dis[nx][ny] = dis[x][y] + 1;
		            q.push_back({nx,ny});
	    	    }		
            }	
    	}
	}
   	cout<<((dis[t][u]>mod)?-1:dis[t][u])<<endl;
   	return 0;
}

Measured memory_bytes: 12620
<?php
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
//fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
$s=fgets(STDIN);
$array=explode(' ', $s);
$sum = 0;

for($i=0; $i<$a; $i++){
  $sum += 1 / $array[$i];
}
echo 1 / $sum;
?>

Measured memory_bytes: 3828
import numpy as np

n=int(input())
d_list=list(map(int,input().split()))
d=np.array(d_list)
s=0

for i in range(n):
	for j in range(1,n):
		if j>i:
			s1=d[i]*d[j]
			s+=s1

print(s)


Measured memory_bytes: 21132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int w, h, x, y; cin >> w >> h >> x >> y;
  cout << double(w) * double(h) / 2 << " " << (x * 2 == w && y * 2 == h ? 1 : 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	set<string> s;
	int n;
	cin>>n;
	rep(i,0,n){
		string x;
		cin>>x;
		s.insert(x);
	}
	cout<<sz(s);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(30)<<fixed;
	
	string s;
	cin>>s;
	s+='#';
	int c=0;
	int c1=0;
	for(int i=0;i<4;i++)
	{
		if(s[i]=='R')
			c1++;
		else
		{
			c=max(c,c1);
			c1=0;
		}
	}
	cout<<c<<endl;
	return 0;
}





Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



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

    vector < int > v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k - 1];

    return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t i = 1; i < N; i++) {
        int a;
        cin >> a;
        A[a - 1]++;
    }
    for (int64_t i = 0; i < N; i++) {
        cout << A[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4844
import sys
sys.setrecursionlimit(10000000)


def main():
    X = int(input())
    a = 100
    year = 0
    while(True):
        a = int(a * 1.01)
        year += 1
        if a >= X:
            print(year)
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

		public static void main(String args[]) throws IOException{
			Scanner scan = new Scanner(System.in);

			double cx1, cy1, r1;
			double cx2, cy2, r2;
			
			//if(args.length != 0){
				cx1 = scan.nextDouble();
				cy1 = scan.nextDouble();
				r1 = scan.nextDouble();
				cx2 = scan.nextDouble();
				cy2 = scan.nextDouble();
				r2 = scan.nextDouble();
				
				double l = (Math.pow(cx1 - cx2, 2) + Math.pow(cy1 - cy2, 2));
				double rlen = r1+r2;
				double revlen = r1 - r2;
				if(l > rlen*rlen) 
					System.out.println("4");
				else if(l == rlen*rlen) 
					System.out.println("3");
				else if(l < rlen*rlen) {
					if(l > revlen*revlen)
						System.out.println("2");
					else if(l == revlen*revlen)
						System.out.println("1");
					else if(l < revlen*revlen)
						System.out.println("0");
				}
			//}
				scan.close();
			//else System.out.println("Input doesn't be exist");
		}	
	}


Measured memory_bytes: 28092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int k=s.nextInt();
        int [] arr= new int[n];
        for(int i=0;i<n;i++)
            arr[i]=s.nextInt();
        for(int i=k;i<n;i++){
            if(arr[i] > arr[i-k]){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }

    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 73512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  if (n & 1) {
    cout << "No\n";
    return 0;
  }
  string s; cin >> s;
  cout << (s.substr(0, s.length() / 2) == s.substr(s.length() / 2) ? "Yes\n" : "No\n");
  return 0;
}


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

int n, m;

vector<int> factor;

int main()
{
    scanf("%d%d", &n, &m);

    int i;
    for(i=1; i*i<m; i++)
    {
        if(m%i!=0) continue;
        factor.push_back(i);
        factor.push_back(m/i);
    }
    if(i*i==m) factor.push_back(i);

    sort(factor.begin(), factor.end(), greater<int>());

    for(i=0; i<factor.size(); i++)
    {
        if(m/factor[i]>=n)
        {
            printf("%d", factor[i]);
            return 0;
        }
    }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int x;  cin>>x;
  if(30<=x){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!

import queue
import sys
input = sys.stdin.readline
        
N, Q = map(int, input().rstrip().split())
e = [list(map(lambda x: int(x)-1, input().rstrip().split())) for _ in range(N-1)]
q = [list(map(int, input().rstrip().split())) for _ in range(Q)]

v2e = [set() for _ in range(N)]
for a, b in e:
    v2e[a].add(b)
    v2e[b].add(a)

v = [0] * N
for i in range(Q):
    v[q[i][0]-1] += q[i][1]
    
que = queue.Queue()
que.put((0, 0))
f = [False] * N
f[0] = True
while que.qsize() > 0:
    a, b = que.get()
    v[a] += b
    for c in v2e[a]:
        if f[c] == False:
            que.put((c, v[a]))
            f[c] = True
            
print(' '.join(list(map(str, v))))

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

void solve(int64_t N, string S)
{
    string res;
    for (auto c : S)
    {
        res += (c - 'A' + N) % 26 + 'A';
    }
    cout << res << endl;
}

int main()
{
    int64_t N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const int di[4] = { 1,0,-1,0 };
const int dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n,a[100010],ans;
double ave;
double diff=1000000;

void input(){
		cin>>n;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<n;i++)ave+=a[i];
		ave/=(double)n;
	return;
}


void solve(){
	for(int i=0;i<n;i++){
		if(diff>abs(ave-(double)a[i])){
			ans=i;
			diff=abs(ave-(double)a[i]);
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K; cin>>N>>K;
  int memo; cin>>memo;
  int ans=0;
  if(memo>K){
    ans+=memo-K;
    memo=K;
  }
  rep(i,1,N){
    int X; cin>>X;
    if(X+memo>K){
      int Z=memo+X-K;
      ans+=Z;
      X-=Z;
    }
    memo=X;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        int w = 0;
        for (int i = 0; i < H; i++) {
        	char[] map = sc.next().toCharArray();
        	for (int j = 0; j < W; j++) {
        		if (map[j] == '#' && w <= j) {
        			w = j;
        		} else if (map[j] == '#' && w > j) {
        			System.out.println("Impossible");
        			return;
        		}
        	}
        }
        
        System.out.println("Possible");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


template<class T>
vector<T> cumsum1d(const vector<T> &v){
    int size = v.size();
    vector<T> cum(size+1,0);
    for(int i = 0; i < size; i++){
        cum[i+1] = v[i] + cum[i];
    }
    return cum;
}

int main() {
    ll n, num;
    cin >> n >> num;

    vector<ll> p(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    vector<ll> group(n, -1);
    vector<vector<ll>> loops(n);
    ll group_id = 0;
    for(int i = 0; i < n; i++){
        ll idx = i;
        if(group[idx] != -1){continue;}

        while(group[idx] == -1){
            group[idx] = group_id;
            loops[group_id].push_back(c[idx]);
            idx = p[idx];
        }
        group_id++;
    }

    for(int i = 0; i < group_id; i++){
        int lim = loops[i].size();
        for(int j = 0; j < lim; j++){
            loops[i].push_back(loops[i][j]);
        }
    }

    vector<vector<ll>> loops2(group_id);
    for(int i = 0; i < group_id; i++){
        loops2[i] = cumsum1d(loops[i]);
    }

    vector<ll> loop_sum(group_id, 0);
    for(int i = 0; i < group_id; i++){
        loop_sum[i] = loops2[i][loops[i].size()/2];
    }

    ll ans = -1e9-1;
    for(int i = 0; i < group_id; i++){
        ll size =  loops[i].size()/2;
        for(int j = 0; j < size; j++){
            for(int k = j+1; k < j+1 + size; k++){
                if(num < k-j){continue;}
                ll tmpsum = loops2[i][k] - loops2[i][j];
                ans = max(ans, tmpsum);
                if(loop_sum[i] > 0){
                    ans = max(ans, tmpsum + (num - (k-j))/size*loop_sum[i]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4104
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF 1000000000
int n;
vector <int> G[100000];
int d1[100000],dn[100000];

void dfs(int i,int d,int ar[]) {
	ar[i] = d;

	REP(j,G[i].size()) {
		if(ar[G[i][j]] == INF) {
			dfs(G[i][j],d + 1,ar);
		}
	}
}

int main(){
	cin >> n;
	REP(i,n - 1) {
		int a,b;
		cin >> a >> b;
		a--;b--;

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

	REP(i,n) {
		d1[i] = dn[i] = INF;
	}

	dfs(0,0,d1);
	dfs(n-1,0,dn);

	if(n % 2) {
		int c = 0;
		FOR(i,1,n - 1) {
			if(d1[i] <= dn[i]) {
				c++;
			}
		}

		if(c >= (n - 1) / 2){
			cout << "Fennec" << endl;
		}else{
			cout << "Snuke" << endl;
		}
	}else {
		int c = 0;
		FOR(i,1,n - 1) {
			if(d1[i] > dn[i]) {
				c++;
			}
		}
		if(c >= (n - 2) / 2) {
			cout<< "Snuke" << endl;
		}else {
			cout << "Fennec" << endl;
		} 
	}
	
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    
    int n;
    cin >> n;
    int w[n];
    inrep(n,w);
    //   sort(w,w+n);

    int ww[n] = {};
    ww[0] = w[0];
    rep(i,1,n)ww[i] = ww[i-1] + w[i];

    int ans = inf;

    //  rep(i,0,n)PS(ww[i]);
    //  cout << endl;
    rep(i,0,n-1){

	ans = min(ans,  abs( ww[i] - (ww[n-1] -ww[i] )  ) );
    }
    P(ans);
    
    return  0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

int main() {
    int n, a, b;
    vector<int> p1, p2, p3;
    cin >> n >> a >> b;
    int p;
    for (int i = 0; i < n; i++) {
        cin >> p;
        if (p <= a) p1.push_back(p);
        else if (p <= b) p2.push_back(p);
        else p3.push_back(p);
    }
    int ans = min(p1.size(), min(p2.size(), p3.size()));
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())

l = [chr(i) for i in range(65,65+26)]*2

alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
    alpha_dict[chr(c)] = i

ans = ''
for i in range(len(s)):
  j = alpha_dict[s[i]]
  ans += l[j+n]
  
print(ans)

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for(int i = 0; i < n; i++){
        std::cin >> h[i];
    }
    int sum = 1;
    int maxv = h[0];
    for(int i = 1; i < n; i++){
        if(maxv <= h[i] && h[i] >= h[i-1]){
            sum++;
        }
        maxv = std::max(maxv, h[i]);
    }
    std::cout << sum;
    return 0;
}


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

using namespace std;
int mn = 1;
int utility(int idx, string &s, vector<int> dislikes) {
	if (idx == -1) {
      string tmp;
      tmp += mn + '0';
      tmp += s;
      s = tmp;
      return 0;
    }
  int x = s[idx] - '0';
  int j;
  for (j = x + 1; j < 10 && find(dislikes.begin(), dislikes.end(), j) != dislikes.end(); ++j);
  if (j == 10)
    return utility(idx - 1, s, dislikes);
  s[idx] = j + '0';
  return idx;
  
}

string solve(string n, int k, vector<int> dislikes) {
  	int i;
	for (i = 0; i < n.size(); ++i) {
    	if (find(dislikes.begin(), dislikes.end(), n[i] - '0') != dislikes.end()) {
        		
          i = utility(i, n, dislikes) + 1;
          	break;
        }
    }
 
  if (find(dislikes.begin(), dislikes.end(), 0) == dislikes.end())
    mn = 0;
  while (i < n.size()) {
    n[i] = mn + '0';
    ++i;
  }
  return n;
}

int main() {

   	string n;
  	cin >> n;
	int k;
  	cin >> k;
    vector<int> dislikes(k);
    for(int &d : dislikes)
        cin >> d;

  while (find(dislikes.begin(), dislikes.end(), mn) != dislikes.end())
    ++mn;
    cout << solve(n, k, dislikes) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<tuple<int, int, int>> wow;
	REP(i, n-1) {
		int a, b, c;
		cin >> a >> b >> c;
		wow.push_back(make_tuple(a, b, c));
	}
	for (int i = 0;i < n;++i) {
		int ans = 0;
		for (int q = i;q < n-1;++q) {
			if (ans < get<1>(wow[q])) {
				ans = get<1>(wow[q]) + get<0>(wow[q]);
			}else{
				int gogo = ans - get<1>(wow[q]);
				if (gogo % get<2>(wow[q]) != 0) {
					ans += get<0>(wow[q]) + get<2>(wow[q]) - (gogo % get<2>(wow[q]));
				}
				else {
					ans += get<0>(wow[q]);
				}
			}
		}
		cout << ans << endl;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;
int n;
int b[MAXN];

void solve() {
  ll sum = 0;
  for (int i=0;i<n;i++) {
    if (i == 0) {
      sum += b[i];
    } else if (i == n - 1) {
      sum += b[n-2];
    } else {
      sum += min(b[i], b[i-1]);
    }
  }
  cout << sum << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n-1;i++) {
    cin >> b[i];
  }
  solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,C,X;
    scanf("%d%d%d%d",&A,&B,&C,&X);
    int num = 0;
    for(int i=0;i<=A;i++)
    {
        for(int j=0;j<=B;j++)
        {
            for(int k=0;k<=C;k++)
            {
                if(i*500+j*100+k*50==X)num++;
            }
        }
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 128
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val Array(x, y) = input.split(" ").map(_.toInt)
    if ((x * 2 to x * 4 by 2).contains(y)) "Yes" else "No"
  }

  def medianCalculator(seq: Seq[Long]): Long = {
    //In order if you are not sure that 'seq' is sorted
    val sortedSeq = seq.sortWith(_ < _)

    if (seq.size % 2 == 1) sortedSeq(sortedSeq.size / 2)
    else {
      val (up, down) = sortedSeq.splitAt(seq.size / 2)
      (up.last + down.head) / 2
    }
  }

  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """3 8""".stripMargin -> """Yes
                               |
                                     |
                                   |
                                   |""".stripMargin,
    """2 100""".stripMargin -> """No
                                 |""".stripMargin,
    """1 2""" -> """Yes"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55276
#include <stdio.h>

int main(void)
{
	int S, h, m, s;
	scanf("%d", &S);
	
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	printf("%d:%d:%d\n", h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>

int main(void)
{
    int h,w;
    int i,j;

    scanf("%d%d",&h,&w);

    char a[h+1][w+1];
    int score[h+1][w+1];
    int ver[h+1][w+1];
    int hor[h+1][w+1];

    for(i=0;i<=h;i++){
        for(j=0;j<=w;j++){
            score[i][j]=0;
            ver[i][j]=0;
            hor[i][j]=0;
        }
    }

    for(i=1;i<=h;i++){
            scanf("%s",&a[i]);
    }

    for(i=1;i<=h-1;i++){
        for(j=0;j<=w-1;j++){
            if(a[i][j] == '.' && a[i+1][j] == '#')
                ver[i+1][j] = 1;
        }
    }

    for(i=1;i<=h;i++){
        for(j=0;j<=w-2;j++){
            if(a[i][j] == '.' && a[i][j+1] == '#')
                hor[i][j+1] = 1;
        }
    }

    if(a[1][0] == '.')
        score[1][0]=0;
    else
        score[1][0]=1;
    
    for(j=1;j<=w-1;j++){
        score[1][j]=score[1][j-1] + hor[1][j];
    }

    for(i=2;i<=h;i++){
        score[i][0]= score[i-1][0] + ver[i][0];
        for(j=1;j<=w-1;j++){
            if(score[i-1][j]+ver[i][j]>=score[i][j-1]+hor[i][j])
                score[i][j]=score[i][j-1]+hor[i][j];
            else
                score[i][j]=score[i-1][j]+ver[i][j];
        }
    }

    printf("%d\n",score[h][w-1]);

    return 0;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    
    bool ok = true;
    for (auto e : a) if (e % 2 == 0) {
        if (e % 3 == 0 || e % 5 == 0) continue;
        else ok = false;
    }
    
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, i;
    double xa, ya, ra, xb, yb, rb;
    double dd;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
        dd = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
        if (dd > (ra + rb) * (ra + rb)) {
            printf("0\n");
        } else {
            if (ra > rb && dd < (ra - rb) * (ra - rb)) {
                printf("2\n");
            } else if (ra < rb && dd < (rb - ra) * (rb - ra)) {
                printf("-2\n");
            } else {
                printf("1\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 620
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]

dp=[[-float('inf')]*101*400 for i in range(n+1)]
dp[0][0]=0

kijun=wv[0][0]
for i in range(n):
    for j in range(101*400):
        if dp[i][j]!=-float('inf'):
            dp[i+1][j]=max(dp[i+1][j],dp[i][j])
            ko,a=j//400,j%400
            dp[i+1][(ko+1)*400+a+wv[i][0]-kijun]=max(dp[i+1][(ko+1)*400+a+wv[i][0]-kijun],dp[i][j]+wv[i][1])

ans=0
for i in range(101*400):
    ko,a=i//400,i%400
    if ko*kijun+a<=w:
        ans=max(ans,dp[n][i])
print(ans)

Measured memory_bytes: 133748