akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e18;

int main(){
    vector<string> s(3);
    rep(i,3){
        cin >> s[i];
    }
    bool ok=true;
    rep(i,2){
        if(s[i][s[i].length()-1]!=s[i+1][0]) ok=false;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3596
--https://www.lua.org/pil/11.4.html
local List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

-------------------------------------------------------------------

local n,m=io.read("n","n")
local cave={}
for i=1,n do
    cave[i]={}
end
for i=1,m do
    local a,b=io.read("n","n")
    cave[a][b]=true
    cave[b][a]=true
end

local dist={}
local prev={}
for i=1,n do
    dist[i]=-1
    prev[i]=-1
end
dist[1]=0

local que=List.new()
List.pushright(que,1)
while true do
    local a=List.popleft(que)
    if not a then break end
    for next,_ in pairs(cave[a]) do
        if dist[next]==-1 then
            dist[next]=dist[a]+1
            prev[next]=a
            List.pushright(que,next)
        end
    end
end

print("Yes")
for i=2,n do
    print(prev[i])
end


Measured memory_bytes: 36688
#include <stdio.h>
#include <string.h>

int NextInt() { int d; scanf("%d", &d); return d; }


int main() {
  int i, j, n;
  int t, u;
  char s[11];
  int a[41];
  int c;
  int b[5] = {5, 7, 5, 7, 7};
  int ans;

  while (1) {
    n = NextInt();
    if (n == 0) {
      break;
    }  
    for (i = 0; i < n; i++) {
      scanf("%s", s);
      a[i] = strlen(s);      
    }
    ans = n;
    for (j = 0; j < n; j++) {
      c = 0;
      t = 0;
      u = j + 1;
      for (i = j; i < n; i++) {
        t += a[i];
        if (t > b[c]) {
          t = a[i];
          c = 0;
          u = i + 1;
        }    
        if (t == b[c]) {
          t = 0;
          c++;
          if (c == 5) {
            break;
          } 
        } 
      }
      if (u < ans) {
        ans = u;
      } 
    }
    printf("%d\n", ans);
  }

  return 0;
}

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


int main() {

    string s , t ;
    cin >> s ;
    t=s ;
    int i ,n=s.size();
    reverse(t.begin(),t.end()) ;
    if (s==t) {
            string p , q ;
        for(i=0;i<(n-1)/2;i++) {
            p+=s[i] ;
        }
        q=p ;
        reverse(q.begin(),q.end()) ;
             string p1 , q1 ;
        for(i=(n+3)/2-1;i<s.size();i++) {
            p1+=s[i] ;
        }
        q1=p1 ;
        reverse(q1.begin(),q1.end()) ;
        if (p==q and p1==q1)
            cout << "Yes\n" ;
        else cout << "No\n" ;
    }
    else
    cout << "No\n" ;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

struct number {
	int pos,val;
	int l,r,o;
};
bool operator < (const number &a,const number &b) {
	return a.pos<b.pos;
}
bool operator ==(const number &a,const number &b) {
	return a.pos==b.pos;
}

const int N=201000;
set<number> ps;
set<PII> hs;
int n,l,ss[N];
ll ans;
int main() {
	scanf("%d%d",&n,&l);
	rep(i,0,n) {
		int x;
		scanf("%d",&x);
		hs.insert(mp(x,i));
		ps.insert((number){i,x,1,1,1});
	}
	while (!hs.empty()) {
		int c=hs.begin()->fi;
		auto it=ps.lower_bound((number){hs.begin()->se,0,0,0,0});
		vector<number> cc;
		while (1) {
			cc.pb(*it);
			if (it==ps.end()) break;
			++it; if (it->val!=c) break;
		}
		for (auto p:cc) hs.erase(mp(p.val,p.pos));
		if (SZ(cc)<l) continue;
		int nxt=1<<30,m=SZ(cc);
		if (SZ(cc)>=l) {
			ss[m]=0;
			per(i,0,m) ss[i]=ss[i+1]+cc[i].l;
			per(i,0,m) {
				if (cc[i].o) nxt=i;
				if (nxt<m&&i+l-1<m) {
					ans+=(ll)cc[i].r*ss[max(nxt,i+l-1)];
//					printf("gg %d %d\n",cc[i].r,ss[max(nxt,i+l-1)]);
				}
			}
			rep(i,0,m) ps.erase(cc[i]);
		}
		int z=m/l;
		VI fl(z,0),fr(z,0);
		rep(i,0,m) {
			if (i>=l-1) fl[(i+1)/l-1]+=cc[i].l;
			if (m-i-1>=l-1) fr[(m-i)/l-1]+=cc[i].r;
		}
		reverse(all(fr));
		rep(i,0,z) {
			ps.insert((number){cc[i*l].pos,c+1,fl[i],fr[i],0});
			hs.insert(mp(c+1,cc[i*l].pos));
		}
/*		puts("ffff");
		for (auto p:ps) {
			printf("%d %d %d %d %d\n",p.pos,p.val,p.l,p.r,p.o);
		}
		printf("zz %lld\n",ans);*/
	}
	printf("%lld\n",ans+n);
}


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

int main() {
  int n;
  cin>>n;
  long double s;
  cin>>s;
  for(int i=1;i<n;i++){
      double a;
      cin>>a;
      s=s*a/(s+a);

  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
    //変数の宣言
    char T[2000]; //入力１
    char W [11]; //入力２
    int i, n=0;; //処理用
    
    scanf("%s", W);
    
    do{
        scanf("%s", T);
        if (!strcmp (T, "END_OF_TEXT")) { //0が帰ってきたらbreak
            break;
        }
        
        for (i=0; T[i] != '\0'; i++) { //入力２の文字数
            if (T[i] < 91) { //アスキーで大文字以上の
                T[i] += 32; //小文字にする
            }
        }
        if (!strcmp(W,T)) { //同じだったら数える
                n++; //カウント
        }
    }while(1);
    
    printf("%d\n", n);
    
    
    
    return 0;
}



Measured memory_bytes: 2048
n, y = map(int, input().split())

rem = 0
for i in range(y//10000 +1):
    rem = y-10000*i
    for j in range(rem//5000 + 1):
        k = (rem - 5000*j) // 1000
        if (i + j+ k) == n:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 65516
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int k[10], sum;
int main() {
	for (int i = 0; i < 5; i++) {
		cin >> k[i];
		sum += max(k[i], 40);
	}
	cout << sum / 5 << endl;
}


Measured memory_bytes: 3088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n < 1000 ? "ABC" : "ABD");
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



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


int main()
{
    int x[100]={};
    string S;
    cin>>S;

    for(int i=0;i<S.length();i++){
        x[S[i]-'A']+=1;
    }

    for(int i=0;i<100;i++){
        if(x[i]%2==1){
            cout<<"No"<<endl;
            return 0;
        }
        
    }

    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define rrep(i, n) for(int i = n-1; i >= 0; i--)
    #define  all(x) (x).begin(),(x).end()     // 昇順ソート
    #define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
    #define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    typedef long long ll;
    using P = pair<int,int>;
    using VI = vector<int>;
    using VVI = vector<vector<int>>;
    using VL = vector<ll>;
    using VVL = vector<vector<ll>>;
    using VP = vector<P>;
    template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
    template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

    int main(){
        int n;
        cin >> n;
        VVI d(n, VI(2));
        rep(i,n){
            cin >> d[i][0] >> d[i][1];
        }

        rep(i,n-2){
            if (d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1]){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

Measured memory_bytes: 3636
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
sp = []
for i in range(n):
    s,p = input().split()
    sp.append((s,-int(p),i+1))
sp.sort()
for z in sp:
    print(z[2])


Measured memory_bytes: 3556
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint X, Y;

int main(void)
{
	cin >> X >> Y;
	
	if(abs(Y - X) <= 1) cout << "Brown" << endl;
	else cout << "Alice" << endl;
	
	return 0;
}

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


class Main {
	public static void main(String[] a) {
		Scanner scanner = new Scanner(System.in);
		int[] kekka = new int[10];
		for (int i = 0; i < 10; i++) {
			kekka[i] = scanner.nextInt();
		}
		Arrays.sort(kekka);
		System.out.println(kekka[9]);
		System.out.println(kekka[8]);
		System.out.println(kekka[7]);
	}
}

Measured memory_bytes: 17168
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = list(input())
    reslut = []
    for s in S:
        if s == 'B' and len(reslut) == 0:
            continue
        elif s == 'B':
            reslut.pop()
        else:
            reslut.append(s)
    print(''.join(reslut))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
using large = long long;
int main() {
    large h, w;
    cin >> h >> w;

    if (w == 1 || h == 1) {
        cout << 1;
        return 0;
    }

    auto n = (w + 1) / 2;
    auto m = w - n;

    auto a = (h + 1) / 2;
    auto b = h - a;

    cout << (n * a + m * b);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    char s[4];
    scanf("%s", &s);
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1')
            s[i] = '9';
        else if (s[i] == '9')
            s[i] = '1';
    }
    printf("%s", s);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

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

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

template<class T> struct flow {
  struct edge {
    int to;
    T cap;
    int rev;
  };

  int n;
  vector<vector<edge>> g;
  vector<bool> used;

  flow(int n) : n(n) {
    g = vector<vector<edge>>(n);
  }

  void add(int from, int to, T cap) {
    g[from].push_back({ to, cap, (int) g[to].size() });
    g[to].push_back({ from, 0, (int) g[from].size() - 1 });
  }

  T dfs(int v, int t, T f) {
    if (v == t) {
      return f;
    }
    used[v] = true;
    for (auto &e : g[v]) {
      if (used[e.to] || e.cap <= 0) {
        continue;
      }
      T d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }

  T max_flow(int s, int t) {
    T flow = 0;
    while (true) {
      used = vector<bool>(n);
      T f = dfs(s, t, numeric_limits<T>::max());
      if (f == 0) {
        break;
      }
      flow += f;
    }
    return flow;
  }
};

int main() {
  ioinit();
  int n;
  cin >> n;
  vi32 a(n);
  rep(i, n) cin >> a[i];
  flow<i64> g(n + 2);
  rep(i, n) {
    if (a[i] <= 0) {
      g.add(0, i + 1, -a[i]);
    } else {
      g.add(i + 1, n + 1, a[i]);
    }
  }
  reps(i, n) {
    for (int j = i + i; j <= n; j += i) {
      g.add(i, j, numeric_limits<i64>::max());
    }
  }
  i64 ans = 0;
  rep(i, n) ans += max(0, a[i]);
  ans -= g.max_flow(0, n + 1);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#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()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
string itos(int a){
	string out="";
	while(a){
		out=(char)(a%10+'0')+out;
		a/=10;
	}
	return out;
}
string f(string s){
	string out="";
	int to=0;
	while(1){
		int co=0;
		char q=s[to];
		while(q==s[to]){
			to++;
			co++;
			if(to==s.size())break;
		}
		out+=itos(co)+q;
		if(to==s.size())break;
	}
	return out;
}
int main(){
	int n;
	while(cin>>n,n){
		string s;
		cin>>s;
		rep(i,n)s=f(s);
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1344
P = 10**9 + 7
N = 700000 #使う最大値以上にする、値に注意4*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N+1):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b: return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
x, y = map(int, input().split())
if (2*y-x)%3!=0 or (2*x - y)%3!=0:
    print(0)
    exit(0)
A = (2*y-x)//3
B = (2*x-y)//3
if A<0 or B<0:
    print(0)
    exit(0)
print(comb(A+B, A))


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  cout << a[2] << ' ' << a[0] << ' ' << a[1] << '\n';
}


Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <iomanip>

using namespace std ;
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define LOCAL
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;
//#define int long long

int32_t main(){_
	ld w,h,x,y ;
	cin >> w >> h >> x >> y ;
	int cases = (w == 2*x && h == 2*y) ? 1 : 0 ;
	cout << fixed << setprecision(10) << 0.5 * w * h << " "  << cases << endl ;
		
}

Measured memory_bytes: 256
n = int(input())
*a, = map(int, input().split())

*b, = filter(lambda x: x%4 != 0, a)
mul_4 = n-len(b)

*c, = filter(lambda x: x%2 != 0, b)
mul_2 = (len(b)-len(c))//2

print("Yes" if n//2 <= mul_4+mul_2 else "No")


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
typedef long long LL;
int main() {
	std::string t;
	std::string r;
	std::cin >> t >> r;
	std::sort(t.begin(), t.end());
	std::sort(r.begin(), r.end());
	std::reverse(r.begin(), r.end());
	if (r > t) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<array>
#define nguyendz the_best


#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)
//do not use "\n" in interactive problem
// ((x|y)-y) (x&(~y))
// __gcd(fibo(x),fibo(y)=fibo(__gcd(x,y))
//so luong tap hop gom d phan tu khac nhau dc tao tu k so phan biet la k mu d
// a+b=(a^b)+2*(a&b)
using namespace std;
const ll maxn=5e5+100;

const ll maxx=1e13;
const ll mod1=1000000007;
const ll mod2=998244353;
priority_queue<pll,vector<pll>,greater<pll>> q;

ll  a[34]= {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};
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
   //   freopen("PHONGHAU.INP", "r", stdin);
    //   freopen("PHONGHAU.OUT", "w", stdout);
 ll a, b,c ;
 cin>>a>>b>>c;
 ll t= c-a-b;
 if (t<0)
 {
     cout <<"No";
     return 0;
 }
 ll t1=4*a*b;
 ll x=t*t;
 if (x>t1)
 {
     cout <<"Yes";
 }
 else
 {
     cout <<"No";

 }

}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int c;
    cin >> c;
    long long ans = 0;
    ans += (c/500)*1000;
    c -= (c/500)*500;
    ans += (c/5)*5;
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
import sys

A, B, M = [int(x) for x in sys.stdin.readline().strip().split(" ")]
list_a = [int(x) for x in sys.stdin.readline().strip().split(" ")]
list_b = [int(x) for x in sys.stdin.readline().strip().split(" ")]
min_a = sorted(list_a)[0]
min_b = sorted(list_b)[0]

dict_c = {}
idx = []
for i in range(M):
    x, y, c = [int(x) for x in sys.stdin.readline().strip().split(" ")]
    if x not in dict_c:
        dict_c[x] = {}
    if c > dict_c[x].get(y, 0):
        dict_c[x][y] = c

    idx.append(tuple([x, y]))

s = min_a + min_b
for (x, y) in idx:
    t = list_a[x - 1] + list_b[y - 1] - dict_c[x][y]
    if t < s:
        s = t
print(s)


Measured memory_bytes: 49504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
const int maxn = 3e5 + 5;
int mx[maxn<<2];
void pull(int x) {
    mx[x] = max(mx[x<<1], mx[x<<1|1]);
}
void update(int x,int l,int r,int p,int v) {
    if (r == l) {
        mx[x] = max(mx[x], v);
        return;
    }
    int mid = (l + r) >> 1;
    if (p <= mid) {
        update(x<<1,l,mid,p,v);
    }
    else {
        update(x<<1|1,mid+1,r,p,v);
    }
    pull(x);
} 
int query(int x,int l,int r,int ql,int qr) {
    if (ql <= l && qr >= r) {
        return mx[x];
    }
    int mid = (l + r) >> 1;
    if (qr <= mid) {
        return query(x<<1,l,mid,ql,qr);
    }
    else if (ql > mid) {
        return query(x<<1|1,mid+1,r,ql,qr);
    }
    return max (query(x<<1,l,mid,ql,qr),query(x<<1|1,mid+1,r,ql,qr));
}
void go() {
    int n, k;
    cin >> n >> k;
    f(n) {
        int x;
        cin >> x;
        int m = query(1,0,300000,max(0,x-k),min(300000,x+k));
        update(1,0,300000,x,m + 1);
    }
    cout << mx[1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
}

Measured memory_bytes: 7740
from itertools import product
n,m = map(int,input().split())
S = []
for i in range(m):
    A = [int(i)-1 for i in input().split()]  
    S.append(A[1:])
P = list(map(int,input().split()))
ass = ["1","0"]
for i in range(n-1):
    ass2 = []
    for x in ass:
        ass2.append(x+"1")
        ass2.append(x+"0")
    ass = ass2[::]
res = 0
for a in ass:   
    cnt = 0 
    for i in range(m):
        tmp = 0
        for j in S[i]:
            if a[j] == "1":
                tmp += 1
        if tmp%2 == P[i]:
            cnt +=1
    if cnt == m:
        res += 1
print(res)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <queue>
#define N_MAX 30
#define INF (1e9)
using namespace std;
void dijkstra();
int w,h,data[N_MAX][N_MAX],d[N_MAX][N_MAX][4],c[4];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
typedef struct stu{
  int mincost,y,x,dir;
  bool operator<(const stu & right)const{
    return mincost>right.mincost;
  }
} dat;

int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin>>data[i][j];
    for(int i=0;i<4;i++) cin>>c[i];
    dijkstra();
  }
  return 0;
}

void dijkstra(){
  priority_queue<dat > Q;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<4;k++) d[i][j][k]=INF;
  d[0][0][1]=0;
  Q.push((dat){0,0,0,1});
  while(!Q.empty()){
    dat t=Q.top(); Q.pop();
    int cost=t.mincost,y=t.y,x=t.x,dir=t.dir;
    if(cost>d[y][x][dir]) continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[(dir+i)%4],nx=x+dx[(dir+i)%4];
      int ndir=(dir+i)%4;
      if(ny<0||nx<0||h<=ny||w<=nx) continue;
      if(d[ny][nx][ndir]>cost+c[i]){
	d[ny][nx][ndir]=cost+c[i];
	Q.push((dat){d[ny][nx][ndir],ny,nx,ndir});
      }
      if(data[y][x]!=i) continue;
      if(d[ny][nx][ndir]>cost){
	d[ny][nx][ndir]=cost;
	Q.push((dat){d[ny][nx][ndir],ny,nx,ndir});
      }
    }
  }
  cout<<min(d[h-1][w-1][1],d[h-1][w-1][2])<<endl;
}

Measured memory_bytes: 1360
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(b >= a){
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head

int t,q,m,n,k,res,tmp,tmp2;
int a[200010] = {};
int b[200010] = {};
//vector<PII> g[500010];
queue<int> que2;
int dp[200010][18]={};
int dp2[200010][18]={};
//string s;

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n;
	rep(i,0,n) {
		cin>> a[i];
		b[i] = a[i]*(-2);
	}
	rep(i,0,16) dp[n][i] = i;
	per(i,1,n){
		rep(j,0,16){
			tmp = 1LL<<60;
			rep(x,0,16){
				tmp2 = 0;
				k = a[i];
				while(a[i-1] > k){
					k*=4;
					tmp2 += 1;
				}
				k = a[i-1];
				while(a[i] > k*4){
					k*= 4;
					tmp2-=1;
				}
				tmp = min(tmp,dp[i+1][x]+max(0LL,tmp2+j-x)*(n-i)+j);
			}
			dp[i][j] = tmp;
		}
	}
	rep(i,0,16) dp2[1][i] = i;
	rep(i,2,n+1){
		rep(j,0,16){
			tmp = 1LL<<60;
			rep(x,0,16){
				tmp2 = 0;
				k = b[i-2];
				while(b[i-1] < k){
					k*=4;
					tmp2 += 1;
				}
				k = b[i-1];
				while(b[i-2] < k*4){
					k*=4;
					tmp2 -= 1;
				}
				tmp = min(tmp,dp2[i-1][x]+max(0LL,tmp2+j-x)*(i-1)+j);
			}
			dp2[i][j] = tmp;
		}
	}
	res = 1LL<<60;
	rep(i,1,n+1){
		res = min(res,dp[i][0]*2+dp2[i-1][0]*2+i-1);
	}
    cout<<res<<endl;
}

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

int n, m;
string s;
int c[1000001];

signed main()
{
	while (true) {
		cin >> n;
		if (n == 0) break;
		cin >> m;
		cin >> s;

		rep(i,1000001) c[i] = 0;
		//c[m-1] = c[m-2] = 0;

		for (int i=m-3; i>=0; i--) {
			if (s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I') {
				c[i] = c[i+2] + 1;
			}
		}

		int ans = 0;
		rep(i,m) {
			if (c[i] >= n) ans++;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 7704
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

typedef long long ll;

using namespace std;
int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for (int i=0; i<n; ++i) cin >> a[i];
	vector<ll> cs = a;
	for (auto it = cs.begin()+1; it != cs.end(); ++it){
		*it += *(it-1);	
	}
	for (auto it = cs.begin(); it != cs.end(); ++it){
		*it = (*it)%m;
	}
	map<ll,ll> mp;
	mp[0] =1;
	for (auto it = cs.begin(); it != cs.end(); ++it){
		mp[*it] += 1;
	}
	ll ret = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it){
		ll n = it->second;
		ret += n*(n-1)/2;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 5760
town=[0 for i in range(4)]
for i in range(3):
    a,b=[int(j) for j in input().split()]
    town[a-1]+=1
    town[b-1]+=1
ans=0
for i in range(4):
    if town[i]>ans:
        ans=town[i]
if ans==3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
    int value;
    struct Node *next;
    struct Node *prev;
};

typedef struct Node * ndpt;

ndpt nil;

void init(){
    nil = malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int value){
    ndpt x;
    x = malloc(sizeof(struct Node));
    x->value = value;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

ndpt listSerach(int value){
    ndpt cur = nil->next;
    while( cur != nil && cur->value != value){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(ndpt t){
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteValue(int value){
    deleteNode(listSerach(value));
}

void printList(){
  ndpt cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->value);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

int main(){
  int value, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &value);
    if ( com[0] == 'i' ) {insert(value); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	deleteValue(value); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32972
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,q;
string s;
int d[110000];


int main(){
  cin>>n>>q;
  cin>>s;
  rep(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C') d[i+1]++;
    d[i+1]+=d[i];
  }

  rep(i,q){
    int  r,l;
    cin>>l>>r;
    l--;
    r--;
    cout<<d[r]-d[l]<<endl;
  }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll f[100010], fi[100010];

ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll comb(int r, int c) {
	if (r < c) return 0;
	return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<int> hoge(n + 1, -1);
	int idx1 = -1, idx2 = -1;
	for (int i = 0; i <= n; i++) {
		int a;
		cin >> a;
		if (hoge[a] != -1) {
			idx1 = hoge[a];
			idx2 = i + 1;
			break;
		}
		hoge[a] = i;
	}

	f[0] = 1;
	for (int i = 1; i <= n + 1; i++) f[i] = f[i - 1] * i % MOD;
	fi[n + 1] = modpow(f[n + 1], MOD - 2);
	for (int i = n + 1; i >= 1; i--) fi[i - 1] = fi[i] * i % MOD;

	for (int i = 1; i <= n + 1; i++) {
		cout << (comb(n + 1, i) - comb(n + 1 - idx2 + idx1, i - 1) + MOD) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char ac,uc[100000];
	cin >>a ;
	cout << "ABC"<<a << endl;
		return 0;
}

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

typedef long long int ll;
vector<ll> a;
ll n;
ll mod=256;
const double EPS=1e-9;

double str(ll s,ll A,int c){
  vector<ll> k(n+1);
  vector<ll> C(256,0);
  k[0]=s;
  //C[(s+a[0])%mod]++;
  for(int i=1;i<=n;i++){
    k[i]=(k[i-1]*A+c)%mod;
    C[(int)((k[i]+a[i-1])%mod)]++;
  }
  double ret=0;
  for(int i=0;i<256;i++){
    if(C[i]==0){continue;}
    double k=C[i];
    k/=n;
    //cout<<k<<" "<<log(k)<<endl;
    k*=log(k);
    //cout<<k<<endl;
    ret+=k;
  }  
  return ret;
}


int main(){
  while(cin>>n && n){
    a.clear();
  a.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  double mx=str(0,0,0);
  ll s=0,a=0,c=0;
  for(int i=0;i<16;i++){
    for(int t=0;t<16;t++){
      for(int h=0;h<16;h++){
	double ret=str(i,t,h);
	if(ret>mx+EPS){
	  mx=ret;
	  s=i; a=t; c=h;
	}
      }
    }
  }
  cout<<s<<" "<<a<<" "<<c<<endl;
  }
  return 0;
}



Measured memory_bytes: 3380
#include<iostream>
#include<string>
#include<vector>
using namespace std;
//stringのサイズは .size()　　←括弧忘れるな！！！
int main(void) {
	string S;
	cin >> S;
	bool s1 = true;
	bool s2 = true;
	bool s3 = true;
	
	int N = S.size();
	
	
	//s1
	for (int i = 0; i < (N); i++) {
		if (S[i] != S[N -1 - i]) {
			s1 = false;
		}
	}
	//s2
	int i2 = (N - 1) / 2;
	for (int i = 0; i < i2; i++) {
		if (S[i] != S[i2 -1 - i]) {
			s2 = false;
		}
	}
	//s3
	int i3 = (N + 3) / 2;
	for (int i = 0; i < (N-i3); i++) {
		if (S[i3 -1 + i] != S[N -1 -i]) {
			s3 = false;
		}
	}

	if ((s1 == true) && (s2 == true) && (s3 == true)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  OUT(N*(N+1)/2);
  return 0;
}



Measured memory_bytes: 256
n,k,d = map(int,input().split())
#n位置 k回数 d移動距離

abs_n = abs(n)
min_move = abs_n // d #とりあえず0に近づく

if k <= min_move:
  if n < 0:
    ans = abs(n + k * d)
  elif n > 0:
    ans = n - k * d
else:
  if (k - min_move) % 2 == 0: #0に近づいたあと複数回移動できるならば
    ans = abs_n % d 
  else:
    ans = d - abs_n % d 
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	deque<ll> q;
	if (n % 2) {
		REP(i, n)
		{
			if (i % 2) {
				q.push_back(v[i]);
			} else {
				q.push_front(v[i]);
			}
		}
	} else {
		REP(i, n)
		{
			if (i % 2) {
				q.push_front(v[i]);
			} else {
				q.push_back(v[i]);
			}
		}
	}


	REP(i, n)
	{
		cout << q.at(i) << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 5500
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

const int NILL = -1;

typedef long int lint;

typedef struct node
{
  lint key;
  struct node* parent;
  struct node* left;
  struct node* right;
  
}TREE;

TREE* root = NULL;

void insert(TREE* t)
{
  TREE* x;
  TREE* y;

  y = NULL;
  x = root;

  while(x != NULL)
  {
    y = x;
    if(t->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  
  if(y == NULL) root = t;
  else if(t->key < y->key){
    y->left = t;
  }
  else{
    y->right = t;
  }
}

int find(TREE* p, lint key)
{
  while(p != NULL && p->key != key){
    if(p->key > key){
      p = p->left;
      //print();
    }
    else{
      p = p->right;
      //print();
    }
  }
  if(p != NULL) return 1;
  else return 0;
}

void PreOrder(TREE* n)
{
  if(n == NULL) return;
  printf(" %ld",n->key);
  PreOrder(n->left);
  PreOrder(n->right);
}

void InOrder(TREE* n)
{
  if(n == NULL) return;
  InOrder(n->left);
  printf(" %ld",n->key);
  InOrder(n->right);
}

void print()
{
  InOrder(root);
  printf("\n");
  PreOrder(root);
  printf("\n");
}

int main()
{
  int m;
  int i;
  char order[20];
  lint key;
  
  scanf("%d",&m);

  for(i = 0; i < m;i++){
    scanf("%s",order);
    
    if(order[0] == 'i'){
      scanf("%ld", &key);

      //if(i == 0) root = tree;
      TREE* t = (TREE *)malloc(sizeof(TREE));
      t->right = t->left = NULL;

      t->key = key;
      insert(t);
    }
    else if(order[0] == 'f'){
      scanf("%ld",&key);
      
      if(find(root, key)) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(order,"print") == 0){
      print();
    }
  }
  return 0;
}


Measured memory_bytes: 20452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    double l;cin>>l;
    double div = l / 3.0;
    double ans = div*div*div;
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 256
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld x, a;
      cin >> x >> a;
      if (x < a)
      	cout << "0";
      else
      	cout << "10";
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int k;
    cin>>k;
    int c=k%10;
    if(c%2==0 || c==5)
        cout<<-1;
    else
    {
        int chec=0;
        for(int i=1;i<=10000000;i++)
        {
            chec=(chec*10+7)%k;
            if(chec==0){
                cout<<i;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int n = int.Parse(Console.ReadLine());
            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
            // 整数の入力
            int q = int.Parse(Console.ReadLine());

            var countArray = new long[100001];
            for (int i = 0; i < a.Length; i++)
            {
                countArray[a[i]]++;
            }

            long result = a.Sum();

            for (int i = 0; i < q; i++)
            {
                var bc = Console.ReadLine().Split().Select(long.Parse).ToArray();
                result += (bc[1] - bc[0]) * countArray[bc[0]];
                countArray[bc[1]] += countArray[bc[0]];
                countArray[bc[0]] = 0;
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 50872
import math
def Solve():
    L=[]
    N=int(input())
    for i in range(N):
        L.append(int(input()))

    mx=max(L)
    if L.count(mx)-1:#最大の個数が1個よりおおかったら
        for _ in L:
            print(mx)
    else: 
        for i,a in enumerate(L):
            if a==mx:
                K=L[:i]+L[i+1:]
                print(max(K))#i番目を除いた最大値
            else:
                print(mx)

Solve()


Measured memory_bytes: 15604
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<ll> x(n);

  rep(i, 0, n) cin >> x[i];

  ll ans = 1e18;
  rep(l, 0, n - k + 1) {
    int r = l + k - 1;
    ans =
        min({ans, abs(x[l]) + abs(x[r] - x[l]), abs(x[r]) + abs(x[r] - x[l])});
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	char a[3];
	cin >> a;
	
	int ans = 0;
	for(int i = 0; i < 3; i++)
	{
		if(a[i] == '1')
		{
			ans++;
		}
	}
	
	cout << ans << endl;
}

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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long ll;

ll INF = 100000000000000;
ll MOD = 1e9+7;

int main(){
    string S,T;cin >> S >> T;
    int n = S.size(),m = T.size();
    vector<vector<int>> dp(3010,vector<int>(3010));
    vector<vector<string>> dpS(3010,vector<string>(3010));
    /*for(int i = 0;i < 3010;i++){
        for(int j = 0;j < 3010;j++){
            dp[i][j] = 0;
            dp[i][j] = "";
        }
    }*/
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            if(S[i] == T[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    int len = dp[n][m];
    string ans = "";
    while(len > 0){
        if(S[n-1] == T[m-1]){
            ans = S[n-1] + ans;
            len--;
            n--;
            m--;
        }else if(dp[n][m] == dp[n-1][m]){
            n--;
        }else{
            m--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 106752
#include<iostream>
#include<cstdio>
int n,k;
long long a[100005];
inline int Abs(int A){
    return A>=0?A:-A;
}
inline int Max(int A,int B){
    return A>B?A:B;
}
inline int Min(int A,int B){
    return A<B?A:B;
}
void init(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i){
        scanf("%lld",a+i);
    }
    int ans=0x3f3f3f3f;
    for(int i=1;i<=n-k+1;++i){
        if(a[i]*a[i+k-1]>=0){
            ans=Min(ans,Max(Abs(a[i]),Abs(a[i+k-1])));
        }else{
            ans=Min(ans,Min(Abs(a[i]),Abs(a[i+k-1]))*2+Max(Abs(a[i]),Abs(a[i+k-1])));
        }
    }
    printf("%d\n",ans);
}
int main(){
    init();
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N, K; cin >> N >> K;
    vi count(200001, 0);
    REP(i, N)
    {
        int A; cin >> A;
        count[A]++;
    }
    sort(ALL(count), greater<>());
    int ans = 0;
    for(int i = K; i < count.size(); i++)
    {
        ans += count[i];
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1024
#違う数との組-->同じ数での組の順に考える

from collections import defaultdict, Counter

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

d = defaultdict(int) #mod Mで見たときの個数
for x in X:
    d[x % M] += 1


ans = 0 #Mの倍数//2 組の和はすべてMの倍数となる

lst = [0] * M
for m in range(1, M):
    ans += min(d[m], d[M - m])
    lst[m] = d[m] - min(d[m], d[M - m]) #mod Mで見たときに残っている個数

ans //= 2

ans += d[0] // 2 #0だけは1ダブルカウントしていないのであとから足す

C = Counter(X)
for c in C:
    tmp = min(C[c], lst[c % M]) // 2
    lst[c % M] -= 2 * tmp
    ans += tmp

print (ans)

Measured memory_bytes: 28124
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  s += s;
  cout << (s.find(t) != -1 ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256