akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<P> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
long long o[211111];
long long l[222221];
long long j[211111];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[111111];
stack<int> s;
//set<int> s,s1;

//priority_queue<int> q;
queue<int> q;
//string r;
char r[211111],r1[11],r2[11];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    //if(a.x!=b.x)
    //return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

long long f(long long x,long long y)
{
    long long p=1;
    for(;y;x*=x,x%=mod,y/=2)
    if(y%2) p*=x,p%=mod;
    return p;
}

int main()
{
    o[0]=l[0]=j[0]=1;
    scanf("%d %d",&a,&b);
    z=f(2,mod-2);
    for(int t=1;t<=200010;t++)
        j[t]=j[t-1]*z%mod,o[t]=o[t-1]*t%mod,l[t]=f(o[t],mod-2);
    for(int t=0;t<min(a,b);t++)
        printf("%lld\n",z);

    for(int t=min(a,b);t<max(a,b);t++)
    {
        if(a>b)
        {
            //if(t>min(a,b)+1)
            x=(x+o[t-1]*l[t-b]%mod*l[b-1]%mod*j[t]%mod)%mod;
            printf("%lld\n",(1+x+mod)*j[1]%mod);
        }
        else
        {
            //if(t>min(a,b)+1)
            y=(y+o[t-1]*l[t-a]%mod*l[a-1]%mod*j[t]%mod)%mod;
            printf("%lld\n",(1-y+mod)*j[1]%mod);
        }
    }
    for(int t=max(a,b);t<a+b;t++)
    {
        x=(x+o[t-1]*l[t-b]%mod*l[b-1]%mod*j[t]%mod)%mod;
        y=(y+o[t-1]*l[t-a]%mod*l[a-1]%mod*j[t]%mod)%mod;
        printf("%lld\n",(1+x-y+mod)*j[1]%mod);
    }
}



Measured memory_bytes: 7168
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
N, K = map(int, input().split())
X = 10**9 + 7
for i in range(1, K+1):
    if N-K+1 >= i:
        print(cmb(K-1,i-1)*cmb(N-K+1,i)%X)
    else:
        print(0)

Measured memory_bytes: 50780
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  std::cin >> a;
  // scanf("%llu", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    std::cin >> input;
    // scanf("%llu", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

void out(int p){
  if(p==0){
    cout << "First"<< endl;
  } else {
    cout << "Second" << endl;
  }
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{
  // int N = inputValue<int>();
  // vector <int> v;
  // inputVector(&v, N);

  

  char c;
  int N = 0;
  char first, last;
  while ((c = getc(stdin)) != EOF && (c >= 'a' && c <= 'z'))
  {
    if (N == 0) {
      first = c;
    }
    N++;
    last = c;
  }

  out( (N <= 2) || !((first == last) ^ (N & 1)));

  // if (N<=2){
  //   out(1);
  // } else{
  //   out(((first != last) && !(N & 1)) || ((first == last) && (N & 1)));
  // }

  return 0;
}


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

int main(void){
  int N;
  cin >> N;
  
  vector<int> vec(N+1, 0);
  for(int x=1; x < sqrt(N); x++){
    for(int y=1; y<sqrt(N); y++){
      for(int z=1; z<sqrt(N); z++){
        int index = x*x + y*y + z*z + x*y + y*z + z*x;
        if(index > N) break;
        vec.at(index) += 1;
      }
    }
  }
  int i=0;
  for(int v : vec){
    if(i++==0) continue;
    cout << v << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int no[4][100001],color[100001];
int n;
void calc_color(int depth,int first_pos,int first_color,int l,int r,int curr_color){
  int s1 = 0,s2 = 0;
  for(;l > 0&& color[l] == curr_color ;l--,s1++);
  for(;r <= n&& color[r] == curr_color ;r++,s2++);
  int len = s1 + s2 + (depth == 0 ? 1:0); 
  if(4 <= len){

    no[first_color][first_pos] += len;
    if(color[l] == color[r]){
      calc_color(depth+1,first_pos,first_color,l,r,color[l]);
    }
  }
}

int main(){

  while( cin >> n,n ){
    fill(color,color + 100001,-1 );

    for(int i = 1 ; i <= n ; i++ ){
      for(int j = 1 ; j <= 3 ; j++ ){
	no[j][i] = 0; 
      }
    }
    for(int i = 1 ; i <= n ; i++ ){
      cin >> color[i];
    }

    for(int i = 1 ; i <= n ; i++ ){
      for(int j = 1 ; j <= 3 ; j++ ){
	calc_color(0,i,j,i-1,i+1,j);
      }
    }
    int res = n;
    for(int i = 1 ; i <= n ; i++ ){
      for(int j = 1 ; j <= 3 ; j++ ){
	res = min(res,n-no[j][i]);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int num = 0;
		String msg = null;

		if (Integer.parseInt(s.substring(0, 2)) < 13 && Integer.parseInt(s.substring(0, 2)) > 0) {
			num++;
		}
		if (Integer.parseInt(s.substring(2, 4)) < 13 && Integer.parseInt(s.substring(2, 4)) > 0) {
			num += 2;
		}

		switch (num) {
		case 0:
			msg = "NA";
			break;
		case 1:
			msg = "MMYY";
			break;
		case 2:
			msg = "YYMM";
			break;
		case 3:
			msg = "AMBIGUOUS";
			break;
		}
		System.out.println(msg);
	}
}

Measured memory_bytes: 21716
import java.math.BigInteger;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		BigInteger a=new BigInteger("1");
		
		BigInteger b=new BigInteger("1000000007");
		for(int i=1;i<=n;i++){
			a=a.multiply(new BigInteger(Integer.toString(i)));
			a=a.mod(b);
		}
		//System.out.println(a);
		
		
		System.out.println(a);
		
	}

}


Measured memory_bytes: 40740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int n = s.length();
        String s2 = s.substring(0, (n-1)/2);
        String s3 = s.substring(((n+3)/2)-1, n);
        
        boolean flag = true;
        for(int i = 0; i < n/2; i++){
            if(s.charAt(i) != s.charAt(n-1-i)){
                flag = false;
            }
        }
        for(int i = 0; i < s2.length()/2; i++){
            if(s2.charAt(i) != s2.charAt(s2.length()-1-i)){
                flag = false;
            }
        }
        for(int i = 0; i < s3.length()/2; i++){
            if(s3.charAt(i) != s3.charAt(s3.length()-1-i)){
                flag = false;
            }
        }
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    ma: usize,
    mb: usize,
    abc: [(usize, usize, i32); n],
  }
  let max_amt = 11 * n;
  let mut dp = vec![vec![vec![1 << 30; max_amt]; max_amt]; n + 1];
  dp[0][0][0] = 0;
  for (i, &(a, b, c)) in abc.iter().enumerate() {
    for x in 0 .. max_amt {
      for y in 0 .. max_amt {
        dp[i+1][x][y] = dp[i][x][y];
        if let (Some(xx), Some(yy)) = (x.checked_sub(a), y.checked_sub(b)) {
          dp[i+1][x][y] = cmp::min(dp[i+1][x][y], dp[i][xx][yy] + c);
        }
      }
    }
  }
  let mut ans = 1 << 30;
  for x in 1 .. max_amt {
    for y in 1 .. max_amt {
      if x * mb == y * ma {
        ans = cmp::min(ans, dp[n][x][y]);
      }
    }
  }

  if ans == 1 << 30 {
    ans = -1;
  }
  puts!("{}\n", ans);
}


Measured memory_bytes: 37116
N = int(input())
import math
N_keta = int(math.log10(N))+1

count = 0
for i in range(N_keta-1):
#  print('i' + str(i))
  if i % 2 == 0:
    count += 9 * (10 ** i)  
#  print(count)

if N_keta % 2 != 0:
  count +=  N - (10 ** (N_keta - 1) -1)
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main(void) {
    int N;
    vector<int> W(110);
    cin >> N;
    for (int i=0;i<N;i++) cin >> W[i];
    int ans = 100010;
    for (int i=1;i<N;i++) {
        vector<int> S1(W.begin(), W.begin()+i), S2(W.begin()+i,W.end());
        ans = min(ans, abs(accumulate(S1.begin(),S1.end(),0)-accumulate(S2.begin(),S2.end(),0)));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N_MAX 100000

int gcd(int a, int b){
  if (a > b) return gcd(b,a);
  if (b % a == 0) return a;
  return gcd(a, b%a);
}
int main(){
  int N;
  int result;
  scanf("%d", &N);

  for(int i = 0; i < N; i ++){
    if (i == 0) scanf("%d", &result);
    else{
      int A;
      scanf("%d", &A);
      result = gcd(result, A);
    }
  }

  printf("%d", result);
  return 0;
}

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

int main(){
    string s;cin>>s;
    bool judge = false;
    for (int i=0;i<s.size();i++){
        if (s[i] == 'C'){
            for (int j=i;j<s.size();j++){
                if (s[j] == 'F'){
                    judge = true;
                    break;
                }
            }
            break;

        }
    }
    if (judge){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

ll cnt[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;cin>>n;
    ll s=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        cnt[x]++;
        s+=x;
    }
    int q;
    cin>>q;
    while(q--){
        int x,y;
        cin>>x>>y;
        s+=(y-x)*cnt[x];
        cnt[y]+=cnt[x];
        cnt[x]=0;
        cout<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 4396
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define inf 10e8
using namespace std;

typedef struct {
    long app;
    long deli;
    long popu;
    long point1=app+deli+popu;
    long point2=-app+deli+popu;
    long point3=app-deli+popu;
    long point4=app+deli-popu;
    long point5=-app-deli+popu;
    long point6=app-deli-popu;
    long point7=-app+deli-popu;
    long point8=-app-deli-popu;
}foods;

//昇順降順をこっちでいじる
bool cmp1(const foods &a,const foods &b){
    return a.point1>b.point1;
}
bool cmp2(const foods &a,const foods &b){
    return a.point2>b.point2;
}
bool cmp3(const foods &a,const foods &b){
    return a.point3>b.point3;
}
bool cmp4(const foods &a,const foods &b){
    return a.point4>b.point4;
}
bool cmp5(const foods &a,const foods &b){
    return a.point5>b.point5;
}
bool cmp6(const foods &a,const foods &b){
    return a.point6>b.point6;
}
bool cmp7(const foods &a,const foods &b){
    return a.point7>b.point7;
}
bool cmp8(const foods &a,const foods &b){
    return a.point8>b.point8;
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<foods> vec(n);
    for (int i=0;i<n;i++) {
        cin >> vec[i].app >> vec[i].deli >> vec[i].popu;
        vec[i].point1=vec[i].app+vec[i].deli+vec[i].popu;
        vec[i].point2=-vec[i].app+vec[i].deli+vec[i].popu;
        vec[i].point3=vec[i].app-vec[i].deli+vec[i].popu;
        vec[i].point4=vec[i].app+vec[i].deli-vec[i].popu;
        vec[i].point5=-vec[i].app-vec[i].deli+vec[i].popu;
        vec[i].point6=vec[i].app-vec[i].deli-vec[i].popu;
        vec[i].point7=-vec[i].app+vec[i].deli-vec[i].popu;
        vec[i].point8=-vec[i].app-vec[i].deli-vec[i].popu;
    }
    long ans=0;
    for (int i=1;i<=8;i++){
        long score=0;
        long x,y,z;x=0;y=0;z=0;
        if(i==1) sort(vec.begin(),vec.end(),cmp1);
        else if(i==2) sort(vec.begin(),vec.end(),cmp2);
        else if(i==3) sort(vec.begin(),vec.end(),cmp3);
        else if(i==4) sort(vec.begin(),vec.end(),cmp4);
        else if(i==5) sort(vec.begin(),vec.end(),cmp5);
        else if(i==6) sort(vec.begin(),vec.end(),cmp6);
        else if(i==7) sort(vec.begin(),vec.end(),cmp7);
        else sort(vec.begin(),vec.end(),cmp8);
        
        for (int j=0;j<m;j++){
            x+=vec[j].app;
            y+=vec[j].deli;
            z+=vec[j].popu;
        }
        score=abs(x)+abs(y)+abs(z);
        ans=max(ans,score);
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int x,y;
  cin >> x >> y;
  cout << ((x*y%2==1)?"Odd":"Even") << endl;
}


Measured memory_bytes: 256
#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)


const int INF = 1e9;
int main() {
    int n;
    cin >> n;
    vector<int> p(n+1);
    int dp[105][105];
    rep(i,n) cin >> p[i] >> p[i+1];
    rep(i,n){
        rep(j,n) dp[i][j] = INF;
    }
    int mn;
    for(int i = 0; i < n; ++i) dp[i][i] = 0;
    for(int l = 2; l <= n; ++l){
        for(int i = 1; i + l -1 <= n; ++i){
            int j = i + l -1;
            for(int k = i; k < j; ++k){
                if(k==i) mn = dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j];
                else mn = min(mn, dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]);
            }
            dp[i][j] = mn;
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3128
N = int(input())
ans = [0]*41
answer = ""
def finder(n):
    global ans
    if n == 0:
        return 1
    elif n >= 1:
        for i in range(1,20):
            if n <= (4**i-1)//3:
                ans[2*(i-1)] = 1
                return finder(n-2**(2*(i-1)))
    else:
        for i in range(1,20):
            if n >= -2*(4**i-1)//3:
                ans[2*i-1] = 1
                return finder(n+2**(2*i-1))
finder(N)
flg = False
for i in range(len(ans)):
    if ans[-(i+1)] == 1:
        flg = True
    if flg:
        answer += str(ans[-(i+1)])
if not flg:
    answer ="0"
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<stdio.h>
#include<string>

using namespace std;

list<int> L;

int main(void) { 
  int n, item;
  char c[10];


  cin >> n;
  for(int i = 0; i < n; i++) {
    scanf("%s", c);
    if(c[0] == 'i') {
      scanf("%d", &item);
      L.push_front(item);
    }
    else if(c[6] == 'L') {
      L.pop_back();
    }

    else if(c[6] == 'F') {
      L.pop_front();
    }
    else if(c[0] == 'd') {
      scanf("%d", &item);
      for(list<int>::iterator it = L.begin(); it != L.end(); it++) {
        if(*it == item) {
          L.erase(it);
          break;
        }
      }
    }
  }

  int sep = 0;
  for(list<int>::iterator it =  L.begin(); it != L.end(); it++) {
    if(sep == 0) {
      sep++;
      cout << *it;
    }
    else {
      cout << " " << *it;
    }
  }
  cout << endl;
  return 0;
}

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

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }
            int[] B = new int[N];
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }
            int[] C = new int[N];
            for (int i = 0; i < N; i++) {
                C[i] = in.nextInt();
            }
            Arrays.sort(A);
            Arrays.sort(B);
            Arrays.sort(C);

            long count = 0;
            long[] b = new long[N];
            long[] sumB = new long[N];
            for (int i = B.length - 1; i >= 0; i--) {
                int index = binarySearch(C, B[i]);
                if (index + 1 < C.length) {
                    if (C[index + 1] >= B[i]) {

                    } else {
                        Utils.debug("false");
                    }
                } else {
                    Utils.debug("false2");
                }
                b[i] = N - (index + 1);
                sumB[i] = (i + 1 < N ? sumB[i + 1] : 0) + b[i];
            }

            Utils.debug("b", b);
            Utils.debug("sumB", sumB);

            for (int i = 0; i < A.length; i++) {
                int index = binarySearch(B, A[i]);
                if (index + 1 >= 0 && index + 1 < N) {
                    count += sumB[index + 1];
                    Utils.debug(i, count);
                }
            }
            System.out.println(count);
        }
    }

    private static int binarySearch(int[] a, int key) {
        int low = 0;
        int high = a.length - 1;

        while (low <= high) {
            int mid = (low + high) >>> 1;
            int midVal = a[mid];

            if (midVal <= key) {
                if (mid + 1 < a.length && a[mid + 1] > key) {
                    return mid;
                } else if (mid + 1 >= a.length) {
                    return mid;
                } else {
                }
                low = mid + 1;
            } else if (midVal > key) {
                if (mid - 1 >= 0 && a[mid - 1] <= key) {
                    return mid - 1;
                } else if (mid - 1 < 0) {
                    return mid - 1;
                } else {
                }
                high = mid - 1;
            } else {
            }
        }
        return -(low + 1);
    }
}

final class Utils {
    private Utils() {
    }

    public static final void debug(Object... o) {
        System.err.println(toString(o));
    }

    public static final String toString(Object... o) {
        return Arrays.deepToString(o);
    }

}


Measured memory_bytes: 117244
/*
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2331
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
  int n;
  cin >> n;
  vi a(n), b(n);
  int maxn = 0;
  REP(i, n){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    maxn = max(b[i], maxn);
  }
  maxn++;

  SORT(a);
  SORT(b);

  auto ita = a.begin();
  auto itb = b.begin();

  int res = 0;
  int cnt = 0;

  REP(i, maxn){
    while(*ita == i) {
      ita++;
      cnt++;
    }
    while(*itb == i - 1) {
      itb++;
      cnt--;
    }

    if (i <= cnt) {
      res = i;
    }
  }
  cout << res << endl;
}

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

int n;

int gcd(int a, int b) { return b?gcd(b, a%b):a; }

int main() {
	scanf("%d", &n);
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(i==1) {
			ans += n*n;
			continue;
		}
		for(int j=1;j<=n;j++) {
			int t = gcd(i, j);
			if(t==1) {
				ans += n;
				continue;
			}
				
			for(int k=1;k<=n;k++) {
				ans += gcd(k, t);
			}
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
    int N,i,j,T,A;
    int arr[1005];
    double map[1005];
    double vis[1005];
    double num;
    cin>>N;
    cin>>T>>A;
    for(i=1;i<=N;i++){
        cin>>arr[i];
    }
    for(j=1;j<=N;j++){
        num=A-(T-arr[j]*0.006);
        num=(num>0)?num:-num;
        map[j]=num;
    }
    memcpy(vis,map,sizeof(map));
    sort(map+1,map+N+1);
    for(i=1;i<=N;i++){
        if(vis[i]==map[1]){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int W,H,a,b,c;
	while(1){
		scanf("%d %d",&H,&W);
		c = 0;
		if(W == 0 && H == 0){
			break;
		}
		for(b=0;b<H;b++){
			for(a=0;a<W;a++){
				if(c==0){
					printf("#");
					c = 1;
				}else{
					printf(".");
					c = 0;
				}
			}
			if(W%2==0){
				if(c==0){
					c = 1;
				}else{
					c = 0;
				}
			}
			printf("\n");
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 1000
use std::io;

fn main() {
    let mut s = String::new();

    io::stdin().read_line(&mut s)
        .expect("Failed to read line");

    let numbers: Vec<i32> =
        s.split(' ').map(|s| s.trim())
        .filter(|s| !s.is_empty())
        .map(|s| s.parse().unwrap())
        .collect();

    let a = numbers[0];
    let b = numbers[1];

    if a > b {
        println!("{}", 2 * a - 1);
    } else if a < b {
        println!("{}", 2 * b - 1);
    } else {
        println!("{}", a + b);
    }
}


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

#define ll long long int
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n+1);
  ll sum;
  vector<ll> ans(n+1);
  vector<ll> cnt(n+1);
  for(int i = 1; i < n+1; i++){
    cin >> a.at(i);
    cnt[a[i]]++; 
  }
  for(int j=1;j<n+1;j++){
  	sum += cnt[j]*(cnt[j]-1)/2;
    
  }
  for(int j=1;j<n+1;j++){
  	ans[j] = sum - (cnt[a[j]]-1); 
  }
  for(int i = 1; i < n+1; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
char m[444][444];
int ans[444][444];
int main()
{
	int mx, my, ko;
	scanf("%d%d%d", &mx, &my, &ko);
	for (int i = 0; i < mx; i++)scanf("%s", m[i]);
	int pt = 1;
	int tt = -1;
	for (int i = 0; i < mx; i++)
	{
		int las = -1;
		for (int j = 0; j < my; j++)
		{
			if (m[i][j] == '#')
			{
				for (int k = las + 1; k <= j; k++)ans[i][k] = pt;
				las = j;
				pt++;
			}
		}
		if (las != -1)
		{
			for (int k = las + 1; k < my; k++)ans[i][k] = ans[i][las];
			tt = i;
		}
	}
	for (int i = tt - 1; i >= 0; i--)
	{
		for (int j = 0; j < my; j++)if (ans[i][j] == 0)ans[i][j] = ans[i + 1][j];
	}
	for (int i = tt + 1; i < mx; i++)
	{
		for (int j = 0; j < my; j++)if (ans[i][j] == 0)ans[i][j] = ans[i - 1][j];
	}
	for (int i = 0; i < mx; i++)
	{
		for (int j = 0; j < my; j++)
		{
			printf("%d ", ans[i][j]);
		}
		printf("\n");
	}
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << N * 800 - N / 15 * 200 << endl;

  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {



	map<int, char> m ;
	char x = 'a';
	for (int i = 1 ; i <= 26 ; i++) {
		m.insert(make_pair(i, x));
		x++;
	}


	int n ;
	cin >> n;

	if (n <= 26) {
		cout << m[n];
	}
	else {
		string a ;
		a.clear();
		while (n > 26) {
			int s = (n % 26);
			// cout << s << "\n";
			if (s == 0) {
				s = 26;
			}
			a += m[s];
			if (s == 26) {
				n--;
			}
			n /= 26;
		}
		if (n <= 26) {
			a += m[n];
		}

		reverse(a.begin(), a.end());
		cout << a;

	}


	return 0;
}

Measured memory_bytes: 3628
n = int(input())
s=input()

ans=s.count("R")*s.count("G")*s.count("B")

for start in range(n):
    for kousa in range(n):
        if start+2*kousa>n-1:
            break
        if s[start]!=s[start+kousa] and s[start+kousa]!=s[start+2*kousa] and s[start+2*kousa]!=s[start]:
            ans-=1

print(ans)

Measured memory_bytes: 73692
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> x(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    ll ans = LLINF;
    for(int i = 0; i < n - k + 1; i++) {
        chmin(ans, llabs(0 - x[i]) + llabs(x[i + k - 1] - x[i]));
        chmin(ans, llabs(0 - x[i + k - 1]) + llabs(x[i + k - 1] - x[i]));
    }
    cout << ans << endl;
}

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

int main()
{
  int N,D;
  cin>>N>>D;
  int X[10][10];
  for(int i = 0;i<N;i++)
  {
    for(int j = 0;j<D;j++)
    {
      cin>>X[i][j];
    }
  }
  int count = 0;
  for(int i = 0;i<N;i++)
  {
    for(int j = i + 1;j<N;j++)
    {
      int sum = 0;;
      for(int k = 0;k<D;k++)
      {
        sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      double _sqrt = sqrt(sum);
      if(ceil(_sqrt) == floor(_sqrt))
      {
        count++;
      }
   }
 }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


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

int H, W; cin >> H >> W;
VS A(H); rep(i, 0 , H) cin >> A[i];

VVI dist(H, VI(W, -1));
queue<PII> q;
//元からある # を始点にする．親ノードがいくつもある場合のBFS
rep(i, 0, H){
    rep(j, 0, W){
        if (A[i][j] == '#'){
            dist[i][j] = 0;
            q.push(make_pair(i, j));
        }
    }
}
// BFS
while (!q.empty()){
    PII v = q.front();
    q.pop();

    rep(i,0, 4){
        int nh = v.first + dy[i], nw = v.second + dx[i];
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (A[nh][nw] == '#') continue;

        A[nh][nw] = '#';
        dist[nh][nw] = dist[v.first][v.second] + 1;
        q.push(make_pair(nh, nw));
    }
}

int maxi = 0;
rep(i, 0, H) maxi  = max(maxi, (int)*max_element(ALL(dist[i])));

cout << maxi << endl;

}

// 境界，出力文字列 チェック



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

int main() {
  ll n;
  cin >> n;
  /*vector<string> s(26) = {"z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
                         "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
                         "w", "x", "y"};*/
  string s = "zabcdefghijklmnopqrstuvwxy";
  /*s.at(1) = "a"; s.at(2) = "b"; s.at(3) = "c"; s.at(4) = "d"; s.at(5) = "e";
  s.at(6) = "f"; s.at(7) = "g"; s.at(8) = "h"; s.at(9) = "i"; s.at(10) = "j";
  s.at(11) = "k"; s.at(12) = "l"; s.at(13) = "m"; s.at(14) = "n"; s.at(15) = "o";
  s.at(16) = "p"; s.at(17) = "q"; s.at(18) = "r"; s.at(*/
  string ans = "";
  int cnt = 0;
  /*if(n == 1) {
    cout << "a" << endl;
    return 0;
  }*/
  while(n > 0){
    cnt++;
    ll a = n % 26;
   //cout << "a = " << a << endl;
   n--;
    //n -=26;
    n /= 26;
   // if(n > pow(26, cnt) && n <= pow(26, cnt+1) + pow(26, cnt)) n--;
   // cout << "n=" << n << endl;
    ans = s.at(a) + ans;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3612
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    vector<vector<ll> >vec(26);
    ll len1 = s1.size();
    ll len2 = s2.size();
    for(int i=0; i<len1; i++)
    {
        vec[s1[i]-'a'].push_back(i);
    }
    ll pp  =-1;
    ll n=0;
    for(int i=0; i<len2; i++)
    {
        if(vec[s2[i]-'a'].empty())
        {
            cout<<-1<<endl;
            return 0;
        }
        else
        {
            auto pos = upper_bound(vec[s2[i]-'a'].begin(),vec[s2[i]-'a'].end(),pp);
            if(pos!=vec[s2[i]-'a'].end())
            {
                pp=vec[s2[i]-'a'][pos-vec[s2[i]-'a'].begin()];
                //cout<<pp<<" L "<<endl;
            }
            else
            {
                n++;
                pp=vec[s2[i]-'a'][0];
            }
            //cout<<pp<<endl;
        }
    }
    cout<<n*s1.size()+pp+1<<endl;

}


Measured memory_bytes: 1724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	int co;
	cin>>co;
	int n=s.size();
	
	rep(i,s.size()){
		if(s[i]!='a'&&'z'+1-s[i]<=co){
			co-='z'+1-s[i];
			s[i]='a';
		}
	}
	s[n-1]=(s[n-1]-'a'+co)%26+'a';
	cout<<s<<endl;
}





Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  while(n!=0)
  {
      if(n%10==7)
      {
          cout<<"Yes"<<endl;
          return 0;
      }
      n=n/10;
  }
  cout<<"No"<<endl;
 
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll k;
    cin>>k;
    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<arr[k-1]<<"\n";
}


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

int cnt_digits(ll N) {
  int digits = 0;
  while (N > 0) {
    N /= 10;
    digits++;
  }
  return digits;
}

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

  int ans = cnt_digits(N);
  for (ll A = 1LL; A * A <= N; ++A) {
    if (N % A != 0) continue;
    const ll B = N / A;
    const int cur = max(cnt_digits(A), cnt_digits(B));
    ans = min(ans, cur);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 

P = {}
def gcd(a, b):
    if a > b:
        a, b = b, a
    if (a, b) in P:
        return P[(a, b)]
    
    v = math.gcd(a, b)
    P[(a, b)] = v
    return v


def main():
    K = int(input()) - 1
    A = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
    print(A[K])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9888
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b;
	char op;
	cin >> a >> op >> b;
	print(op == '+' ? a + b : a - b);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let s=ts().split('')
  let t=ts()
  for(let i=0;i<s.length;i++){
    if(s.join('')===t){
      to('Yes')
      return
    }
    s.unshift(s[s.length-1])
    s.pop()
  }
  to('No')
}
main()


Measured memory_bytes: 9420
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
bool thr(string s,int num, int idx) {
	if (idx != 0) {
		if (s[idx] == '?' || s[idx] == num + '0') {
			return true;
		}
	}
	else {
		if ((s[idx] == '?'&&num!=0) || s[idx] == num + '0') {
			return true;
		}
	}
	return false;
}
int main() {
	string s1, s2, s3;
	while (cin >> s1, s1 != "0") {
		cin >> s2 >> s3;
		long long nc = 1;
		long long yc = 0;
		REP(i, s1.length()) {
			int keta = s1.length() - 1 - i;
			long long ncnt = 0;
			long long ycnt = 0;
			REP(j, 10) {
				if (thr(s1,j,keta))
					REP(k, 10) {
					if (thr(s2, k, keta))
						REP(l, 10) {
						if (thr(s3, l, keta)) {
							if ((j + k) % 10 == l)
								if (j + k < 10)
									ncnt += nc;
								else
									ycnt += nc;
							if ((j + k+1) % 10 == l)
								if (j + k+1 < 10)
									ncnt += yc;
								else
									ycnt += yc;
							ncnt %= 1000000007;
							ycnt %= 1000000007;
						}
					}
				}
			}
			nc = ncnt;
			yc = ycnt;
		}
		cout << nc << endl;
	}
}

Measured memory_bytes: 3144
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
F = [int("".join(input().split()), base=2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = - (1 << 30)
for i in range(1 << 10):
    profit = 0
    ok = False
    for j in range(N):
        cnt = bin(i & F[j]).count("1")
        if cnt > 0:
            ok = True
        profit += P[j][cnt]

    if ok:
        ans = max(ans, profit)

print(ans)


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  vector<i64> h(n+5);
  rep(i, n) {
    cin >> h[i];
  }

  if (n == 1) {
    cout << "Yes" << "\n";
    return 0;
  }

  for (int i = n-1; i > 0; --i) {
    if (h[i-1] > h[i]) --h[i-1];
  }

  bool isYes = true;
  for (int i = 1; i < n; ++i) {
    if (h[i-1] > h[i]) isYes = false;
  }

  cout << (isYes ? "Yes" : "No") << "\n";

  return 0;
}

Measured memory_bytes: 1024