akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

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

  std::vector<int> p_vec;
  for (size_t i = 0; i < n; ++i) {
    int p;
    std::cin >> p;
    p_vec.push_back(p);
  }

  int counter = 0;
  for (size_t i = 1; i < n - 1; ++i) {
    const int max = std::max({p_vec.at(i - 1), p_vec.at(i), p_vec.at(i + 1)});
    const int min = std::min({p_vec.at(i - 1), p_vec.at(i), p_vec.at(i + 1)});
    if (p_vec.at(i) != max && p_vec.at(i) != min) {
      counter++;
    }
  }

  std::cout << counter << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
	return 0;
}

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

int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e-a<=k){
        cout << "Yay!" << endl;
    }    
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int dp[51][51];
vector<string> v;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; ++i)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }

    for (int i = 0; i < 51; ++i)
    {
        for (int j = 0; j < 51; ++j)
        {
            dp[i][j] = 100000;
        }
    }

    dp[0][0] = 0;
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            if (i == 0 && j >= 1)
            {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + v[i][j] - '0');
            }
            else if (i >= 1 && j == 0)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + v[i][j] - '0');
            }
            else
            {
                dp[i][j] = min({dp[i][j], min(dp[i - 1][j], dp[i][j - 1]) + v[i][j] - '0'});
            }
        }
    }
    cout << dp[H - 1][W - 1] << endl;

    return 0;
}



Measured memory_bytes: 3240
#include <stdio.h>
#include <cstring>
#include <algorithm>
using namespace std;
int f(int n)
{
    int sum=0;
    for(int i=1;i<=n+1;i++)
        sum=sum+i;
    return sum;
}
int main()
{
    int a,b,s[1000],m[1000],c,r;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        c=b-a;
        s[0]=1;
        m[0]=0;
        for(int i=1;i<999;i++)
        {
            s[i]=f(i);
            m[i]=s[i]-s[i-1];
        }
        for(int i=0;i<999;i++)
        {
            if(m[i]==c)
            {
                r=s[i]-b;
            }
        }
        printf("%d\n",r);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

/*
  What if this problem were DP on Tree?
  And we actually want to calculate how many paths pass through u (for every u)
*/

const int maxN = 2e5; int n;
int colors[maxN]; lli ans[maxN];
int colorCnt[maxN];
vector<int> tree[maxN];

int subtreeSize[maxN];
void dfs1(int u = 0, int prv = -1)
{
  subtreeSize[u] = 1;
  for (int v: tree[u])
    if (v != prv)
    {
      dfs1(v, u);
      subtreeSize[u] += subtreeSize[v];
    }
}

lli toAdd(int branchSize)
{
  return 2LL*branchSize + (lli)branchSize*(n - branchSize - 1);
}
int colorSubtree[maxN]; int hadAbove[maxN];
void dfs2(int u = 0, int prv = -1)
{
  ans[colors[u]] += 2; // path with only u (times 2 because we will divide by 2 later)

  if (prv != -1) // parent as a child
    ans[colors[u]] += toAdd(n - subtreeSize[u]);

  int beforeAll = colorSubtree[colors[u]];

  hadAbove[colors[u]]++;

  for (int v: tree[u])
    if (v != prv)
    {
      // if (hadAbove[colors[v]] == 0)
      ans[colors[v]] -= 2LL * colorSubtree[colors[v]] * subtreeSize[v];
      DEBUG printf("left %d | %d - %d = %lld\n", colors[v] + 1, u + 1, v + 1, 2LL * colorSubtree[colors[v]] * subtreeSize[v]);

      int before = colorSubtree[colors[u]], bf = colorSubtree[colors[v]];
      hadAbove[colors[v]]--;
      dfs2(v, u);
      int after = colorSubtree[colors[u]], af = colorSubtree[colors[v]];

      ans[colors[u]] += toAdd(subtreeSize[v]);

      ans[colors[u]] -= 2LL * (after - before) * (n - subtreeSize[v] - before); // but you still need to count the ones the have passed before you (not only below)
      DEBUG printf("down %d | %d - %d = %lld\n", colors[v] + 1, u + 1, v + 1, 2LL * (after - before) * (n - subtreeSize[v] - before));
      // if (bf) ans[colors[v]] -= (af - bf) * subtreeSize[v] >> 1LL;
      // ans[colors[v]] -= 2LL * (subtreeSize[v] - (af - bf) + 1) * (bf);
    }
  // ans[colors[u]] -= 2LL * beforeAll * subtreeSize[u];

  colorSubtree[colors[u]] = beforeAll + subtreeSize[u];
}

int main()
{
  int t = 0;
  while (scanf("%d", &n) != EOF)
  {
    if (t++) printf("----------------------\n");
    for (int i = 0; i < n; i++) tree[i].clear(), ans[i] = 0, colorSubtree[i] = 0, hadAbove[i] = 0;

    for (int i = 0; i < n; i++)
    {
      scanf("%d", &colors[i]);
      colors[i]--;
      colorCnt[colors[i]]++;
    }

    for (int i = 1; i < n; i++)
    {
      int u, v; scanf("%d %d", &u, &v); u--, v--;
      tree[u].push_back(v), tree[v].push_back(u);
    }

    dfs1();
    dfs2();

    for (int i = 0; i < n; i++)
      printf("%lld\n", ans[i] >> 1LL);
  }
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  string A = "CODEFESTIVAL2016";
  int s = 0;
  for(int i = 0; i < A.size(); ++i){
    if(S.at(i) != A.at(i)) ++s;
  }
  cout << s << endl;
}

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



int64_t departure(int64_t arrival,int64_t f,int64_t s){
  if (arrival<=s){
    return s;
  }
  
  if (arrival>s){
    return ((arrival+f-1)/f)*f;
  }
}





int main(){
  


  int64_t n;
  cin>>n;
  
  vector<int64_t> cdata(n),sdata(n),fdata(n);
  
  for (int64_t i=1;i<=n-1;i++){
    int64_t c,s,f;
    cin>>c>>s>>f;
    cdata.at(i)=c;
    sdata.at(i)=s;
    fdata.at(i)=f;
  }
  
  for (int64_t i=1;i<=n;i++){
    
    int64_t arrival=0;
    
    for (int64_t j=i+1;j<=n;j++){
      arrival=departure(arrival,fdata.at(j-1),sdata.at(j-1))+cdata.at(j-1);
    }
    
    cout<<arrival<<endl;
  }
  
  
    
      
  

      
  
    

  
  
    
  
  
  
}

Measured memory_bytes: 256
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const list_a = myconv(input[1], 4);
  const list_b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();

  a = Math.min.apply(null, list_a);
  b = Math.min.apply(null, list_b);
  let m = a + b;

  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0] - 1;
    let y = myconv(input[i], 4)[1] - 1;
    let c = myconv(input[i], 4)[2];
    let deals = list_a[x] + list_b[y] - c;
    if (deals < m) {
      m = deals;
    }
  }
  console.log(m);
}
Main(myin());

Measured memory_bytes: 63952
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	stack<char> stc;
	int ans = 0;
	rep(i, s.size()){
		char c = s[i];
		if(c == ('0')){
			if(!stc.empty() && stc.top() == '1'){
				stc.pop();
				ans += 2;
			}else{
				stc.push(c);
			}
		}else{
			if(!stc.empty() && stc.top() == '0'){
				stc.pop();
				ans += 2;
			}else{
				stc.push(c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
#define NMAX 100000

// 入力
int N, M;
int dp[NMAX];        // メモ化再帰
vector<int> G[NMAX]; // グラフ
// vector<vector<int>> G; // グラフ

int rec(int v) {
    if (dp[v] != 0)
        return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : G[v]) {
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main() {
    // 入力受け取り
    cin >> N >> M;
    // G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
    }

    // 全ノードを一通り更新しながら答えを求める
    int res = 0;
    for (int v = 0; v < N; ++v) {
        res = max(res, rec(v));
    }
    cout << res << endl;
}

Measured memory_bytes: 8192
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();//よこ

		int M = sc.nextInt();//たて

		int T = sc.nextInt();//折返し回数

		int P = sc.nextInt();//穴

		while(true) {

			if(N==0&&M==0&&P==0&&T==0) break;

			//折り紙の配列a[よこ][たて]
			int[][] a = new int[N*T*2][M*T*2];

			//初期化
			//折り紙部分は1,その他0
			for(int i=0;i<N*T*2;i++) {

				for(int j=0;j<M*T*2;j++) {

					if(i<N && j<M) a[i][j] = 1;

					else a[i][j] = 0;
				}
			}

			int[][] t = new int[T][2];

			for(int i=0;i<T;i++) {

				for(int j=0;j<2;j++) {

					t[i][j] = sc.nextInt();
				}
			}

			int[][] p = new int[P][2];

			for(int i=0;i<P;i++) {

				for(int j=0;j<2;j++) {

					p[i][j] = sc.nextInt();
				}
			}

			//↑ここまでで格納、初期化終了

			//(0,0)を左上にして考える
			int top = 0;	//折り紙の一番上

			int left = 0;//折り紙の一番左

			int count = 0;

			//折る
			while(count<T) {

				int c = t[count][1];

				if(t[count][0] == 1) {	//左から

					//まず上からt[count][1]分だけ0にする
					//次にtop+t[count][1]からt[count][1]分だけ++
					//top更新


					for(int j=0;j<M*T*2;j++) {

						int xx = 0;

						for(int i=left+c;i<left+c+c;i++) {

							a[left+c+c-xx-1][j] += a[left+xx][j];

							xx++;
						}
					}

					for(int i=left;i<left+c;i++) {

						for(int j=0;j<M*T*2;j++) {

							a[i][j] = 0;
						}
					}


					left += c;

				}else if(t[count][0] == 2) {	//上から(下から）

					for(int i=0;i<N*T*2;i++) {

						int xx = 0;

						for(int j=top;j<top+c;j++) {

							a[i][top+c+c-xx-1] += a[i][top+xx];

							xx++;
						}

					}

					for(int i=0;i<N*T*2;i++) {

						for(int j=top;j<top+c;j++) {

							a[i][j] = 0;
						}
					}

					top += c;

				}

				count++;
			}

			//穴をあける
			count = 0;

			int ans = 0;

			while(count<P) {

				int x = p[count][0];

				int y = p[count][1];

				ans = a[left+x][top+y];

				System.out.println(ans);

				count++;
			}

			//System.out.println("ANS"+ans+" N"+N);

			N = sc.nextInt();

			M =sc.nextInt();

			T = sc.nextInt();

			P = sc.nextInt();
		}
	}

}



Measured memory_bytes: 75320
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>a[i][j];
  vector<pair<int,int>> v;
  int p[h][w];
  for(i=0;i<h;i++)for(j=0;j<w;j++)p[i][j]=-1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]=='#'){
        v.push_back(pair<int,int>(i,j));
        p[i][j]=0;
      }
    }
  }
  while(cnt!=v.size()){
    int x=v[cnt].first,y=v[cnt++].second;
    if(x>0 && p[x-1][y]==-1){
      v.push_back(pair<int,int>(x-1,y));
      p[x-1][y]=p[x][y]+1;
    }
    if(x<h-1 && p[x+1][y]==-1){
      v.push_back(pair<int,int>(x+1,y));
      p[x+1][y]=p[x][y]+1;
    }
    if(y>0 && p[x][y-1]==-1){
      v.push_back(pair<int,int>(x,y-1));
      p[x][y-1]=p[x][y]+1;
    }
    if(y<w-1 && p[x][y+1]==-1){
      v.push_back(pair<int,int>(x,y+1));
      p[x][y+1]=p[x][y]+1;
    }
  }
  int ma=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      ma=max(ma,p[i][j]);
    }
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 15212
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define MOCK 0

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 300;
vector<VI> trans(const vector<VI> &a) {
  vector<VI> ret(N, VI(N));
  REP(i, 0, N) REP(j, 0, N) ret[i][j] = a[j][i];
  return ret;
}

ll calc(const vector<VI> &sig) {
  ll tot = 0;
  vector<VI> acc(N, VI(N + 1, 0));
  REP(i, 0, N) {
    REP(j, 0, N) {
      acc[i][j + 1] = acc[i][j] + sig[i][j];
    }
  }
  REP(i, 0, N) {
    REP(j, 0, N) {
      if (sig[i][j] == 0) continue;
      REP(k, j + 1, N) {
        if (sig[i][k] == 0) continue;
        int dif = k - j;
        if (i - dif >= 0) {
          int idx = i - dif;
          tot += 2 * (acc[idx][k + 1] - acc[idx][j]);
          if (sig[i - dif][j] == 1) tot--;
          if (sig[i - dif][k] == 1) tot--;
        }
        if (i + dif < N) {
          int idx = i + dif;
          tot += 2 * (acc[idx][k + 1] - acc[idx][j]);
          if (sig[i + dif][j] == 1) tot--;
          if (sig[i + dif][k] == 1) tot--;
        }
      }
    }
  }
  return tot;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
#if MOCK
  REP(i, 0, h) s[i] = string(w, '#');
#else
  REP(i, 0, h) cin >> s[i];
#endif
  ll tot = 0;
  REP(par, 0, 2) {
    vector<VI> sig(N, VI(N, 0));
    REP(i, 0, h) {
      REP(j, 0, w) {
        if (s[i][j] == '.') continue;
        if ((i + j) % 2 == par) {
          int x = (i + j - par) / 2;
          int y = (i - j - par + w) / 2;
          sig[x][y] = 1;
        }
      }
    }
    tot += calc(sig);
    sig = trans(sig);
    tot += calc(sig);
  }
  cout << tot / 2 << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    char s[h + 50][w + 50];
    for(int i = 0;i < h;i++)
    {
        for(int j = 0;j < w;j++)
        {
            cin >> s[i][j];
        }
    }
    for(int i = 0;i < h;i++)
    {
        for(int j = 0;j < w;j++)
        {
            int count = 0;
            if(s[i][j] == '#')
            {
                cout << "#";
            }
            else
            {
                if(s[i - 1][j - 1] == '#')
                {
                    count++;
                }
                if(s[i - 1][j] == '#')
                {
                    count++;
                }
                if(s[i - 1][j + 1] == '#')
                {
                    count++;
                }
                if(s[i][j - 1] == '#')
                {
                    count++;
                }
                if(s[i][j + 1] == '#')
                {
                    count++;
                }
                if(s[i + 1][j - 1] == '#')
                {
                    count++;
                }
                if(s[i + 1][j] == '#')
                {
                    count++;
                }
                if(s[i + 1][j + 1] == '#')
                {
                    count++;
                }
                cout << count;
            }
            count = 0;
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
b = deque()
Alist = list(map(int,input().split()))
i = 1
if n%2 == 0:
    for a in Alist:
        if i%2 == 0:
            b.appendleft(a)
        else:
            b.append(a)
        i += 1
else:
    for a in Alist:
        if i%2 == 0:
            b.append(a)
        else:
            b.appendleft(a)
        i +=1
print(*b)

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

#define scanf cin
#define printf cout

int main()
{
	std::ios::sync_with_stdio(false);
    string ori;
    scanf>>ori;
    string b=ori;
    reverse(ori.begin(),ori.end());
    for(int i=0;i<ori.size();++i)
    {
        if(ori[i]=='b') ori[i]='d';
        else if(ori[i]=='d') ori[i]='b';
        else if(ori[i]=='p') ori[i]='q';
        else if(ori[i]=='q') ori[i]='p';
    }
    if(ori==b) printf<<"Yes"<<endl;
    else printf<<"No"<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

void proc()
{
	int N,A[100100]; scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);

	int a = A[0], b = A[N - 1];
	for (int i = 1; i < N - 1; i++) {
		if (abs(b - 2 * a) > abs(b - 2 * A[i])) a = A[i];
	}
	printf("%d %d\n", b, a);
}

int main()
{
#ifdef __LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	proc();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (ll i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (ll i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

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

Measured memory_bytes: 256
package main

import (
  "fmt"
  "strings"
  "sort"
  "bufio"
  "os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
  var N int
  fmt.Scanf("%d", &N)
  
  // var ss []string
  
  m := map[string]uint64{}
  
  for i := 0; i < N; i++ {
    var s string
    if sc.Scan() {
      s = sc.Text()
    }
    
    arr := strings.Split(s, "")
    sort.Strings(arr)
    str := strings.Join(arr, "")
    
    m[str] = m[str] + 1
  }
  
  var cnt uint64
  for _, v := range m {
    for i := v-1; i > 0; i-- {
      cnt += i
    }
  }
  
  fmt.Println(cnt)
}

Measured memory_bytes: 11776
#include <iostream>
using namespace std;
 
int main() {
    
    int H,W;
    cin >> H >> W;

    string s[H];
    
    for (int i=0 ; i<H ;i++){
        cin >> s[i];
    }
    
    char M[H+2][W+2];
    
    for (int j=0 ; j<W+2 ;j++){
        M[0][j] = '.';
        M[H+1][j] = '.';
    }
    for (int i=0 ; i<H+2 ;i++){
        M[i][0] = '.';
        M[i][W+1] = '.';
    }
    
    for (int i=1 ; i<H+1 ;i++){
        for(int j=1 ;j<W+1 ;j++){
            M[i][j] = s[i-1].at(j-1);
        }
    }
    
    /*
    for (int i=0 ; i<H+2 ;i++){
             for(int j=0 ;j<W+2 ;j++){
                 cout << M[i][j] ;
             }
          cout <<endl;
      }
     */
    
    cout <<endl;
    
    for (int i=1 ; i<H+1 ;i++){
        for(int j=1 ;j<W+1 ;j++){
            
            if( M[i][j] == '#'){
                cout << '#';
            }
            else{
                int counter =0;
                
                for (int m=-1 ; m<2 ;m++){
                    for(int n=-1 ; n<2 ;n++){
                        if( M[i+m][j+n] == '#'){
                            counter++ ;
                        }
                    }
                }
                cout << counter ;
            }
        }
        cout <<endl;
    }
    
    cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<i64> a(n, 0);
  while (q--) {
    int p, x;
    cin >> p >> x;
    --p;
    a[p] += x;
  }
  function<void(int,int)> dfs = [&] (int u, int p) {
    for (const int &v : g[u]) if (v != p) {
      a[v] += a[u];
      dfs(v, u);
    }
  };
  dfs(0, -1);
  for (i64 x : a) {
    cout << x << ' ';
  }
  cout << '\n';
    
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);

    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        double s = 0;
        for (int ii = 1; ii < n; ii++) {
            int i = ids[ii], j = ids[ii - 1];
            int xx = x[i] - x[j];
            int yy = y[i] - y[j];
            int tmp = xx * xx + yy * yy;
            s += sqrt(tmp);
        }
        sum += s;
    } while (next_permutation(ids.begin(), ids.end()));
    sum /= cnt;
    cout << fixed << setprecision(15) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())

def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        if tmp == 1:
            ans += 1*K
        else:
            for k in range(1,K+1):
                ans += gcd(gcd(i,j), k)

print(ans)

Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[110000][13];
const int mod = 1000000007;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n)rep(j,13){
        if(s[i] == '?')rep(a,10){
            (dp[i+1][(j*10+a)%13] += dp[i][j])%mod;
            dp[i+1][(j*10+a)%13] %= mod;
        }
        else{
            int x = s[i] - '0';
            (dp[i+1][(j*10+x)%13] += dp[i][j])%mod;
            dp[i+1][(j*10+x)%13] %=mod;

        }
    }
    cout << dp[n][5]%mod << endl;




    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int  i = 0 ; i < n ; i++ ) 
typedef long long ll ;
int main(){
    int N ;
    cin >> N ;
    int A  ;
    int count4 = 0  ;
    int count2 = 0  ;
    rep(i,N){
        cin >> A ;
        if( A%2 == 0 && A%4 != 0 ) count2++ ;
        if( A%4 == 0 ) count4 ++ ;
    } 
    if( (N-count2)%2 == 0 ){
        if( (N-count2) <= 2*count4 ){
            cout << "Yes" << endl;
            return 0 ;
        }
        else{
            cout << "No" << endl;
            return 0 ;
        }
    }
    if( (N-count2)%2 == 1 && count2 > 0 ){
        if( (N-count2) + 1 <= 2*count4 ){
            cout << "Yes" << endl;
            return 0 ;
        }
        else{
            cout << "No" << endl;
            return 0 ;
        }
    }
    if( N%2 == 1 ){
        if( N - 1 <= 2*count4 ){
            cout << "Yes" << endl;
            return 0 ;
        }
        else{
            cout << "No" << endl;
            return 0 ;
        }
    }
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    double a,b,n,t=0,t1=0,i;
    scanf("%lf%lf%lf",&a,&b,&n);
    t=a;
    t1=b;
    if(a>n)
    {
        printf("0\n");
    }
    else
    {
        for(i=a;i<=n+0.5;i=i+t)
        {
            if((i+t)>n+0.5)
            {
                break;
            }
            b=b+t1;
        }
        printf("%.lf\n",b);
    }
    return 0;
}


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

int main()
{
	int H, N, power = 0;

	cin >> H >> N;
	for (int i = 0; i < N; i++)
	{
		int p;
		cin >> p;
		power += p;
	}

	if (H > power)
	{
		cout << "No" << endl;
		return 0;
	}
	else
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        double a = input.nextDouble();
        double b = input.nextDouble();
        double c = input.nextDouble();
        double h = Math.abs(b * Math.sin(c / 180 * Math.PI));
        System.out.println(a * h / 2);
        double aa = a + (90 <= c && c <= 270 ? 1 : -1) * Math.sqrt(Math.pow(b,2) - Math.pow(h,2));
        System.out.println(a+b+Math.sqrt(Math.pow(aa,2)+Math.pow(h,2)));
        System.out.println(h);
    }
}

Measured memory_bytes: 18208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <queue>
typedef long long lint;
const int N=1e5+5;
int n,qx,qy,qz;
lint sum_z,cx[N],cy[N];
struct _pair{
	int x,y;
}pep[N];

template <class T> inline void apx(T &x,const T y){
	x<y?x=y:0;
}

inline int nxi(FILE *fd=stdin){
	int x=0;
	char c;
	while((c=fgetc(fd))>'9'||c<'0');
	while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
	return x;
}

inline bool _pr_cmp_dif(const _pair &a,const _pair &b){
	return (a.x-a.y)<(b.x-b.y);
}

void solve(){
	static std::priority_queue <int> pq;
	lint sum=0;
	for(int i=1; i<=qy; ++i){
		sum+=pep[i].y;
		pq.push(-pep[i].y);
	}
	cy[qy]=sum;
	for(int i=qy+1; i<=n-qx; ++i){
		if(pep[i].y>-pq.top()){
			sum+=pep[i].y;
			pq.push(-pep[i].y);
			sum+=pq.top();
			pq.pop();
		}
		cy[i]=sum;
	}
	while(!pq.empty()) pq.pop();
	sum=0;
	for(int i=n-qx+1; i<=n; ++i){
		sum+=pep[i].x;
		pq.push(-pep[i].x);
	}
	cx[n-qx+1]=sum;
	for(int i=n-qx; i>qy; --i){
		if(pep[i].x>-pq.top()){
			sum+=pep[i].x;
			pq.push(-pep[i].x);
			sum+=pq.top();
			pq.pop();
		}
		cx[i]=sum;
	}
}

int main(){
	qx=nxi(),qy=nxi(),qz=nxi();
	n=qx+qy+qz;
	for(int i=1; i<=n; ++i){
		const int x=nxi(),y=nxi(),z=nxi();
		sum_z+=z;
		pep[i]=(_pair){x-z,y-z};
	}
	std::sort(pep+1,pep+n+1,_pr_cmp_dif);
	solve();
	lint ans=-1e16;
	for(int i=qy; i<=n-qx; ++i){
		apx(ans,cy[i]+cx[i+1]);
	}
	printf("%lld\n",ans+sum_z);
	return 0;
}


Measured memory_bytes: 2304
#include <string>
#include <queue>
#include <iostream>

using namespace std;

int main()
{
	priority_queue<int> height;
	int i = 0, tmp;

	while ( i < 10 )
	{
		cin >> tmp;
		height.push( tmp );
		i = i + 1 ;
	}
	
	for ( i = 0 ; i < 3 ; i = i + 1 )
	{
		cout << height.top() << endl;
		height.pop();
	}

	return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    string s;
    ll q;
    cin >> s >> q;

    string ans = "";
    string ans_l = "";
    string ans_r = "";

    ll f;
    char c;

    bool flag = false;
    REP(i,q){
        ll t;
        cin >> t;
        if(t == 1){
            flag = flag ? false:true;
        }else{
            cin >> f >> c;
            if(f == 1){
                if(!flag){
                    ans_l = c + ans_l;
                }else{
                    ans_r = ans_r + c;
                }
            }else{
                if(!flag){
                    ans_r = ans_r + c;
                }else{
                    ans_l = c + ans_l;
                }
            }
        }
    }

    if(flag){
        reverse(all(s));
        reverse(all(ans_l));
        reverse(all(ans_r));
        ans += s;
        ans = ans_r + s + ans_l;
    }else{
        ans += s;
        ans = ans_l + s + ans_r;
    }

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

Measured memory_bytes: 1416
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);
  bool res = a <= x && x <= a+b;
  if(res) printf("YES\n");
  else printf("NO\n");
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x-r<0||y-r<0||x+r>w||y+r>h){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        struct Point
        {
            internal double x, y;
        }

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] nums = Array.ConvertAll(input.Split(' '), double.Parse);

                Point a, b, c, p;
                a.x = nums[0]; a.y = nums[1];
                b.x = nums[2]; b.y = nums[3];
                c.x = nums[4]; c.y = nums[5];
                p.x = nums[6]; p.y = nums[7];

                sb.AppendLine(IsContain(a, b, c, p) ? "YES" : "NO");
            }
            Console.Write(sb);
        }

        static bool IsContain(Point a, Point b, Point c, Point p)
        {
            double c1 = Cross(a, b, p);
            double c2 = Cross(b, c, p);
            double c3 = Cross(c, a, p);

            if (c1 > 0 && c2 > 0 && c3 > 0) return true;
            if (c1 < 0 && c2 < 0 && c3 < 0) return true;

            return false;
        }

        static double Cross(Point p0, Point p1, Point p2)
        {
            Point a, b;
            a.x = p1.x - p0.x; a.y = p1.y - p0.y;
            b.x = p2.x - p0.x; b.y = p2.y - p0.y;

            return a.x * b.y - a.y * b.x;
        }
    }
}

Measured memory_bytes: 9324
import java.util.Arrays;
import java.util.Scanner;

//Balloon Collecting
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int[] b = new int[4];
			Arrays.fill(b, 1<<29);
			int p = sc.nextInt(), t = sc.nextInt();
			if(p<=t)b[1] = p;
			int k = p<=t?0:1;
			for(int j=1;j<n;j++){
				int pos = sc.nextInt(), time = sc.nextInt();
				if(k!=0)continue;
				int d = Math.abs(p-pos), dt = Math.abs(time-t);
				int[] nb = new int[4];
				Arrays.fill(nb, 1<<29);
				for(int i=1;i<4;i++){
					if(b[i]==1<<29)continue;
					//put balloon and get
					if(p*(i+1)+pos<=dt){
						nb[1] = Math.min(nb[1], b[i]+p+pos);
					}
					if(i==3)continue;
					if(d*(i+1)<=dt){
						nb[i+1] = Math.min(nb[i+1], b[i]+d);
					}
				}
				b = nb; p = pos; t = time;
				if(b[1]==1<<29&&b[2]==1<<29&&b[3]==1<<29)k = j+1;
			}
			if(k!=0){
				System.out.println("NG "+k); continue;
			}
			int res = 1<<29;
			for(int i=1;i<4;i++)if(b[i]!=-1)res = Math.min(res, b[i]+p);
			System.out.println("OK "+res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
	int H, W;
	for(int i=0 ; ; i++){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}else{
			for(int ii=1 ;ii<=H; ii++){
				for(int iii=1 ;iii<=W; iii++){
					if(ii==H || ii==1 || iii==W || iii==1){
						cout << "#";
					}else{
						cout << ".";
					}
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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


bool dp[5010][5010];


int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    // 単調性が成り立つことを示す。
    // k - a[i] <= S < k となるSが存在するとすると、
    // a[j] > a[i] を満たす任意のa[j]について、k - a[j] <= S' < k が成り立つようなS'が存在することが示せる。
    // (Sに a[j]が含まれる場合と、a[j]が含まれない場合に分けると示せた。)

    int left = -1;
    int right = n;
    int mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        bitset<5010> dp;
        dp[0] = 1;

        rep(i, n) {
            if (i != mid) {
                dp = dp | (dp << a[i]);
            }
        }

        bool flag = 0;
        for (int j = max(0, k - a[mid]); j < k; j++) {
            flag |= dp[j];
        }
        if (flag) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;

    return 0;
}


    

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n;
	cin >> n;

	ll ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = i; j <= n; j += i)
		{
			ans += j;
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	string result = "No";

	if (a == b && b != c)
	{
		result = "Yes";
	}
	
	if (a == c && a != b)
	{
		result = "Yes";
	}

	if (b == c && a != b)
	{
		result = "Yes";
	}

	cout << result << endl;
    return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int count=0;
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(b/a>=c){
		printf("%d\n",c);
	}else{
		printf("%d\n",b/a);
	}
	
	return 0;
}
		

Measured memory_bytes: 128
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab = sorted(ab, key=lambda x:(x[1],-x[1]))

total = 0
for a, b in ab:
    total += a
    if total <= b:
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Measured memory_bytes: 116152
import java.util.*;
public class Main {
static Scanner inp=new Scanner(System.in);
static int a[]=new int [100000];
    public static void sort(int x,int y){
        int l=x;
        int r=y;
        int m=a[(l+r)/2];
        while (l<r){
            while(a[l]<m)l++;
            while(a[r]>m)r--;
            if (l<=r){
                int z=a[l];a[l]=a[r];a[r]=z;
                l++;
                r--;
            }
        }
        if (l<y)sort(l,y);
        if (r>x)sort(x,r);
    }
    public static void main(String args[]) {
        int n=inp.nextInt();
        while (n>0){
            for (int i=1;i<=n;i++)a[i]=inp.nextInt();
            sort(1,n);
            int ans=100000000;
            for (int i=2;i<=n;i++)if (a[i]-a[i-1]<ans)ans=a[i]-a[i-1];
            n=inp.nextInt();
            System.out.println(ans);
        }
    }
 
}

Measured memory_bytes: 46616
import sys
from collections import Counter

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = tuple(map(int, readline().split()))
Q = int(readline())
BC = map(int, read().split())

d = Counter(A)

sub_s = sum(A)

for b, c in zip(BC, BC):
    sub_s += d[b] * (c - b)
    d[c] += d[b]
    d[b] = 0

    print(sub_s)


Measured memory_bytes: 34688
#include<stdio.h>
int main()
{
    int n,i,j,k,ara[10005],s;
    scanf("%d",&n);
    for(i=1;i<=10000;i++)
        ara[i]=0;
    for(i=1;i<100;i++)
    {
        for(j=1;j<100;j++)
        {
            for(k=1;k<100;k++)
            {
                s=i*i+j*j+k*k+i*j+j*k+k*i;
                if(s<=10000)
                    ara[s]++;
            }
        }
    }
    for(i=1;i<=n;i++)
        printf("%d\n",ara[i]);
    return 0;
}

Measured memory_bytes: 1680
using System;

class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int T = N / 3600;
            int T1 = N % 3600;
            

            var M = T1 / 60;
            var S = T1 % 60;
            string A = string.Format("{0}:{1}:{2}",T,M,S);
            Console.WriteLine(A);

        }
    }


Measured memory_bytes: 17976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();

		int area = ((a + b)* h) /2;
		System.out.println(area);

		scan.close();

	}

}


Measured memory_bytes: 9684
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    if N % 2 == 0:
        print(N)
    else:
        print(2 * N)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

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

const int mod = 1e9 + 7;

int N, A[100010];

long long fact[100010];

int cnt[100010];

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; ++i)
        scanf("%d", &A[i]);

    fact[0] = 1;
    for (long long i=1;i<=N;++i) fact[i] = (long long)fact[i-1]*i%mod;

    vector<int> a;

    for (int i = 1; i <= N; ++i) {
        a.push_back(abs(i - 1 - (N - i)));
        cnt[abs(i - 1 - (N - i))]++;
    }

    sort(begin(a),end(a));
    sort(A,A+N);

    for(int i=0;i<N;++i)if(a[i]!=A[i]){
        printf("0\n");
        return 0;
    }

    long long ans = 1;

    for (int i=0;i<N;++i) {
        ans *= fact[cnt[i]];
        ans %= mod;
    }

    cout<<ans<<endl;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

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

  mint ans = mint(10).pow(n) - mint(9).pow(n) * 2 + mint(8).pow(n);
  ANS(ans);

  return 0;
}

Measured memory_bytes: 3636
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 3e5 + 100;
const long long MNN = 2e3 + 10;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, m, cnt[MXN], ans;
bool may[MXN];

int main(){
	ios;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cnt[i] = 1;
	}may[1] = 1;
	for(int i = 1; i <= m; i++){
		int from, to;
		cin >> from >> to;
		if(may[from] == 1){
			may[to] = 1;
		}
		cnt[to]++;
		cnt[from]--;
		if(cnt[from] == 0){
			may[from] = 0;
		}
	}
	for(int i = 1; i <= n; i++){
		if(may[i] == 1){
			ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >> N >> X;
  int l=0;
  int ans=1;
  for(int i=0; i<N; i++){
    int L;
    cin >> L;
    l+=L;
    if(l<=X)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let _ = read();
    let v: Vec<u64> = read().split(" ").map(|n| n.parse().unwrap()).collect();
    
    let mut c = 0;
    for i in 0..v.len() {
        if i == 0 {
            c = c + 1;
        } else {
            let t = &v[..i+1];
            let mut p: Vec<u64> = t.to_vec();
            let s = p.pop().unwrap();
            if p.into_iter().all(move |n| s >= n) {
                c = c + 1;
            }
        }
    }
    println!("{}", c);
}

fn read() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

Measured memory_bytes: 4352