akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 105
int vx [4]= {1,0,-1,0};
int vy [4]= {0,1,0,-1};
long long  dp[MAX_N][4][4];//dp[date][today][yesterday]
int V[MAX_N],W[MAX_N];
int data[MAX_N],B[MAX_N];
int K ,N;
using namespace std;
void init(){
    REP(i,4)REP(j,4)dp[2][i][j]=1;
    REP(j,K){
      if(data[j]==1)
        switch (B[j]) {
          case 1 : FOR(l,1,4){dp[2][l][2]=0;dp[2][l][3]=0;}break;
          case 2 : FOR(l,1,4){dp[2][l][1]=0;dp[2][l][3]=0;}break;
          case 3 : FOR(l,1,4){dp[2][l][1]=0;dp[2][l][2]=0;}break;
        }
        else if (data[j]==2)
        switch (B[j]) {
          case 1 : FOR(l,1,4){dp[2][2][l]=0;dp[2][3][l]=0;}break;
          case 2 : FOR(l,1,4){dp[2][1][l]=0;dp[2][3][l]=0;}break;
          case 3 : FOR(l,1,4){dp[2][1][l]=0;dp[2][2][l]=0;}break;
        }

      }
  for(int i=3;i<=N;i++){
    dp[i][1][1]= dp[i-1][1][2]+dp[i-1][1][3];
    dp[i][2][2]= dp[i-1][2][1]+dp[i-1][2][3];
    dp[i][3][3]= dp[i-1][3][2]+dp[i-1][3][1];
    dp[i][1][2]= dp[i-1][2][1]+dp[i-1][2][2]+dp[i-1][2][3];
    dp[i][1][3]= dp[i-1][3][1]+dp[i-1][3][2]+dp[i-1][3][3];
    dp[i][2][1]= dp[i-1][1][1]+dp[i-1][1][2]+dp[i-1][1][3];
    dp[i][2][3]= dp[i-1][3][1]+dp[i-1][3][2]+dp[i-1][3][3];
    dp[i][3][1]= dp[i-1][1][1]+dp[i-1][1][2]+dp[i-1][1][3];
    dp[i][3][2]= dp[i-1][2][1]+dp[i-1][2][2]+dp[i-1][2][3];
    REP(x,4)REP(y,4)dp[i][x][y]%=10000;
    REP(j,K){
      if(data[j]==i){
        switch (B[j]) {
          case 1 : FOR(l,1,4){dp[i][2][l]=0;dp[i][3][l]=0;}break;
          case 2 : FOR(l,1,4){dp[i][1][l]=0;dp[i][3][l]=0;}break;
          case 3 : FOR(l,1,4){dp[i][1][l]=0;dp[i][2][l]=0;}break;
        }
      }
    }
  }
  long long total=0;
    for(int j =1 ;j<=3;j++){
      for(int l =1;l<=3;l++){
        total += dp[N][j][l];
        total %= 10000;
        //cout << '[' <<j<<','<<l<<']'<<dp[N][j][l]<<endl;
      }

  }
  cout << total <<endl;

}
void solve(){
  cin >> N >> K;
  REP(i,K){
    cin >> data[i]>>B[i];
  }
  init();

}
int main(){
    solve();
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {

	set <int> todos;

	for(int i = 1; i < 10; i++) {
		for(int j = 1; j < 10; j++) {
			todos.insert(i*j);
		}
	}

	int n;
	scanf("%d", &n);

	if(todos.find(n) != todos.end()) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n; long a,b;
  cin>>n>>a>>b;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  long l=0, r=INF/2;
  while(r-l>1){
    long m = (r+l)/2;

    auto f = [&](){
      long cnt = 0;
      rep(i,n){
        if(vec[i] <= m*b) continue;
        long c = a-b;
        cnt += (vec[i] - m*b + c - 1)/c;
      }
      if(cnt <= m) return true;
      else return false;
    };

    if(f())  r=m;
    else l=m;
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 1024
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll MOD=(ll)1e9+7;
const int N=1e6;

ll fac[N],invfac[N+3];

ll QPow(ll Ca,ll Cb){
	ll ret=1;
	while(Cb){
		if(Cb&1) ret=ret*Ca%MOD;
		Ca=Ca*Ca%MOD;
		Cb>>=1;
	}
	return ret;
}
ll funC(int Ca,int Cb){return fac[Cb]*invfac[Ca]%MOD*invfac[Cb-Ca]%MOD;}
//sum( A[1~n] ) + B = S, A[1~m] >= Vr , 0 <= A[m+1,n] < Vl
ll funF(int n,int m,ll S,ll Vl,ll Vr){
	if(S-m*Vr<0) return 0;
	else S-=m*Vr;
	ll ret=0;
	for(int i=0,tmp=1;i<=n-m && Vl*i<=S;i++,tmp*=-1)
		ret=(ret+MOD+tmp*funC(i,n-m)*funC(n,S-i*Vl+n)%MOD)%MOD;
	return ret*funC(m,n)%MOD;
}
ll Solve(int n,int m,int S){
	ll ret=funC(n,S+n);
	for(int i=S;i>=1;i--)
		ret=(ret+MOD-(funF(n,m,S,i,i)+MOD-funF(n,m,S,i,i+1))%MOD)%MOD;
	return ret;
}
int main(){
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%MOD;
	invfac[N-1]=QPow(fac[N-1],MOD-2);
	for(int i=N-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%MOD;
	int n,m,Sl,Sr;
	scanf("%d%d%d%d",&n,&m,&Sl,&Sr);
	printf("%lld\n",(Solve(n,m,Sr)+MOD-Solve(n,m,Sl-1))%MOD);
	return 0;
}

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

#define ll long long int 
#define FOR(i,N) for(i=0;i<(N);i++)
#define FORe(i,N) for(i=1;i<=(N);i++)
#define FORr(i,a,b) for(i=(a);i<(b);i++)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first 
#define ss second 
#define mp make_pair
#define pb push_back
#define ldd long double 
#define cd complex<double>
#define vcd vector<cd>
#define all(x) (x).begin(),(x),end()

using namespace std;

const ll MAXN = 1e5+5;
const ll MOD = 1e9+7;
const ll INF = 1e17+1011;
const ll ROOTN = 320;
const ll LOGN = 17;

const ldd PI = acos(-1);
const ldd EPS = 1e-7;

const short int __PRECISION = 9;
const short int Alp = 26;

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll i,freq[Alp],ans = 1;
	string s;
	cin>>s;
	FOR(i,Alp)
		freq[i] = 0;
	FOR(i,s.size())
		freq[(s[i] - 'a')]++;
	ans = (s.size()*(s.size()-1))/2 + 1;
	FOR(i,Alp)
		ans -= (freq[i]*(freq[i]-1))/2;
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    bool je=true;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]%2) je=false;
    }
    if(je) cout << "second" << "\n";
    else cout << "first" << "\n";

    return 0;
}

Measured memory_bytes: 3704
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))

num_table = [0] * N
ans = 1
for i in range(N):
    if A[i] == 0:
        ans *= (3 - num_table[A[i]])
        num_table[A[i]] += 1
        continue
    ans *= (num_table[A[i] - 1] - num_table[A[i]])
    ans %= mod
    num_table[A[i]] += 1

print(ans)

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(char, c);
    Cout("T G   C            A"[c - 'A']);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int i,n,x[10001];
        long min,max,sum;
        scanf("%d",&n);
        scanf("%d",&x[0]);
        min=x[0];max=x[0];sum=x[0];
        for(i=1;i<n;i++){
                scanf("%d",&x[i]);
                sum+=x[i];
                if(x[i]>max) max=x[i];
                if(x[i]<min) min=x[i];
        }
        printf("%ld %ld %ld\n",min,max,sum);
        return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,v,ans;cin>>n;map<ll,ll> odd,even;
  rep(i,n) {cin>>v;if(i%2==0) odd[v]++;else even[v]++;}
  ll of=0,ofk=0,os=0,ef=0,efk=0,es=0;
  for(auto i=odd.begin();i!=odd.end();++i) {
    ll v=i->second,k=i->first;
    if(of<v) {os=of;of=v;ofk=k;} else {if(os<v) os=v;}
  }
  for(auto i=even.begin();i!=even.end();++i) {
    ll v=i->second,k=i->first;
    if(ef<v) {es=ef;ef=v;efk=k;} else {if(es<v) es=v;}
  }
  if (ofk!=efk) ans=n-of-ef;
  else {
    ll ans1=n-of-es,ans2=n-ef-os;
    ans=min(ans1,ans2);
  } 
  print(ans);
  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <math.h>

int main(void){
    int n, i;
    double S[1100], sum, alpha, m;
    
    while(scanf("%d", &n), n) {
        sum=0.0, alpha=0.0, m=0.0;
        for(i=1; i<=n; i++) {
            scanf("%lf", &S[i]);
            sum += S[i];
        }
        m = sum / n;
        for(i=1; i<=n; i++) {
           alpha += pow(S[i]-m, 2);
        }
        printf("%.8f\n", sqrt(alpha/n));
    }
    
    return 0;
}


Measured memory_bytes: 2040
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,d) = get!(usize, usize);
    let res = if n%(1+2*d) == 0 {
        n/(1+2*d)
    } else {
        n/(1+2*d) +1
    };
    println!("{}", res);
}


Measured memory_bytes: 8572
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int a = p + q;
	int b = q + r;
	int c = r + p;
	vector<int> vec;
	vec = { a, b, c };
	sort(vec.begin(), vec.end());
	cout << vec[0] << endl;
	return 0;
}

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

int main(){
    int a,b; cin >> a >> b;
    string s; cin >> s;
    bool flag = 1;
    for(int i=0;i<a+b+1;i++){
        if(i == a){
            if(s[i] == '-'){
                flag = 1;
            }else{
                flag = 0;
                break;
            }
        }else{
            if(s[i] >= '0' && s[i] <= '9'){
                flag = 1;
            }else{
                flag = 0;
                break;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int S=in.nextInt();
        int h,m,s,a;
        h=S/3600;
        a=S%3600;
        m=a/60;
        s=a%60;
        System.out.println(h+":"+m+":"+s);
    }
}


Measured memory_bytes: 26216
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int s = a+b;

            if(a<0 && b<0 && c<0) System.exit(0);

            if(a<0 || b<0 || s<30){
                System.out.println("F");
            }else if(s>=80){
                System.out.println("A");
            }else if(65<=s && s<80){
                System.out.println("B");
            }else if(50<=s && s<65){
                System.out.println("C");
            }else{
                if(c>=50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }
        }
    }
}


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

using namespace std;

using ll = long long;

int main(){
    ll arr[3], k;
    cin >> arr[0] >> arr[1] >> arr[2] >> k;
    sort(arr, arr + 3);
    cout << arr[2] * (2 << (k - 1)) + arr[1] + arr[0];
    return 0;
}


Measured memory_bytes: 256
N=int(input())

L=["R"]
for c in input():
    L.append(c)
L.append("W")



ans=0
left=0
right=len(L)-1

while left<right:
    while L[left]=="R":
        left+=1
    while L[right]=="W":
        right-=1

    if left<right:
        L[left],L[right] = L[right],L[left]
        ans+=1

print(ans)


Measured memory_bytes: 87880
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int rank { get; set; }
    public char suit { get; set; }
}
public class hello
{
    public static void Main()
    {
        var c = "23456789TJQKA";
        var d = new Dictionary<char, int>();
        for (int i = 0; i < 13; i++) d[c[i]] = i + 2;
        while (true)
        {
            var t = Console.ReadLine().Trim();
            if (t == "#") break;
            var t0 = t[0];
            var ps = new P[4, 13];
            for (int i = 0; i < 4; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < 13; j++)
                {
                    var r = line[j][0];
                    var r2 = line[j][1] == t0 ? d[r] + 100 : d[r];
                    ps[i, j] = new P { rank = r2, suit = line[j][1] };
                }
            }
            getAns(ps, t0);
        }
    }
    static void getAns(P[,] ps, char t0)
    {
        var win02 = 0; var win13 = 0;
        var d = 0;
        for (int i = 0; i < 13; i++)
        {
            var win = getWintTeam(ps, d, i, t0);
            d = win;
            if (d == 0 | d == 2) win02++;
            else win13++;
        }
        if (win02 > win13) Console.WriteLine("NS {0}", win02 - 6);
        else Console.WriteLine("EW {0}", win13 - 6);
    }
    static int getWintTeam(P[,] ps, int d, int p, char t0)
    {
        var ts = ps[d, p].suit;
        var card = new int[4];
        for (int i = 0; i < 4; i++)
        {
            var w = ps[i, p];
            if (w.suit == ts) card[i] = w.rank;
            else if (w.rank > 100) card[i] = w.rank;
        }
        var max = card.Max();
        for (int i = 0; i < 4; i++)
            if (card[i] == max) return i;
        return 0;
    }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    set<ll> s;
    rep(i,n){
        ll a; cin>>a;
        if (s.count(a)){
            cout<<"NO\n";
            return 0;
        }
        s.ins(a);
    }
    cout<<"YES\n";
    return 0;
}


Measured memory_bytes: 9600
/*
 * 日本では、3 月 3 日にひなあられという、色のついたお菓子をお供えする習慣があります。
 * 
 * 1 つの袋があり、ひなあられが N 個入っています。
 * 
 * この袋には、桃色、白色、緑色の 3 種類か、桃色、白色、緑色、黄色の 4 種類のひなあられが入っていることが分かっています。
 * 
 * 桃色を P、白色を W、緑色を G、黄色を Y と表したとき、袋からひなあられを 1 粒ずつ取り出していったところ、i 番目に取り出したひなあられの色は Si でした。
 * 
 * この袋に 3 種類のひなあられが入っていた場合は Three、4 種類のひなあられが入っていた場合は Four と出力してください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            int n = Integer.parseInt(sc.next());
            for(int i=0; i<n; i++){
            	// 文字列の入力
                String a = sc.next();
                if(a.equals("Y")){
                	// 出力
                    System.out.println("Four");
                    return;
                }
            }
            // 出力
            System.out.println("Three");
            
            sc.close();
        }
    }


Measured memory_bytes: 21716
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let A = N.to_string().chars().map(|c| c.to_digit(10).unwrap() as i64).collect::<Vec<_>>();

    let ans = std::cmp::max(A.iter().map(|&a| a).sum::<i64>(), A[0] - 1 + 9 * (A.len() as i64 - 1));

    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
a = input().split()
a = [int(i) for i in a]
single = 0
double = 0
triple = 0
for i in a:
    if i %2 ==1:
        single +=1
    elif i %4 != 0:
        double +=1
    else:
        triple +=1
if N//2 <= (double* 0.5 + triple):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main(){
  int n,a,b; cin >> n >> a >>b;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int tmp = i;
    int bitsum = 0;
    while(tmp > 0){
      bitsum += tmp % 10;
      tmp /=10;
    }
    if(bitsum >= a and bitsum <= b)
      ans += i;
  }
  cout << ans;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int dist_a = Math.abs(x-a);
		int dist_b = Math.abs(x-b);
		if(dist_a > dist_b)System.out.println("B");
		else System.out.println("A");

	}
}


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

int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  
  int cnt = 0;
  int i, j;
  for (i=0; i<=a; i++) {
    for (j=0; j<=b; j++) {
      int y = x;
      y -= 500 * i;
      y -= 100 * j;
      if (y >= 0 && y <= 50 * c) cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

const int N = (int)1e5 + 7;

int dp[N];
int n, k;
int a[102];

main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= k; i++) {
		if (i < a[1]) continue;
		int ok = 0;
		for (int j = 1; j <= n; j++) {
			if (i - a[j] < 0) break;
			ok |= (dp[i - a[j]] ^ 1);
		}
		dp[i] = ok;
	}
	cout << (dp[k] ? "First" : "Second");
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 2000000;
int main(void){
    int R[MAX], n;
    
    cin >> n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}



Measured memory_bytes: 3900
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair
#define pb                  push_back

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

void solve(string &s){
    stack<double> st;
    char buf[120], *p, *ctx;
    strcpy(buf, s.c_str());

    p = strtok_r(buf, " ", &ctx);
    while(p){
        if(isdigit((unsigned char)p[strlen(p)-1])){
            st.push(atof(p));
        } else {
            double p2 = st.top(); st.pop();
            double p1 = st.top(); st.pop();
            switch(p[0]){
            case '+': st.push(p1+p2); break;
            case '-': st.push(p1-p2); break;
            case '*': st.push(p1*p2); break;
            case '/': st.push(p1/p2); break;
            }
        }
        p = strtok_r(NULL, " ", &ctx);
    }
    if(st.size() != 1) return;

    double ans = st.top();
    printf("%.9f\n", ans);
}

int main(){
    string s;
    while(getline(cin,s)){
        solve(s);
    }
    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define LL long long
#define M 100005
using namespace std;
const int P=1e9+7;
int mu[M],prime[M],cnt=0;
bool mark[M];
void Init(){
	mu[1]=1;
	for(int i=2;i<=100000;i++){
		if(!mark[i])prime[cnt++]=i,mu[i]=-1;
		for(int j=0;j<cnt&&prime[j]*i<=100000;j++){
			mark[prime[j]*i]=1;
			if(i%prime[j]==0){
				mu[i*prime[j]]=0;break;
			}else mu[i*prime[j]]=-mu[i];
		}
	}
}
int fast(int x,int n){
	LL res=1,a=x;
	while(n>0){
		if(n&1)res=res*a%P;
		a=a*a%P;
		n>>=1;
	}
	return res;
}
int main(){
	int n,k;
	Init();
	cin>>n>>k;
	LL ans=0;
	for(int i=1;i<=k;i++){
		LL t=0;
		for(int j=1;j*i<=k;j++){
			t+=mu[j]*fast(k/(i*j),n);
		}
		t%=P;
		if(t<0)t+=P;
		//printf("i=%d %lld\n",i,t);
		ans=(ans+t*i%P)%P;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
    string s;
    rep(i,4) {
        char c;
        cin >> c;
        s += c;
    }
    sort(all(s));
    cout << ((s=="1479") ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;


int main() {

	int N, Y;
	cin >> N >> Y;

	int A, B;
	int X = 0;
	int a = -1;
	int b = -1;
	int c = -1;

	for (int i = 0; i <= N; i++) {

		

		for (int k = 0; k <= N - i; k++) {
			if (((i * 10000) + (k * 5000) + ((N - i - k) * 1000)) == Y) {
				a = i;
				b = k;
				c = N - i - k;
				X++;

				goto sit;
			}
		}
	}
sit:;
	cout << a << " " << b << " " << c << endl;

	return 0;
}


		

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

long long dp[3001][3001][3];
const long long MOD = 998244353;

signed main () {
	int n, s;
	cin >> n >> s;
	vector < int > a(n);
	for (int &x: a)
		cin >> x;
	for (int i = 0; i <= n; ++i)
		dp[i][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= s; ++j) {
			(dp[i + 1][j][1] += dp[i][j][1]) %= MOD;
			(dp[i + 1][j][2] += dp[i][j][1] + dp[i][j][2]) %= MOD;
			if (j == 0) {
				(dp[i + 1][j][1] += dp[i][j][0]) %= MOD;
				(dp[i + 1][j][2] += dp[i][j][0]) %= MOD;
			}
			if (j + a[i] <= s) {
				(dp[i + 1][j + a[i]][1] += dp[i][j][1]) %= MOD;
				(dp[i + 1][j + a[i]][2] += dp[i][j][1]) %= MOD;
				if (j == 0) {
					(dp[i + 1][j + a[i]][1] += dp[i][j][0]) %= MOD;
					(dp[i + 1][j + a[i]][2] += dp[i][j][0]) %= MOD;
				}
			}
		}
	}
	cout << dp[n][s][2];
}


Measured memory_bytes: 211328
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K, S;
  cin>>N>>K>>S;
  if(S==(int)1e9) {
    for(int i=0;i<K;++i) cout<<S<<" ";
    for(int i=K;i<N;++i) cout<<1<<" ";
    cout<<endl;
  }
  else {
    for(int i=0;i<K;++i) cout<<S<<" ";
    for(int i=K;i<N;++i) cout<<(int)1e9<<" ";
    cout<<endl;
  }
}



Measured memory_bytes: 3560
#include <iostream>

#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>

using namespace std;
//const char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
// input - given string
// You need to update in the given string itself i.e. in input. No need to return or print.


int solver() {
    // Write your code here
    int n;
    cin>>n;

    int l;
    cin>>l;
    //vector<int> my;
    int freq[10];
    for(int i=0;i<=9;i++)
    {
        freq[i]=0;
    }
    for(int i=0;i<l;i++)
    {
        int x;
        cin>>x;
      //  my[i]=x;
        freq[x]=1;
    }
    //cout<<my[0];
    for(int j=n;j<100000;j++)
    {
        int num=j;
        bool k=true;
        while(num>0)
        {
            int m=num%10;
            if(freq[m]==1)
            {
                k=false;
                break;
            }
            num=num/10;
        }
        if(k)
        {
            return j;
        }


    }
    return 0;























}


int main() {
    int n=1;
    //cin>>n;
    while(n--)
    {
        cout<<solver();
    }
}


Measured memory_bytes: 3124
from collections import Counter
MOD = 10**9 + 7
N = int(input())
P = []
for M in range(2,N+1):
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    P += Q

C = Counter(P)
ans = 1
for e in C:
    ans *= C[e]+1
    ans %= MOD
print(ans)


Measured memory_bytes: 39664
a,b = map(int,input().split(" "))
ar = list(input())
if ar[b-1] == "A":
    ar[b-1] = 'a'
elif ar[b-1] == "B":
    ar[b-1] = 'b'
elif ar[b-1] == "C":
    ar[b-1] = 'c'
print("".join(ar))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    ll a; string s; cin >> a >> s;
    ll b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
    ll ans = a*b/100;
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
  int n,m,i,j,k,l,o;

  for(;;){
    scanf("%d", &n);
    if(n==0) break;
    char cvs[n][2];

    for(i=0;i<n;i++){
      for(j=0;j<2;j++){
	scanf("%s", &cvs[i][j]);
      }
    }

    scanf("%d", &m);
    char data[m];

    for(k=0;k<m;k++){
      scanf("%s", &data[k]);
      for(l=0;l<n;l++){
	if(data[k]==cvs[l][0]){
	  data[k]=cvs[l][1]; break;
	}
      }
    }

    printf("%s\n", data);
  }

  return 0;
}


Measured memory_bytes: 688
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> ac(N), wa(N);
  for (int i = 0; i < M; ++i)
  {
    int p;
    string S;
    cin >> p >> S;
    if (S == "AC")
      ac[p - 1] = 1;
    else if (0 == ac[p - 1])
      ++wa[p - 1];
  }
  cout << accumulate(ac.begin(), ac.end(), 0);
  cout << " ";
  cout << inner_product(ac.begin(), ac.end(), wa.begin(), 0);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    if(x <= k/2)
      ans += 2 * x;
    else
      ans += 2 * (k-x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  set<char> A = {'A', 'T', 'G', 'C'};
  cin >> s;
  int n = s.size(), ret = 0;
  for (int i = 0, j; i < n; i = j) {
    for (; i < n && !A.count(s[i]); ++i);
    if (i == n) break;
    for (j = i + 1; j < n && A.count(s[j]); ++j);
    ret = max(ret, j - i);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,count=0,judge;
    int a[10000];
    int j;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    
    for(int i=0;i<n;i++){
        judge=a[i];
        if(judge==2){
            count++;
        }
        else if(judge%2!=0){
            for(j=3;judge%j!=0;j+=2){
                if(j*j>=judge){
                    count++;
                    break;
                }
            }
            if(j>=judge){
                count++;
            }
        }
    }
    
    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>

using namespace std;

constexpr int64_t MOD = 1'000'000'007;

int64_t f(int64_t n, int64_t m) {
    int64_t res = 0;
    for(int d=1; d<m; d++) {
        res += d * (m-d);
        res %= MOD;
    }
    res *= n*n % MOD;
    return res % MOD;
}

int64_t modinv(int64_t a) {
    int64_t b = MOD, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int main(void) {
    int64_t N, M, K;
    cin >> N >> M >> K;

    int64_t ans = f(N, M) + f(M, N);
    for(int64_t i=1; i<=K-2; i++) {
        ans *= (N*M-1-i);
        ans %= MOD;
        ans *= modinv(i);
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


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

int n;
int a[8][8];
bool emptyrow[8], emptycol[8], emptyrightup[15], emptyleftup[15];

bool solve(){
        for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                        if(emptyrow[i]) continue;
                        if(emptycol[j]) continue;
                        if(emptyrightup[i+j]) continue;
                        if(emptyleftup[i-j+7]) continue;
                        a[i][j] = 1;
                        emptyrow[i] = true;
                        emptycol[j] = true;
                        emptyrightup[i+j] = true;
                        emptyleftup[i-j+7] = true;
                        if(solve()) return true;
                        a[i][j] = 0;
                        emptyrow[i] = false;
                        emptycol[j] = false;
                        emptyrightup[i+j] = false;
                        emptyleftup[i-j+7] = false;
                }
        }
        int sum=0;
        for(int i=0;i<8;i++)
                for(int j=0;j<8;j++)
                        sum+=a[i][j];
        return sum==8;

}

int main(){
        int r,c;
        cin>>n;
        for(int i=0;i<8;i++){
                for(int j=0;j<8;j++)
                        a[i][j] = 0;
        }
        for(int i=0;i<8;i++) emptyrow[i] = false;
        for(int i=0;i<8;i++) emptycol[i] = false;
        for(int i=0;i<15;i++) emptyrightup[i] = false;
        for(int i=0;i<15;i++) emptyleftup[i] = false;
        for(int i=0;i<n;i++){
                cin>>r>>c;
                a[r][c] = 1;
                emptyrow[r] = true;
                emptycol[c] = true;
                emptyrightup[r+c] = true;
                emptyleftup[r-c+7] = true;
        }

        solve();

        for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                        if(a[i][j]) cout<<"Q";
                        else cout<<".";
                }
                cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,K;
bool table[105];

int main(){

	scanf("%d %d",&N,&K);

	for(int i = 1; i <= N; i++){

		table[i] = false;
	}

	int tmp,id;

	for(int i = 0; i < K; i++){
		scanf("%d",&tmp);
		for(int k = 0; k < tmp; k++){
			scanf("%d",&id);
			table[id] = true;
		}
	}

	int ans = 0;

	for(int i = 1;i <= N; i++){
		if(!table[i]){

			ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3792
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
break;
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
System.out.printf("#");
}else{
System.out.printf(".");
}
}
System.out.printf("\n");
}
System.out.printf("\n");
}}}


Measured memory_bytes: 62956
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


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

    auto dp = make_vec<ll>(N+1, 5, 5, 5);
    dp[0][0][0][0]=1;
    ll ans=0;
    REP(i,N){
        REP(j,5){
            REP(k,5){
                REP(l,5){
                    REP2(m,1,5){
                        if(k==1&&l==2&&m==3) continue;
                        if(k==1&&l==3&&m==2) continue;
                        if(k==2&&l==1&&m==3) continue;
                        if(j==1&&l==2&&m==3) continue;
                        if(j==1&&k==2&&m==3) continue;
                        dp[i+1][k][l][m]+=dp[i][j][k][l];
                        dp[i+1][k][l][m]%=MOD;
                    }
                }
            }
        }
        
    }

    REP2(j,1,5){
        REP2(k,1,5){
            REP2(l,1,5){
                ans+=dp[N][j][k][l];
                ans%=MOD;
            }
        }
    }

    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 384
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
all_comb = 0
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(int(all_comb-tmp+1))


Measured memory_bytes: 25896
s = input()
if len(s)%2 == 1:
    s_0 = s[0:(len(s)//2)+1]
    m = s[::-1]
    s_1 = m[0:(len(s)//2)+1]
    
else:
    s_0 = s[0:(len(s)//2)]
    m = s[::-1]
    s_1 = m[0:(len(s)//2)]

ans = 0

for i in range(len(s_1)):
    if s_1[i] != s_0[i]:
        ans += 1
print(ans)

Measured memory_bytes: 9040
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

result = ""
def move(r, u, l, d):
    return r * abs(dx) + u * abs(dy) + l * abs(dx) + d * abs(dy) + d + r * (abs(dx)+1) + u * (abs(dy)+1) + l + u + l * (abs(dx)+1) + d *(abs(dy)+1) + r

def horizen_move(r, u, l, d):
    return r * abs(dx+dy) + u + l * abs(dx+dy) + d * 2 + r * abs(dx+dy) + u + r + u * 2 + l * (abs(dx+dy) + 2) + d*2 + r

if dx > 0:
    if dy > 0:
        result = move("R", "U", "L", "D")
        
    elif dy < 0:
        result = move("R", "D", "L", "U")
    elif dy == 0:
        result = horizen_move("R", "U", "L", "D")
        
elif dx < 0:
    if dy > 0:
        result = move("L", "U", "R", "D")
    elif dy < 0:
        result = move("L", "D", "R", "U")
    elif dy == 0:
        result = horizen_move("L", "U", "R", "D")

else:
    if dy > 0:
        result = horizen_move("U", "R", "D", "L")
    elif dy < 0:
        result = horizen_move("D", "R", "U", "L")
        
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

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

    vector<int> t(N);
    vector<p> xy(N);

    rep(i, 0, N)
    {
        t[i] = i;
    }

    rep(i, 0, N)
    {
        int x, y;
        cin >> x >> y;
        xy[i] = p(x, y);
    }

    double d = 0;
    int count = 0;
    do
    {
        int size = static_cast<int>(t.size());
        rep(k, 1, size)
        {
            int i = t[k - 1];
            int j = t[k];
            int x0 = xy[i].first;
            int y0 = xy[i].second;
            int x1 = xy[j].first;
            int y1 = xy[j].second;

            d += sqrt(pow(static_cast<double>(x0 - x1), 2) + pow(static_cast<double>(y0 - y1), 2));
        }
        ++count;

    } while (next_permutation(t.begin(), t.end()));

    d /= static_cast<double>(count);

    // 表示桁数指定
    cout << std::fixed << std::setprecision(10) << d << endl;

    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int k, a, b;

int main () {

    cin >> k >> a >> b;

    for (int i = a ; i <= b ; ++ i) {
        if (i % k == 0) return !printf("OK");
    }

    printf("NG");
}
/*
    Good Luck
        -Lucina
*/
/*
    I hate Progmeth
*/


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

using namespace std;

typedef long long  ll;

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

    const int lim = 3600;
    int a, b, c, t = 0;
    bool flag = false;

    cin >> a >> b >> c;
    while (t * (a + b) <= lim) {
        int l = (t * (a + b)) % 60;
        int r = (t * (a + b) + a) % 60;

        if (l <= r) {
            if (l <= c && c <= r) {
                t = (c - l) + t * (a + b);
                flag = true;
                break;
            }
        }
        else {
            if ((t * (a + b) % 60) <= c || c <= (t * (a + b) + a) % 60) {
                t = (c - l) + t * (a + b);
                flag = true;
                break;
            }
        }
        ++t;
    }

    if (flag)
        cout << t << endl;
    else
        cout << "-1\n";

    return 0;
}

Measured memory_bytes: 1192
// "bits/stdc++.h" {{{
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <limits>
#include <typeinfo>
#include <initializer_list>
#include <bitset>
#include <chrono>
#include <functional>
#include <tuple>
#include <typeindex>
#include <utility>
#include <string>
#include <regex>
// }}}

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

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

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

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

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  string s;
  i64 k;
  IN(s, k);

  i64 len = min((i64)s.length(), k);
  for (int i = 0; i < len; ++i) {
    if (s[i] >= '2') {
      OUTL(s[i]); return 0;
    }
  }

  OUTL(1);
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict

INF = 10 ** 18

N, *A = map(int, read().split())
dp_not = defaultdict(lambda: -INF)
dp_take = defaultdict(lambda: -INF)
dp_not[(0, 0)] = 0

for i, x in enumerate(A, 1):
    j = (i - 1) // 2
    for n in (j, j + 1):
        dp_not[(i, n)] = max(dp_not[(i - 1, n)], dp_take[(i - 1, n)])
        dp_take[(i, n)] = dp_not[(i - 1, n - 1)] + x

print(max(dp_not[(N, N // 2)], dp_take[(N, N // 2)]))


Measured memory_bytes: 192656
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,q;
int lp[200004],dfn[200004];
vector<int>G[200004];
int cnt,a[200004],b[200004];
ll v[200004];
struct tree{
    ll tag,w;
}tr[800004];

void dfs(int x){
    dfn[x]=++cnt;
    for(int i=0;i<G[x].size();i++){
        if(!dfn[G[x][i]]){
            v[G[x][i]]+=v[x];
            dfs(G[x][i]);
        }
    }

}
int main(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    cnt=0;
    while(q--){
        int p,x;
        scanf("%d%d",&p,&x);
        v[p]+=x;
    }
    dfs(1);
    for(int i=1;i<=n;i++)printf("%lld ",v[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 26880