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

int main(){
	long long n;
 cin>>n;
  long long a[n];
  for(long long i = 0;i < n;i++)cin>>a[i];
  long long b = 0,c = 0;
  long long sum = 0;
  for(long long i = 0;i < n;i++){
    sum += a[i];
    if(i&1){
      if(sum >= 0){
      	b += sum + 1;
        sum = -1;
      }
    }
    else {
      if(sum <= 0){
        b += -sum + 1;
        sum = 1;
      }
    }
}
    sum = 0;
    for(long long i = 0;i < n;i++){
    sum += a[i];
    if(i&1){
      if(sum <= 0){
      	c += -sum + 1;
        sum = 1;
      }
    }
    else {
      if(sum >= 0){
        c += sum + 1;
        sum = -1;
      }
    }
  }
    cout<<min(b,c)<<endl;
}


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

using namespace std;

#define ll long long

signed main(){
    int n; ll h,w;
    cin >> n >> h >> w;

    int ans = 0;
    for (int i = 0;i < n;++i){
        ll a,b;
        cin >> a >> b;
        if (a >= h && b >= w)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  string s;
  int i, q, f, query;
  char c;
  bool r = 0;
  string head = "", tail = "";

  cin >> s;
  cin >> q;

  for(i=0;i<q;i++){
    cin >> query;

    if(query==1){
      if(r) r = 0;
      else r = 1;
    }
    else{
      cin >> f >> c;
      if((r+f)%2){
        head += c;
      }
      else{
        tail += c;
      }
    }
  }

  reverse(head.begin(),head.end());

  head += s;
  head += tail;

  if(r){
    reverse(head.begin(),head.end());
  }

  cout << head << endl;

  return 0;
}


Measured memory_bytes: 1348
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    long long int x,y=100;
    int cnt=0;
    long long int ans;
    cin >> x;
    while(x > y){
        y = y*1.01;
        cnt++;
    }

    //y = (log(x)-log(100))/log(1.01) + 1;
    cout << cnt << endl;

    return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n, vector<int>(0));
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.at(a).push_back(b);
//		g.at(b).push_back(a);
	}
	rep(i, n) sort(g.at(i).begin(), g.at(i).end());
	int ans = 0;
	int mi = n;
	rep(i, n){
		if(i == mi){
			mi = n;
			ans++;
		}
		if(g.at(i).size() != 0) if(g.at(i).at(0) < mi) mi = g.at(i).at(0);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'c') {
      cout << "No" << "\n";
    } else if(s[i] == 'b') {
      if(b > 0) {
        cout << "Yes" << "\n";
        b--;
      } else {
        cout << "No" << "\n";
      }
    } else {
      if(a > 0) {
        cout << "Yes" << "\n";
        a--;
      } else if(b > 0) {
        cout << "Yes" << "\n";
        b--;
      } else {
        cout << "No" << "\n";
      }
    }
  }
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s,t,u;
  cin>>s>>t;
  int a,b;
  cin>>a>>b>>u;
  map<string,int> mp;
  mp[s]=a;
  mp[t]=b;
  mp[u]--;
  cout<<mp[s]<<" "<<mp[t]<<endl;
  
  

  return 0;
}


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;
    int cnt2 = 0;
    ArrayList<Integer>[] tree;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        out.println(main.solve());
        out.flush();
    }
    long solve() throws IOException {
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        long ans = 1, left = 0;
        int cntPair = 0;
        for(char c:s){
            if(c=='W'){
                // this is 'W' plus self gives black
                if(left%2==1){
                    // then this is '('
                    left ++;
                } else{
                    // left%2==0, this should be ')'
                    if(left==0) return 0;
                    ans = ans*left%mod;
                    left--;
                    cntPair++;
                }
            } else{ // c = 'B'
                if(left%2==1){
                    // then this is ')'
                    ans = ans*left%mod;
                    left--;
                    cntPair++;
                } else{
                    // then this is '('
                    left ++;
                }
            }
        }
        if(left!=0) return 0;
        for(int i=1;i<=cntPair;i++){
            ans = ans*i%mod;
        }
        return ans;
    }
}

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

int main(void)
{
	int i, N, A, B, C, X, count;

	while(1){
		count = 0;
		cin >> N >> A >> B >> C >> X;
		if(N == 0 && A == 0 && B == 0 && C == 0 && X == 0){
			break;
		}

		vector<int> rail(N);
		for(i = 0; i < N; i++){
			cin >> rail[i];
		}
		
		i = 0;
		while(1){
			if(rail[i] == X){
				rail[i] = -1;
				i += 1;
			}
			if(i == N){
				cout << count << endl;
				break;
			}
			count += 1;
			X = ( A * X + B ) % C;
			if(count == 10001){
				cout << -1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>

int main(){
 int n,i,j,X,Y;
 scanf("%d",&n);
 for(i=1;i<=n;i++){
  Y =0;
  if(i%3==0){
   printf(" %d",i);}
  else{
  for(j=1;j<5 && Y==0;j++){
   X =pow(10,j-1);
   if(3*X <= i%(X*10) && 4*X > i%(X*10)){
    printf(" %d",i);
    Y=1;}}}}
 printf("\n");
 return 0;}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  static int n;
  static int[] a;

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

    n = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int[] count = new int[9];
    for(int i = 0; i < n; i++){
      if(a[i] < 400){
        count[0]++;
      }
      else if(a[i] < 800){
        count[1]++;
      }
      else if(a[i] < 1200){
        count[2]++;
      }
      else if(a[i] < 1600){
        count[3]++;
      }
      else if(a[i] < 2000){
        count[4]++;
      }
      else if(a[i] < 2400){
        count[5]++;
      }
      else if(a[i] < 2800){
        count[6]++;
      }
      else if(a[i] < 3200){
        count[7]++;
      }
      else{
        count[8]++;
      }
    }

    int min = 0;
    for(int i = 0; i < 8; i++){
      if(count[i] > 0){
        ++min;
      }
    }

    if(count[8] == 0){
      System.out.println(min + " " + min);
      return;
    }

    int max = min + count[8];
    min = Math.max(min, 1);

    System.out.println(min + " " + max);
  }
}


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

int main(){
    vector<int> w(10);
    vector<int> k(10);
    for(int i = 0; i<10;i++){
        cin >> w[i];
    }
    for(int i = 0; i<10;i++){
        cin >> k[i];
    }
    sort(w.begin(), w.end());
    sort(k.begin(), k.end());
    cout << w[9]+w[8]+w[7] << " " << k[9] + k[8]+k[7] << endl;
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> pair;
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする
 
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//dpTable
int dp[100050];

int main(){
    string S;
    int w;
    cin >> S >> w;
    for (int i = 0; i < S.size(); i += w) {
        cout << S.at(i);
    }
    cout << endl;
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AProgrammingEducation {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, a, b;
	    in >> n;
	    if(n == 1) out << "Hello World" << endl;
	    else {
	        in >> a >> b;
	        out << a+b << endl;
	    }
	}
};


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


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

public struct P
{
    public int x { get; set; }
    public int y { get; set; }
    public bool red { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var w  = setArray(n);
        var hs = new HashSet<P>();
        var count = 0;
        foreach (var x in w.OrderBy(y =>y.x))
            if (x.red) hs.Add(x);
            else
            {
                var t = hs.Where(z => z.x < x.x && z.y < x.y).OrderByDescending(z => z.y);
                if (t.Count() > 0) { hs.Remove(t.First()); count++; }
            }
        Console.WriteLine(count);
    }
    public static P[] setArray(int n)
    {
        var w = new P[2 * n];
        for (int i = 0; i < 2 * n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            if (i < n) w[i] = new P { x = a, y = b, red = true };
            else w[i] = new P { x = a, y = b };
        }
        return w;
    }
}

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

int myPow(int x, int y){
    int tmp = 1;
    for(int i = 0; i < y; i++){
        tmp *= x;
    }
    return tmp;
}

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

    if(number < 100 || 999 < number){
        cout << "error" << endl;
        return 0;
    }

    vector<int> digit(3);
    int tmp_num = number;
    for(int i = 2; i >= 0; i--){
        int pow_num = myPow(10, i);
        digit.at(i) = tmp_num / pow_num; 
       if(digit.at(i) == 7){
            cout << "Yes" << endl;
            return 0;
        }
        tmp_num -= digit.at(i) * pow_num;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
s = input()
def guu(t):
    if len(t) % 2 == 1:
        return False
    return t[:len(t)//2] == t[len(t)//2:]
for i in range(len(s)-1, 0, -1):
    if guu(s[:i]):
        ans = len(s[:i])
        break
print(ans)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  vstr s(3);
  cin >> s;
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
}


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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a; string s;
	cin>>a>>s;
	if(a >= 3200){
		cout<<s;
	}
	else{
		cout<<"red";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		int d=Integer.parseInt(scan.next());
    				
    		if (a+b==c+d) {
    			System.out.print("Balanced");
    		}else if (a+b>c+d) {
    			System.out.print("Left");
    		}else {
    			System.out.print("Right");
    		}
     
    }
    }
// end 

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

 int main() {
     int A, V, B, W, T;
     cin >> A >> V >> B >> W >> T;
     
     int dis = abs(A-B);
     int spe = V - W;

     if (V <= W) cout << "NO" << endl;
     else if (dis <= (ll)spe * T) cout << "YES" << endl;
     else cout << "NO" << endl;
     
 }

Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H[MAX], D[MAX],S[MAX],DG[MAX];

int getHeight(int u,int left,int right){

  if(T[u].l == NIL && T[u].r == NIL) return 0;
  
  if(T[u].l != NIL){ 
    left = getHeight(T[u].l,left,0)+1;
  }
    if(T[u].r != NIL) right = getHeight(T[u].r,0,right)+1;

  if(left > right) {
    return left;
  }
  else{
    return right;
  }
}

int getDepth(int u){
  int d = 0;
  int i = 0;
  while(1){
    if(T[u].p == NIL) break;
    d++;
    u = T[u].p;
  }
  return d;
}

int getDegree(int u){
  if((T[u].l == NIL) && (T[u].r == NIL)) return 0;
  else if((T[u].l == NIL) || (T[u].r == NIL)) return 1;
  else return 2;
}

int getSibling(int u){
  
  /*  if(T[u].p == NIL) return NIL;
      
      else if(T[T[u].p].l == NIL){ 
      printf("u = %d T[u].l = %d\n",u,T[T[u].p].l); 
      return T[T[u].p].r;  
      }
      
      else { 
      printf("u = %d T[u].r = %d\n",u,T[u].r); 
      return T[T[u].p].l;  
      }*/
  
  /*  int i;
      for(i=0; i<n; i++){
      if((T[u].p == T[i].p) && (u != i))
      return i;
      }
      return NIL;
  */
  
  if(T[u].p == NIL) return NIL;
  
  else if(T[T[u].p].l != u){ 
    return T[T[u].p].l;  
  }
  
  else { 
    return T[T[u].p].r;  
  }
}

void print(int u){
  
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p, S[u],DG[u], D[u], H[u]);
  
  if( T[u].p == NIL) printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
  else printf("internal node\n");
  
}


main(){
  int i, j, d, v, l;
  int pre;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d",&v);
    scanf("%d %d",&T[v].l,&T[v].r);
    T[T[v].l].p = v;
    T[T[v].r].p = v;
  }
  
  for(i=0; i < n; i++){
    S[i] = getSibling(i);
    DG[i] = getDegree(i);
    D[i] = getDepth(i);
    H[i] = getHeight(i,0,0);
  }  
    
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

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

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

    if (a > b) swap(a,b);
    rep(i,b) cout << to_string(a);
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static class Calculator {
        enum Operator {
            NULL {
                @Override
                public int apply(int r1, int r2) {
                    if (r2 < 0 || r2 > 9999) {
                        throw new RuntimeException();
                    } else {
                        return r2;
                    }
                }
            },
            ADD {
                @Override
                public int apply(int r1, int r2) {
                    if (r1 + r2 < 0 || r1 + r2 > 9999) {
                        throw new RuntimeException();
                    } else {
                        return r1 + r2;
                    }
                }
            },
            SUB {
                @Override
                public int apply(int r1, int r2) {
                    if (r1 - r2 < 0 || r1 - r2 > 9999) {
                        throw new RuntimeException();
                    } else {
                        return r1 - r2;
                    }
                }
            },
            MULT {
                @Override
                public int apply(int r1, int r2) {
                    if (r1 * r2 < 0 || r1 * r2 > 9999) {
                        throw new RuntimeException();
                    } else {
                        return r1 * r2;
                    }
                }
            };
            public int apply(int r1, int r2) {
                return 0;
            }
        }

        private int calc(char[] input) {
            int R1 = 0;
            int R2 = 0;
            Operator R3 = Operator.NULL;

            for (int i = 0; input[i] != '='; i++) {
                if (Character.isDigit(input[i])) {
                    R2 = Operator.MULT.apply(R2, 10);
                    R2 = Operator.ADD.apply(R2, input[i] - '0');
                } else if (input[i] == '+') {
                    R1 = R3.apply(R1, R2);
                    R2 = 0;
                    R3 = Operator.ADD;
                } else if (input[i] == '-') {
                    R1 = R3.apply(R1, R2);
                    R2 = 0;
                    R3 = Operator.SUB;
                } else if (input[i] == '*') {
                    R1 = R3.apply(R1, R2);
                    R2 = 0;
                    R3 = Operator.MULT;
                } else {
                    assert false;
                }
            }
            R1 = R3.apply(R1, R2);
            R2 = 0;
            R3 = Operator.NULL;
            return R1;
        }

        public void run(char[] input) {
            try {
                System.out.println(calc(input));
            } catch (Throwable e) {
                System.out.println("E");
            }
        }
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        Calculator calculator = new Calculator();

        while (scanner.hasNext()) {
            char[] input = scanner.next().toCharArray();
            calculator.run(input);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

map<long long,long long> mp;

int main()
{
    int n;
    cin>>n;
    long long ret=0,sum=0;
    mp[0]++;
    for(int i=0;i<n;i++){
    	long long a;
    	cin>>a;
    	sum+=a;
    	ret+=mp[sum];
    	mp[sum]++;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 12800
expr = gets.chomp.split(' ')

s = []
expr.each do |v|
  if v == '+' || v == '-' || v == '*'
    v1 = s.pop
    v2 = s.pop
    s.push(eval("#{v2}#{v}#{v1}"))
  else
    s.push(v)
  end
end

puts s[0]


Measured memory_bytes: 6916
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel &x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
void pr(vel& v) {
    int n = v.size();
    if (n != 0) {
        cout << v[0];
        rep(i, n - 1) {
            cout << " " << v[i + 1];
        }
        cout << endl;
    }
}
signed main() {
    int n; cin >> n;
    int m; cin >> m;
    int inf = 3 * m + 2;
    veb S(n + inf, false);
    string qs; cin >> qs;
    rep(i, n) {
        if (qs[i] == '0') { S[i] = true; }
    }
    vel dp(n+inf, -1);
    dp[n] = 0;
    priority_queue<int> pq;
    pq.push(n);
    vel nex(n + 1);
    for(int i=n-1;i>=0;i--) {
        if (!pq.empty()) {
            int now_max = pq.top();
            int ans = dp[now_max];
            while (!pq.empty()) {
                if (dp[pq.top()] != ans) { break; }
                now_max = pq.top(); pq.pop();
            }
            pq.push(now_max);
            dp[i] = ans+ 1;
            nex[i] = now_max;
            if (now_max == i + m) { pq.pop();}
            if (S[i]) { pq.push(i); }
        }
    }
    if (dp[0] == -1) {
        cout << -1 << endl;
    }
    else {
        vel v;
        int now = 0;
        while (now != n) {
            int nnow = nex[now];
            v.push_back(nnow - now);
            now = nnow;
        }
        pr(v);
    }
    return 0;
}


Measured memory_bytes: 6080
N = int(input())
out_ans = []
while N > 26:
    N -= 1
    out_ans.append(int(N % 26))
    N = (N // 26)
N -= 1
out_ans.append(int(N))
out_dic = ['a', 'b', 'c','d', 'e', 'f','g','h','i','j',
              'k','l','m','n','o','p','q','r','s','t','u','v',
              'w','x','y','z']
ans = ''
for i in range(len(out_ans)-1, -1, -1):
    ans = ans + (out_dic[out_ans[i]])
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  double n, m, sum, cnt;
  cin >> n >> m;
  cnt = 0;
  sum = 0;
  vector<double> a(n);
  for(int i = 0; i < n; i++)
  {
    cin >> a.at(i);
    sum += a.at(i);
  }
  for(int i = 0; i < n; i++)
    if(a.at(i) >= (sum / (4 * m))) cnt++;
  if(cnt >= m) cout << "Yes";
  else cout << "No";
  return 0;
}

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

int main(){
  int n;
  char s,t,b;
  while(true){

    //input
    cin >> n;
    if(!n)
      break;
    cin >>s >>t >>b;
    int room[n+1][9];
    for(int i=0;i<9;i++)
      room[0][i] = 0;
    room[0][(int)(s-'A')] = 1;
    
    //wall
    int wall[5][5];
    for(int y=0;y<5;y++){
      for(int x=0;x<5;x++){
	if (x==0||x==4||y==0||y==4)
	  wall[x][y]=1;
	else
	  wall[x][y]=0;
      }
    }
    wall[(int)(b-'A')%3+1][(int)(b-'A')/3+1] = 1;

    for(int i=0;i<n;i++){
      for(int j=0;j<9;j++)
	room[i+1][j] = 0;
      for(int pos=0;pos<9;pos++){
	if(wall[pos%3+1][pos/3])
	  room[i+1][pos]+=room[i][pos];
	else
	  room[i+1][pos-3]+=room[i][pos];
	if(wall[pos%3][pos/3+1])
	  room[i+1][pos]+=room[i][pos];
	else
	  room[i+1][pos-1]+=room[i][pos];
	if(wall[pos%3+2][pos/3+1])
	  room[i+1][pos]+=room[i][pos];
	else
	  room[i+1][pos+1]+=room[i][pos];
	if(wall[pos%3+1][pos/3+2])
	  room[i+1][pos]+=room[i][pos];
	else
	  room[i+1][pos+3]+=room[i][pos];
      }
    }
    printf ("%.8f\n",((double)(room[n][(int)(t-'A')])/pow(4,(double)n)));
  }
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  int cnt=0;
  for (int i=0;i<S.length()-1;i++){
    if(S.at(i)!=S.at(i+1)){
      cnt++;
    }
  }
  cout<<cnt<<endl; 
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vector<int> as(n), bs(m);
    set<int> sa, sb;
    rep(i, n) {
        int a;
        cin>>a;
        as[i] = a;
        sa.insert(a);
    }
    rep(i, m) {
        int b;
        cin>>b;
        bs[i] = b;
        sb.insert(b);
    }
    if (sa.size() < n) {
        cout<<0<<endl;
        return 0;
    }
    if (sb.size() < m) {
        cout<<0<<endl;
        return 0;
    }
    sort(rng(as));
    sort(rng(bs));

    mint ans = 1;
    for (int i = n * m; i >= 1; --i) {
        ll ad = lower_bound(rng(as), i) - as.begin();
        ll bd = lower_bound(rng(bs), i) - bs.begin();
        if (ad != n && bd != m && as[ad] == i && bs[bd] == i) continue;
        if (ad != n && as[ad] == i) {
            ans *= m - bd;
            continue;
        }
        if (bd != m && bs[bd] == i) {
            ans *= n - ad;
            continue;
        }
        ans *= (n - ad) * (m - bd) - (n * m - i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

vector<vector<ll>> dp;

ll rec(int l, int r, vector<ll> &sum) {
  if(dp[l][r] != -1) return dp[l][r];
  ll res = INF;
  rep(i, r - l) {
    chmin(res,rec(l, l + i, sum) + rec(l + i + 1, r, sum));
  }
  return dp[l][r] = res + sum[r + 1] - sum[l];
}

int main() {
  int N; cin >> N;
  vector<ll> a(N), sum(N + 1, 0);
  rep(i, N) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  dp = vector<vector<ll>>(N, vector<ll>(N, -1));
  rep(i, N) dp[i][i] = 0;
  ll ans = rec(0, N - 1, sum);
  cout << ans << endl;
}

Measured memory_bytes: 4864
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [[] for _ in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
    
cnt = 0

for i in range(n):
    ab = sum([a[i][j]*b[j] for j in range(m)])
    if ab + c > 0:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          int n,x;
          cin >> n >> x;
          int m[n];
          REP(i,n){
                    cin >> m[i];
          }
          sort(m,m+n);
          int count=0;
          int total=0;
          REP(i,n){
                    total+=m[i];
                    if(total>x){
                              break;
                    }
                    count+=1;
          }
          while(true){
                    total+=m[0];
                    if(total>x){
                              break;
                    }
                    count+=1;
          }
          cout << count << endl;
          return 0;
}


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

typedef long long int lld;

main(){
	string str;
	cin >> str;
	lld n = 0, ans = 0;
	lld mask;
	int i = str.length();
	for(int j = 0; j<(1<<i-1); j++){
		mask = j;
		n = 0;
		for(int k = 0; k < i; k++){
			n = n*10+ (str[k]-'0');
			if(mask&(1<<k)){
		//		cout << n << " ";
				ans += n;
				n=0;
			}
		}
		ans += n;
		//cout << n <<" ";
		//cout << "mask = " << mask << endl;
		//cout << endl;
	}
	cout << ans << endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> A >> B >> K;
	if (A + K - 1 >= B + 1 - K) {
		for (int i = A; i < B + 1; i++)cout << i << endl;
	}
	else {
		for (int i = A; i < A + K; i++)cout << i << endl;
		for (int i = B + 1 - K; i < B+1; i++)cout << i << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MAX_N = 100010;
int par[MAX_N], uniteRank[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        cin >> nums.at(i);
    }
    sort(nums.begin(), nums.end());
    ll answer1 = nums.at(nums.size() - 1);
    ll answer2 = nums.at(0);
    for (int i = 1; i < N - 1; i++)
    {
        if(min(answer2, answer1 - answer2) < min(nums.at(i), answer1 - nums.at(i)))
        {
            answer2 = nums.at(i);
        }
    }
    cout << answer1 << " " << answer2 << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        while (true) {
            int p = a;
            int q = b;
            a = Math.max(p, q);
            b = Math.min(p, q);
            if (a == 1) {
                System.out.println("YES");
                return;
            } else if (b == 0) {
                if (c % a == 0) {
                    System.out.println("YES");
                    return;
                } else {
                    System.out.println("NO");
                    return;
                }
            }
            a = a % b;
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int n;
long long a[100005], x, ans;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }

    for (int i = 1; i < n; i++) {
    	long long sum = a[i-1] + a[i], d = max(0LL, sum - x);
    	long long tmp = min(a[i], d);
    	ans += d;
    	a[i] -= tmp;
    	d -= tmp;

    	tmp = min(a[i-1], d);
    	a[i-1] -= tmp;
    	d -= tmp;
    }
    cout << ans << '\n';
   	
    return 0;
}

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

using namespace std;

typedef long long ll;

ll n, dp[100100],h[100100];

int main() {
	
	scanf("%lld", &n);
	
	for(int i = 0; i < n; i++) {
		scanf("%lld", &h[i]);
		if(i == 0) dp[0] = 0;
		else if(i == 1) {
			dp[i] = abs(h[i] - h[i - 1]);
			//continue;
		}
		else 
		dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1],abs(h[i] - h[i - 2]) + dp[i - 2]);
		
		//printf("%lld\n",dp[i]);
	}
	
	printf("%lld",dp[n - 1]);
	
	return 0;
}

Measured memory_bytes: 1792
a = int(input())
b = list(map(int,input().split()))

money = 1000
kabu = 0
for i in range(a):
    if i == a - 1:
        if b[i] >= b[i-1]:
            money += b[i] * kabu
            kabu = 0              
    elif b[i] < b[i + 1]:
        kabu += int(money / b[i])
        money %= b[i]
    elif b[i] > b[i + 1]:
        money += b[i] * kabu
        kabu = 0
        
print(str(money))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> vec,vec2;
    unordered_map<int,int> cnt,cnt2;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        if(i%2==0)
            cnt[temp]++;
        else
            cnt2[temp]++;
    }
    for(auto const&e:cnt)
        vec.push_back({e.second,e.first});
    for(auto const&e:cnt2)
        vec2.push_back({e.second,e.first});
    sort(vec.rbegin(),vec.rend());
    sort(vec2.rbegin(),vec2.rend());
    int ans=0;
    // cout<<vec[0].first<<" "<<vec[0].second<<"\n";
    // cout<<vec2[0].first<<" "<<vec2[0].second<<"\n";
    // cout<<vec[1].first<<" "<<vec[1].second<<"\n";
    // cout<<vec2[1].first<<" "<<vec2[1].second<<"\n";
    if(vec[0].second!=vec2[0].second)
    {
        ans=n-vec[0].first-vec2[0].first;
    }
    else
    {
        if(vec.size()==1 && vec2.size()==1)
        {
            ans=n/2;
        }
        else if(vec.size()==1)
        {
            ans=n/2-vec2[1].first;
        }
        else if(vec2.size()==1)
        {
            ans=n/2-vec[1].first;
        }
        else
        {
            ans=min(n-vec[0].first-vec2[1].first,n-vec2[0].first-vec[1].first);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8484
n, t = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort()
a_max = x[-1][0]

dp_pre = [0 for j in range(t + a_max)]
dp = [0 for j in range(t + a_max)]
for ai, bi in x:
    for j in range(ai):
        dp[j] = dp_pre[j]
    for j in range(ai, t + ai):
        dp[j] = max(dp_pre[j], dp_pre[j - ai] + bi)
    for j in range(t + ai, t + a_max):
        dp[j] = dp_pre[j]
    dp_pre, dp = dp, dp_pre
print(max(dp_pre))


Measured memory_bytes: 48872
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N= 0;
	cin >> N;
	vector<ll> A(N),B(N);
	rep(i,N)cin >> A[i];
	rep(i,N){
		B[i] = A[i];
		if(i!=0)B[i] ^= B[i-1];
		if(i!=0)A[i] += A[i-1];
	}
	ll ans = 0;
	for(int i=0;i<N;i++){
		int ok = i;
		int ng = N;
		ll t;
		ll sum;
		while(abs(ok-ng)>1){
			int mid = (ok+ng)/2;
			if(i==0){
				sum = A[mid];
				t = B[mid];
			}else {
				sum = A[mid] - A[i-1];
				t = B[mid]^B[i-1];
			}
			if(sum == t)ok = mid;
			else ng = mid;
		}
		ans += (ok-i)+1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define cases int t;cin>>t;while(t--)
int main()
{
    iso;
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int a,b;
    cin>>a>>b;
    b=max(0,a-2*b);
   cout<<b;
    
}


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

// 内部定数
#define D_CITY_MAX		300										// 最大都市数

// 内部変数
static int si2Table[D_CITY_MAX][D_CITY_MAX];					// 都市表
static int siCCnt;												// 都市数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 道路の和を取得
long long
fGetSum(
)
{
	int i, j, k;

	// 各道路をチェック
	long long llSum = 0;
	for (i = 0; i < siCCnt - 1; i++) {
		for (j = i + 1; j < siCCnt; j++) {

			// 接続チェック
			for (k = 0; k < siCCnt; k++) {
				if (k == i) {
					continue;
				}
				if (k == j) {
					continue;
				}

				// 距離合計
				int liLen = si2Table[i][k] + si2Table[j][k];
				if (si2Table[i][j] == liLen) {
					break;
				}
				else if (si2Table[i][j] > liLen) {
					return -1;
				}
			}
			if (k < siCCnt) {
				continue;
			}

			// 距離加算
			llSum += (long long)si2Table[i][j];
		}
	}

	return llSum;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 都市数取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &siCCnt);

	// 都市表取得
	for (i = 0; i < siCCnt; i++) {
		for (j = 0; j < siCCnt; j++) {
#ifdef D_TEST
			fscanf(szpFpT, "%d", &si2Table[i][j]);
#else
			fscanf(stdin, "%d", &si2Table[i][j]);
#endif
		}
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	}

	// 道路の和を取得
	long long llSum = fGetSum();

	// 結果セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
typedef struct node
{
	int a[51][51];
	int n;
	struct node operator * (const struct node & f)
	{
		struct node ret;
		memset(ret.a,0,sizeof(ret.a));
		ret.n=n;
		for(int k=1;k<=n;k++)
		{
			for(int i=1;i<=n;i++)
			{
				for(int j=1;j<=n;j++)
				{
					if(this->a[i][k]&&f.a[k][j])
						ret.a[i][j]=(this->a[i][k]*(long long)f.a[k][j]+ret.a[i][j])%1000000007;
				}
			}
		}
		return ret;
	}
	void myprintf()
	{
		cout<<endl;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				printf("%d ",a[i][j]);
			}
			cout<<endl;
		}
	}
}NODE,*PNODE;
NODE g,ans;
int n;
long long k;
int flag;
int s=0;
int main()
{
	scanf("%d%lld",&n,&k);
	g.n=n;
	ans.n=n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&g.a[i][j]);
	while(k)
	{
		if(k%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	//ans.myprintf();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			s=((long long)s+ans.a[i][j])%1000000007;
	printf("%d",s);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

  double ans = 0;
  for( int i=0;i<N;i++ )
    {
      double x;
      string u;
      cin >> x >> u;
      if(u == "JPY")
	ans += x;
      else
	ans += x*380000;
    }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b+c||b==a+c||c==a+b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
array = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    array[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            if k < 9:
                print(" " + str(array[i][j][k]), end="")
            if k == 9:
                print(" " + str(array[i][j][k]))
    if i < 3:
        print("#" * 20)




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

int main(){
  int n,i;
  cin>>n;
  int p[n];
  for(i=0;i<n;i++)cin>>p[i];
  int q[n];
  for(i=0;i<n;i++)q[i]=p[i];
  sort(p,p+n);
  int cnt=0;
  for(i=0;i<n;i++){
    if(p[i]!=q[i])cnt++;
  }
  if(cnt>=3)cout<<"NO";
  else cout<<"YES";
}
  

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

int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  int tak = (c-1)/b + 1;
  int aok = (a-1)/d + 1;
  if (tak <=aok) cout<<"Yes";
  else cout << "No";
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string ans = "";
    REP(i, N) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
    return 0; 
}

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

int main() {
  
  int a=0, b=0;
  string s;
  cin >> a >> s >> b;
  
  if(s=="+") {
    
    int sum = a+b;
    
    cout << sum << endl;
    
  } else if(s=="-") {
    
    int sub = a-b;
    
    cout << sub << endl;
    
  }
  
  return 0;
  
}

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

vector<ll> memo(100, 0);
ll lucas(int n) {
	if (n == 0) return memo[n] =  2;
	if (n == 1) return memo[n] =  1;

	if (memo[n] > 0) return memo[n];
	
	else return memo[n] = lucas(n-1) + lucas(n-2);
} 
int main() {
	int n;
	cin >> n;
	cout << lucas(n) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    public void Proc()
    {
        double r = double.Parse(Console.ReadLine());
        Console.WriteLine((r * r * Math.PI) + " " + (r * 2 * Math.PI));
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9172