akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        a1: i32, a2:i32, a3:i32
    }
    let ans = vec![
        (a2-a1).abs()+(a3-a2).abs(),
        (a3-a1).abs()+(a3-a2).abs(),
        (a1-a2).abs()+(a3-a1).abs()
      ];

    println!("{}", ans.iter().min().unwrap());
}

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

bool bans=0;
int k, a, b;

int main(){
	cin >> k >> a >> b;
	for (int i=a;i<=b;i++){
		if (i%k==0) bans=1;
	}
	cout << (bans ? "OK\n" : "NG\n");
}

Measured memory_bytes: 3636
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

class SegmentTree {
  vector<long long> dat;
  int n;
  long long def;
public:
  SegmentTree(int num, long long d) {
    n = 1;
    while (n < num)
      n <<= 1;
    def = d;
    dat.resize(2 * n - 1, def);
  }
  void update(int i, long long x) {
    i += (n - 1);
    dat[i] += x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  long long query(int a, int b, int i = 0, int li = 0, int ri = -1) {
    if (!i) ri = n;
    if (ri <= a || li >= b) return def;
    if (li >= a && ri <= b) return dat[i];
    long long vl = query(a, b, 2 * i + 1, li, (li + ri) / 2);
    long long vr = query(a, b, 2 * i + 2, (li + ri) / 2, ri);
    return vl + vr;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  SegmentTree st(n, 0);
  rep(i, n) {
    int a;
    cin >> a;
    st.update(i, a);
  }
  rep(_, q) {
    int que;
    cin >> que;
    if (que) {
      int l, r;
      cin >> l >> r;
      cout << st.query(l, r) << '\n';
    } else {
      int p;
      ll x;
      cin >> p >> x;
      st.update(p, x);
    }
  }
  return 0;
}

Measured memory_bytes: 12536
#include <iostream>

using namespace std;

int main()
{
	char s;
	cin >> s;
	switch (s) {
	case 'A':
		cout << "T" << endl;
		break;
	case 'C':
		cout << "G" << endl;
		break;
	case 'G':
		cout << "C" << endl;
		break;
	case 'T':
		cout << "A" << endl;
		break;
	}
	
	return 0;
}



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


using namespace std;

int main (void)
{

  char N[4];
  int i;

  for(i=0; i<4; i++)
  {
    cin >> N[i];
  }

  if(N[1] == N[2])
  {

    if(N[0] == N[1] || N[3] == N[1])
    {
      cout << "Yes\n";
    }

    else
    {
      cout << "No\n";
    }

  }
  else
  {
    cout << "No\n";
  }


  return 0;

}


Measured memory_bytes: 256
n = int(input())
a = [0]
a.extend(list(map(int,input().split())))
a.append(0)

s = []
for i in range(n+1):
    s.append(abs(a[i]-a[i+1]))
ss = sum(s)
for i in range(1,n+1):
    print(ss+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])))


Measured memory_bytes: 13920
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[300000][5][3] = {};
int main() {
	string s;
	cin >> s;
	if (s.length() == 2) {
		if (s[0] == s[1]) {
			cout << 1 << endl;
		}
		else {
			cout << 2 << endl;
		}
		return 0;
	}
	if (s.length() == 3) {
		map<string, int> aa;
		queue<string> next;
		aa[s] = 1;
		next.push(s);
		while (next.empty() == false) {
			string now = next.front();
			next.pop();
			if (now[0] != now[1]){
				string b = now;
				if (now[0] != 'a' && now[1] != 'a') {
					b[0] = 'a';
					b[1] = 'a';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
				else if (now[0] != 'b' && now[1] != 'b') {
					b[0] = 'b';
					b[1] = 'b';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
				else {
					b[0] = 'c';
					b[1] = 'c';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
			}
			if (now[1] != now[2]) {
				string b = now;
				if (now[1] != 'a' && now[2] != 'a') {
					b[1] = 'a';
					b[2] = 'a';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
				else if (now[1] != 'b' && now[2] != 'b') {
					b[1] = 'b';
					b[2] = 'b';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
				else {
					b[1] = 'c';
					b[2] = 'c';
					if (aa[b] == 0) {
						aa[b] = 1;
						next.push(b);
					}
				}
			}
		}
		cout << aa.size() << endl;
		return 0;
	}
	int ok = 0;
	REP(i, s.length()-1) {
		if (s[i] != s[i + 1]) ok = 1;
	}
	if (ok == 0) {
		cout << 1 << endl;
		return 0;
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < s.length(); ++i) {
		for (int q = 0; q <= 3; ++q) {
			for (int j = 0; j < 3; ++j) {
				//dp[i][q][j];
				for (int chose = 0; chose < 3; ++chose) {
					if (q == chose+1) {
						//ok
						dp[i + 1][4][(j + chose) % 3] += dp[i][q][j];
						dp[i + 1][4][(j + chose) % 3] %= MOD;
					}
					else {
						//not ok
						dp[i + 1][chose+1][(j + chose) % 3] += dp[i][q][j];
						dp[i + 1][chose+1][(j + chose) % 3] %= MOD;
					}
				}
			}
		}
		for (int q = 0; q < 3; ++q) {
			REP(t, 3) {
				dp[i + 1][4][(q + t) % 3] += dp[i][4][q];
				dp[i + 1][4][(q + t) % 3] %= MOD;
			}
		}
	}
	int now = 0;
	int neko = 1;
	for (int i = 0; i < s.length(); ++i) {
		now += s[i] - 'a';
		now %= 3;
		if (i != 0 && s[i] == s[i - 1]) neko = 0;
	}
	cout << dp[s.length()][4][now] + neko << endl;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;

//REPEAT
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//container util
//------------------------------------------
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define PRINT(V)     \
  for (auto v : (V)) \
  cout << v << " "
#define PRINTL(V)    \
  for (auto v : (V)) \
  cout << v << endl
#define SORT(V) sort((V).begin(), (V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//最大公約数
//------------------------------------------
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

//grobal variable
//------------------------------------------
int N, M;
VI Vec;

//main
//------------------------------------------
signed main()
{
  int n,m;
  cin >> n >> m;
  VI h(n);
  VI a(m);
  VI b(m);
  VI t(n,0);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
    for (int i = 0; i < m; i++)
    {
      cin >> a[i] >> b[i];
    }
  for (int i = 0; i < m;i++)
  {
    if (h[a[i]-1] > h[b[i]-1])
    {
      t[b[i]-1] = 1;
    }
    else if(h[a[i]-1] == h[b[i]-1]){
      t[b[i] - 1] = 1;
      t[a[i] - 1] = 1;
    }
    else{
      t[a[i]-1] = 1;
    }
  }
  int c = 0;
  for (auto &e : t)
  {
    if(e==0){
      c++;
    }
  }
  cout << c;
}

Measured memory_bytes: 4824
#include <iostream>
#include <vector>
#include <math.h>
//v.erase(unique(v.begin(),v.end()),v.end());

using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef  pair <ll, ll> pii;
 
const ll N = 200500;
const ll mod = 1e9 + 7;
const ld PI = acos(-1); 



int main() {


	ld n;
	cin >> n;
 
	cout << (ld)2.0 * n * PI << endl;
	
	return 0;
}

Measured memory_bytes: 3268
x,n = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i)

if !p.include?(x)
  puts x
  exit
end
for i in 1..(n/2+1)
  if !p.include?(x-i)
    puts x-i
    exit
  end
  if !p.include?(x+i)
    puts x+i
    exit
  end
end

Measured memory_bytes: 14276
Imports System.Text
Imports System.String
Imports System
Imports System.Math

Module Module1

    Sub Main()
        Dim ans As String = ""
        'Dim valuelength = CInt(Console.ReadLine)
        Dim input As String = Console.ReadLine

        If input(2) = input(3) AndAlso input(4) = input(5) Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If


        Console.ReadKey()
    End Sub


End Module

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.size()) {
    if (S[i] == T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vector<bool> prime_vec(long n){ //2からnまでの素数を列挙した配列
    vector<bool> vec(n,true);
    vec.at(0) = false;
    vec.at(1) = false;
    for(int i=2; i<n; i++){
        if(vec.at(i)){
            for(int j=2; i*j<n; j++){
                vec.at(i*j) = false;
            }
        }
    }
    return vec;
}

int main(){
  vector<bool> p = prime_vec(1000001);
  long n;
  cin >> n;
  long tmp = n;
  int ans = 0;
  REP(i,2,1000001){
    if(p.at(i)){
      int cnt = 0;
      while(tmp % i == 0){
        tmp /= i;
        cnt++;
      }
      int sum = 0;
      int a = 1;
      while(sum + a <= cnt){
        
        sum += a;
        a++;
      }
      ans += a-1;
    }
  }
  if(tmp != 1) ans++;
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    deque<char> d;
    string s;
    int q;
    cin>>s>>q;
    for(char x: s){
        d.push_back(x);
    }
    int mode = 0;
    int reverseCnt = 0;
    for(int qi=0;qi<q;qi++){
        int t;
        cin>>t;
        if(t==1){
            reverseCnt++;
            mode++;
            mode %= 2;
        }else if(t==2){
            int f;
            char c;
            cin>>f>>c;
            if(mode==0){
                if(f==1){
                    d.push_front(c);
                }else{
                    d.push_back(c);
                }
            }else{
                if(f==1){
                    d.push_back(c);
                }else{
                    d.push_front(c);
                }
            }
        }
    }

    if(reverseCnt%2==1){
        for(auto itr = d.rbegin(); itr!=d.rend(); itr++){
            cout<<*itr;
        }
        cout<<endl;
    }else{
        for(auto itr = d.begin(); itr!=d.end(); itr++){
            cout<<*itr;
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

class UnionFind {
public:
  UnionFind(int n) : tree(vector<ll>(n, -1)) {}

  // 木の頂点を探す
  int find(int x) {
    if (tree[x] < 0)
      return x;
    return tree[x] = find(tree[x]);
  }

  // 長さを返す
  ll length(int x) {
    if (tree[x] < 0)
      return abs(tree[x]);
    return length(tree[x]);
  }

  // 同じグループか
  bool same(int x, int y) { return find(x) == find(y); }

  // 点xを含む木と点yを含む木の融合
  // 既に同じ木だったらfalseを返す
  bool unite(int x, int y) {
    int r1 = find(x);
    int r2 = find(y);
    if (r1 == r2)
      return false;
    // 大きい方に小さい方をくっつけたほうがコストが低い
    if (abs(r1) < abs(r2))
      swap(r1, r2);
    tree[r1] += tree[r2];
    tree[r2] = r1;
    return true;
  }

private:
  vector<ll> tree;
};

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> e;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    e.emplace_back(a, b);
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    UnionFind u(n);
    for (int j = 0; j < m; j++) {
      if (i == j)
        continue;
      u.unite(e[j].first, e[j].second);
    }
    if (!u.same(e[i].first, e[i].second)) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
import java.util.*;
import java.io.*;
public class Main {
    public static int solve(int n , int k , int arr[]){

        int dp[] = new int[n];

        for(int i = 1 ; i < n ; i++){
            int ans = Integer.MAX_VALUE;
            for(int j = i-1 ; j >= 0 && (i-j) <= k ; j--){
                int diff = Math.abs(arr[i] - arr[j]);
                ans = Math.min(ans , diff + dp[j]);
            }
            dp[i] = ans;
        }

        return dp[n-1];
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        int arr[] = new int[n];
        for(int i = 0 ; i < n ; i++){
            arr[i] = s.nextInt();
        }
        System.out.println(solve(n , k , arr));
    }
}

Measured memory_bytes: 59208
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, i, j, ans=0;
  cin >> n;
  int h[n];
  for(i=0; i<n; i++)
    cin >> h[i];
  for(i=0; i<n; i++)
    while(h[i]!=0){
    for(j=i; j<n; j++){
      if(h[j]!=0) {
	h[j]--;
	if(i==j) ans++;
      }
      else break;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int in = sc.nextInt();
			if (in % 2 == 0) {
				list.add(in);
			}
		}
		for (Integer integer : list) {
			if (integer % 3 != 0 && integer % 5 != 0) {
				System.out.println("DENIED");
				return;
			}
		}
		System.out.println("APPROVED");

	}
}


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

int main(){
    int H, W, i;
    string r = "#";
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        i = 0;
        string wide = "";
        while (i < W){
            wide += r;
            i++;
        }
        i = 0;
        while (i < H){
            cout << wide << endl;
            i++;
        }
        cout << "" << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define int int64_t


bool isPalindrome(string S) {
    vector<char> Sv;
    vector<char> Svreverse;
    
    for (int i = 0; i<S.size(); i++) {
        Sv.push_back(S.at(i));
    }
    
    for (int i = S.size()-1; i>=0; i--) {
        Svreverse.push_back(S.at(i));
    }
    
    return Sv == Svreverse;
}



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin >> S;
    
    if(isPalindrome(S) && isPalindrome(S.substr(0, (S.size()-1)/2))) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc,out);
		
		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();

		int m = Integer.parseInt(s.charAt(2) + "" + "" + s.charAt(3));
		int y = Integer.parseInt(s.charAt(0) + "" + "" + s.charAt(1));

			if(y <= 12 && m <= 12 && y > 0 && m > 0){
				out.println("AMBIGUOUS");
				return;
			}
			if(m > 0 && m <= 12){
				out.println("YYMM");
				return;
			}
			if(y > 0 && y <= 12){
				out.println("MMYY");
				return;
			}
		out.println("NA");

	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<iostream>
#include<fstream>

int main() {
	int x = 0;

	std:: cin >> x;

	if (x < 1 || x > 9) {
		std::cout << "error" << std::endl;
	}
	else if (x == 3 || x == 5 || x == 7) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main 
{
	static ArrayList<Integer> prime = new ArrayList<>();
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		create();
		
		for(;;)
		{
			int n = scanner.nextInt();
			if(n == 0)
			{
				break;
			}
			
			int sum = 0;		
			for(int i=0; i<n; i++)
			{
				sum += prime.get(i);
			}
			System.out.println(sum);
		}
	}
	
	private static void create()
	{
		for(int i=2; i<999999; i+=(i==2)?1:2)
		{
			int p = (int)Math.sqrt(i);
			boolean is_prime = true;
			for(int j=2; j<=p; j+=(j==2)?1:2)
			{
				if(i % j == 0)
				{
					is_prime = false;
					break;
				}
			}
			if(is_prime)
			{
				prime.add(i);
			}
		}
	}
}

Measured memory_bytes: 29568
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n;
int A[100000];

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

// indexがi以下の要素はpivotより小さく、
// -----がiより大きい要素はpivotより大きくなるように並び替え
int partition(int l, int r) {
    int i = l - 1;
    int pivot = A[r];
    for (int j = l; j < r; j++) {
        if (A[j] <= pivot) {
            i++;
            swap(A + i, A + j);
        }
    }
    swap(A + i + 1, A + r);
    return i + 1;
}

void printA(int pivot_i) {
    for (int i = 0; i < n; i++) {
        if (i == pivot_i && i == n - 1) {
            cout << "[" << A[i] << "]" << endl;
        } else if (i == pivot_i) {
            cout << "[" << A[i] << "]" << " ";
        } else if (i == n - 1) {
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }        
    }
}

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

    int pivot_i = partition(0, n - 1);

    printA(pivot_i);

    return 0;
}


Measured memory_bytes: 3460
#include <stdio.h>
int main ()
{
	int i, jia=0, jian=0, t=0;
	int m;
	scanf ("%d", &m);
	char x[m];
	scanf ("%s", &x);
	int zui[m];
	for (i=0;i<m;i++)
	{
		if (x[i]=='I')
			++jia;
		if (x[i]=='D')
			++jian;
		zui[i]= 0 + jia - jian;
	}
	for (i=0;i<m;i++)
	{
		if (zui[i]>=t)
		{
			t = zui[i];
		}
	}
	printf ("%d", t);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int cx[] = {0, w};
        int cy[] = {0, h};
        for(int i = 0; i < n; i++){
        	int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();
            if(a == 1 && cx[0] < x){
            	cx[0] = x;
            }else if(a == 2 && cx[1] > x){
            	cx[1] = x;
            }else if(a == 3 && cy[0] < y){
            	cy[0] = y;
            }else if(a == 4 && cy[1] > y){
            	cy[1] = y;
            }
            if(cx[0] >= cx[1] || cy[0] >= cy[1]){
            	System.out.println(0);
                return;
            }
        }
        int yoko = cx[1] - cx[0];
        int tate = cy[1] - cy[0];
        System.out.println(yoko * tate);
	}
}


Measured memory_bytes: 36020
N = int(input())
P = {}
for _ in range(N):
    s = input()
    if s not in P.keys():
        P[s] = 1
    else:
        P[s] += 1

P = sorted(P.items(), key=lambda x: [-x[1], x[0]])
max_n = P[0][1]
for p in P:
    if p[1] == max_n:
        print(p[0])

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

N = int(input())
list = list(map(int, input().split()))

stair = 1
cnt = 0

for i in list : 
    if i == stair : 
        stair += 1
    else : 
        cnt += 1
        
if stair == 1 : 
    print(-1)
else : 
    print(cnt)

Measured memory_bytes: 24744
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    cout<<n*n*n<<endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
int aa[213456];
signed main() {
  int n;cin>>n;
  cout<<(n+1)/2<<endl;
}

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

typedef long long ll;

bool solve(const int n, const vector<int> & in){
  ll sum = accumulate(in.begin(), in.end(), 0LL);

  if (sum % ((static_cast<long long>(n) * static_cast<long long>(n+1))/2)
	      != 0){
    return false;
  }
  ll k = sum / ((static_cast<long long>(n) * static_cast<long long>(n+1))/2);

  ll ops = 0;
  for(int i = 0;i < n;i++){
    ll tmp = in[(i+1)%n] - in[i] - k;
    if (tmp <= 0 &&  - tmp % n == 0){
      ops += -tmp / n;
    }else return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  for(int i = 0;i < n;i++){
    cin >> in[i];
  }
  if (solve(n, in)){
    cout <<"YES" << endl;
  } else {
    cout <<"NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define TARUNNO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
   #define INF 99999
   #define MAX 100000
   #define pb push_back
   #define pf push_front
   #define pob pop_back
   #define pof pop_front
   #define ins insert
   #define mp make_pair
   #define F first
   #define S second
   #define Endl endl
   #define PII pair<ll,ll>
   #define pii pair<int, int>
   #define PIPII pair<ll , pair<ll, ll> >
#define testing() {cout<<"OK"<<endl;}
#define array(a,n) for(int i=0;i<int(n);i++){cout<<a[i];}
#define vector(v) for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
using namespace std;
template<typename T>
string to_string(T str){stringstream stream;stream << str;return stream.str();}


int main(){
    TARUNNO;
    ll N, K; cin >> N >> K;
    ll R, S, P; cin >> R >> S >> P;
    string s, sx="", sxx=""; cin >> s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='r') sx+='p';
        else if(s[i]=='p') sx+='s';
        else sx+='r';
    }
    for(int i=0; i<s.length()-K; i++) if(sx[i]==sx[i+K]) sx[i+K] = s[i];
    ll res = 0;
    ll mins = 0;
    for(int i=0;i<sx.length();i++){
        if(sx[i]==s[i]){
            if(sx[i]=='s') mins += S*1ll;
            else if(sx[i]=='r') mins += R*1ll;
            else mins += P*1ll;
        }
    }
    for(int i=0; i<sx.length(); i++){
        if(sx[i]=='s') res += S*1ll;
        else if(sx[i]=='p') res += P*1ll;
        else res += R*1ll;
    }
    cout <<res - mins<<endl;

    return 0;
}



                             //   C O M F O R T A B L Y   N U M B   //


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

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
int main() {
	string S;
	cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  return 0;
}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
    cin>>n;
	string str;
	map<string,int> mp;
	for(int i=0;i<n;i++)
	{
		cin>>str;
		++mp[str];
	}
	cout<<sz(mp);
	return 0;
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
#define enter putchar('\n')
#define space putchar(' ')
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
map<pii, int> M;
vector<pii> E[500005];
set<pii> s;
int n, m, ncnt, d[500005];
template <class T> int read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (c > -1 && c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
	if (c == -1) return 0;
	while (c >= '0' && c <= '9') { x = x * 10 + c - 48; c = getchar(); }
	return x *= f, 1;
}
template <class T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
int main() {
	while (read(n), read(m)) {
		M.clear();
		ncnt = n;
		for (int i = 1; i <= n; ++i)
			E[i].clear();
		for (int i = 1; i <= m; ++i) {
			int u, v, c;
			read(u), read(v), read(c);
			if (!M[mp(u, c)]) {
				M[mp(u, c)] = ++ncnt;
				E[ncnt].clear();
				E[ncnt].pb(mp(u, 1));
				E[u].pb(mp(ncnt, 1));
			}
			if (!M[mp(v, c)]) {
				M[mp(v, c)] = ++ncnt;
				E[ncnt].clear();
				E[ncnt].pb(mp(v, 1));
				E[v].pb(mp(ncnt, 1));
			}
			E[M[mp(u, c)]].pb(mp(M[mp(v, c)], 0));
			E[M[mp(v, c)]].pb(mp(M[mp(u, c)], 0));
		}
		fill(d, d + ncnt + 1, -1);
		d[1] = 0;
		s.insert(mp(d[1], 1));
		while (!s.empty()) {
			int u = s.begin() -> se;
			s.erase(s.begin());
			for (int i = 0; i < E[u].size(); ++i) {
				int v = E[u][i].fi;
				if (d[v] > d[u] + E[u][i].se || d[v] == -1) {
					s.erase(mp(d[v], v));
					d[v] = d[u] + E[u][i].se;
					s.insert(mp(d[v], v));
				}
			}
		}
		write(d[n] >> 1), enter;
	}
	return 0;
}

Measured memory_bytes: 62080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

ll f(ll x, vector<ll> &v){
	ll ans = 0;
	for(auto &y : v){
		ll d = x - y;
		ans += d * d;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	int n;
	cin >> n;

	ll s = 0;
	vector<ll> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
		s += v[i];
	}

	s /= n;

	ll ans = 1e17;
	for(ll x = s - 2; x <= s + 2; x++)
		ans = min(ans, f(x, v));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
n = int(input())
p = list(map(int,input().split()))

answer = 0
for i in range(n - 2):
    if p[i] < p[i + 1] < p[i + 2]:
        answer += 1
    if p[i] > p[i + 1] > p[i + 2]:
        answer += 1

print(answer)

Measured memory_bytes: 9136
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;





int main(){

    ll N,A,B; cin>>N>>A>>B;

    ll s = A + B;

    ll n = N/(A+B);

    ll ans = n * A;

     N = N - s * n;

    if(N <=A) ans += N;
    else ans += A;

    cout<<ans<<endl;



return 0;



}

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

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[(1<<20)][21];
int go[(1<<20)][21];
int n,k;
int main(){
	cin>>n>>k;
	for(int i=0;i<=n;i++){
		string s; cin>>s;
		for(int j=0;j<(1<<i);j++){
			if(s[j] == '1'){
				dp[j][i]++;
			}
		}
	}
	//x -> x*
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<(1<<i);j++){
			dp[j][i] += dp[j*2+0][i+1]+dp[j*2+1][i+1];
			//cout<<j<<" "<<i<<" "<<dp[j][i]<<endl;
		}
	}
	for(int a=1;a<=n;a++){
		for(int j=0;j<(1<<n);j++){
			int hoge = j%(1<<a);
			int x = 1-(((j>>(a-1))&1));
			x *= (1<<a);
			go[j][a] = (j-hoge)*2+hoge+x;
		}
	}
	//1->(0...0)1 & 0->(1...1)0
	for(int a=1;a<=n-1;a++){
		for(int i=n-1;i>=a;i--){
			for(int j=0;j<(1<<i);j++){
				dp[j][i] += dp[go[j][a]][i+1];
			}
		}
	}
	for(int a=n;a>=1;a--){
		for(int i=0;i<(1<<a);i++){
			if(dp[i][a] >= k){
				string ret = "";
				rep(x,a){
					ret.pb('0'+i%2);
					i/=2;
				}
				reverse(ret.begin(),ret.end());
				cout<<ret<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 172480
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int N = r.ri();
		String nStr = ""+N;
		int div = 0;
		
		for(int i = 0; i<nStr.length(); i++)
			div += Integer.parseInt(""+nStr.charAt(i));
		
		if((N%div) == 0)
			print("Yes");
		else
			print("No");
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

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

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21200
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

//---------------------------------------------------------------------------------------------------

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

   if(a < 1200){
      cout << "ABC" << endl;
   }
   else if(a >= 1200 && a < 2800){
      cout << "ARC" << endl;
   }else{
      cout << "AGC" << endl;
   }

   return 0;
}

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

#define ll long long 
#define int long long
#define G vector<vector<int>> 
const int mod = 1e9 + 7;

ll mul (ll a, ll b){
	return (a*b)%mod;
	}

pair<ll, ll> dfs(int u, int parent, G &adj){
	//~pair<ll, ll> ans;
	ll all_white = 1;
	ll some_black = 0;
	for(int v: adj[u]){
		if(parent != v){
			pair<ll, ll> p = dfs(v, u, adj);
			some_black = (mul(all_white, p.second) + mul(some_black, p.first + p.second))%mod;
			all_white = mul(all_white, p.first);
			
			}
		}
	return {(all_white + some_black)%mod ,all_white};
	}

signed main(){
	
	int n;
	cin>>n;
	G adj(n+1);
	for(int i = 0; i<n-1; i++){
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
		
		}
	pair<ll, ll > ans = dfs(1, -1, adj);
	cout << (ans.first + ans.second)%mod;
	return 0;
	}


Measured memory_bytes: 12672
(defun solve-bezout (m n d)
  (if (not (= (gcd m n) d))
      nil
      (loop for k in (if (>= m n)
			 (euclidean-alg m n)
			 (euclidean-alg n m))
	 for x = 0 then (+ (* 0 x) (* 1 u))
	 and y = 1 then (+ (* 0 y) (* 1 v))
	 and u = 1 then (+ (* 1 x) (* (- k) u))
	 and v = (- k) then (+ (* 1 y) (* (- k) v))
	 finally (return (if (>= m n)
			     (cons x y)
			     (cons y x))))))

(defun euclidean-alg (m n)
  (let ((rem (mod m n)))
    (if (zerop rem)
	(list (/ m n))
	(cons (/ (- m rem) n)
	      (euclidean-alg n rem)))))

;; Es sucht k in Z, so dass x+k*alpha ist das kleinste nicht negative Nummer.
(defun get-minimum-factor (x alpha)
  (funcall (if (plusp alpha) #'ceiling #' floor)
	   (/ (- x) alpha)))

(defun sign (x) (cond ((> x 0) 1) ((= x 0) 0) (t -1)))

;; Es sucht eine ganzzahlige Lösung, so dass
;; m*x+n*y=d, 0<=x, 0<=y, x+y<=sup.
(defun solve-bezout-positive (m n d sup)
  (let ((gcdmn (gcd m n)))
    (if (/= (mod d gcdmn) 0)
	nil
	(let* ((root (solve-bezout m n gcdmn))
	       (factor (/ d gcdmn))
	       (x0 (* (car root) factor))
	       (y0 (* (cdr root) factor))
	       (deltax (/ n gcdmn))
	       (deltay (/ m gcdmn)))
	  ;; (format t "(~A + k * ~A, ~A - k * ~A)~%" x0 deltax y0 deltay)
	  (let* ((k-min1 (get-minimum-factor x0 deltax))
		 (k-min2 (get-minimum-factor y0 (- deltay)))
		 (x1 (+ x0 (* k-min1 deltax)))
		 (y1 (- y0 (* k-min1 deltay)))
		 (x2 (+ x0 (* k-min2 deltax)))
		 (y2 (- y0 (* k-min2 deltay))))
	    ;; (format t "k-min1=~A, k-min2=~A~%" k-min1 k-min2)
	    ;; (format t "deltax=~A, deltay=~A~%" deltax deltay)
	    (if (and (>= y1 0) (<= (+ x1 y1) sup))
		(cons x1 y1)
		(if (and (>= x2 0) (<= (+ x2 y2) sup))
		    (cons x2 y2)
		    nil)))))))


;; Sei y=1000y'. Wir lösen folgende ganzahlige Gleichungen:
;; 10i + 5j + k = y',
;; i + j + k = n,
;; i, j, k >= 0.

;; Sie sind wie folgt reduziert:
;; 9i + 4j = y' - n,
;; i, j >= 0, i + j <= n.

;; Es ist eine so gennnte Bézout-Gleichung: y'-n soll ein Vielfaches von gcd(9, 4) sein.


(defun judge-solve-print (n y)
  (let* ((ij (solve-bezout-positive 9 4 (- (/ y 1000) n) n)))
    ;; (format t "9i+4j=~A~%" (- (/ y 1000) n))
    (if (null ij)
	(format t "-1 -1 -1")
	(format t "~A ~A ~A~%" (car ij) (cdr ij) (- n (car ij) (cdr ij))))))

(judge-solve-print (read) (read))


Measured memory_bytes: 17248
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

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

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

    for (int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);//更新される可能性があるのはR[i]>minvのとき
        minv = min(minv, R[i]);//更新されるのはR[i]<minvのとき
    }
    cout << maxv << endl;
    return 0;    
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  int sum = 0;
  
  int vs[n];
  int cs[n];
  
  rep(i,n) cin>>vs[i];
  rep(i,n) cin>>cs[i];
  
  rep(i,n) {
    int diff = vs[i]-cs[i];
    if(diff>0) sum += diff; 
  }
  
  cout<<sum;
  
  return 0;
}

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

int main(){
    char s[10];
    int i, x, sa, min=1000;

    scanf("%s", s);

    i = 0;

    while(s[i+2] != '\0'){
        x = (s[i] - '0')*100 + (s[i+1] -'0')*10 + (s[i+2] - '0');
        sa = 753 - x;

        sa = abs(sa);

        if(min > sa)
            min = sa;

        i++;
    }

    printf("%d\n", min);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int ans=0;
  REP(i,N/2)if(S[i]!=S[N-1-i])ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256