akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>

int main()
{
  std::set<char> al;
  std::string s;
  std::cin >> s;
  for ( char c : s ) {
    al.insert(c);
  }
  bool full = true;
  std::string alphabets = "abcdefghijklmnopqrstuvwxyz" ;
  for (char c : alphabets) {
    auto re = al.find(c);
    if (re == al.end()) {
      std::cout << c << std::endl;
      full = false;
      break;
    }
  }
  if ( full ) {
    std::cout << "None" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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...));
}
int main() {
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
8 3
7 3 1 8 4 6 2 5
)");
#define cin input
#endif

int main()
{
	int n, k;
	cin >> n >> k;
	int a = 0;

	a = n-k;

	if (a%(k-1)==0)
		cout << a/(k-1)+1 << endl;
	else
		cout << a/(k-1)+2 << endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x - a) < abs(x - b) ? 'A' : 'B') << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int b = sc.nextInt();

            b -= m;

            if ( b > 0 ) {
                if ( b <= f ) {
                    System.out.println(b);
                } else {
                    System.out.println("NA");
                }
            } else {
                System.out.println(0);
            }
        }
    }
}



Measured memory_bytes: 26120
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

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


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>

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

using namespace std;


int main(){
    int N;
    
    cin>>N;
    queue<int> q;
    vector<int> vec;
    int d[N+1];
    rep(i,N+1)d[i]=0;
    
    vec.push_back(1);
    for(int i=1;i<=6;++i){
        vec.push_back(pow(6,i));
    }
    for(int i=1;i<=5;++i){
        vec.push_back(pow(9,i));
    }
    

    /*
    for(int i=0;i!=vec.size();++i){
        cout<<vec[i]<<" ";
    }
    cout<<endl;
     */
    
    int count=0;
    
    ++count;
    for(int i=0;i<vec.size();++i){
        int a=vec[i];
        if(a<=N){
           d[a]=count;
        }

        q.push(a);
    }
    
    
    
    while(!q.empty()){
        int b=q.front();
        //cout<<"b:"<<b<<endl;
        q.pop();
        //cout<<"count:"<<count<<endl;
        for(int j=0;j<vec.size();++j){
            int c=b+vec[j];
            if(c<=N){
                if(d[c]!=0)continue;
                d[c]=d[b]+1;
                q.push(c);
            }
        }
    }
    
    
    cout<<d[N]<<endl;
    
}


Measured memory_bytes: 4396
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int cardCount = int.Parse(Reader.ReadLine());
        int[] cards = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).OrderBy(a => a).ToArray();
        Dictionary<int, int> dic = new Dictionary<int,int>();
       
        for (int i = 1; i < cards.Length; i++)
        {
            if (cards[i - 1] == cards[i])
            {
                if(!dic.ContainsKey(cards[i])) {
                    dic.Add(cards[i], 1);
                } else {
                   dic[cards[i]]++;
                }
            }
        }

        int ans = cards.Length;
        if (dic.Count > 0)
        {
            while (dic.Count > 1)
            {
                int key = dic.Keys.First();
                int nex = dic.Keys.Skip(1).First();
                if (key == nex)
                {
                    break;
                }
                if (dic[key] > dic[nex])
                {
                    ans -= dic[nex]*2;
                    dic[key] -= dic[nex];
                    dic[nex] = 0;
                }
                else
                {
                    ans -= dic[key]*2;
                    dic[nex] -= dic[key];
                    dic[key] = 0;
                }
                if (dic[key] == 0)
                {
                    dic.Remove(key);
                }
                if (dic[nex] == 0)
                {
                    dic.Remove(nex);
                }
            }
            int nokori = dic.Select(a=>a.Value).Sum();
            while (nokori >= 2)
            {
                ans -= 2;
                nokori -= 2;
            }
            ans -= nokori * 2;
        }
        Console.WriteLine(ans);


    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 17880
#include <iostream>
#include <queue>
#include <cstring>
#include <climits>
#include <cstdio>

using namespace std;

#define pii pair<int, int>

enum {U, R, D, L};

int main() {
  int w, h;
  while (cin >> w >> h && w + h) {
    int wall[w][h][4];
    
    memset(wall, 0, sizeof(wall));
 
    for (int i = 0; i < w; i++) {
      wall[i][0][U] = 1;
      wall[i][h-1][D] = 1;
    }
    for (int i = 0; i < h; i++) {
      wall[0][i][L] = 1;
      wall[w-1][i][R] = 1;
    }

    for (int i = 0; i < 2*h-1; i++) {
      int wf;
      if (i%2 == 0) {
        for (int j = 0; j < w - 1; j++) {
          cin >> wf;
          if (wf) wall[j][i/2][R] = wall[j+1][i/2][L] = 1;
        }
      } else {
        for (int j = 0; j < w; j++) {
          cin >> wf;
          if (wf) wall[j][i/2][D] = wall[j][i/2+1][U] = 1;
        }
      }
    }
    
    queue<pii > Q;
    Q.push(pii(0, 0));

    int mpath[w][h];
    memset(mpath, 0, sizeof(mpath));
    mpath[0][0] = 1;
    
    while (!Q.empty()) {

      pii now = Q.front();
      int x = now.first, y = now.second;
    
      Q.pop();
      
      const int dx[4] = {0, 1, 0, -1};
      const int dy[4] = {-1, 0, 1, 0};
      
      for (int i = 0; i < 4; i++) {
        if (!wall[x][y][i] && !mpath[x+dx[i]][y+dy[i]]) {
          Q.push(pii(x+dx[i], y+dy[i]));
          mpath[x+dx[i]][y+dy[i]] = mpath[x][y] + 1;
        }
      }
    }

    cout << mpath[w-1][h-1]  << endl;
  }
}

Measured memory_bytes: 0
n = int(input())
from collections import defaultdict
dic = defaultdict(int)

for _ in range(n):
    s = input()
    dic[s] += 1

k = max(dic.values())

ansl = []
for s in dic:
    if dic[s] == k:
        ansl.append(s)

ansl = sorted(ansl)

for s in ansl:
    print(s)


Measured memory_bytes: 35292
from math import floor
from math import sqrt

def f(bb,nn):
    if(nn<bb): return nn
    else: return f(bb,floor(nn/bb))+(nn%bb)
        

n=int(input())
s=int(input())

if n==s:
    print(n+1)
    exit()
elif n<s:
    print(-1)
    exit()

for i in range(2,int(sqrt(n))+2):
    if s==f(i,n):
        print(i)
        exit()

for i in reversed(range(1,int(sqrt(n))+2)):
    if (n-s)%i == 0:
        tmpb=(n-s)//i+1
        if tmpb >= sqrt(n) and f(tmpb,n)==s: 
            print(tmpb)
            exit()
print(-1)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	int n, i, j, k;
	cin >> s >> k;
	
	for (i = 0; (i < s.length()) && (s[i] == '1'); i++);
	if (k <= i) cout << "1\n";
	else cout << s[i] << "\n";

	return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n, k; cin>>n>>k;
	vl a(n); forn(i, n) cin>>a[i];
	sort(all(a));
	ll sum = 0;
	forn(i, k) sum += a[i];
	cout<<sum<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3652
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		char[] a = {'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'};
		for(int i=0; i<a.length; i++){
			if(c == a[i]){
				System.out.println(a[i+1]);
				break;
			}
		}
		
	}
}


Measured memory_bytes: 35588
#include <string>
#include <iostream>

#define MOD 1000000007

#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 ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << #x << ": " << x << endl

// grid-repainting-2.cpp --- Grid Repainting 2
// author: Seong Yong-ju <sei40kr@gmail.com>

using namespace std;

int h, w;
bool data[51][51];

bool check() {
  REP(i, h) {
    REP(j, w) {
      if (data[i][j] && (i == 0 || !data[i - 1][j]) && !data[i+1][j] && (j == 0 || !data[i][j - 1]) && !data[i][j+1]) {
        return false;
      }
    }
  }

  return true;
}

int main() {
  std::ios::sync_with_stdio(false);

  fill((bool *)&data[0], (bool *)&data[49], false);

  cin >> h >> w;
  REP(i, h) {
    string s;
    cin >> s;

    REP(j, w) {
      data[i][j] = s[j] == '#';
    }
  }

  cout << (check() ? "Yes" : "No") << endl;

  return 0;
}


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

struct Data{
  
  int team_num;
  int c_num;
  int p_time;
  int w_num[11];
  
  bool operator<(const Data& data)const{
    if(data.c_num != c_num)return c_num > data.c_num;
    if(data.p_time != p_time)return p_time < data.p_time;
    return team_num < data.team_num;
  }
  
};
void Init(Data *list,int T,int P){
  
  for(int i=1 ; i <= T ; i++){
    list[i].team_num = i;
    list[i].c_num = 0;
    list[i].p_time = 0;
    for(int j=1 ; j <= P ; j++){
      list[i].w_num[j] = 0;
    }
  }
  
}
void Correct(Data *list,int tID,int pID,int time){
  
  list[tID].c_num++;
  list[tID].p_time+=(1200*list[tID].w_num[pID])+time;
  
}
void Wrong(Data *list,int tID,int pID){
  
  list[tID].w_num[pID]++;
  
}
int main(){
  
  int T,P,R;
  int tID,pID,time;
  string message;
  
  while(1){
    
    cin >>T>>P>>R;
    if(T==0 && P==0 && R==0)break;
    
    Data list[T+1];
    
    Init(list,T,P);
    
    for(int i=0 ; i < R ; i++){
      cin >>tID>>pID>>time>>message;
      if(message == "CORRECT"){
	Correct(list,tID,pID,time);
      }else{
	Wrong(list,tID,pID);
      }  
    }
    
    sort(list+1,list+T+1);
    
    for(int i=1 ; i <= T ; i++){
      cout <<list[i].team_num<<" "<<list[i].c_num<<" "<<list[i].p_time<<endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,X,Y;
  cin >> N >> A >> B;
  X = N * A;
  Y = B;
  if (X < Y) {
    cout << X << endl;
  }
  if (X > Y) {
    cout << Y << endl;
  }
  else if (X == Y) {
    cout << X << endl;
  }
}

Measured memory_bytes: 256
def main():

   A,B = map(int,input().split())

   if B ==1:
      print(0)
      exit()
   
   if A >= B:
      print(1)
      exit()
   
   increase = A -1
   count = A
   ans = 1

   while(count < B):
      count += increase
      ans += 1

   print(ans)
      

if __name__== "__main__":
    main() 






Measured memory_bytes: 3060
#include <iostream>

int main(void){
    int A, B, ans=-1;
    std::cin >> A >> B;

    for (int i=0; i<10001; ++i){
        if (i * 8 / 100 == A && i / 10 == B){
            ans = i;
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var rgbn = Input.ar;var k = 0;
        for(var i=0;i<=rgbn[3];i++)
            for(var j=0;j<=rgbn[3];j++)
            {
                var p = rgbn[3] - i * rgbn[0] - j * rgbn[1];
                if (p >= 0&&p%rgbn[2]==0) k++;
            }WriteLine(k);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N;
    cin >> N;
    Vec<i32> v(N);
    iota(ALL(v), 1);
    Vec<i32> P(N);
    Vec<i32> Q(N);
    for (u32 i = 0; i < N; i++) cin >> P[i];
    for (u32 i = 0; i < N; i++) cin >> Q[i];
    i32 pv, qv;
    i32 a = 1;
    do {
        bool p = true, q = true;
        for (u32 i = 0; i < N; i++) {
            if (P[i] != v[i]) {
                p = false;
                break;
            }
        }
        for (u32 i = 0; i < N; i++) {
            if (Q[i] != v[i]) {
                q = false;
                break;
            }
        }
        if (p) pv = a;
        if (q) qv = a;
        a++;
    } while (next_permutation(ALL(v)));
    cout << (i32)abs(pv - qv) << endl;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int MOD = 1e9 + 7;
ll dp[100005][4];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		char c = s[i-1];
		for (int j = 0; j <= 3; j++)
			dp[i][j] = dp[i-1][j] * (c == '?'? 3 : 1);

		if (c == 'A' || c == '?') dp[i][1] += dp[i-1][0];
		if (c == 'B' || c == '?') dp[i][2] += dp[i-1][1];
		if (c == 'C' || c == '?') dp[i][3] += dp[i-1][2];

		for (int j = 0; j <= 3; j++) dp[i][j] %= MOD;
	}
	printf("%lld\n", dp[n][3]);
}


Measured memory_bytes: 3584
#include <iostream>

std::string solve(long n, long a) {
  if(n % 500 <= a){
    return "Yes";
  } else {
    return "No";
  }
}

int main() {
  long n, a;
  std::cin >> n;
  std::cin >> a;

  std::cout << solve(n, a) << "\n";
}


Measured memory_bytes: 764
import sys
from heapq import *
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    
    tree = [[] for _ in range(n)]
    for i in range(m):
        s, t, c = map(int, input().split())
        tree[t-1].append((s-1, c))
        tree[s-1].append((t-1, c))
    
    for i in range(n-1):
        tree[i+1].append((i, 0))
    
    ans = [-1]*n
    already = [False]*n
    not_yet = [(0, 0)]
    
    while not_yet:
        value, key = heappop(not_yet)
        if already[key]:
            continue
        already[key] = True
        ans[key] = value
        
        for k, v in tree[key]:
            if already[k]:
                continue
            heappush(not_yet, (v+value, k))
        
    print(ans[n-1])
    
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 101572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static bool IsOdd(long n)
		{
			bool isOdd = n % 2 == 1;
			return isOdd;
		}

		public static void Exec()
		{
			var n = long.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			var list = array.ToList();

			var oddList = list.Where(x => IsOdd(x)).ToList();
			var noOddList = list.Where(x => IsOdd(x) == false).ToList();

			bool isOK = false;
			if (oddList.Count == 0)
			{
				isOK = true;
			} else if (oddList.Count - 1 <= noOddList.Count)
			{
				var list4 = noOddList.Where(x => x % 4 == 0).ToList();
				if (noOddList.Count - list4.Count == 0 && oddList.Count <= list4.Count + 1)
				{
					isOK = true;
				} else if (oddList.Count <= list4.Count)
				{
					isOK = true;
				}
			}

			if (isOK) {
				Console.WriteLine($"Yes");
			} else {
				Console.WriteLine($"No");
			}

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 25824
#include <stdio.h>
#define NIL -1
int fibo[49];

int fibfunc(int n){
  if(n==1||n==0){
    fibo[n]=1;
    return 1;
  }
  else {
    if(fibo[n]!=NIL)return fibo[n];
    
    else{
      fibo[n]= fibfunc(n-1)+fibfunc(n-2);
      return fibo[n];
    }
  }
}

int main(){int n;
  int i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)fibo[i]=NIL;
  
  printf("%d\n",fibfunc(n));

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

ll dp[114514][2][102] = {};
ll d, n;
string k;

ll rec(ll i, bool t, ll sum){
	
	if(i == n)return (sum % d == 0);

	ll &tmp = dp[i][t][sum];
	if(~tmp)return tmp;

	
	int keta = k[i] - '0';
	int m = (t ? keta : 9);

	tmp = 0;
	for (int j = 0;j <= m;++j) {
		tmp += rec(i + 1,t && j == m,(sum + j) % d);
		tmp %= MOD;
	}
	return tmp;
}

signed main(){
	IOS();
	cin >> k >> d;
	Fill(dp, -1);
	n = k.size();
	if(n <= 3 && stol(k) < d){
		cout << 0 << endl;
		return 0;
	}
	ll ans = rec(0, true, 0) + MOD - 1;
	ans %= MOD;
	cout << ans << endl;	
}

Measured memory_bytes: 183552
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
c = S()
boin = ['a', 'i', 'u', 'e', 'o']
if c in boin:
    print('vowel')
else:
    print('consonant')

Measured memory_bytes: 74360
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N];
  vector<pair<int, bool>> xy[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    xy[i].resize(A[i]);
    for (int j = 0; j < A[i]; j++) {
      cin >> xy[i][j].first >> xy[i][j].second;
      xy[i][j].first--;
    }
  }
  int ans = 0;
  for (int s = 1; s < (1 << N); s++) {
    bool isok = true;
    for (int i = 0; i < N; i++)
      if ((s >> i) & 1) {
        for (int j = 0; j < A[i]; j++) {
          isok &= !(((s >> xy[i][j].first) & 1) ^ xy[i][j].second);
        }
      }
    if (isok) ans = max(ans, __builtin_popcount(s));
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
  string n;
  cin >> n;
  int ans = 1000;
  for(int i=0; i<=n.size()-3; i++){
    int tmp = stoi(n.substr(i,3));
    ans = min(ans,abs(753-tmp));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N;
	cin >> N;
	int L;
	int longest = -1,sum=0;
	REP(i,N) {
		cin >> L;
		if(L > longest){
			longest = L;
		}
		sum += L;
	}
	sum -= longest;
	println(((longest < sum) ? "Yes":"No" ));
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]
point = [0]*n
for i in range(q):
    point[a[i]-1] += 1
for i in range(n):
    if point[i] > q-k:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 13668
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y,w;
    char hoge,fuga;
    cin>>str>>g>>ko;
    vector<string> sa;
    char ca,cb,cc;
    ca=str[0]-0x20;
    cb=g[0]-0x20;
    cc=ko[0]-0x20;
    a='A'-'a';
    
cout<<ca<<cb<<cc<<endl;    

    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
}p[10];
int a[10];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,m,f=0,h=0;
	cin >> n >> m;
	a[1]=1;
	for(int i=0;i<m;i++){
		cin >> p[i].x >> p[i].y;
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(p[i].x==p[j].x&&p[i].y!=p[j].y) f=1;
		}
		if(p[i].x==1){
			if(n!=1&&p[i].y==0) f=1;
			if(n==1){
				a[0]=0;
			}
		}
		a[p[i].x]=p[i].y;
	}
	if(n==1&&m==0) cout << 0 << endl;
	else if(f==1) cout << -1 << endl;
	else if(f==0){
		for(int i=1;i<=n;i++){
			cout << a[i] ;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[10000];
int A_78(long long n)
{
    while(n!=0)
    {
        if(arr[n%10]==1)
            return 0;
        n=n/10;
    }
    return 1;
}
int main()
{
    long long n,p,i,j,k,l;
    cin>>n>>k;
    for(i=0;i<k;i++)
    {
        cin>>l;
        arr[l]=1;
    }
    for(j=n;j<1000006;j++)
    {
        if(A_78(j))
        {
            cout<<j<<endl;
            break;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int A, B, C, D;
    io.read(A, B, C, D);
    string ans;
    if(A + B < C + D){
        ans = "Right";
    }
    else if(A + B == C + D){
        ans = "Balanced";
    }
    else{
        ans = "Left";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>

signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y;
if(0<=y){
rep(i,x){
  z+=i+y;
}
std::cout << z-y<< '\n';
}else{
  if(x<=abs(y)){
    rep(i,x-1){
      z+=i+y;
    }
    std::cout << z << '\n';
  }else{
    rep(i,x){
      z+=i+y;
    }
    std::cout << z << '\n';
  }
}
return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<long long>> v(2, vector<long long>(n));
    vector<pair<long long, int>> sum(n);
    for (int i = 0; i < n; i++) {
        cin >> v.at(0).at(i) >> v.at(1).at(i);
        sum.at(i) = make_pair(v.at(0).at(i) + v.at(1).at(i), i);
    }

    sort(sum.begin(), sum.end());
    reverse(sum.begin(), sum.end());

    vector<long long> score(2);
    int turn = 0;
    for (int i = 0; i < n; i++) {
        score.at(turn) += v.at(turn).at(sum.at(i).second);
        turn ^= 1;
    }

    cout << score.at(0) - score.at(1) << endl;
}   

Measured memory_bytes: 3440
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    cin >> S;
    string key = "keyence";
    int N = (int)S.size();
    bool is = false;
    if(S == key){ //取り除く文字列が空の時に満たされる
        cout << "YES" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        for(int j = N-i; j >= 1; j--){
            string af = S;
            af.erase(i, j);
            if(af == key) is = true;
        }
    }
    if(is) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for i in range(N):
    AB.append(list(map(int, input().split())))
AB.sort()
ans = 0
i = 0
for A, B in AB:
    if i + B >= M:
        ans += A * (M - i)
        break
    ans += A * B
    i += B
print(ans)

Measured memory_bytes: 60888
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
void hack(ll n)
{
    if(n==124)
    cout<<"hacked";   
}
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
ll mod=998244353;
ll mod1=1e9+6;
#define int ll
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod,b/2);
    else return a*power(a*a%mod,b/2)%mod;
}
ll power1(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod1,b/2);
    else return a*power(a*a%mod1,b/2)%mod1;
}
void show(vector <pair<int,int>> v)
{
    for(int i=0;i<v.size();++i) cout<<v[i].first<<" "<<v[i].second<<" ";
        cout<<endl;
}
#define endl '\n'
bool comp(pair<int,int> p,pair<int,int> p1)
{
    if(p.first!=p1.first)
        return p.first<p1.first;
    else
        return p.second>p1.second;
}

int32_t main()
{
    IOS
 
    int n,m;
    cin>>n>>m;
    int a[n],b[n];
    vector<pair<int,int>>v;
    for(int i=0;i<n;++i)
        {
            cin>>a[i]>>b[i];
            if(a[i]<=m)
            {
                v.push_back({b[i],a[i]});
            }
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        int ans=0;
        bool visited[m+1];
        memset(visited,false,sizeof(visited));
        int count[m+1];
        set<int> s;
        memset(count,0,sizeof(count));
        for(int i=1;i<=m;++i)
            s.insert(i);
        int count1=0;
        for(int i=0;i<v.size();++i)
        {
           // cout<<v[i].first<<" "<<v[i].second<<endl;
            int index=-1;
            auto it=s.lower_bound(m-v[i].second+2);
           // cout<<*it<<endl;
            if(it==s.begin())
                continue;
            else
            {
                it--;
                s.erase(it);
                ans+=v[i].first;
            }
            
        }
        cout<<ans;


}


Measured memory_bytes: 8944
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
x = list(map(int, input().split()))

def fact(n, mod=1000000007):
	ans = 1
	for i in range(n):
		ans *= i + 1
		if mod != 0 and ans >= mod:
			ans = ans % mod
	return ans

num = 0
ans = 1
mod = 10**9 + 7
for i in range(N - 1):
	if x[i] < 2*(i - num) + 1:
		ans *= i - num + 1
		ans %= mod
		num += 1
ans *= fact(N - num)
ans %= mod
print(ans)

Measured memory_bytes: 62704
#include <stdio.h>
#include <string.h>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>

int main(){
  long n,k,q;
  scanf("%ld",&n);
  scanf("%ld",&k);
  scanf("%ld",&q);
  std::vector<long> p(n);
  long tmp = k - q;
  std::fill(p.begin(),p.end(),tmp);
  long int a;
  for(int i=0;i<q;i++){
    scanf("%ld",&a);
    ++p[--a];
  }
  for(int i=0;i<n;i++){
    if(p[i]>0){
      std::cout << "Yes" <<std::endl;
    }else{
      std::cout << "No" <<std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
function Main (X) {
  X = parseInt(X.split("\n")[0], 10);
  var ft = Math.floor(X/500);
  X %= 500;
  var fo = Math.floor(X/5);
  console.log((ft * 1000) + (fo * 5));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
#include <cstring>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<long double> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = 1.0 * (1 + a[i]) * a[i] / (2 * a[i]);
	}
	long double best = 0, cur = 0;
	for (int i = 0; i < k; i++) {
		best += a[i];
	}
	cur = best;
	for (int i = k; i < n; i++) {
		cur -= a[i - k];
		cur += a[i];
		best = max(best, cur);
	}
	cout << fixed << setprecision(10) << best;
}



Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define MAX 100002

bool use[MAX];
int dp[MAX];
inline int dfs(int a) {
	if (a == 0)return 0;
	if (use[a]) {
		return dp[a];
	}
	use[a] = true;
	set<int> s;
	vector<int> v;
	s.insert(0);
	for (int i = a - 1; i >= 0; i--) {
		v.push_back(dfs(i));
		int ar = 0;
		for (int j = 0; j < v.size(); j++) {
			ar ^= v[j];
		}
		s.insert(ar);
	}
	int c = 0;
	while (s.count(c)) {
		c++;
	}
	dp[a] = c;
	return c;
	
}
int n;
long long int l;
char buf[100002];
int go[100012][2];

string s;
int root;

vector<long long int> xr;
void dfs(int b,long long int dep) {
	if (go[b][0] == -1 && go[b][1] == -1) {
		//leave
		return;
	}
	if (go[b][0] == -1) {
		xr.push_back(dep);
	}
	else {
		dfs(go[b][0], dep - 1);
	}
	if (go[b][1] == -1) {
		xr.push_back(dep);
	}
	else{
		dfs(go[b][1], dep - 1);
	}

}
int main() {
	cin >> n ;
	scanf("%lld", &l);
	int sz = 1;
	memset(go, -1, sizeof(go));
	for (int i = 0; i < n; i++) {
		scanf("%s", buf);
		s = buf;
		int cur = root;
		for (int j = 0; j < s.size(); j++) {
			int nex = s[j] - '0';
			if (go[cur][nex] == -1) {
				go[cur][nex] = sz;
				sz++;
			}
			cur = go[cur][nex];
		}
	}
	dfs(root,l);
	long long int X = 0;
	for (int i = 0; i < xr.size(); i++) {
		long long int val = xr[i];
		long long int cnt = 1;
		while (val % 2 == 0LL) {
			cnt <<= 1LL;
			val >>= 1LL;
		}
		X ^= cnt;
	}
	if (X) {
		puts("Alice");
	}
	else {
		puts("Bob");
	}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  bool ans=false;
  if(s.at(0)==s.at(1)){
    if(s.at(2)==s.at(3)){
      if(s.at(0)!=s.at(2)){
        ans=true;
      }
    }
  }
  else if(s.at(1)==s.at(2)){
    if(s.at(0)==s.at(3)){
      if(s.at(1)!=s.at(0)){
        ans=true;
      }
    }
  }
  else if(s.at(2)==s.at(3)){
    if(s.at(0)==s.at(1)){
      if(s.at(2)!=s.at(0)){
        ans=true;
      }
    }
  }
  else if(s.at(0)==s.at(2)){
    if(s.at(1)==s.at(3)){
      if(s.at(0)!=s.at(1)){
        ans=true;
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep2(i,a,n) for(int i = (a);i < (n);i++)
#define rep(i,n) rep2(i,0,n)
#define INF (1LL << 60)
#define vec vector

int main(void){
    int n;ll k;
    cin >> n >> k;
    int a[n];
    vector<int> b(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }

    ll now = 0;
    ll ans = -1;
    vec<int> memo;
    for(ll i = 0;;i++){
        if(k == 0){
            ans = now+1;
            break;
        }
        
        b[now] = 1;
        now = a[now];
        k--;
        
        if(b[now] > 0){
            break;
        }
    }
    
    if(ans == -1){
        ll memo2 = now;
        while( 1 ){
            memo.push_back(now);
            now = a[now];
            if(now == memo2)break;
        }
        ans = memo[k % memo.size()]+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5700
import math
n, k = map(int, input().split())
 
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
for i in range(1, k+1):
    if i <= n - k + 1:
        c = 1
        c *= comb(n-k+1, i)
        c *= comb(k-1, i-1)
        print(c%(10**9+7))
    else:
        print(0)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int a;
	
	cin>>a;
	
	cout<<a+a*a+a*a*a<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> values(N);
    rep(i, 0, N) cin >> values[i];
    sort(values.begin(), values.end());

    int diff = 12;
    rep(s, 0, 2)
    {
        int prev = 0;
        for (int i=s; i<N; i+=2)
        {
            diff = min(diff, values[i]-prev);
            prev = values[i];
        }
    }
    if (N>1)
        diff = min(diff, 24-values[N-1]-values[N-2]);

    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0; i<(n); ++i)

int d[2][100][100];

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    while (cin >> n >> m, n || m) {
        REP(i,2) REP(j,m) REP(k,m) {
            d[i][j][k] = (j == k ? 0 : 1e8);
        }
        int a, b, cost, time;
        REP(i,n) {
            cin >> a >> b >> cost >> time;
            -- a; -- b;
            d[0][a][b] = min(d[0][a][b], cost);
            d[0][b][a] = min(d[0][b][a], cost);
            d[1][a][b] = min(d[1][a][b], time);
            d[1][b][a] = min(d[1][b][a], time);
        }
        REP(k,m) REP(i,m) REP(j,m) {
            d[0][i][j] = min(d[0][i][j], d[0][i][k] + d[0][k][j]);
            d[0][j][i] = min(d[0][j][i], d[0][j][k] + d[0][k][i]);
            d[1][i][j] = min(d[1][i][j], d[1][i][k] + d[1][k][j]);
            d[1][j][i] = min(d[1][j][i], d[1][j][k] + d[1][k][i]);
        }
        int k, p, q, r;
        cin >> k;
        REP(i,k) {
            cin >> p >> q >> r;
            -- p; -- q;
            cout << d[r][p][q] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1272
/*
ex3_3
tomatokan
*/
#include<stdio.h>
 
int main(void){
    int n,k,digits,k_powered;
    scanf("%d",&n);
    scanf("%d",&k);
    digits=1;
    k_powered=k;/*k_powered=k^digits*/
    while(n>=k_powered){/*n>=k_powered ならn>=k^digits*/
        digits++;
        k_powered=k_powered*k;
    }
    printf("%d\n",digits);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        ULL A, B, N; cin >> A >> B >> N;
        if (N < B) cout << (A * N / B) << endl;
        else cout << (A * (B - 1) / B) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3628
n, m, err = gets.to_i, gets.to_i, false

s = m

n.times do
  in_car, out_car = gets.split.map(&:to_i)
  
  m += in_car - out_car
  
  if m < 0
    err = true
  else
    s = [s, m].max
  end
end

puts err ? 0 : s

Measured memory_bytes: 8876
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    string s;
    cin >> s;
    for (auto &x : s)
        if (x == '?')
            x = 'D';
    cout << s << "\n";
}



Measured memory_bytes: 3816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input N
        // 1 以上 N 以下の整数のうち、桁数が奇数の数の個数を求める
        Scanner sc = new Scanner(System.in);
        int maxNum = sc.nextInt();
        int retNum = 0;
        // maxNum が 1 ～ 8 なら retNum は maxNum
        // maxNum が 9 ～ 99 なら retNum は 9
        // maxNum が 100 ～ 998 なら retNum は 10 + (maxNum - 100)
        // maxNum が 999 ～ 9999 なら retNum は 909
        // maxNum が 10000 ～ なら retNum は 910 + (maxNum - 10000)
        if(maxNum < 9){
            retNum = maxNum;
        } else if(maxNum < 100){
            retNum = 9;
        } else if(maxNum < 999){
            retNum = 10 + maxNum - 100;
        } else if(maxNum < 10000){
            retNum = 909;
        } else if(maxNum < 100000){
            retNum = 910 + maxNum - 10000;
        } else {
            retNum = 90909;
        }
        System.out.println(retNum);
    }
}


Measured memory_bytes: 21972