akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
# define ll  long long



	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);  

	  	string s,t;
	  	cin>>s>>t;
	  	for(int i=0;i< t.size();i++){
	  		s=s+'$';
	  	}
	  	int ans=(int)t.size();
	  	// int n=((int)s.size()-(int)t.size());
	
	  	for(int i=0;i< (int)s.size();i++){
	  		int unmatch=0;
	  		for(int j=0;j<(int)t.size();j++){
	  			if(s[i+j]!=t[j]){
	  				unmatch++;
	  			}
	  			if(s[i+j]=='$'){
	  				unmatch=t.size();
	  			}
	  		}
	  		ans=min(ans,unmatch);
	  	}
	  	cout<<ans<<endl;
	}



	


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n,k;
ll h[100005];
ll ans[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin >> n >> k;

    fr(i,1,n)
    {
        cin >> h[i];
    }

    ans[1] = 0;
    fr(i,2,n)
    {
        ans[i] = INF;
    }

    fr(i,2,n)
    {
        fr(j,1,min(i-1,k))
        {
            ll x = abs(h[i]-h[i-j]);
            ans[i] = min(ans[i], ans[i-j]+x);
        }
    }

    cout << ans[n] << endl;
}

Measured memory_bytes: 1792
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    let n = 26;
    input! {
        d: usize,
        c: [isize; n],
        s: [[isize; n]; d],
        t: [Usize1; d],
    }
    let mut last = vec![0; n];
    let mut score = 0;
    for i in 0..d {
        let ti = t[i];
        score += s[i][ti];
        last[ti] = i + 1;
        for j in 0..n {
            score -= c[j] * (i + 1 - last[j]) as isize;
        }
        println!("{}", score);
    }
}


Measured memory_bytes: 2268
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int num[10];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	num[a]++;
	num[b]++;
	num[c]++;
	for(int i=1;i<=9;i++)if(num[i]==2){puts("Yes");return 0;}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

//C: Fastest Route
public class Main{

	public static int[] dist;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] cost = new int[n][n+1];
			for(int i=0;i<n;i++)for(int j=0;j<=n;j++)cost[i][j]=sc.nextInt();
			dist = new int[1<<n];
			Arrays.fill(dist, 1<<30);
			dist[0] = 0;
			Queue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
				public int compare(Integer o1, Integer o2) {
					return dist[o1]-dist[o2];
				}
			});
			q.add(0);
			while(true){
				int u = q.poll();
				if(u==(1<<n)-1)break;
				for(int i=0;i<n;i++){
					if((u&(1<<i))>0)continue;
					int nu = u | (1<<i);
					int min = dist[u] + cost[i][0];
					for(int j=0;j<n;j++){
						if((u&(1<<j))>0)min=Math.min(min, dist[u]+cost[i][j+1]);
					}
					if(min < dist[nu]){
						dist[nu] = min;
						q.add(nu);
					}
				}
			}
			System.out.println(dist[dist.length-1]);
		}
	}
}

Measured memory_bytes: 17000
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define testcase int t;cin>>t;while(t--)
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define P pair<int,int>
/*bool isprime(lli n)
{
    if(n==1) return 0;
    for(lli i=2;i<=n/2;i++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}
bool issemiprime(lli n)
{
    for(int i=2;i<n;i++)
    {
        if(isprime(i)&&isprime(n/i)&&n%i==0&&i!=n/i){
            return 1;
        }
    }
    return 0;
}
lli extendedgcd(lli q,lli r1,lli r2,lli r,lli s1,lli s2,lli s,lli t1,lli t2,lli t)
{
if(r2==0) return r1;
	r1=r2;
        r2=r;
        s1=s2;
        s2=s;
        t1=t2;
        t2=t;
        q=r1/r2;
        r=r1%r2;
        s=s1-(s2*q);
        t=t1-(t2*q);
return extendedgcd(q,r1,r2,r,s1,s2,s,t1,t2,t);
}
lli gcd(lli a,lli b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
void SOE()
{
    for(lli i=2;i<=100000;i++)
    {
        if(sieve[i]) continue;
        for(lli x=i;x<=100000;x+=i)
        {
            sieve[x]+=1;
        }
    }
}*/
/*bool func(pair<int,int> a,pair<int,int> b)
{
    return a.first<b.first;
}*/

void solve()
{
    string s,t;
    cin>>s>>t;
    int m=s.length();
    int n=t.length();
    int dp[m+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans="";
    int x=m,y=n;
    while(x!=0&&y!=0)
    {
        if(dp[x-1][y]==dp[x][y]){
            --x;
        }
        else if(dp[x][y-1]==dp[x][y]){
            --y;
        }
        else{
            ans=t[y-1]+ans;
            --y;
            --x;
        }
    }
    cout<<ans;
}
int main()
{
    solve();
}


Measured memory_bytes: 38828
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int lli;

bool OK(vector<lli> &a, vector<lli> &vs, int pos){
  lli size = vs[pos];
  int n = a.size();
  for (int i = pos + 1; i < n; i++) {
    if(2*size >= a[i]){
      size += a[i];
      if(i == n - 1)return true;
    }else{
      return false;
    }
  }
}
        

lli binarySearch(vector<lli> &a, vector<lli> &vs){
  int n = a.size();
  int l = 0, r = n - 1, mid = (r + l)/2;
  if(OK(a, vs, 0))return n;
  while(r - l > 1){
    if(OK(a, vs, mid)){
      r = mid;
    }else{
      l = mid;
    }
    mid = (r + l)/2;
  }
  return n - r;
}

int main(){
  int n;
  std::cin >> n;
  vector<lli> a(n), vs(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  sort(a.begin(), a.end());
  vs[0] = a[0];
  for (int i = 1; i < n; i++) {
    vs[i] = a[i] + vs[i - 1];
  }
  std::cout << binarySearch(a, vs) << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n, l; cin >> n >> l;
    int a[n];

    int t, su=0, mi=10000000;
    rep(i, n){
        a[i] = l+i;
        su+=a[i];
        if(mi>abs(a[i])){
            mi = abs(a[i]);
            t = a[i];
        }
    }
    out(su-t);
}

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

int main(){
  int c[3][3] = {};
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  int a[3] = {};
  int b[3] = {};
  for(int i = 0; i < 3; i++) b[i] = c[0][i] - a[i];
  for(int i = 1; i < 3; i++) a[i] = c[i][0] - b[0];
  bool flag = true;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(a[i] + b[j] != c[i][j]) flag = false;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
n,m=map(int,input().split())
if abs(n -m) > 1:
    print(0)
elif abs(n-m) == 1:
    a = math.factorial(n)
    b = math.factorial(m)
    print((a * b) % ((10 ** 9)+7))
else:
    a = math.factorial(n)
    b = math.factorial(m)
    print((2 * a * b) % ((10 ** 9)+7))

Measured memory_bytes: 5324
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#define MAX 100005
typedef long long LL;

using namespace std;

int main()
{
	int k,n;
	int a[1005];
	int sum = 0;
	cin >> n >> k;
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i = 0;i < k;i++)
	{
		sum += a[i]; 
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(itn i=a;i>=b;i--)
using namespace std;
const int Mod=1e9+7;
typedef long long ll;
ll ans,Ans,fib[105]={1,1},x,y;
vector<pair<ll,ll> >p[105];
map<pair<ll,ll>,bool> checker;
int main(){
	rep(i,2,90) fib[i]=fib[i-1]+fib[i-2];
	//rep(i,1,100) if(fib[i]>1e18) printf("Here %d\n",i);
	p[1].push_back(make_pair(1,2));
	p[1].push_back(make_pair(1,3));
	p[1].push_back(make_pair(1,4));
	rep(i,1,90){
		for(int j=0;j<p[i].size();j++){
			ll u=p[i][j].second,v=p[i][j].first+u;
			for(;v<=fib[i+3]+fib[i];v+=u){
				if(checker[make_pair(u,v)]) puts("fuck i am wrong!");
				checker[make_pair(u,v)]=1;
				p[i+1].push_back(make_pair(u,v));
			}
		}
	}
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%lld%lld",&x,&y);
		if(x>y) swap(x,y);
		for(ans=1,Ans=0;fib[ans+1]<=x&&fib[ans+2]<=y;ans++); printf("%d ",ans);
		if(ans==1){
			printf("%lld\n",x*y%Mod);
			continue;
		}
		for(int j=0;j<p[ans-1].size();j++){
			ll u=p[ans-1][j].first,v=p[ans-1][j].second;
			if(v<=x) Ans=(Ans+(y-u)/v%Mod)%Mod;
			if(v<=y) Ans=(Ans+(x-u)/v%Mod)%Mod;
		}
		printf("%lld\n",Ans);
	}
	return 0;
}

Measured memory_bytes: 4352
import * as fs from "fs";

const split = (str: string): string[] =>
  str.split(" ").map((v: string) => v.trim());
const split_number = (str: string): number[] =>
  split(str).map((v: string) => +v);

export function main(input: string) {
  const lines = input.split("\n");
  const [n] = split_number(lines[0]);
  let S = lines.slice(1);

  let datums: { [keys: string]: number } = {};
  let max = 0;

  for (let i = 0; i < n; i++) {
    datums[S[i]] = (datums[S[i]] || 0) + 1;
    max = max < datums[S[i]] ? datums[S[i]] : max;
  }

  const result = Object.keys(datums)
    .sort()
    .filter(key => datums[key] === max);

  return result.join("\n");
}

if (!process.env.LOCAL_DEBUG) {
  console.log(main(fs.readFileSync("/dev/stdin", "utf8")));
}


Measured memory_bytes: 115592
#include<bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

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

long long InverseEuler(int n, int MOD)
{
    return fastpow(n,MOD-2,MOD);
}
 
long long f[300000];
bool init;
long long C(int n, int r, int MOD)
{
    if (!init){
        init=1;
        f[0]=1;
        for (int i=1; i<300000;i++)
            f[i]= (f[i-1]*i) % MOD;
        
    }
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}


int N;
int a[100005];
int main(){
   std::ios::sync_with_stdio(false); 

   cin>>N;
   readN(N,a);
   for (int i=0;i<N;i++){
        a[i]--;
   }

   int res = 0;
   for (int i=0;i+1<N;i++){
    if (a[i] != i) continue;
    res++;
    swap(a[i], a[i+1]);
   }
   if (a[N-1] == N-1) res++;
   cout<<res<<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define mem(a) memset(a, 0, sizeof(a))
using namespace std;
const int MAXN = 105;

int main()
{
    int a, b, c;
    while(~scanf("%d %d %d", &a, &b, &c))
    {
        int mod=c%b;
        int flag=0;
        for(int i=1;i<=100;++i)
        {
            if(a*i%b==mod)
            {
                flag=1;
                printf("YES\n");
                break;
            }
        }
        if(flag==0)
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
def solve():
    A, B, C = [int(x) for x in input().split()]
    K = int(input())
    ans = False
    for i in range(K):
        red = A * 2**i
        green = B * 2**(K - i)
        blue = C
        # print(i, red, green, blue)
        if green > red and blue > green:
            ans = True
            break

        red = A
        green = B * 2**i
        blue = C * 2**(K - i)
        # print(i, red, green, blue)
        if green > red and blue > green:
            ans = True
            break

        red = A * 2**i
        green = B
        blue = C * 2**(K - i)
        # print(i, red, green, blue)
        if green > red and blue > green:
            ans = True
            break

    if ans:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    solve()

Measured memory_bytes: 61752
//It is made by ljh2000
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long LL;
const int MAXN = 400011;
const int MAXM = 800011;
int n,m,Q,ecnt,first[MAXN],to[MAXM],nxt[MAXM],col[MAXN],maxd[MAXN];
struct ask{ int x,d,c; }q[MAXN];
inline void link(int x,int y){ nxt[++ecnt]=first[x]; first[x]=ecnt; to[ecnt]=y; }
inline void dfs(int x,int d,int c){
	if(!col[x]) col[x]=c; if(maxd[x]>=d) return ;
	if(d==0) return ; maxd[x]=d;
	for(int i=first[x];i;i=nxt[i]) {
		int v=to[i]; 
		dfs(v,d-1,c);
	}
}

inline void work(){
	scanf("%d%d",&n,&m); int x,y;
	for(int i=1;i<=m;i++) { scanf("%d%d",&x,&y); link(x,y); link(y,x); }
	scanf("%d",&Q); for(int i=1;i<=Q;i++) { scanf("%d%d%d",&q[i].x,&q[i].d,&q[i].c); }
	for(int i=Q;i>=1;i--) dfs(q[i].x,q[i].d,q[i].c);
	for(int i=1;i<=n;i++) printf("%d\n",col[i]);
}

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


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

using namespace std;
int main() {
	string s;
	cin >> s;
	string a, b, c, d, e;
	int n = s.size();
	a = s.substr(0, n/2);
	b = a;
	c = s.substr(n/2+1);
	d = c;
	e = s;

	reverse(b.begin(), b.end());
	reverse(d.begin(), d.end());
	reverse(e.begin(), e.end());

	if (a == b and c == d and e == s) cout << "Yes" << endl;
	else cout << "No" << endl;

}


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

int main(){
  int A[2];
  cin >> A[0] >> A[1];
  if ((A[0] == 1 && A[1] == 2) || (A[0] == 2 && A[1] == 1)){
    cout << 3 << "\n";
  } else if ((A[0] == 1 && A[1] == 3) || (A[0] == 3 && A[1] == 1)){
    cout << 2 << "\n";
  } else {
    cout << 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    else:
        if m + f >= 80:
            print("A")
        elif m+f < 80 and m+f >= 65:
            print("B")
        elif m+f < 65 and m+f >= 50 or r >= 50:
            print("C")
        elif m+f < 50 and m+f >= 30:
            print("D")
        else:
            print("F")


Measured memory_bytes: 5596
a,b=map(int,input().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

ll calc(mat &s, vec &c, vec &ans){
    ll res = 0;
    vec last(26, 0);
    rep(day, N){
        last[ans[day]] = day + 1;
        rep(i, 26){
            if(i == ans[day]){
                res += s[day][i];
            }else{
                res -= c[i] * (day + 1 - last[i]);
            }
        }
    }
    return res;
}

int main() {
    cin>>N;
    vec c(26), last(26, 0), ans(N);
    mat s(N, vec(26)), ans_another(26, vec(1, 0));
    rep(i,26) cin>>c[i];
    rep(i,N) rep(j, 26) cin>>s[i][j];
    ll score = 0;
    rep(day, N){
        vec temp(26, 0);
        rep(i, 26) temp[i] += s[day][i];
        rep(i, 26) temp[i] += c[i] * (day + 1 - last[i]);
        auto ite = max_element(ALL(temp));
        ans[day] = ite - temp.begin();
        ans_another[ans[day]].push_back(day + 1);
        last[ite - temp.begin()] = day + 1;
        rep(i, 26){
            if(i == ans[day]){
                score += s[day][i];
            }else{
                score -= c[i] * (day + 1 - last[i]);
            }
        }
    }
    rep(i,26) ans_another[i].push_back(N + 1);

    ll total_num = 210000;
    while(total_num) {
        mat minus(N + 1, vec(26, 0));
        priority_queue<P> pque;
        rep(i, 26) {
            vec &table = ans_another[i];
            int id = 0;
            reps(day, 1, N) {
                if (table[id + 1] == day) {
                    ++id;
                } else {
                    ll weight = s[day - 1][i], len = table[id + 1] - table[id] - 1;
                    ll wh = day - table[id];
                    weight += c[i] * ((len * (len + 1) / 2) - (wh * (wh - 1) / 2 + (len - wh) * (len - wh + 1) / 2));
                    pque.emplace(weight, day * 26 + i);
                }
            }
        }
        if((total_num -= 20) < 0) break;
        ll non_update = 0;
        rep(check, 10000) {
            P p = pque.top();
            pque.pop();
            ll day = p.se / 26, i = p.se % 26;
            --day;
            ll old = ans[day];
            ans[day] = i;
            if (!chmax(score, calc(s, c, ans))) {
                ans[day] = old;
                check += non_update * 3;
            }else{
                ++non_update;
            }
            if((--total_num) < 0) break;
        }
    }

    rep(i,N) cout<<ans[i] + 1<<'\n';
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=10000002;
const int p=998244353;
int n;

void read(int &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
}

void Add(ll &x,ll y){
	x+=y;
	while(x>=p) x-=p;
	while(x<0) x+=p;
}

ll qpow(ll a,ll n){
	ll ans=1;
	for(;n;n>>=1,a=a*a%p) if (n&1) ans=ans*a%p;
	return ans;
}

ll fac[N],inv[N];
void init(){
	fac[0]=1;
	frl(i,1,N) fac[i]=fac[i-1]*i%p;
	inv[N-1]=qpow(fac[N-1],p-2);
	rf(i,N-2,0) inv[i]=inv[i+1]*(i+1)%p;
}

ll C(int n,int m){ return fac[n]*inv[m]%p*inv[n-m]%p; }

int main(){
	cin>>n;
	init();
	ll ans=qpow(3,n);
	ll pw=2;
	rf(i,n,n/2+1){
		Add(ans,-C(n,i)*pw%p);
		pw=pw*2%p;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 156544
#include <stdio.h>

int main(void)
{
	int n,i;
	double x1,x2,x3,x4,y1,y2,y3,y4,ans1,ans2;
	
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		ans1=(y2-y1)/(x2-x1);
		ans2=(y4-y3)/(x4-x3);
		if(ans1==ans2)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 620
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

row1 = s()
row2 = s()

if row1 == row2[::-1] and row2 == row1[::-1]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
n = int(input())
a = input().split()
a = [int(m) for m in a]
k = 1
i = 0
t = a[0]
count = 1
p = 0
if n != 1:
    while i < n:
        if i != 0:
            t -= a[i - 1]
            if p == 1:
                count += k - i + 1
            else:
                count += k - i
        if p != 1:
            for j in range(k, n):
                if t + a[j] == t ^ a[j]:
                    t += a[j]
                    count += 1
                    if j == n - 1:
                        k = j
                        p = 1
                        i += 1
                else:
                    k = j
                    i += 1
                    break
        else:
            i += 1
    print(count)
else:
    print(count)

Measured memory_bytes: 25556
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n;
ll K,a[200111];
int c[200111];
void add(int x)
{
	for(int i=x;i<=200005;i+=i&(-i))c[i]++;
}
int query(int x)
{
	int ans=0;
	for(int i=x;i>0;i-=i&(-i))ans+=c[i];
	return ans;
}
vector<ll>v;
int main()
{
	getii(n,K);
	for(int i=1;i<=n;i++)geti(a[i]),a[i]=a[i]-K+a[i-1],v.PB(a[i]);
	v.PB(0);
	sort(v.begin(),v.end());
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
		ans+=query(a[i]);
		add(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    
    vector<pair<int,int>> p(M);
    rep(i,M)cin>>p[i].first>>p[i].second;
    
    rep(x,1000){
        string s=to_string(x);
        
        if(s.size()!=N)continue;
        
        bool ok=true;
        rep(i,M)if(s[p[i].first-1]!=p[i].second+'0')ok=false;
        
        if(ok){
            cout<<x<<endl;
            return 0;
        }
    }
    
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define endl '\n'
#define N 200005
int a[N][3],dp[N][3];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<3;j++)
    	cin>>a[i][j];
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1;i<n;i++)
    {
    	dp[i][1] = a[i][1]+max(dp[i-1][2],dp[i-1][0]);
    	dp[i][2] = a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    	dp[i][0] = a[i][0]+max(dp[i-1][1],dp[i-1][2]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)



int main(){
    string s;
    cin>>s;
    
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[501][501];
  int n,i,j,U,k,V;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) a[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&U,&k);
    U--;
    for(j=0;j<k;j++){
      scanf("%d",&V);
      V--;
      a[U][V]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i%d == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
fun main(args: Array<String>) {
  val n = readInt()
  val p = readInts()

  var cnt = 0
  for (i in 0 until n - 2) {
    if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) cnt++
  }
  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37768
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        if(0 <= S && S < 86400){
            int s = S%60;
            int m = (S/60)%60;
            int h = (S/60)/60;
            System.out.println(h + ":" + m + ":" +s );
        }
    }
}



Measured memory_bytes: 26336
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


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

  int n[N];

  rep(i, N) n[i] = -1;
  rep(i, M) {
    int s, c;
    cin >> s >> c;
    --s;
    if (n[s] == -1) {
      n[s] = c;
    } else if (n[s] != c) {
      cout << "-1\n";
      return 0;
    }
  }
  if (n[0] == 0 && N > 1) {
    cout << "-1\n";
    return 0;
  }
  if (n[0] == -1)
    n[0] = (N == 1 ? 0 : 1);
  rep(i, N) {
    if (n[i] == -1)
      n[i] = 0;
    cout << n[i];
  }
  cout << endl;

  return 0;
}


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

struct Node{
  struct Node *right;
 struct Node *left;
 struct Node *parent;
  int key;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int n, i, x;
  char a[20];
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", a);
    if (strcmp(a,"insert")==0){
      scanf("%d", &x);
      insert(x);
    }
    else if (strcmp(a,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25180
import kotlin.*

fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.next()
        var c = 1
        for (i in 1 until s.length) {
            if (s[i - 1] != s[i]) c++
        }
        println(c - 1)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        if (ptr >= l.size) {
            var s: String
            do {
                s = readLine()!!
            } while (s.isEmpty())
            l = s.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        val s = readLine()!!
        return if (s.isEmpty()) listOf() else s.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 39116
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N)cin >> A[i];
    rep(i,N)cin >> B[i];
    rep(i,N)cin >> C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    ll res = 0;
    rep(i,N){
        ll aitr = lower_bound(A.begin(),A.end(),B[i])-A.begin();
        ll citr = C.end()-upper_bound(C.begin(),C.end(),B[i]);
        res += aitr*citr;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main()
{
	fast	
	set<string> st;
	map<string ,int> m;
	string s;
	int n,i;
	cin>>n;
	int mx=0;
	for(i=0;i<n;i++)
	{
		cin>>s;
		if(!m[s])
		st.insert(s);
		m[s]++;
		mx=max(mx,m[s]);
	}
	for(auto a:st)
		if(m[a]==mx)
			cout<<a<<"\n";
}	

Measured memory_bytes: 33280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String code = sc.nextLine();
        String answer = "";

        for(int i=0;i<code.length();i++){
            char box = code.charAt(i);

            if(Character.isLowerCase(box)){
                answer += Character.toUpperCase(box);
            }else{
                answer += Character.toLowerCase(box);
            }
        }

        System.out.println(answer);

        sc.close();
    }
}


Measured memory_bytes: 31244
#include <bits/stdc++.h>
#define int long long
#define Matrix vector<vector<int> >
// #define Matrix vector<vector<int> >
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const long long INF = 5e18;
const double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
double rad(double x){
    return x*pi/180.0;
}
 
bool isleft(pair<int,int> a, pair<int,int> b, pair<int,int> c){
    int det = (b.first-a.first)*(c.second-a.second) - (c.first-a.first)*(b.second-a.second);
    if(det>=0) return true;
    if(det<0) return false;
    return false;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,MOD);
 
        b >>= 1;
        a = mod(a*a,MOD);
    }
    return result;
}

int memo[123456][3];
int v[123456][3];
int n;
int dp(int pos, int at){
    if(pos==n) return 0;
    int &ans = memo[pos][at];
    // cout<<"HERE"<<endl;
    if(ans!=-1) return ans;
    for(int i=1;i<=2;i++){
        ans = max(ans,v[pos][at]+dp(pos+1,(at+i)%3));
    }
    // cout<<ans<<endl;
    return ans;
}
void solve(){
    memset(memo,-1,sizeof(memo));
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>v[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(ans,dp(0,i));
    }
    cout<<ans<<endl;
}
 
signed main(){
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int x;
      cin >> x;
      A.at(x - 1) = 1;
    }
  }
  int cnt = 0;
  for(int i = 0; i < N; i++){
    cnt += A.at(i);
  }
  cout << N - cnt << endl;
  
}

Measured memory_bytes: 3624
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int ans=0;
  for(int i=0;i<n-1;i++){
    ans=ans+vec.at(i);
  }
  if(vec.at(n-1)>=ans){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
   
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int color[600][600][2];
const int dx[4] = {-1,-1,1,1};
const int dy[4] = {-1,1,1,-1};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    auto calc=[](ll x, ll D) {
        if (x*x > D) return -1LL;
        ll ng = -1;
        ll ok = D+1;
        while (abs(ng-ok)>1) {
            ll mid = (ng+ok)/2;
            if (mid*mid+x*x>=D) ok = mid;
            else ng = mid; 
        }
        if (x*x+ok*ok==D) return ok;
        return -1LL;
    };

    ll N,D1,D2; cin >> N >> D1 >> D2;
    vector<vector<pll>> d(2);
    rep(i,N*2) {
        ll val = calc(i,D1);
        if (val != -1) d[0].emplace_back(i,val);
        val = calc(i,D2);
        if (val != -1) d[1].emplace_back(i,val);
    }

    rep(i,N*2) rep(j,N*2) rep(k,2) color[i][j][k] = -1;
    queue<pll> que;
    rep(i,N*2) {
        rep(j,N*2) {
            rep(k,2) {
                if (color[i][j][k]!=-1) continue;
                color[i][j][k] = 0;
                que.emplace(i,j);
                while (!que.empty()) {
                    auto[x,y] = que.front(); que.pop();
                    for (auto[ddx,ddy] : d[k]) {
                        rep(l,4) {
                            ll nx = x+ddx*dx[l];
                            ll ny = y+ddy*dy[l];
                            if (nx < 0 or nx >= N*2 or ny < 0 or ny >= N*2) continue;
                            if (color[nx][ny][k]!=-1) continue;
                            color[nx][ny][k] = 1 - color[x][y][k];
                            que.emplace(nx,ny);
                        }
                    }
                } 
            }
        }
    }

    vector<int> cnt(4);
    rep(i,N*2) {
        rep(j,N*2) {
            cnt[color[i][j][1]*2+color[i][j][0]]++;
        }
    }
    int n = max_element(all(cnt)) - cnt.begin();
    vector<pii> ans;
    rep(i,N*2) {
        rep(j,N*2) {
            if (color[i][j][0]==(n&1) and color[i][j][1]==((n>>1)&1)) {
                ans.emplace_back(i,j);
            }
        }
    }

    ans.resize(N*N);
    for (auto i : ans) print(i.first,i.second);
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;
string tos(ll n)
{
    stringstream ss;
    ss<<n;
    string g=ss.str();
    return g;
}
ll toi(string s)
{
    stringstream ss;
    ss<<s;
    ll n;
    ss>>n;
    return n;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n;
    rep(i,1,n+1){
        string s=tos(i);
        if(s.length()%2==1) cnt++;
    }    
    ret(cnt)
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication{
    public class Program{
        public static void Main(string[] args){
            string searchWord;          //????´¢????±?????????????
            int wordCount = 0;
            searchWord = Console.ReadLine();
            searchWord = searchWord.ToLower();

            while(true){
                string allWord = Console.ReadLine();

                //?????????????????´???????????????????????????
                if("END_OF_TEXT".Equals(allWord)){
                    break;
                }

                //????????°??????????????¢??°
                wordCount += CountSearchWord(allWord, searchWord);
                
            }

            Console.WriteLine(wordCount.ToString());
        }

        ///????????°??????????????¢??°
        private static int CountSearchWord(string allwords, string keyword){
            allwords = allwords.ToLower();
            string[] words = allwords.Split(' ');
            int count = 0;

            for(int i = 0; i < words.Length; i++){
                if(keyword.Equals(words[i])){
                    count++;
                }
            }

            return count;
        }
    }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        ll a=0,b=0,c=0,counter=0;
	cin>>a>>b>>c;
        bool k=true;
        while(a%2==0 && b%2==0 && c%2==0)
        {   int tempa=0,tempb=0,tempc=0;
            tempa=a;
            tempb=b;
            tempc=c;
            a=(tempb+tempc)/2;
            b=(tempa+tempc)/2;
            c=(tempa+tempb)/2;
            counter++;
	if(a==b && b==c){
	cout<<"-1";
k=false;	
break;
	
	}
        }
if(k)
        cout<<counter;
        
        
        
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n;cin>>n;
    pair<pair<string, int>, int> p[n];
    rep(i,n){
        string name;int score;
        cin>>name>>score;
        p[i] = make_pair(make_pair(name, -1*score), i+1);
    }
    sort(p, p+n);
    rep(i,n){
        co(p[i].second);
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,ans,t,l[100005],r[100005];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		l[i]=-read(),r[i]=read();
	sort(l,l+n),sort(r,r+n);
	for(int i=0;i<n;i++)
		ans=min(ans,t+min(min(l[i],r[i]),l[i]+r[i])),t+=l[i]+r[i];
	printf("%lld",-ans*2);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try(Scanner sc = new Scanner(System.in)){
		
			int a = sc.nextInt();
			int b = sc.nextInt();
			int t = sc.nextInt();
			
			System.out.println(t / a * b);
		}

	}
}


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

int main(){
  int n;
  cin>>n;
  ll vec[n];
  ll powers[31];
  map<ll,int> ma;
  powers[0]=2;
  for(int i=1;i<31;i++){
    powers[i]=2*powers[i-1];
  }
  for(int i=0;i<n;i++){
    cin>>vec[i];
    ma[vec[i]]++;
  }
  sort(vec,vec+n);
  reverse(vec,vec+n);
  int ans=0;
  ll x;
  int y;
  for(int i=0;i<n;i++){
    if(ma[vec[i]]>0){
      for(int j=30;j>=0;j--){
        x=powers[j]-vec[i];
        if(x<=0){
          break;
        }
        if(x==vec[i]){
          ans+=ma[vec[i]]/2;
          ma[vec[i]]%=2;
          continue;
        }
        ans+=min(ma[vec[i]],ma[x]);
        y=min(ma[vec[i]],ma[x]);
        ma[vec[i]]-=y;
        ma[x]-=y;
      }
    }
  }
  cout<<ans<<endl;      
}

Measured memory_bytes: 52736
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        Console.WriteLine(Console.ReadLine().ToCharArray().Count(c => c == '2'));
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead() {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 11220
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

const int MOD = 1000000007;

int main() {
	int N, T;
	cin >> N >> T;
	vi stage(N);
	REP(i, N) {
		cin >> stage[i];
	}

	sort(ALL(stage));
	vector<ll> dp(N);
	dp[0] = 1;
	FOR(i, 1, N - 1) {
		ll num = stage.begin() + i - lower_bound(ALL(stage), stage[i] - T) + 1;
		dp[i] = dp[i - 1] * num % MOD;
	}

	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 2328
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    string res = "";
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '1') res.push_back('1');
        else if(s[i] == '0') res.push_back('0');
        else if(res.size() > 0) res.erase(res.size()-1);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}

int main()
{
    
      int l,r,d;
      cin>>l>>r>>d;
      int ans =0;
      for(int i=l;i<=r;i++)
          if(i%d==0)ans++;
      cout<<ans;
    
    return 0;
}


Measured memory_bytes: 3496