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

using namespace std;

int main(){
	long long int n,m;
	cin>>n>>m;
	vector<set<int>>VSI(n);
	vector<int>imosmax(n), imosmin(n);
	for(int i = 0; i < n; i++){
		VSI[i].insert(i);
		imosmax[i] = 1;
		imosmin[i] = 1;
	}
	vector<pair<long long int, long long int>>xy(m);
	for(int i = 0; i < m; i++){
		cin >> xy[i].first >> xy[i].second;
	}
	sort(xy.begin(), xy.end());
	for(int i = 0; i < m; i++){
		int y = xy[i].second;
		imosmax[y] += imosmax[y-1];
		imosmax[y-1] = 0;
		imosmin[y-1] += imosmin[y];
		imosmin[y] = 0;
	}
	vector<int>imos(n+1);
	
	for(int i = 0; i < n; i++){
		imos[i] += imosmin[i];
		imos[i+1] += imos[i];
		imos[i+1] -= imosmax[i];
		cout << imos[i] << (i==n-1?"\n":" ");
	}
}

Measured memory_bytes: 25432
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	char[] s;
	char[] result;
	boolean enable = false;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		s = in.readLine().toCharArray();
	}

	boolean enable(char first, char second, char third) {
		char[] pat = new char[N];
		pat[0] = first;
		pat[1] = second;
		pat[2] = third;
		// ここでは矛盾しないものが来ているとする
		for (int i = 3; i < N; ++i) {
			if (s[i - 1] == 'o') {
				if (pat[i - 1] == 'S') {
					pat[i] = pat[i - 2];
				} else {
					pat[i] = pat[i - 2] == 'S' ? 'W' : 'S';
				}
			} else {
				if (pat[i - 1] == 'S') {
					pat[i] = pat[i - 2] == 'S' ? 'W' : 'S';
				} else {
					pat[i] = pat[i - 2];
				}
			}
		}
		// 矛盾がないかチェック
		boolean isOK = true;
		if (s[N - 1] == 'o') {
			if (pat[N - 1] == 'S') {
				if (pat[0] != pat[N - 2]) {
					isOK = false;
				}
			} else {
				if (pat[0] == pat[N - 2]) {
					isOK = false;
				}
			}
		} else {
			if (pat[N - 1] == 'S') {
				if (pat[0] == pat[N - 2]) {
					isOK = false;
				}
			} else {
				if (pat[0] != pat[N - 2]) {
					isOK = false;
				}
			}
		}
		if (s[0] == 'o') {
			if (pat[0] == 'S') {
				if (pat[1] != pat[N - 1]) {
					isOK = false;
				}
			} else {
				if (pat[1] == pat[N - 1]) {
					isOK = false;
				}
			}
		} else {
			if (pat[0] == 'S') {
				if (pat[1] == pat[N - 1]) {
					isOK = false;
				}
			} else {
				if (pat[1] != pat[N - 1]) {
					isOK = false;
				}
			}
		}
		if (isOK) {
			result = Arrays.copyOf(pat, N);
		}
		return isOK;
	}

	void calc() {
		if(s[1] == 'o') {
			if(enable('S', 'S', 'S')) {
				enable = true;
				return;				
			}
			if(enable('W', 'S', 'W')) {
				enable = true;
				return;				
			}
			if(enable('S', 'W', 'W')) {
				enable = true;
				return;				
			}
			if(enable('W', 'W', 'S')) {
				enable = true;
				return;				
			}
		}else {
			if(enable('S', 'S', 'W')) {
				enable = true;
				return;				
			}
			if(enable('W', 'S', 'S')) {
				enable = true;
				return;				
			}
			if(enable('S', 'W', 'S')) {
				enable = true;
				return;				
			}
			if(enable('W', 'W', 'W')) {
				enable = true;
				return;				
			}
		}
	}

	void showResult() {
		if (!enable) {
			System.out.println("-1");
		} else {
			for (int i = 0; i < N; ++i) {
				System.out.print(result[i]);
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 40864
N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

ans = -1
nearest = float('inf')
for k, h in enumerate(H, 1):
    # 平均気温を1000倍した値で比較してもいい(小数の扱いを考えなくていい)
    tmp = abs(1000 * A - (1000 * T - 6 * h))
    if tmp < nearest:
        ans = k
        nearest = tmp
print(ans)


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

public class Main {
  Scanner sc;

  void run() {
    boolean[] pt = new boolean[123456 * 2 + 1];
    Arrays.fill( pt, true );
    pt[ 0 ] = pt[ 1 ] = false;
    for ( int i = 2; i * i < pt.length; ++i ) {
      if ( pt[ i ] ) {
        // debug(i);
        for ( int j = i * 2; j < pt.length; j += i ) {
          pt[ j ] = false;
        }
      }
    }

    for ( ;; ) {
      int n = ni();
      if ( n == 0 )
        break;

      int sum = 0;
      for ( int i = n + 1; i <= 2 * n; ++i ) {
        if ( pt[ i ] )
          ++sum;
      }

      System.out.println( sum );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  String ns() {
    return sc.next();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 20536
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = (int)1e7+5;
#ifndef LOCAL
#define cerr if(0)cout
#endif

int cnt[MAXN];

int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,1,n)cnt[i]=1;
	for(int i = 2;i<=n;i++) {
		for(int j=i;j<=n;j+=i)cnt[j]++;
	}
	ll ans = 0;
	FOR(i,1,n) {
		ans +=i*cnt[i];
		//db(ans);
	}
	cout<<ans;
}


Measured memory_bytes: 81780
def solve(remains, num=4):
    if remains > 9 * num or remains < 0:
        return 0
    if num == 1:
        return 1
    return sum(solve(remains - i, num - 1) for i in range(10))


while True:
    try:
        print(solve(int(input())))
    except:
        break

Measured memory_bytes: 7616
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <complex>
#include <math.h>

typedef long long ll;

using namespace std;

double pi=2*acos(0);
const int INF = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    if(k>=a+b) cout << 0 << ' ' << 0;
    else if(a<=k && k<a+b) cout << 0 << ' ' << a+b-k;
    else cout << a-k << ' ' << b;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
template <typename T, class F = function<T(const T &, const T &)>>
class Matrix
{
public:
    vector<vector<T>> mat;
    T unity;
    F add, mul;
    Matrix(int h, int w, T unity, const F &add, const F &mul)
        : mat(h, vector<T>(w)), unity(unity), add(add), mul(mul) {}

    inline vector<T> &operator[](int i) { return mat[i]; }
    inline int height() const { return (int)mat.size(); }
    inline int width() const { return (int)mat[0].size(); }

    Matrix identity()
    {
        Matrix E(height(), width(), unity, add, mul);
        for (int i = 0; i < height(); ++i)
            E[i][i] = unity;
        return E;
    }

    Matrix &operator*(Matrix &m)
    {
        int h = m.height(), w = m.width();
        vector<vector<T>> tmp(height(), vector<T>(w));
        for (int i = 0; i < height(); ++i)
            for (int j = 0; j < w; ++j)
                for (int k = 0; k < h; ++k)
                    tmp[i][j] = add(tmp[i][j], mul(mat[i][k], m[k][j]));
        mat.swap(tmp);
        return *this;
    }

    Matrix operator^(T exponent)
    {
        Matrix res = identity();
        Matrix product = *this;

        while (exponent)
        {
            if (exponent & 1)
                res = res * product;
            product = product * product;
            exponent >>= 1;
        }
        return res;
    }
};

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    Matrix<long long> A(n, m, 1, [](auto i, auto j) { return i + j; }, [](auto i, auto j) { return i * j; });
    Matrix<long long> B(m, l, 1, [](auto i, auto j) { return i + j; }, [](auto i, auto j) { return i * j; });
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> A[i][j];
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < l; ++j)
            cin >> B[i][j];
    auto C = A * B;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < l; ++j)
            cout << C[i][j] << " \n"[j == l - 1];
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	bool ok = true;
	string ans(n, '0');
	bool used[n] = {};
	for (int i = 0; i < m; i++) {
		int s; cin >> s;
		char c; cin >> c;
		if (!used[s - 1]) {
			ans[s - 1] = c;
			used[s - 1] = true;
		} else if (ans[s - 1] != c) {
			ok = false;
		}
	}
	if (n > 1 and ans[0] == '0') {
		if (used[0]) ok = false;
		else ans[0] = '1';
	}
	cout << (ok ? ans : "-1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll const MOD = 1e9+7;
  ll dp[N+1][4][4][4];
  for(int i=0; i<N+1; i++) for(int j=0; j<4; j++) for(int k=0; k<4; k++) for(int l=0; l<4; l++) dp[i][j][k][l] = 0;
  dp[0][3][3][3] = 1;

  //c1c2c3 <- a
  //c2c3a
  for(int i=0; i<N; i++){
    for(int c1=0; c1<4; c1++){
      for(int c2=0; c2<4; c2++){
          for(int c3=0; c3<4; c3++){
              for(int a=0; a<4; a++){
                if(c1 == 0 && c2 == 2 && a == 1) continue;
                if(c1 == 0 && c3 == 2 && a == 1) continue;
                if(c2 == 0 && c3 == 2 && a == 1) continue;
                if(c2 == 2 && c3 == 0 && a == 1) continue;
                if(c2 == 0 && c3 == 1 && a == 2) continue;
                dp[i+1][c2][c3][a] += dp[i][c1][c2][c3];
                dp[i+1][c2][c3][a] %= MOD;
              }
          }
      }
    }
  }
  ll ans = 0;
  for(int c1=0; c1<4; c1++){
      for(int c2=0; c2<4; c2++){
          for(int c3=0; c3<4; c3++){
            ans += dp[N][c1][c2][c3];
            ans %= MOD;
          }
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int A = 0;
	int B = 0;
	int C = 0;
	int D = 0;

	cin >> A >> B >> C >> D;

	if (B<C || A>D ) {
		cout << 0 << endl;
	}
	else  {
	
		if (A>=C && D<=B) {
			cout << abs(A-D)<< endl;
		}
	   else if (A>=C && D>=B) {
			cout << abs(A - B) << endl;
		}
	   else if (A<=C && B<=D) {
		   cout << abs(B - C) << endl;
	   
	   }
	   else if (A<=C && D<=B) {
		   cout << abs(C - D) << endl;
	   }
	


	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   int d=min(a+b,2*c);
   if(d==2*c){
      if(x>=y){
         cout<<2*c*y+min((x-y)*a,(x-y)*2*c);
      }
      else{
         cout<<2*c*x+min((y-x)*b,(y-x)*2*c);
      }
   }
   else{
      cout<<a*x+b*y;
   }


   return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  cout << b * 2 - a << endl;
  return 0;
}


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

using namespace std;

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

  for(int q=0;q<n;q++) {
    string str;
    cin >> str;
    if(str[0] != '>') {
      cout <<"NA"<<endl; 
      continue;
    }  else if(str[1] != '\''&& str[1] != '^') {
      cout << "NA" << endl;
      continue;
    }
    int flg = 0,sum;
    if(str[1] == '\'') {
      int t = 0;
      sum=0;
      for(int i=2;i<str.size();i++) {
	if(str[i] == '=') t++;
	else if(str[i] == '#' && sum==0 && i!=2) sum = t , t = 0;
	else break;
	if(str[str.size()-1] == '~' && i == str.size() -2 && sum==t ) flg = 1;
	
      }
    }

      if(str[1] == '^' && flg == 0) {
	flg = 0;
	for(int i=2;i<str.size() ;i++) {
	  if(i%2 == 0 && str[i] != 'Q') break;
	  if(i%2 == 1 && str[i] !='=')  break;

	  if(str[str.size()-2] == '~' && str[str.size()-1] =='~' && i == str.size()-3&& i%2==1 ){
	    flg = 2;
	    break;
	  }
	}
      }

      if(flg == 0) cout << "NA" << endl;
      else if(flg == 1)cout <<"A" << endl;
      else if(flg == 2) cout << "B"<<endl;
  }     


  return 0;
}

Measured memory_bytes: 1208
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left

class Solution:
    def main(self):
        N, L = map(int, input().split())
        # print(list(range(L, L+N)))
        if L <= 0 < L+N:
            print(sum(list(range(L, L+N))))
        elif L + N <= 0:
            print(sum(list(range(L, L+N-1))))
        else:
            print(sum(list(range(L+1, L + N))))


if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;

namespace Queue
{
    class Program
    {
        static void Main(string[] args)
        {
            var queue = new Queue<string>();
            var line = Console.ReadLine();
            var n = int.Parse(line.Split(' ')[0]);
            var q = int.Parse(line.Split(' ')[1]);
            var endTime = 0;

            //initialization
            for(var i = 0; i < n; i++)
            {
                queue.Enqueue(Console.ReadLine());
            }

            while(queue.Count > 0)
            {
                var process = queue.Dequeue();
                var time = int.Parse(process.Split(' ')[1]);
                if(time <= q)
                {
                    endTime += time;
                    Console.WriteLine(process.Split(' ')[0] + " " + endTime.ToString());                    
                }
                else
                {
                    endTime += q;
                    time -= q;
                    queue.Enqueue(process.Split(' ')[0] + " " + time.ToString());
                }
            }
        }
    }
}



Measured memory_bytes: 23864
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <math.h>
#include <bitset>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

const ll INF = 1e18, MOD = 1e9 + 7;
const int INT_MAX = 1e9;

ll n, W;

string s, t;

struct bc
{
	int l, x, y;

	bool operator < (const bc& b)
	{
		return l < b.l;
	}

} d[3000][3000];

int main () 
{
	cin >> s >> t;

	if (s[0] == t[0]) d[0][0] = {1, -1, -1};
	else d[0][0] = {0, -1, -1};

	for (int i = 1; i < s.length (); i++)
	{
		if (s[i] == t[0]) d[i][0] = {1, -1, -1};
		else d[i][0] = {d[i-1][0].l, i - 1, 0};
	}

	for (int i = 1; i < t.length (); i++)
	{
		if (s[0] == t[i]) d[0][i] = {1, -1, -1};
		else d[0][i] = {d[0][i-1].l, 0, i - 1};
	}

	for (int i = 1; i < s.length (); i++)
		for (int j = 1; j < t.length (); j++)
		{
			if (s[i] == t[j])
			{
				d[i][j] = {d[i-1][j-1].l + 1, i - 1, j - 1};
			}
			else if (d[i][j-1].l > d[i-1][j].l) d[i][j] = {d[i][j-1].l, i, j - 1};
			else d[i][j] = {d[i-1][j].l, i - 1, j};
		}

	string ans;

	bc a = {0, (int) s.length () - 1, (int) t.length () - 1};

	while (a.x != -1 && a.y != -1)
	{
		if (s[a.x] == t[a.y]) ans += s[a.x];

		a = d[a.x][a.y];
	}

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

	cout << ans;
}

Measured memory_bytes: 105728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<a+k&&i<=b;i++) cout<<i<<endl;
  if(a+k-1>=b-k+1)
    for(int i=a+k;i<=b;i++)cout<<i<<endl;
  else  for(int i=b-k+1;i<=b;i++)cout<<i<<endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input!{
        N: usize,
        M: usize,
        AB: [(usize,usize);M],
    }

    let mut d = Dsu::new(N);
    for (a, b) in AB{
        d.merge(a-1, b-1);
    }
    let ans = d.groups().len()-1;
    println!("{}",ans);
}

pub struct Dsu {
    n: usize,
    // root node: -1 * component size
    // otherwise: parent
    parent_or_size: Vec<i32>,
}

impl Dsu {
    // 0 <= size <= 10^8 is constrained.
    pub fn new(size: usize) -> Self {
        Self {
            n: size,
            parent_or_size: vec![-1; size],
        }
    }
    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        assert!(a < self.n);
        assert!(b < self.n);
        let (mut x, mut y) = (self.leader(a), self.leader(b));
        if x == y {
            return x;
        }
        if -self.parent_or_size[x] < -self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as i32;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        assert!(a < self.n);
        assert!(b < self.n);
        self.leader(a) == self.leader(b)
    }
    pub fn leader(&mut self, a: usize) -> usize {
        assert!(a < self.n);
        if self.parent_or_size[a] < 0 {
            return a;
        }
        self.parent_or_size[a] = self.leader(self.parent_or_size[a] as usize) as i32;
        self.parent_or_size[a] as usize
    }
    pub fn size(&mut self, a: usize) -> usize {
        assert!(a < self.n);
        let x = self.leader(a);
        -self.parent_or_size[x] as usize
    }
    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0; self.n];
        let mut group_size = vec![0; self.n];
        for i in 0..self.n {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.n];
        for i in 0..self.n {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.n {
            result[leader_buf[i]].push(i);
        }
        result
            .into_iter()
            .filter(|x| !x.is_empty())
            .collect::<Vec<Vec<usize>>>()
    }
}


Measured memory_bytes: 10360
#include <stdio.h>

int main(void)
{
    int A, B;
    
    
    scanf("%d", &A);
    scanf("%d", &B);
    
    
    if(A > 2*B)
        printf("%d\n", A-2*B);
    else
        printf("%d\n", 0);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result

def run():
  X, Y = map(int, input().split())
  b = X+Y
  if b%3 != 0:
    print(0)
    exit()
  x = b//3
  if X < x or Y < x:
    print(0)
    exit()
  i = X - x
  if i > x//2:
    i = x - i
  ans = cmb(x, i)
  mod=10**9+7
  print(ans%(mod))
  
if __name__ == '__main__':
  run()

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> point(N + 1);

  for(int i = 0; i < N; i++) {
    if(S[i] == 'I') point[i + 1] = point[i] + 1;
    if(S[i] == 'D') point[i + 1] = point[i] - 1;
  }

  int ans = 0;
  for(int i = 0; i < N + 1; i++) {
    if(ans < point[i]) ans = point[i];
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  int c[33]={0};
  cin>>a>>b;
  int p=a;
  while(a--){
  int n;
    cin>>n;
    while(n--){
    int x;
      cin>>x;
      c[x]++;
    }
  }
  int cnt=0;
  for(int i=0;i<33;i++)cnt+=c[i]==p;
cout<<cnt;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
  //"math"
  // "sort"
  //"regexp"
)
 
func main(){
  var a, b string
  var count int
  fmt.Scan(&a)
  fmt.Scan(&b)
  for i := 0; i < len(a); i++ {
    if a[i:i + 1] != b[i: i + 1] {
      count++
    }
  }
  fmt.Printf("%d\n",count)
}

Measured memory_bytes: 4588
def mul_mod(x, y):
    return x * y % 1000000007


N = int(input())
S1 = input()
S2 = input()
L = []
i = 0
while i < N-1:
    if S1[i] == S1[i+1]:
        L.append(2)
        i += 2
    else:
        L.append(1)
        i += 1
if i == N-1:
    L.append(1)
ans = 1
if L[0] == 1:
    ans = 3
else:
    ans = 6
for i in range(1, len(L)):
    if L[i] == 1:
        if L[i-1] == 1:
            ans = mul_mod(ans, 2)
    else:
        if L[i-1] == 1:
            ans = mul_mod(ans, 2)
        else:
            ans = mul_mod(ans, 3)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[1000005],b[1000005];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	if(n%2==0)
	{
		for(i=1;i<=n;i++)if(i%2==1)b[i]=a[n/2+(i+1)/2];
		else b[i]=a[(i+1)/2];
		long long ans=0;
		for(i=1;i<n;i++)ans+=abs(b[i]-b[i+1]);
		printf("%lld\n",ans);
	}
	else
	{
		long long ans=0,sum=0;
		for(i=1;i<=n;i++)if(i%2==1)
		{
			if(i==1)
				b[i]=a[n/2+(i+1)/2];
			else
			{
				if(i==n)	b[i]=a[n/2+2];
				else b[i]=a[n/2+(i+1)/2+1];
			}
		}
		else b[i]=a[(i+1)/2];
		for(i=1;i<n;i++)sum+=abs(b[i]-b[i+1]);
//		for(i=1;i<=n;i++)printf("%d ",b[i]);printf("\n");
		ans=sum,sum=0;

		for(i=1;i<=n;i++)if(i%2==1)
		{
			if(i==1)
				b[i]=a[n/2+1];
			else
			{
				b[i]=a[i/2];
			}
		}
		else b[i]=a[n/2+i/2+1];
		for(i=1;i<n;i++)sum+=abs(b[i]-b[i+1]);
//		for(i=1;i<=n;i++)printf("%d ",b[i]);printf("\n");
		ans=max(ans,sum);
		printf("%lld\n",ans);
	}
	return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n;cin>>n;
    vector<int> l(n);
    for(auto & a : l) cin>>a;
    sort(l.begin(),l.end());
    int m = l[n-1];
    int sum = accumulate(l.begin(),l.end()-1,0);
    if(m < sum) cout << "Yes" << endl;
    else cout << "No"  <<endl;
    return 0;
}



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

using namespace std;

int main(){
	string str;
	getline(cin,str);
	for(int i=0;i<str.length();i++){
		if(str[i]>='A' && str[i]<='Z'){
			str[i]+='a'-'A';
		}
		else if(str[i]>='a' && str[i]<='z'){
			str[i]-='a'-'A';
		}
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();

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

        long sum = 0;
        for (int i = 0; i < 100001; i++) {
            sum += arr[i];
            if (k <= sum) {
                System.out.print(i);
                return;
            }
        }
    }

}


Measured memory_bytes: 85324
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL N, K;
  cin >> N >> K;

  LL sum = (N/K)*(N/K)*(N/K);

  if (K % 2 == 0)
  {
    LL a = N / (K / 2) - N / K;
    sum += a * a * a;
  }
  cout << sum << endl;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int s, w;

  while(cin >> s >> w){
    pout(s <= w ? "unsafe" : "safe");
  }


  return 0;
}


Measured memory_bytes: 3560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int h[] = new int[N];
        for (int i=0; i<N; i++) {
            h[i] = in.nextInt();
        }

        int ans = 0;
        int min = 1<<29;
        loop:while (true){
            int idx1 = 0;
            int idx2 = 0;
            while (h[idx1] == 0){
                if(idx1 == N-1 && h[idx1] == 0){
                    break loop;
                }
                idx1++;
                idx2++;
            }
            while (idx2 <= N-1){
                if(h[idx2] == 0){
                    break;
                }
                min = Math.min(min, h[idx2]);
                idx2++;
            }
            for(int i = idx1; i<=idx2-1; i++){
                h[i]-=min;
            }
            ans+=min;
        }
        out.println(ans);
    }

}
}



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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;

const ll INF = LLONG_MAX;

ll best(ll h, ll w) {
	if(h % 3 == 0) return 0;
	if(w % 3 == 0) return 0;
	else {
		ll ans = INF;
		if(h >= 3) ans = min(ans, w);
		if(w >= 3) ans = min(ans, h);
		return ans;
	}
}

ll solve(ll x, ll y) {
	ll ans = INF;
	fo(i, 1, y-1, 1) {
		ll temp1 = x*i, temp2 = (x/2)*(y-i), temp3 = (x-(x/2))*(y-i);
		ans = min(ans, max(temp1, max(temp2, temp3)) - min(temp1, min(temp2, temp3)));
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll h, w;
	cin >> h >> w;
	cout << min(best(h, w), min(solve(h, w), solve(w, h)));
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k: Int = sc.nextInt
  val monsters: Seq[Long] = Seq.fill(n)(sc.nextInt)
  val specialAttack: Int = Math.min(monsters.size, k)
  println(monsters.sorted.reverse.drop(specialAttack).sum)
}

Measured memory_bytes: 89588
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,n;
  cin >> k >> n;
  vector<int> vec(n);
  int i,sum=0;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  int maxi=0;
  sort(vec.begin(),vec.end());
  for(i=0;i<n-1;i++){
    maxi=max(maxi,vec.at(i+1)-vec.at(i));
  }
  maxi=max(maxi,min(vec.at(n-1)-vec.at(0),k-(vec.at(n-1)-vec.at(0))));
  cout << k-maxi;
}

Measured memory_bytes: 1024
import java.util.Scanner


object Main extends App {

  def read(): (Int, Int, IndexedSeq[IndexedSeq[Int]]) = {
    val sc = new Scanner(System.in)
    val n, m = sc.nextInt()
    val rlArr: IndexedSeq[IndexedSeq[Int]] = IndexedSeq.fill(m, 2)(sc.nextInt())
    (n, m, rlArr)
  }

  def solve() = {
    val (n, m, arr) = read()
    var maxL = 1
    var minR = n
    arr.foreach { list =>
      maxL = Math.max(maxL, list.head)
      minR = Math.min(minR, list.last)
    }
    if(maxL <= minR) minR - maxL + 1
    else 0
  }


  println(solve)

}


Measured memory_bytes: 93672
main = do
    ss <- getLine
    let (m,f,r) = (ns!!0, ns!!1, ns!!2)
                    where ns = map (\x -> read x :: Int) $ words ss
    if m==(-1) && f==(-1) && r==(-1)
        then return ()
        else do
            putStrLn $ grade m f r
            main

grade m f r
  | m == (-1) || f == (-1) = "F"
  | m+f >= 80 = "A"
  | m+f >= 65 = "B"
  | m+f >= 50 || (m+f >= 30 && r >= 50)= "C"
  | m+f >= 30 = "D"
  | otherwise = "F"


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll X;
	ll val = 100;
	cin >> X;	
	const double EPS = 1e-10;
	int i;
	for (i = 0; val < X - EPS; i++) {
		val = val * 1.01;
	}
	cout << i << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int h, n;
    cin >> h >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    int tot = 0;
    rep(i,n){
        tot += vec[i];
    }
    if (tot < h){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

}


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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int sum = X + Y;
      if  (S - sum >= 0 && S - sum <= K) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    using namespace std;
    int main()
    {
      long long n,i,a;
      vector<long long> l;
      cin >> n;
      l.push_back(2);
      l.push_back(1);
      for(i=0;i<n-1;i++)
      {
        a=l[i]+l[i+1];
        l.push_back(a);
    }
      cout << l[n];
      return 0;
    }

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int K[200001];
int zentai, N;
ll kotae[200001];
int C[200001];
int E[400001], ne[400001], he[200001];
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
char dn[2400000], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void dfs(int p, int mae) {
	int k = K[C[p]] + zentai;
	int k0 = k;
	for (int to = he[p]; to; to = ne[to]) {
		if (mae != E[to]) {
			dfs(E[to], p);
			int sa = K[C[p]] + zentai - k;
			kotae[C[p]] -= ll(sa) * (sa + 1) >> 1;
			k += sa;
		}
	}
	zentai++;
	K[C[p]] = k0 - zentai;
}


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


	N = getint();
	rep1(i, N) C[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();

		E[k] =b;
		ne[k] = he[a];
		he[a] = k++;
		E[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	dfs(1, -1);
	ll n = ll(N) * (N + 1) / 2;
	rep1(i, N) {
		int sa = K[i] + zentai;
		putint(n + kotae[i] - (ll(sa) * (sa + 1) >> 1));
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> as;
    as.resize(n);
    for(int i=0; i<n; i++)
    {
        cin >> as.at(i);
    }

    int mxdiff = as.at(0) + k - as.back();
    int prea = as.at(0);
    for(int i=1; i<n; i++)
    {
        int diff = as.at(i) - prea;
        if(mxdiff < diff)
        {
            mxdiff = diff;
        }
        prea = as.at(i);
    }
    cout << k - mxdiff << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define sq(x) ((x) * (x))
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    vs v = {"AC", "WA", "TLE", "RE"};
    int n;
    cin >> n;
    map<str, int> cnt;
    while (n--)
    {
        str s;
        cin >> s;
        cnt[s]++;
    }
    for (str s : v)
        cout << s << " x " << cnt[s] << endl;
    GAME_OVER;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if(a[i]!=max({a[i-1],a[i],a[i+1]})&&a[i]!=min({a[i-1],a[i],a[i+1]})) cnt++;
    }
    cout << cnt;


    return 0;
}

Measured memory_bytes: 256
<?php

$s = trim(fgets(STDIN));

$i = 0;
$no = false;
while (isset($s[$i])) {
    if ($i % 2 === 0 && $s[$i] === 'L' || $i % 2 === 1 && $s[$i] === 'R') {
        $no = true;
        break;
    }
    $i++;
}

echo $no ? 'No' : 'Yes';

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N,a;
	cin >> N >> a;
	int x = 0;
	rep(i, 3) {
		x = i + 1 != N && i + 1 != a ? i + 1 : x;
	}
	cou(x);
	
}

Measured memory_bytes: 384
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<Integer,Integer> map = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            int key = sc.nextInt();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            }else {
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<Integer, Integer> entry : map.entrySet()) {
            int key = entry.getKey();
            int value = entry.getValue();
            if(key < value) {
                ans += value - key;
            } else if(key > value) {
                ans += value;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64196
/*
             ██████  ██████
             ██   ██ ██   ██
 Author ->   ██████  ██   ██
             ██      ██   ██
             ██      ██████
 
    nik is love.
    nik is motivation.
    Use modulus operator very carefully.
    Watch for integer overflows.
*/
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> val(300010,1),vis(300010,0),dis(300010,-1),mini(300010,inf);
vector<pair<int,int>> adj[110];
int seg[5010][5010];
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3==0|a%5==0)
            {
                continue;
            }
            else
            {
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 4992
from math import sqrt


def check(i, j, k):
    cnt = set([i, j, k])
    if len(cnt) == 1:
        return 1
    if len(cnt) == 2:
        return 3
    if len(cnt) == 3:
        return 6


N = int(input())
ans = [0] * N

R = int(sqrt(N))
for x in range(1, R + 1):
    for y in range(x, R + 1):
        for z in range(y, R + 1):
            f = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if f <= N:
                ans[f - 1] += check(x, y, z)
print(*ans, sep='\n')


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

using namespace std;

using ll = long long;

bool dp[2][20000];

bool solve(int cur, int goal, vector<int>& v) {
    int n = v.size();
    int geta = 8000;
    for (int i = 0; i < 20000; i++) {
        dp[0][i] = false;
        dp[1][i] = false;
    }
    dp[0][cur + geta] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 20000; j++) {
            if (!dp[i % 2][j]) continue;
            dp[i % 2][j] = false;
            if (j + v[i] < 20000) dp[(i + 1) % 2][j + v[i]] = true;
            if (j - v[i] >= 0) dp[(i + 1) % 2][j - v[i]] = true;
        }
    }
    return dp[n % 2][goal + geta];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    int cx = 0, cy = 0;
    vector<int> vx, vy;
    int idx = 0;
    for (; idx < n; idx++) {
        if (s[idx] == 'T') break;
        cx++;
    }
    int gx, gy;
    cin >> gx >> gy;
    int cnt_t = 0, cnt_f = 0;
    for (int i = idx; i < n; i++) {
        if (s[i] == 'T') {
            if (cnt_t % 2 == 1) {
                vy.push_back(cnt_f);
            } else {
                vx.push_back(cnt_f);
            }
            cnt_f = 0;
            cnt_t++;
        } else {
            cnt_f++;
        }
    }
    if (cnt_t % 2 == 1) {
        vy.push_back(cnt_f);
    } else {
        vx.push_back(cnt_f);
    }
    cout << (solve(cx, gx, vx) && solve(cy, gy, vy) ? "Yes" : "No") << endl;
    return 0;
}

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

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

int main() {
    int H,W,A,r=0;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));

    rep(i,10)
        rep(j,10)
            cin >> c.at(i).at(j);

    rep(k,10)
        rep(i,10)
            rep(j,10)
                c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k)+c.at(k).at(j));

    rep(i,H)
        rep(j,W) {
            cin >> A;
            if(A==1 || A==-1)
                continue;
            r += c.at(A).at(1);
        }

    cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 60
#define M 1000000007
typedef long long LL;


int main() 
{
	LL m2, x, sum = 0, y;
	int i, j, c1[N] = {0}, n;
		
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		scanf("%lld", &x);
		j = 0;
		while(x){
			if(x & 1) c1[j]++;
			x >>= 1, j++;
		}
	}
	for(i = 0, m2 = 1, y = (LL)n; i < N; i++){
		x = (LL)c1[i];
		sum += x * (y - x) % M * m2 % M;
		m2 <<= 1;
		if(m2 >= M) m2 -= M;
	}
	printf("%lld\n", sum %= M);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
using LLI = long long int;

int main(void) {
	LLI N,cnt,res = 0;
	cin >> N;
	for (int i = 1; i <= N;i += 2) {
		cnt = 0;
		for (int j = 1; j <= i;j++) {
			if (i%j == 0) {
				cnt++;
			}
		}
		if (cnt == 8) {
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256