akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, x: int, a: "List[int]"):
    ret = 0
    for i in range(1, N):
        if a[i] + a[i - 1] > x:
            hoge = (a[i] + a[i - 1]) - x
            ret += hoge
            tmp = min(hoge, a[i])
            a[i] -= tmp
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16148
#include <stdio.h>

int main() {
    long long  n,a,m,M,c,b,i;
    c = 0;
    m = 100000000;
    M =-100000000;
    scanf("%lld",&n);
    
    for(i=1; i<=n; i++){
        scanf("%lld",&a);
        if(a>M) {
            M = a;
        }
        if(a < m){
            m = a;
        }
        c = c+a;
    }
    printf("%lld %lld %lld\n",m,M,c);
    
    return 0;
}



Measured memory_bytes: 2084
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if ( b < c){
			if ( a < b ){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17172
def findnumberofTriangles(arr): 
  
    # Sort array and initialize count as 0 
    n = len(arr) 
    arr.sort() 
    count = 0
  
    # Fix the first element. We need to run till n-3 as 
    # the other two elements are selected from arr[i+1...n-1] 
    for i in range(0,n-2): 
  
        # Initialize index of the rightmost third element 
        k = i + 2
  
        # Fix the second element 
        for j in range(i+1,n): 
  
            # Find the rightmost element which is smaller 
            # than the sum of two fixed elements 
            # The important thing to note here is, we use 
            # the previous value of k. If value of arr[i] + 
            # arr[j-1] was greater than arr[k], then arr[i] + 
            # arr[j] must be greater than k, because the array 
            # is sorted. 
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
  
            # Total number of possible triangles that can be 
            # formed with the two fixed elements is k - j - 1. 
            # The two fixed elements are arr[i] and arr[j]. All 
            # elements between arr[j+1] to arr[k-1] can form a 
            # triangle with arr[i] and arr[j]. One is subtracted 
            # from k because k is incremented one extra in above 
            # while loop. k will always be greater than j. If j 
            # becomes equal to k, then above loop will increment k, 
            # because arr[k] + arr[i] is always greater than arr[k] 
            if(k>j): 
                count += k - j - 1
  
    return count
n = int(input())
l = [int(x) for x in input().split()]
print(findnumberofTriangles(l))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int n;
    cin >> n;

    vector<int> a(n),b(n),c(n-1);

    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int ans=0;
    rep(i,n){
        ans += b[a[i]-1];
        if(i==n-1) continue;
        if(a[i+1]==a[i]+1) ans+=c[a[i]-1];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
point = []
for i in range(N+1):
    point.append(K- Q)
    
for i in range(Q):
    num = int(input())
    point[num] += 1
    
for i in range(1, N+1):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7848
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int N = scan.nextInt();
      	int[] W = new int[N];
      	int[] ans = new int[N];
      	for(int i = 0 ; i < N; i++){
        	W[i] = scan.nextInt();
        }
      	for(int t = 0; t < N; t++){
           int s1 = 0;
           int s2 = 0;
        	for(int j = 0; j < t; j++){
            	s1 = s1 + W[j];
            }
          	for(int k = t; k < N; k++){
            	s2 = s2 + W[k];
            }
          	ans[t] = Math.abs(s1-s2);
        }
      	Arrays.sort(ans);
    	System.out.print(ans[0]);
    }
 
}

Measured memory_bytes: 23636
N, K = map(int, input().split())

# 10^100 = A
# [A, A+1, ..., A + N] (N+1個の数)
# K個以上選ぶときの和として，あり得るものの個数 (mod 10^9 + 7)
MOD = int(10 ** 9 + 7)

la = list(range(N + 1))

def counter(k):
    # laからk個取った場合の話としてあり得る個数
    # 最小のk個 (0, 1, ..., k - 1)
    # 最大のk個 (N - k + 1, ..., N)
    # print(k, "[0,{}]".format(k - 1), "[{},{}]".format(N - k + 1, N))

    # Too slow
    # ft = sum(la[:k])
    # fl = sum(la[-k:])

    # 1からk-1までの和 ((k - 1) * (k - 2)// 2)
    # print(sum(la[:k]), (k - 1) * k // 2)
    # print(sum(la[-k:]), (N + 1) * N // 2 - (N - k + 1) * (N - k) // 2)
    ft = (k - 1) * k // 2
    fl = (N + 1) * N // 2 - (N - k + 1) * (N - k) // 2

    # ftからflまで+1ずつ全部作れる，この個数
    # print(fl - ft + 1)
    return fl - ft + 1

count = 0
for k in range(K, N + 2):
    ans_k = counter(k)
    count = (count + ans_k) % MOD
print(count)

Measured memory_bytes: 66176
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
namespace mp = boost::multiprecision;
using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

vector<ll> par;
ll root(ll x){
  if (par[x] == x){ //根
    return x;
  }
  else {
    return par[x] = root(par[x]); //経路圧縮
  }
}
void unite(ll x,ll y){
  x = root(x);
  y = root(y);
  if (x == y){}
  else{
    par[x] = y;     //xの親をyの親にする
  }
}
ll same(ll x,ll y){
  return root(x) == root(y);
}

//以下main関数内に記述
//nは頂点の数


int main(){
  ll n,m;
  cin>>n>>m;
  par.assign(n+1,0);
  for(ll i=0;i<n;i++){
    par[i]=i;
  }
  for(ll i=0;i<m;i++){
    ll x,y,z;
    cin>>x>>y>>z;
    unite(x,y);
  }
  ll ans=0;
  for(ll i=0;i<n;i++){
    if(par[i]==i)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int[][][] ary = new int[4][3][10];
        
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int b = sc.nextInt()-1;
            int f = sc.nextInt()-1;
            int r = sc.nextInt()-1;
            int v = sc.nextInt();
            ary[b][f][r] += v;
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                StringBuilder sb = new StringBuilder();
                for (int k = 0; k < 10; k++) {
                    sb.append(" ").append(ary[i][j][k]);
                }
                System.out.println(sb.toString());
            }
            if (i != 3) System.out.println("####################");
        }
    }
}

Measured memory_bytes: 29408
n = int(input())
 
li = []
for i in range(n):
    li.append(list(input().split()))
 
 
for money in li:
    if money[1] == 'JPY':
        continue
    else:
        money[0] = float(money[0]) * 380000.0
 
sum_money = sum([float(i[0]) for i in li])
  
print(sum_money)

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

using namespace std;

int main(void)
{
    int n, counter = 0, it = 0, cycle;
    long long k;
    scanf("%d %lld", &n, &k);
    int arr[n][2] = {0};
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i][0]);
    }
    while (k > 0)
    {
        counter++;
        if (arr[it][1] == 0)
        {
            arr[it][1] = counter;
            it = arr[it][0] - 1;
            k--;
        }
        else
        {
            cycle = counter - arr[it][1];
            k = k % cycle;
            for (int i = 1; i <= k; i++)
            {
                it = arr[it][0] - 1;
            }
            break;
        }
        
    }
    printf("%d", it + 1);
}

Measured memory_bytes: 5388
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 1000000000, MAXI = N, D = 14;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 5, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//         int a = rand()%N+1;
//         a *= flag;
      
//         flag *= -1;

//         int b = rand()%MAXI + 1, c;

//         int d = rand()%D + 1;

//         int flag2 = rand()%3, k;

//         if(flag2==0)
//         {
//         	k = rand()%d+1;
//         	c = a + k*b;
//         }
//         else if(flag2==1)
//         {
//         	k = rand()%d + 1;
//         	c = a - k*b;
//         }
//         else
//         	c = rand()%MAXI;

//         cout << a << " " << b << " " << c << " " << d;
//         cout << "\n";
//         cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005

 
// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
   	int n;
   	cin >> n;
   	string s;
   	cin >> s;

   	int ans = 0;
   	int r = 0, b = 0, g = 0;
   	for(int i=0;i<n;i++)
   	{
   		if(s[i]=='R'){
   			ans += b*g;
   			r++;
   		}
   		else if(s[i]=='G'){
   			ans += r*b;
   			g++;
   		}
   		else{
   			ans += r*g;
   			b++;
   		}

   		for(int j=i-1;j>=0;j--)
   		{
   			int k = i-j;
   			if(s[j]!=s[i] and j-k>=0 and s[j-k]!=s[j] and s[j-k]!=s[i])
   				ans--;
   		}


   	}

   	cout << ans;

    
    return 0;
 
} 

Measured memory_bytes: 3552
while true

	aryMondai = gets.split.map(&:to_i);
	
	num1 = aryMondai[0];
	num2 = aryMondai[1];
	
	if num1 == 0 && num2 == 0 then
		break;
	end
	
	for i in 0..num1-1 do
		
		for j in 0..num2-1 do
		
		print "#";
		
		end
		
		print "\r\n";
	end
	
	print "\r\n";
end

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

int A[2000];
int n;

bool find(int s, int q) {
	if (q == 0)
		return true;
	if (s >= n)
		return false;
	return find(s + 1, q) ||
			find(s + 1, q - A[s]);
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)	scanf("%d", &A[i]);
	int q;
	scanf("%d", &q);
	int m;
	for (int i = 0; i < q; ++i ) {
		scanf("%d", &m);
		cout << (find(0, m) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    int n;
    cin>>n;
    int diff=INF;
    int res;
    for(int i=2;i<=12;i++)
    {
        float p=1/(float)i;
        int temp=pow(n,p);
        //cout<<temp<<" ";
        int t_diff=n-pow(temp,i);
        //cout<<t_diff<<endl;
        if(t_diff<diff)
        {
            res=pow(temp,i);
            diff=t_diff;
        }
    }
    cout<<res;
    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;

int main() 
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> V;
    if (s[0] == '0') V.push_back(0); // dummy
    char lastCh = s[0];
    int cnt = 1;
    if (s.size() == 1) V.push_back(1);
    for(int i=1; i<s.size(); i++) {
        char ch = s[i];
        if(ch != lastCh) {
            V.push_back(cnt);
            cnt = 0;
        }
        lastCh = ch;
        cnt++;
        if (i==s.size()-1) V.push_back(cnt);
    }
    if (s[s.size()-1] == '0') V.push_back(0); // dummy

    // 累積和
    ll S[V.size()+1];
    S[0] = 0;
    for(int i=1; i<=V.size(); i++) {
        S[i] = S[i-1] + V[i-1];
    }

    int w = 2*k+1;
    if (w > V.size()) {
        cout << S[V.size()] << endl;
        return 0;
    }

    ll ans = 0;
    for (int i=1; i+w-1<=V.size(); i+=2) {
        ans = max(ans, S[i+w-1]-S[i-1]);
    }

    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 1656
#include <stdio.h>
#include <ctype.h>

int main(void){
  char ch;
  int i, count[26];

  for(i = 0; i < 26; i++){
    count[i] = 0;
  }
  while(scanf("%c", &ch) != EOF){
    if(isupper((int)ch)){
      count[ch - 'A']++;
    }else if(islower((int)ch)){
      count[ch - 'a']++;
    }
  }

  for(i = 0; i < 26; i++){
    printf("%c : %d\n", 'a'+i, count[i]);
  }
  return 0;
}

Measured memory_bytes: 544
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[][] a = new int[M][2];
    for (int i = 0; i < M; i++){
      a[i][0] = scanner.nextInt();
      a[i][1] = scanner.nextInt();
    }
  Arrays.sort(a, new Comparator<int[]>(){
    @Override
    public int compare(int[] o1, int[] o2){
      return o1[1] - o2[1];
    }
  });

  int count = 0;
  for (int i = 0; i < M;){
    count++;
    int right = a[i][1];
    i++;
    while (i < M && a[i][0] < right){
      i++;
    }
  }
    System.out.println(count);
  }
}


Measured memory_bytes: 88904
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::string;

int main(int argc, char* argv[]) {
  std::string s;
  cin >> s;

  bool is_easy = true;
  for (int i = 0; i < s.length(); ++i) {
    is_easy = is_easy && (s[i] == ((i % 2 == 0) ? 'R' : 'L') || s[i] == 'U' || s[i] == 'D');
  }
  cout << (is_easy ? "Yes" : "No");

  return 0;
}


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

int main(){
    int i, j, k;
    int N, x[100], y[100], h[100];
    cin >> N;
    for(i=0; i<N; i++) cin >> x[i] >> y[i] >> h[i];

    for(int Cx=0; Cx<=100; Cx++){
        for(int Cy=0; Cy<=100; Cy++){
            int H = -1; // -1:未確定
            int Hmax = 2e9; // h[i]=0である点から要求されるHの上限
            bool success = true;
            for(i=0; i<N; i++){
                int d = abs(Cx-x[i]) + abs(Cy-y[i]);
                if(h[i] > 0){
                    int H2 = h[i] + d;
                    if(H > 0 && H != H2){
                        success = false;
                        break;
                    }else{
                        H = H2;
                    }
                }else{
                    Hmax = min(Hmax, d);
                }
            }
            if(success && H <= Hmax){
                cout << Cx << " " << Cy << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

const ll INF = 1LL << 60;

int main() {
    ll D, G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    ll ans = INF;

    for (int i = 0; i < (1 << D); i++) {
        vector<bool> all(D, false);
        ll score = 0;
        ll count = 0;
        for (int j = 0; j < D; j++) {
            if (i & (1 << j)) all[j] = true;
        }
        for (int j = 0; j < D; j++) {
            if (all[j]) {
                score += p[j]*(100*(j+1));
                score += c[j];
                count += p[j];
            }
        }

        if (score >= G) ans = min(ans, count);
        else {
            for (int j = D-1; j >= 0; j--) {
                if (!(all[j])) {
                    for (int k = 0; k < p[j]; k++) {
                        if (score >= G) break;
                        score += 100*(j+1);
                        count ++;
                    }
                }
            }
            ans = min(ans, count);
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    sort(s.begin(), s.end());
    int64_t res = 1;
    rep(i, n-1){
        if(s.at(i) != s.at(i+1)) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 9536
(* O(n) *)
let solve n infos =
  let rec loop (t', x', y') = function
  | [] -> "Yes"
  | (t, x, y) :: rest ->
    let min_time = (x - x') + (y - y') in
    let needed_time = t - t' in
    if needed_time < min_time || (needed_time - min_time) mod 2 <> 0 then (* ∵ 格子点の偶奇性より *)
      "No"
    else 
      loop (t, x, y) rest
  in
    loop (0, 0, 0) infos

(* O(n) *)
let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  fold_int
    (fun sofar _ ->
      match read_ints () with
      | [t; x; y] -> (t, x, y) :: sofar
      | _ -> sofar)
    []
    n |> List.rev |> solve n |> print_endline

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b=0;
  cin>>a;
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      for(int k=0;k<a;k++){
	b++;
      }
    }
  }
cout<<b<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

long long int func(long long int x, long long int y){
  long long int a, b;
  if(x >= y){
    a = x;
    b = y;
  }
  else{
    a = y;
    b = x;
  }
  if(b == 0) return a;
  long long int c = a % b;
  while(c != 0){
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

void solve(){
  int n; cin >> n;
  long long int a[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i];
  long long int l[n + 2], r[n + 2];

  long long int ans = 1;
  l[0] = 0;
  a[0] = 0;
  for(int i = 1; i <= n; i++){
    l[i] = func(l[i - 1], a[i - 1]);
  }
  r[n + 1] = 0;
  for(int i = n; i >= 1; i--){
    r[i] = func(r[i + 1], a[i]);
  }

  for(int i = 1; i <= n; i++){
    /*for(int j = 1; j <= n; j++){
      cout << a[j] << " ";
      if(j == i) cout << "| ";
    }
    cout << endl;
    cout << l[i] << " " << r[i + 1] << endl;
    cout << func(l[i], r[i + 1]) << endl;*/
    ans = max(func(l[i], r[i + 1]), ans);
  }

  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

const int N = 200010;

int n;
PII edges[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i)
        scanf("%d%d", &edges[i].first, &edges[i].second);
    LL vsum = 0, esum = 0;
    for (int u = 1; u <= n; ++u) vsum += (LL)u * (n - u + 1);
    for (int i = 0; i < n - 1; ++i) {
        int minu = min(edges[i].first, edges[i].second);
        int maxu = max(edges[i].first, edges[i].second);
        esum += (LL)minu * (n - maxu + 1);
    }
    printf("%lld\n", vsum - esum);
    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
 
#define MAX 100000
 
struct TRAMP{
    char mark;
    int number,inputed_order;
};
 
TRAMP cards[MAX];
 
int n;
 
int Partition(int left,int right){
    int i = left-1,pivot = cards[right].number;
    for(int start = left; start < right; start++){
        if(cards[start].number <= pivot){
                i++;
                std::swap(cards[i],cards[start]);
        }
    }
 
    std::swap(cards[i+1],cards[right]);
 
    return i+1;
}
 
void quickSort(int left,int right){
    if(left < right){
        int q = Partition(left,right);
        quickSort(left,q-1);
        quickSort(q+1,right);
    }
}
 
 
int main(){
 
    bool stableFLG = true;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",&cards[i].mark,&cards[i].number);
        cards[i].inputed_order = i;
    }
 
    quickSort(0,n-1);
 
    for(int i = 1; i < n; i++){
        if(cards[i].number == cards[i-1].number && cards[i].inputed_order < cards[i-1].inputed_order){
            stableFLG = false;
            break;
        }
    }
 
    if(stableFLG){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
 
    for(int i = 0; i < n; i++)   printf("%c %d\n",cards[i].mark,cards[i].number);
}


Measured memory_bytes: 4304
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> getLine >>= putStrLn . solve 

solve :: String -> String
solve = check . map length . group . sort
    where
        check [b, r]
            | r > b = "Yes"
            | otherwise = "No"

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
#include <map>
#include <ctime>
#ifdef WK
	#include <windows.h>
#endif
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define lowbit(x) (x&(-x))
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define drep(i,x,y) for(int i=x;i>=y;i--)
#define repg(i,x) for(int i=p[x];i;i=e[i].nt)  
using namespace std;
typedef long long LL;
LL read(){
	LL rtn=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch<='9'&&ch>='0')rtn=(rtn<<3)+(rtn<<1)+ch-'0',ch=getchar();
	return rtn;
}
const int N=5010;
LL n,a,b,c,d; 
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
	//freopen("ou1.txt","w",stdout);
#endif
	n=read();a=read();b=read();c=read();d=read();
	b-=a; n--;
	rep(i,0,n){
		LL tmp1=c*i+d*i-d*n;
		LL tmp2=d*i+c*i-c*n;
		if(tmp1<=b&&tmp2>=b){
			puts("YES");
			return 0;
		} 
	}printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] a=new int[200];
        int[] b=new int[200];
        int i=0;
        while(true){
            a[i]=scan.nextInt();
            b[i]=scan.nextInt();
            if(a[i]==0&&b[i]==0) break;
            i++;
        }
        i=0;
        while(true){
            if(a[i]==0&&b[i]==0) break;
            int cnt=0;
            for(int j=1;j<a[i];j++){
                for(int k=j+1;k<a[i];k++){
                    if(b[i]-j-k>k&&b[i]-j-k<=a[i]) cnt++; 
                }
            }
            System.out.println(cnt);
            i++;

        }
    }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    cout << accumulate(as.begin(), as.end(), 0ll) << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,l;
    cin >> n >> l;
    vector<string> a(n);
    rep(i,n) cin >> a[i];
    SORT(a);
    string ans = "";
    rep(i,n) ans += a[i];
    PRINT(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string s;
stack<char> St;

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

  cin >> s;
  int n = s.size();
  rep(i, n) {
    if (s[i]=='B') {
      // popは空だとエラーになるので気をつける事
      if (!St.empty()) St.pop();
    } else St.push(s[i]);
  }
  string t = "";
  while (!St.empty()) {
    char c = St.top(); 
    t += c;
    St.pop();
  }
  reverse(ALL(t));
  cout << t << "\n";
  return 0;
}

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

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

    if(a > b){
        for(int i = 0; i < a; i++){
            cout << b;
        }
        cout << endl;
    }else{
        for(int i = 0; i < b; i++){
            cout << a;
        }
        cout << endl;
    }
    
    return 0;
}

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

int main()
{
    int n, k;
    string s[110];
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> s[i];
    sort(s, s+n);
    for(int i = 0; i < n; i++)
        cout << s[i];
}



Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int N,count(0),ans(0);
    cin >> N;
    for(int j=1;j<=N;j++){
        for(int i=1;i<=sqrt(j);i++){
            if(j%i==0){
                count++;
            }
        }
        if(count==4 && j%2!=0){
            ans++;
        }
        count=0;
    }
    cout << ans;
}

Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var t string
	var s = bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if s.Scan() {
		t = s.Text()
	}
	a, err := strconv.Atoi(t)
	if err != nil {
		fmt.Println(-1)
		return
	}

	if s.Scan() {
		t = s.Text()
	}
	b, err := strconv.Atoi(t)
	if err != nil {
		fmt.Println(-1)
		return
	}

	var x = math.Ceil(float64(b) / 0.10)
	if int(float64(x)*0.08) == a {
		fmt.Println(x)
		return
	}

	x = math.Ceil(float64(a) / 0.08)
	if int(float64(x)*0.10) == b {
		fmt.Println(x)
		return
	}

	fmt.Println(-1)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define INFTY 1000000000

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

  vector<ll> x(n+1, 0);
  for(ll i = 1; i <= n; i++){
    cin >> x[i];
  }

  ll mint = INFTY;
  for(ll l = 1; l <= n - k + 1; l++){
    ll r = l + k -1;
    mint = min(x[r] - x[l] + min(abs(x[r]), abs(x[l])), mint);
  }

  cout << mint << endl;

  return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int a[N][N];char s[N][N];
int main(){
	int dx[8]={0,0,1,-1,1,1,-1,-1},dy[8]={1,-1,0,0,1,-1,1,-1};
    int n,m,x,y;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    	scanf("%s",&s[i]);
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		if(s[i][j]=='#'){
    			a[i][j]=-1;
    			for(int k=0;k<8;k++){
    				x=i+dx[k];y=j+dy[k];
    				if(x>=0&&x<n&&y>=0&&y<m&&s[x][y]!='#')a[x][y]++;
    			}
    		}
    	}
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		if(a[i][j]==-1)printf("#");
    		else printf("%d",a[i][j]);
    	}
    	puts("");
    }
}


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

using namespace std;

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

    vector<int> a(n, 1145141919);
    for (int i = 0; i < n - 1; i++) {
        int b;
        cin >> b;
        a[i] = min(a[i], b);
        a[i + 1] = min(a[i + 1], b);
    }

    int ret = 0;
    for (int i = 0; i < n; i++)ret += a[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
n, t = (int(i) for i in input().split())
ts = [int(i) for i in input().split()]
between = []
for i in range(1,n):
    between.append(ts[i]-ts[i-1])
    
ans = t
for d in between:
    if d > t:
        ans = ans + t
    else:
        ans = ans + d
print(ans)


Measured memory_bytes: 25196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(1003);
    for(int i = 2; i <= n; ++i) {
        int x = i;
        for(int j = 2; j <= i; ++j){
            while(x%j==0){
                cnt[j]++;
                x/=j;
            }
        }
    }

    ll ans = 1;
    for(int i = 1; i <= 1000; ++i) {
        ans*=cnt[i]+1;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3468
#include<iostream>
#include<vector>
#include<string>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
#include<cstdint>

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) const { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

// fact
template<typename INT>
struct factorial {
  std::vector<INT> fact, ifact;
  void init(int64_t N) {
    fact.resize(N+1); ifact.resize(N+1);
    fact[0] = fact[1] = INT(1);
    for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
    ifact[N] = fact[N].inv();
    for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
  }
  INT comb(int64_t n, int64_t k) { // nCk
    if(k > n || k < 0) return INT(0);
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int K; std::string S; std::cin >> K >> S;
  int N = S.size();
  factorial<mint> F; F.init(K+N);
  mint ans;
  for(int a = N; a <= N+K; ++a) ans += mint(25).pow(N+K-a)*F.comb(N+K, a);
  fin(ans.v_); 
  return 0;
}


Measured memory_bytes: 35936
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int k, x, i;
	scanf("%d%d", &k, &x);
	loop(i, x-k+1, x+k){
		printf("%d ", i);
	}
	return 0;
}

Measured memory_bytes: 256
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()  





Measured memory_bytes: 6656
def read(): return list(map(int, input().split()))

n, m = read()
x = read()
y = read()

xs, ys = 0, 0
xs = sum([x[i] * (2 * i + 1 - n) for i in range(n)])
ys = sum([y[i] * (2 * i + 1 - m) for i in range(m)])

print((xs * ys) % 1000000007)

Measured memory_bytes: 18624
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	long long n, a, b,souwa; cin >> n >> a >> b;
	n -= 2;
	souwa = n*(b - a); souwa++; if (souwa < 0) { souwa = 0; }
	cout << souwa << endl;
	return 0;
}



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

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        //int n = stdIn.nextInt();
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int c = stdIn.nextInt();
        String s = stdIn.next();
        //char c[] = s.toCharArray();
        //String ss[] = new int[s.length()];
        
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        }else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        }else{
            System.out.println("Sunny");
        }
        
        //int count = 0;
        
        //for(int i = 0; i < n; i++){
            
        //}
        
        //System.out.println();
    }
    
}


Measured memory_bytes: 20820
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int Q = scan.nextInt();

        int L[] = new int[M];
        int R[] = new int[M];
        int X[][] = new int[509][509];
        int C[][] = new int[509][509];
        int p,q,total;

        for(int i = 0; i < M; i++){
            L[i] = scan.nextInt();
            R[i] = scan.nextInt();
            X[L[i]][R[i]]++;
        }

        for(int i = 1; i < N+1; i++){
            for(int j = 1; j < N+1; j++){
                C[i][j] = C[i][j-1] + X[i][j];
            }
        }

        for(int i = 0; i < Q; i++){
            p = scan.nextInt();
            q = scan.nextInt();
            total = 0;
            for(int j = p; j < q+1; j++){
                total += C[j][q] - C[j][p-1];
            }
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 160816
x, n = map(int, input().split())
a = list(map(int, input().split()))
if (x not in a):
    print(x)
    exit()


tar1 = x
tar2 = x
ff1 = True
ff2 = True

while True:
    if (ff1 is True):
        tar1 -= 1
        if (tar1 not in a):
            print(tar1)
            exit()

    if (ff2 is True):
        tar2 += 1
        if (tar2 not in a):
            print(tar2)
            exit()
 

    if ((ff1 is False) and (ff2 is False)):
        break


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

Vi L;
int n;
int A,B,C;
ll ans = INF;
int dfs (int mp, int x , int a, int b, int c){
    if(x<n){
        if(x>2){
            if(a>0&&b>0&&c>0){
                ll tmp = abs(A-a)+abs(B-b)+abs(C-c)+mp;
                ans = min(ans,tmp);
            };
        }
        dfs(mp+10,x+1,a+L[x],b,c);
        dfs(mp+10,x+1,a,b+L[x],c);
        dfs(mp+10,x+1,a,b,c+L[x]);
        dfs(mp,x+1,a,b,c);
    }else{
        if(a>0&&b>0&&c>0){
            ll tmp = abs(A-a)+abs(B-b)+abs(C-c)+mp;
            ans = min(ans,tmp);
        };
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    cin>>n>>A>>B>>C;
    L.resize(n);
    rep(i,n){
        cin>>L[i];
    }
    dfs(-30,0,0,0,0);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
    double r;
    cin >> r;
    cout << fixed;
    cout << setprecision(8) << M_PI*r*r << " ";
    cout << setprecision(8) << 2*M_PI*r << endl;
    return 0;
}


Measured memory_bytes: 3212
n = int(input())
A = [[] * n for _ in range(2)]
for i in range(2):
    a = list(map(int, input().split()))
    A[i] = a

ans = 0
for i in range(n):
    s = sum(A[0][:i + 1]) + sum(A[1][i:])
    ans = max(ans, s)

print(ans)

Measured memory_bytes: 3060
(defun solve (n ps)
  (loop with current-min = most-positive-fixnum
        with count = 0
        for p in ps
        if (<= p current-min)
        do (setf current-min p)
           (incf count)
        finally (return count)))

#-swank
(let* ((n (read))
       (ps (loop repeat n collect (read))))
  (format t "~A~%" (solve n ps)))


Measured memory_bytes: 61928
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<int> count(N, 0);
    loop(i, M){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        ++count[ai];
        ++count[bi];
    }
    bool flag = true;
    for (auto& c : count){
        if (c % 2 == 1){
            flag = false;
            break;
        }
    }
    if (flag){
        puts("YES");
    }else{
        puts("NO");
    }
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int x = 0;
	int y = 0;
	while (a[x] != '\0') {
		x++;
	}
	while (b[y] != '\0') {
		y++;
	 }
	if (a[x - 1] == b[0] && b[y - 1] == c[0])cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print(1)
        exit()
    ans = 0
    ans += (W - (W // 2)) * (H - (H // 2))
    ans += (W // 2) * (H // 2) 

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 38484
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
    ll N; cin >> N;
    vll a(N), b(N);
    rep(i, 0, N){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(N%2==0){
        ll m = a[N/2-1] + a[N/2];
        ll M = b[N/2-1] + b[N/2];
        prt(M-m+1);
    }else{
        ll m = a[N/2];
        ll M = b[N/2];
        prt(M-m+1);
    }
}

Measured memory_bytes: 6340
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int H = sc.nextInt();
        int A = sc.nextInt();

        System.out.println(solve(H, A));
    }

    private static int solve(int H, int A) {
        int count = H/A;

        if (H%A != 0) {
            count++;
        }

        return count;
    }
}

Measured memory_bytes: 21716
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
 for(;;){
	 int n =sc.nextInt();
   if(n==0)break;
 for(int i=0; i<n; i++){
 
 int e=sc.nextInt();
 int m=sc.nextInt();
 int j=sc.nextInt();
 String cl ="C";
 if((e+m)>=180||(e+m+j)>=240||e==100||j==100||m==100)
	 cl ="A";
 else if((e+m+j)>=210||(m>=80&&(e+m+j)>=150)||(e>=80&&(e+m+j)>=150)) 
	 cl="B";
 System.out.println(cl);
 }
 }
 }
 }

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int h, w;
    cin >> h >> w;

    for(int iw=0;iw<w+2;iw++) {
        cout << "#";
    }
    cout << endl;
    for(int ih=0;ih<h;ih++) {
        string s;
        cin >> s;
        cout << "#";
        cout << s;
        cout << "#";
        cout << endl;
    }
    for(int iw=0;iw<w+2;iw++) {
        cout << "#";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3632