akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

long long p[1000];
void solve(long long N, long long K){
  sort(p,p+N);
  cout<<accumulate(p,p+K,0)<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(N, K);
  return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h> 
using namespace std;  
int main () 
{ 
    int n;
    cin>>n;
    int k;cin>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<=i+k;++j ){
            dp[j]=min(dp[i]+abs(arr[j]-arr[i]),dp[j]);
        }
    }
    cout<<dp[n-1]<<" ";
   /* for(int i=0;i<n;i++)
    {
        cout<< arr[i];
        cout<<dp[i];
    }
    */
    return 0; 
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
int defrag;
int defragg;
bool dis[10]= {};
cin>>n>>x;
for(int i=0;i<x;i++){
    cin>>defrag;
    dis[defrag]=1;
}
for(int i=n;i;i++){
    defrag=i;
    int o=0;
    while(defrag>0){
        defragg=defrag%10;
        defrag/=10;
        if(dis[defragg]==1){
            o=1;
            break;
        }
    }
    if(o==1){
        continue;
    }
    else{
        cout<<i;
        break;
    }
}
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    int size = S.size();
    RREP(i,size/2){
        if(S.substr(0,i) == S.substr(i,i)){
            cout << i*2 << "\n";
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
    scanf("%d", &n);
	if(n/100 == 7){
        printf("Yes\n");
        return 0;
    }
    n %= 100;
    if(n/10 == 7){
        printf("Yes\n");
        return 0;
    }
    n %= 10;
   	if(n == 7){
    	printf("Yes\n");
    	return 0;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 1732
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    if int("".join(get_ln_inputs())) % 4 == 0:
        print("YES")
    else:
        print("NO")


main()

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

int main()
{
  int n , A ;
  cin >> n ;
  vector<int> B(n-1) ;
  for(int i=0; i<n-1; i++)
    cin >> B.at(i) ;
  
  A += B.at(0) + B.at(n-2) ;
  
  for(int i=0; i<n-2;i++)
    if(B.at(i)<=B.at(i+1))
      A += B.at(i) ;
    else
      A += B.at(i+1) ;
  
  cout << A << endl  ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N,sum=0;
  cin>>N;
  int MOD=1000000007;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
    sum%=MOD;
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    sum-=A.at(i)-MOD;
    sum%=MOD;
    ans+=sum*A.at(i);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
int t, w[10], d;
ll n;
map<ll, ll> mp;

ll dfs(ll x) {
	if (!x) return 0;
	if (mp.count(x)) return mp[x];
	ll ans = min(__int128(x) * d, __int128(inf));
	for (int i = 2; i <= 5; ++i)
		if (i != 4) {
			ll v1 = x / i * i, v2 = ((x - 1) / i + 1) * i;
			if (v1 / i < x)
				ans = min(ans, dfs(v1 / i) + w[i] + (x - v1) * d);
			if (v2 / i < x)
				ans = min(ans, dfs(v2 / i) + w[i] + (v2 - x) * d);
		}
	return mp[x] = ans;
}

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%lld", &n);
		scanf("%d%d%d%d", &w[2], &w[3], &w[5], &d);
		mp.clear();
		printf("%lld\n", dfs(n));
	}
}


Measured memory_bytes: 4548
N = int(input())
A = list(map(int, input().split()))
X = {}

S = [0]
for a in A:
    S.append(S[-1]+a)

for s in S:
    if s in X.keys():
        X[s] += 1
    else:
        X[s] = 1
    
ans = 0
for x in X:
    ans += (X[x]*(X[x]-1))//2

print(ans)

Measured memory_bytes: 43920
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    print(int(n * (n - 1) / 2 + m * (m - 1) / 2))
    pass


if __name__ == "__main__":
    main()


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

namespace _0049
{
    class Program
    {
        static void Main(string[] args)
        {
            var bloodTable = new Dictionary<string, string>();
            string str = "";
            int a = 0;
            int b = 0;
            int o = 0;
            int ab = 0;
            while (!((str = Console.ReadLine()) == null))
            {
                string[] line = str.Split(',').ToArray();
                switch (line[1])
                {
                    case "A":
                        a++;
                        break;
                    case "B":
                        b++;
                        break;
                    case "O":
                        o++;
                        break;
                    case "AB":
                        ab++;
                        break;
                }
            }
            Console.Write(a + "\n" + b + "\n" + ab + "\n" + o + "\n");
        }
    }
}



Measured memory_bytes: 16176
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,b,c,d, = readline() |> split |> parseMap
	while a>0||c>0
		c-=b
		if c<=0
			println("Yes")
			break
		end
		a-=d
		if a<=0
			println("No")
			break
		end
	end
end

main()

Measured memory_bytes: 161364
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int n = nextInt();
		int k = nextInt();
		String[] wk = next().split("");
		wk[k - 1] = wk[k - 1].toLowerCase();

		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < wk.length; i++) {
			builder.append(wk[i]);
		}

		out.println(builder.toString());
	}

	private void solveB() {
		int wk = nextInt();

		int front = wk / 100;
		int back = wk % 100;

		if ((0 < front && front <= 12) && (back <= 0 || back > 12)) {
			out.println("MMYY");
		} else if ((0 < back && back <= 12) && (front <= 0 || front > 12)) {
			out.println("YYMM");
		} else if ((0 < front && front <= 12) && (0 < back && back <= 12)) {
			out.println("AMBIGUOUS");
		} else {
			out.println("NA");
		}

	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <vector>
using namespace std;

vector<int> p;
vector<int> q;
int n;
int INF = 1000000007;

int main(){
	for(int i=2; i<1001; i++){
		bool b = true;
		for(int j=0; j<p.size(); j++) if(i % p[j] == 0){
			b = false;
			break;
		}
		if(b){
			p.push_back(i);
			q.push_back(0);
		}
	}

//	for(int i=0; i<p.size(); i++) printf("%d\n", p[i]);

	scanf("%d", &n);
	for(int i=2; i<n+1; i++){
		int x = i;
		for(int j=0; j<p.size(); j++){
			while(x % p[j] == 0){
				x /= p[j];
				q[j]++;
			}
		}
	}

//	for(int i=0; i<q.size(); i++) printf("%d\n", q[i]);

	long long int ans = 1;
	for(int i=0; i<q.size(); i++){
		ans = ans * (q[i] + 1);
		ans = ans % INF;
	}
	printf("%lld\n", ans);
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

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

    s[3] = '8';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;

    VL a(N); REP(i,N) cin >> a[i];
    VL b(N); REP(i,N) b[i] = a[i];

    sort(a.begin(),a.end());
    //int ans = -1;
    //LL dif = LINF;
    REP(i,N-1){
        if(a[i] > a[N-1]/2) a[i] = a[N-1] - a[i];
    }
    sort(a.begin(),a.end()-1);

    bool flag = 0;
    REP(i,N){
        if(b[i] == a[N-2]) flag = 1;
    }
    if(flag){
        cout << a[N-1] << " " << a[N-2] << endl;
    }
    else{
        cout << a[N-1] << " " << a[N-1]-a[N-2] << endl;
    }

}

Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    s = input()
    ct = 0
    for i in range(n-2):
        if s[i:i+3] == 'ABC':
            ct += 1
    print(ct)


if __name__=='__main__':
    main()


Measured memory_bytes: 5780
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

ll big=1e9+7;
vector<ll> p(1000001,1);
vector<ll> ip(1000001,1);

struct p_t{
  int s,t;
};

bool asc(p_t left,p_t right) {
    return left.t == right.t ? left.s < right.s : left.t < right.t;
}

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

ll pp(int i,int j){
  if(i<0||j<0||i<j)return 0;
  else{
    ll tem;
    tem=p[i]*ip[i-j]%big;
    return tem;
  }
}

int main(){
  for(int i=1;i<1000001;i++){
    p[i]=p[i-1]*i%big;
  }
  for(int i=1;i<1000001;i++){
    ip[i]=pow_ans(p[i],big-2);
  }
  int n,m;
  cin>>n>>m;
  vector<int>a(n,0);
  vector<int>b(m,0);
  vector<p_t>ab;
  p_t zz;
  int h=0;
  int w=0;
  zz.s=0;
  for(int i=0;i<n;i++){
		cin>>a[i];
    zz.t=a[i];
    ab.push_back(zz);
	}
  zz.s=1;
  for(int i=0;i<m;i++){
		cin>>b[i];
    zz.t=b[i];
    ab.push_back(zz);
	}
  sort(ab.begin(),ab.end(),asc);
  int k=0;
  ll ans=1;
  for(int i=0;i<(int)ab.size();i++){
    if(i-2>=0&&ab[i].t==ab[i-2].t){
      ans=0;
      break;
    }
    if(i<(int)ab.size()-1&&ab[i].t==ab[i+1].t){
      if(ab[i].s==ab[i+1].s){
        ans=0;
        break;
      }
      ans*=pp(ab[i].t-k-1,m-w-1);
      ans%=big;
      ans*=pp(ab[i].t-k-(m-w),n-h-1);
      ans%=big;
      k+=m-w+n-h-1;
      h++;
      w++;
      i++;
    }
    else{
      if(ab[i].s==0){
        ans*=pp(ab[i].t-k-1,m-w-1);
        ans%=big;
        ans*=m-w;
        ans%=big;
        k+=m-w;
        h++;
      }
      else{
        ans*=pp(ab[i].t-k-1,n-h-1);
        ans%=big;
        ans*=n-h;
        ans%=big;
        k+=n-h;
        w++;
      }
    }
	}
  cout<<ans<<endl;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if(s[n-1]==s[n]){
        cout << n-1 << " " << n << endl;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
n=int(input())
s=input()
l=set()
r=set()

for i in range(0,n-2):
    a=set()
    if s[i] in r:
        continue
    else:
        r.add(s[i])
    for j in range(i+1,n-1):
        if s[j] in a:
            continue
        else:
            a.add(s[j])
        for k in range(j+1,n):
            if j==1 and k>=3 and s[k]==s[2]:
                continue
            m=s[i]+s[j]+s[k]
            l.add(m)
print(len(l))


Measured memory_bytes: 41708
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> p(26,-1);
  rep(i,n){
    int c = s[i]-'a';
    if(p[c]!=-1 && i-p[c]<=2){
      cout << p[c]+1 << " " << i+1 << endl;
      return 0;
    }
    p[c] = i;
  }
  cout << "-1 -1" << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cstring>
#define INF 1000000
using namespace std;
int n,d;
int x[200002],y[200002];
int main(){
  cin >> n;
  for(int i=1;i<=n;i++)cin >> x[i];
  for(int i=1;i<=n;i++)y[x[i]]=i;
  int ans=1,t=1;;
  for(int i=2;i<=n;i++){
    if(y[i-1]<y[i])t++;
    else {ans=max(ans,t);t=1;}
  }
  ans=max(ans,t);
  cout << n-ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String taro, hanako, str;
        int st=0, sh=0;
        int n = scan.nextInt();
        for(int i=0; i<n; i++) {
            taro = scan.next();
            hanako = scan.next();
            if(taro.compareTo(hanako) < 0) sh += 3;
            else if(taro.compareTo(hanako) > 0) st+=3;
            else { st++; sh++; }
        }
        System.out.println(st + " " + sh);
    }
}

Measured memory_bytes: 29156
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,i,j,c=0,l;
 	string s;
 	cin>>n;
 	cin>>s;
 	l=s.length();
 	for(i=0;i<l;i++)
 	{	
 		if(s[i]+n<=90)
 			s[i]=s[i]+n;
 		else
 			s[i]=(char)(65+(n-90+s[i]-1));
 			
	 }
	 cout<<s<<endl;
}

Measured memory_bytes: 3588
#include<iostream>

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

    int X,Y; std::cin >> X >> Y;

    int t; //Turtle
    for (int c=0;c<=X;++c){ // Crane
        t=X-c;
        if (2 * c + 4 * t == Y) {
            std::cout << "Yes";
            return 0;
        }
    }
    std::cout << "No";
    return 0;
}

Measured memory_bytes: 3632
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

vector<int> prod(vector<int> A, vector<int> B, int p){
  vector<int> ret(A.size()+B.size()-1,0);
  for(size_t i = 0; i < A.size(); ++i){
    for(size_t j = 0; j < B.size(); ++j){
      ret[i+j] += A[i]*B[j]%p;
      ret[i+j] %= p;
      if(ret[i+j] < 0) ret[i+j] += p;
    }
  }
  return ret;
}

vector<int> div(vector<int> A, vector<int> B, int p){
  // A/B
  vector<int> ret(A.size()+1-B.size());
  for(int i = ret.size()-1; i >= 0; --i){
    ret[i] = A[i+B.size()-1]/B.back();
    for(int j = 0; j < B.size(); ++j){
      A[i+j] += p-ret[i]*B[j]%p;
      A[i+j] %= p;
      if(A[i+j] < 0) A[i+j] += p;
    }
  }
  return ret;
}

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

  vector<int> F_inv(p);
  F_inv.back() = p-1;
  for(int i = p-1; i > 0; --i)
    F_inv[i-1] = (F_inv[i]*i)%p;

  vector<int> G = {1};
  for(int i = 0; i < p; ++i){
    G = prod(G,{-i,1},p);
  }

  vector<int> B(p,0);
  
  for(int i = 0; i < p; ++i){
    vector<int> T = div(G,{-i,1},p);
    assert(prod(T,{-i,1},p) == G);
    int c = F_inv[i]*F_inv[p-i-1]%p;
    if((p-i-1)%2) c = p-c%p;
    c *= A[i];
    
    for(int j = 0; j < p; ++j){
      B[j] += T[j]*c%p;
      B[j] %= p;
    }
  }

  for(int i = 0; i < p; ++i)
    cout << B[i] << ((i+1 < p) ? " " : "\n");

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll x; cin >> x;
	ll a = 100;
	ll cnt = 0;
	while( a < x ){
		a += a/100;
		++cnt;
	}
	cout << cnt << endl; 
}

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

int main(void)
{
	int n, m;
	string str;
	while (cin >> n, n){
		cin >> m >> str;
		int cnt = 0, res = 0;
		for (int i = 1; i < m-1; i++){
			if (str[i-1] == 'I' && str[i] == 'O' && str[i+1] == 'I') {
				cnt++;
				i++;
			}
			else cnt = 0;
			if (n <= cnt) res++;
		}
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1972
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder S = new StringBuilder(sc.next());
		int Q = sc.nextInt();
		int T = 0;
		int F = 0;

		StringBuilder addHead = new StringBuilder();
		StringBuilder addTail = new StringBuilder();
		boolean reverse = false;
		for(int i = 0; i < Q; i++) {
			 T = sc.nextInt();
			 if(T == 1) {
				 reverse = !reverse;//反転
				 continue;
			 }
			 F = sc.nextInt();
			 if((!reverse && F == 1) || (reverse && F == 2) ) {
				 addHead.insert(0, sc.next());
			 }else {
				 addTail.append(sc.next());
			 }
		}
		if(reverse) {
			S = addTail.reverse().append(S.reverse()).append(addHead.reverse());
		}else {
			S = addHead.append(S).append(addTail);
		}
		System.out.println(S.toString());
	}
}


Measured memory_bytes: 112476
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    int comp;
    union_find(int size) : data(size, -1), comp(size) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : (data[x] = root(data[x]));
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() { return comp; }
};

signed main() {
    int N, M;
    cin >> N >> M;
    union_find uf(N);
    rep(i, 0, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }
    cout << uf.components() << endl;
    return (0^_^0);
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  pair<int,int> p[100];
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i].second>>p[i].first,p[i].first*=-1;
  sort(p,p+n);
  cout<<p[0].second<<" "<<-p[0].first<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int ans = 0;
  int mod = pow(10, 9)+7;
  
  int sk = K*(K-1)/2;
  sk %= mod;
  
  rep(i, N) {
    int k = 0;
    int kk = 0;
    rep(j, N) {
      if(A[i] > A[j]) {
        kk++;
        if(i < j) k++;
      }
    }
    ans += k*K;
    ans %= mod;
    ans += kk*sk;
    ans %= mod;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  ll n,k;
  cin >> n >> k;
  cout << min(n%k,k-n%k) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int memo[88];

int f(int n) {
	if (n == 0) return 2;
	if (n == 1) return 1;
	if (memo[n] > 0) return memo[n];
	return memo[n] = f(n - 1) + f(n - 2);
}

signed main() {
  INIT;
	VAR(int, n);
  int ans = f(n);
	OUT(ans)BR;
  return 0;
}


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

using namespace std;

int main(int argc, char** argv){
    string S;
    cin >> S;
    int N = S.length();

    vector<int> structure(0);
    char state = 'R';
    int statelen = 1;
    for (int i=1; i<N; i++){
        if (S[i] == state) statelen++;
        else {
            structure.push_back(statelen);
            state = S[i];
            statelen = 1;
        }
    }
    structure.push_back(statelen);

    vector<int> ans(N, 0);

    int idx = 0;
    for (size_t i=0; i<structure.size(); i+=2){
        int Rs = structure[i];
        int Ls = structure[i+1];
        ans[idx + Rs - 1]  = (Rs/2 + Rs%2) + (Ls/2);
        ans[idx + Rs]      = (Rs/2) + (Ls/2 + Ls%2);
        idx += Rs + Ls;
    }

    for (int i=0; i<N; i++){
        cout << ans[i];
        if (i == N-1) cout << "\n";
        else cout << " ";
    }

    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll power(long long n,int x,long long MOD){
  long long a = 1;
  long long b = x;
  while(n>0){
    if(n%2==1){
      a*=b;
      a%=MOD;
    }
    n/=2;
    b = b*b;
    b%=MOD;
  }
  return a;
}

int main() {
  int n; cin >> n;
  if(n==1) {
    cout << 0 << endl;
    return 0;
    }

  ll ans = power(n,10,mod);
  ans = (ans - power(n,9,mod)*2%mod + mod)%mod;
  ans = (ans + power(n,8,mod))%mod;
  cout << ans << endl;

/*
  mint ans1 = pow(10,n);
  cout << ans1.x << endl;
  mint ans2 = pow(9,n);
  ans2 *=2;
  ans2 -= pow(8,n);
  mint ans = ans1 - ans2;
  cout << ans.x << endl;

  ll ex = pow(10,10);
  cout << ex%mod << endl;
  */



  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int d, t, s; string ans = "Yes";
    cin >> d >> t >> s;
    if(d > t * s) ans = "No";
    cout << ans << endl;
    return 0;
}

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

void print(string str,int a, int b){
    for(int i=a;i<=b;i++){
        cout<<str[i];
    }
    cout<<endl;
    return;
}

string reverse(string str,int a, int b){
    string temp;
    temp=str;
    for(int i=a;i<=b;i++){
        str[i]=temp[b-(i-a)];
    }
    return str;
}

string replace(string str,int a,int b,string text){
    for(int i=0;i<=b-a;i++){
        str[a+i]=text[i];
    }
    return str;
}

int main(void){
    string str,text;
    string command;
    int num,a,b;
    
    cin>>str;
    cin>>num;
    
    for(int i=0;i<num;i++){
        cin>>command;
        if(command=="print"){
            cin>>a>>b;
            print(str,a,b);
        }
        else if(command=="reverse"){
            cin>>a>>b;
            str=reverse(str,a,b);
        }
        else{
            cin>>a>>b>>text;
            str=replace(str,a,b,text);
        }
    }
    return 0;
}



Measured memory_bytes: 3228
from collections import Counter

mod = int(1e9 + 7)
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)

if n % 2 == 1:
    # 誰かは真ん中にいる or 0は1人のみ
    if 0 not in c or c[0] != 1:
        print(0)
        exit()

# 偶数: 5, 3, 1, 1, 3, 5 -> 1, 3, 5をカウント (n//2)
# 奇数: 4, 2, 0, 2, 4 -> 2, 4をカウント (n//2)
for i in range(n // 2):
    x = i * 2 + (1 if n % 2 == 0 else 2)
    if x not in c or c[x] != 2:
        print(0)
        exit()

# (左から右) × 2(左右対称)
print(pow(2, n // 2, mod))

Measured memory_bytes: 55532
#include<algorithm>
#include<cstdio>
using namespace std;

int x, y, a, b, c;
int p[100000], q[100000], r[100000];

bool cmp(const int &i1, const int &i2) {
    return i1 > i2;
}

int main() {
    scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
    for (int i = 0; i < a; i++) scanf("%d", &p[i]);
    for (int i = 0; i < b; i++) scanf("%d", &q[i]);
    for (int i = 0; i < c; i++) scanf("%d", &r[i]);
    sort(p, p + a, cmp);
    sort(q, q + b, cmp);
    sort(r, r + c, cmp);
    int cnta = 0, cntb = 0, cntc = 0;
    for (cntc = 0; cntc < c; cntc++) {
        if (x - cnta > 0 && p[x - 1 - cnta] < r[cntc]) {
            if (y - cntb > 0 && q[y - 1 - cntb] < r[cntc]
             && p[x - 1 - cnta] > q[y - 1 - cntb]) cntb++;
            else cnta++;
        }
        else if (y - cntb > 0 && q[y - 1 - cntb] < r[cntc]) cntb++;
        else break;
    }
    long ans = 0;
    for (int i = 0; i < x - cnta; i++) ans += p[i];
    for (int i = 0; i < y - cntb; i++) ans += q[i];
    for (int i = 0; i < cntc; i++) ans += r[i];
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

ll x, y;
ll C(ll n, ll r) { 
    
    
    if (r == 0 || r == n) {
        return 1; 
    }
    ll fn = 1, fr, fnr;
    for (ll i = 1; i <= n; i++) {
        fn = mul(fn, i);
        if(i==r){
            fr = fn;
        }
        if(i==n-r){
            fnr = fn;
        }
    }
    // cout<<fn<<" "<<fnr<<" "<<fr<<endl;
  
    return mul(mul(fn, mod_inv(fr)), mod_inv(fnr)); 
} 
int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif

    cin>>x>>y;
    if((x+y)%3 != 0){
        cout<<0<<endl;
        return 0;
    }
    ll n, m;
    m = (2*x - y)/3;
    n = (2*y - x)/3;
    if(m<0 || n<0){
        cout<<0<<endl;
        return 0;
    }
    if(m==0 || n==0){
        cout<<1<<endl;
        return 0;
    }
    cout<<C(n+m, m)<<endl;
    
}

Measured memory_bytes: 3660
import java.util.*;
import java.io.*;

public class Main {

	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   long sum = 0; 
	   for(int i = 0; i<n; i++) {
		   int x = in.readInt();
		   sum += x-1;
	   }
	   System.out.println(sum); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21204
x,y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

const long MOD = 1000000007;

long pow2(int n){
    long ans = 1;
    for(int i = 0; i < n; i++){
        ans *= 2;
        ans %= MOD;
    }
    return ans;
}

long inv(int n){
    if(n == 1) return 1;
    return (-(MOD/n)*inv(MOD%n)%MOD+MOD)%MOD;
}

long dp[5001][5001];


int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= 5000; j++){
            if(dp[i-1][j] > 0) {
                dp[i][j+1] = dp[i-1][j]*2;
                dp[i][j+1] %= MOD;
                if(j != 0) {
                    dp[i][j-1] += dp[i-1][j];
                    dp[i][j-1] %= MOD;
                }
                else {
                    dp[i][j] += dp[i-1][j];
                    dp[i][j] %= MOD;
                }
            }
        }
    }
    
    long ans = (dp[N][n]*inv(pow2(n)))%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 193792
# 解説AC
N,K,Q = map(int, input().split())
A = [int(i) for i in input().split()]

def main():
    ans = float("inf")

    # A[i]: 最小値X
    for i in range(N):
        # 最大値Yの候補
        can = []

        # A[left:right]: A[i]以上の連続部分列
        left = 0
        while left < N:
            right = left
            while right < N and A[i] <= A[right]:
                right += 1

            # 連続部分列長
            L = right - left

            tmp = sorted([A[j] for j in range(left, right)])
            can += tmp[:max(0, L - K + 1)]

            left = right + 1
        
        # Q番目に小さいものがYの最小値
        can.sort()
        if len(can) >= Q:
            ans = min(ans, can[Q - 1] - A[i])

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 49604
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

string s,t;
LL ls,lt;
LL dp[3005][3005];
LL pre[3005][3005];

void output(int l,int r){
	if((!l) || (!r)) return;
	if(pre[l][r] == 1){
		output(l - 1,r - 1);
		printf("%c",s[l]);
	}
	if(pre[l][r] == 2) output(l - 1,r);
	if(pre[l][r] == 3) output(l,r - 1);
}

int main(){
	cin >> s; ls = s.length(); s = ' ' + s;
	cin >> t; lt = t.length(); t = ' ' + t;
	for(LL i = 1;i <= ls;i ++){
		for(LL j = 1;j <= lt;j ++){
			if(s[i] == t[j]){
				if(dp[i - 1][j - 1] + 1 > dp[i][j]){
					dp[i][j] = dp[i - 1][j - 1] + 1;
					pre[i][j] = 1;
				}
			}
			if(dp[i - 1][j] > dp[i][j]){
				dp[i][j] = dp[i - 1][j];
				pre[i][j] = 2;
			}
			if(dp[i][j - 1] > dp[i][j]){
				dp[i][j] = dp[i][j - 1];
				pre[i][j] = 3;
			}
		}
	}
	output(ls,lt);
	return 0;
}


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

using namespace std;

int main (){
  char b;
  cin >> b;
  if(b == 'A')
    cout << "T";
  
  if(b == 'T')
    cout << "A";
  
  if(b == 'G')
    cout << "C";
  
  if(b == 'C')
    cout << "G";
  
  return 0;
}

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

ll N, M;
vector<vector<ll>> G;

ll dfs(ll i, vector<ll> seen){
    ll ret = 0;
    bool f = false;
    seen[i] = true;
    for(auto p : G[i]){
        if(seen[p]) continue;
        f = true;
        ret += dfs(p, seen);
    }
    if(!f){
        bool ff = false;
        rep(i, 1, N+1){
            if(!seen[i]) ff = true;
        }
        if(ff) return 0;
        else return 1;
    }
    return ret;
}

int main(){
    cin >> N >> M;
    G.resize(N+1);
    rep(i, 0, M){
        ll a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> seen1(N+1, false);
    cout << dfs(1, seen1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
const int N=1e5+10;
const ll mod=1e9+7;
int n;
ll a[N],fac=1,inv[N],ans;
ll quickpow(ll d,ll k)
{
    ll f=1;
    while(k)
    {
        if(k&1) f=f*d%mod;
        d=d*d%mod;
        k>>=1;
    }
    return f;
}
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
int main()
{
    scanf("%d",&n);
    rep(i,1,n) fac=fac*i%mod,inv[i]=quickpow(i,mod-2),scanf("%lld",a+i);
    rep(i,1,n) (inv[i]+=inv[i-1])%=mod;
    rep(i,1,n) (ans+=a[i]*(inv[i]+inv[n-i+1]-1))%=mod;
    printf("%lld\n",ans*fac%mod);
    return 0;
}

Measured memory_bytes: 1664
N, M = map(int, input().split())
list_A = list(map(int, input().split()))

list_A = sorted(list_A, reverse=True)

total_vote = sum(list_A)

if M > len(list_A):
    answer = 'No'
elif (list_A[M -1] / total_vote) < 1/(4*M):
    answer = 'No'
else:
    answer = 'Yes'

print(answer)


Measured memory_bytes: 3060
s=input()
dict={}
for i in range(4):
    if not s[i] in dict:
        dict[s[i]]=0
    dict[s[i]]+=1

a=list(dict.keys())
for i in range(len(a)):
    if dict[a[i]]!=2:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 38256
fun main(args:Array<String>){
    val l = readLine()!!.split(" ").map { it.toInt() }
    val n = l[0]
    val m = l[1]

    val array = Array(n){it->0}
    var sum = 0

    val height = readLine()!!.split(" ").map{ it.toInt() }
    for(i in 1..m){
        val ab = readLine()!!.split(" ").map{it.toInt()-1}
        if(height[ab[0]]!=height[ab[1]]) {
            if (height[ab[0]] > height[ab[1]]) array[ab[1]] = 1 else array[ab[0]] = 1
        }else{
            array[ab[0]] = 1
            array[ab[1]] = 1
        }
    }
    array.forEach {
        if(it == 0) sum++
    }
    println(sum)
}

Measured memory_bytes: 71820
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main() {
  string a,b,c;
  cin >> a;
  cin >> b;
  c=b+b;
  const char* str1=c.c_str();
  const char* str2=a.c_str();
  if(strstr(str1,str2) !=NULL){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,cnt=0;
    cin >> n;
    bool flag=false;
    rep(i,n){
        int d,dd;
        cin >> d >> dd;
        if(d==dd){
            cnt++;
            if(cnt==3) flag=true;
        }
        else cnt=0;
    }
    if(flag) print("Yes");
    else print("No");
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int n,t[300010];
void update(int x){while(x<=n)++t[x],x+=x&-x;}
int query(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
ll getinv(std::vector<int>&A){
	memset(t,0,sizeof t);
	ll ret=0;
	for(int i=A.size()-1;~i;--i)ret+=query(A[i]),update(A[i]);
	return ret;
}
void myassert(bool o){if(!o)puts("No"),exit(0);}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi();
	std::vector<int>A(n),B,C;for(int i=0;i<n;++i)A[i]=gi();
	for(int i=0;i<n;++i)myassert(A[i]+i&1);
	for(int i=0;i<n;++i)(i&1?B:C).push_back(A[i]);
	myassert((getinv(B)+getinv(C))*3==getinv(A));
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4076
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,an=0;
	ll A[20];
	ll x[20][20];
	ll y[20][20];
	cin >> N;
	rep(i, N) {
		cin >> A[i];
		rep(j, A[i]) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	for (int bit = 1; bit < (1 << N); ++bit) {
		bool ch = true;
		ll k = 0;
		rep(i, N) {
			if (bit & (1 << i)) {
				k++;
				rep(j, A[i]) {
					if (((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
						ch = 0;
					}
				}
			}
		}
		if (ch) {
			an = max(an, k);
		}

	}
	cout << an << endl;

}

Measured memory_bytes: 256
N=int(input())
L_list=list(map(int, input().split()))

ans=0

for i in range(N):
	for j in range(i, N):
		for k in range(j, N):
			if L_list[i]!= L_list[j] and L_list[j] != L_list[k] and L_list[k] != L_list[i]:
				if L_list[i]+L_list[j]> L_list[k] and L_list[j]+L_list[k]>L_list[i] and L_list[k]+L_list[i]>L_list[j]:
					ans+=1
print(ans)


Measured memory_bytes: 9180
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;



int main(void) {
	int n, d;
	cin >> n >> d;
	vector<int> x(n);
	vector<int> y(n);

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

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (pow(pow(x[i], 2) + pow(y[i], 2), 0.5) <= d) ans++;
	}

	cout << ans;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,m;cin>>n>>m;
	int x[alength]={};fori(m){cin>>x[i];}
	if(n>=m){
		cout<<0;return 0;
	}
	sort(x,x+m);
	int d[alength]={};
	fori(m-1){
		d[i]=x[i+1]-x[i];
	}
	sort(d,d+m-1);
	int ans=0;
	fori(m-n){ans+=d[i];}
	cout<<ans;
}

Measured memory_bytes: 4432