akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string S;
  cin >> S;
  int alpha[26] = {};
  for (int i = 0; i < S.size(); i++) alpha[S[i] - 97]++;
  int same = 0;
  for (int i = 0; i < 26; i++) {
    if (alpha[i] >= 2) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m;
string s;

int main() {
  cin>>n;
  vector<int> vec;
  rep(i,2*n) {
    int t;
    cin>>t;
    vec.PB(t);
  }
  SORT(vec);
  int ans=0;
  rep(i,2*n) {
    if(i%2==0) {
      ans+=vec[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//int X[1000000], LL[1000000];
//void margesort(int a[], int a_len, int left, int right);

int main() {

	//C
	int n, k, s,i;
	cin >> n >> k >> s;
	if (s == 1000000000) {
		for (i = 0; i < k; i++) {
			cout << s;
			cout << ' ';
		}
		for (i = k; i < n; i++) {
			cout << 1;
			cout << ' ';
		}
	}
	else {
		for (i = 0; i < k; i++) {
			cout << s;
			cout << ' ';
		}
		for (i = k; i < n; i++) {
			cout << s + 1;
			cout << ' ';
		}
	}
	cout << endl;
	return 0;
	//B
	/*int n;
	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> X[i] >> LL[i];
		X[i] = X[i] + LL[i];
	}
	margesort(X, n, 0, n - 1);
	int rcounter = 1;
	
	int rightmost = X[0];

	for (i = 1; i < n; i++) {
		if (X[i] - 2 * LL[i] >= rightmost) {
			rightmost = X[i];
			rcounter++;
		}
	}

	cout << rcounter << endl;
	return 0;*/

	//A
	/*
	int h, w, n;
	cin >> h;
	cin >> w;
	cin >> n;

	int max;
	if (h > w) {
		max = h;
	}
	else { max = w; }
	if (n % max == 0) {
		cout << n / max << endl;
	}
	else {
		cout << (n - (n % max)) / max + 1 << endl;
	}
	return 0;*/

}



/*int temp[1000000];
int tempb[1000000];

void margesort(int a[], int a_len, int left, int right)
{
	int i, j, mid, L, R;

	if (right <= left)
		return;

	mid = (left + right) / 2;
	margesort(a, mid, left, mid);
	margesort(a, a_len - mid, mid + 1, right);

	for (i = left; i <= mid; i++){
		temp[i] = a[i];
		tempb[i] = LL[i];
	}
	for (i = mid + 1, j = right; i <= right; i++, j--) {
		temp[i] = a[j];
		tempb[i] = LL[j];
	}

	L = left;
	R = right;

	for (i = left; i <= right; i++)
	{
		if (temp[L] <= temp[R])
		{
			a[i] = temp[L];
			LL[i] = tempb[L];
			L++;
		}
		else
		{
			a[i] = temp[R];
			LL[i] = tempb[R];
			R--;
		}
	}
}*/



Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int V,E,s,t,w;
vector<vector<pair<int,int>>> v(10001);
int visited[10001] = {0};
int ans[10001] = {0},d[10001] = {0};

void di(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i].first]==0){
			d[v[n][i].first] = d[n]+v[n][i].second;
			di(v[n][i].first);
		}
	}
}

/*void dfs(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i].first]==0){
			dfs(v[n][i].first);
			d[n] = max(d[n],d[v[n][i].first]+v[n][i].second);
		}
	}
}
*/
int main(){
	cin >> V;
	for(int i=0;i<V-1;i++){
		cin >> s >> t >> w;
		v[s].push_back({t,w});
		v[t].push_back({s,w});
	}
	di(0);
	int a = 0,b = 0,va = 0,vb = 0;
	for(int i=0;i<V;i++){
		if(va<d[i]){
			a = i;
			va = d[i];
		}
	}
	for(int i=0;i<V;i++){
		visited[i] = 0;
		d[i] = 0;
	}
	di(a);
	for(int i=0;i<V;i++){
		if(vb<d[i]){
			b = i;
			vb = d[i];
		}
	}
	for(int i=0;i<V;i++){
		visited[i] = 0;
		ans[i] = d[i];
		d[i] = 0;
	}
	di(b);
	for(int i=0;i<V;i++){
		ans[i] = max(d[i],ans[i]);
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3816
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    int a[10];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int b=1;
    for(int i=0; i<n; i++){
        b*=3;
    }
    int even=1;
    for(int i=0; i<n; i++){
        if(!(a[i]%2)) even*=2;
    }
    cout << b-even << endl;
    
}

Measured memory_bytes: 256
def resolve():
    S = input()
    T = input()

    dp = [[0] * (len(T) + 1) for _ in range(len(S) + 1)]

    for i in range(len(S)):
        for j in range(len(T)):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])

    ans = ""

    i, j = len(S), len(T)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        else:
            ans = S[i - 1] + ans
            i -= 1
            j -= 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 144900
#include<bits/stdc++.h>
#define long long long
using namespace std;
int a,b,c;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>a>>b>>c;
  if(a+b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=205,mod=998244353;
int n,x[N],y[N],Pow[N];
int main(){
	scanf("%d",&n);
	Pow[0]=1;
	for (int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]),Pow[i]=Pow[i-1]*2%mod;
	int ans=(Pow[n]-n-1+mod)%mod;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			int cnt=0;
			for (int k=j+1;k<=n;k++)
				if ((x[i]-x[k])*(y[j]-y[k])==(x[j]-x[k])*(y[i]-y[k]))
					cnt++;
			ans=(ans-Pow[cnt]+mod)%mod;
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
#S = str(input())
a = list(map(int, input().split()))

ave = 0
for i in range(N) :
  ave += a[i]
ave /= N

index = 0
absX = sys.maxsize
for i in range(N) :
  if absX > abs(ave - a[i]) :
    absX = abs(ave - a[i])
    index = i
    
print (index)


Measured memory_bytes: 3436
using System;

public class Hello
{
    public static void Main()
    {
        Console.ReadLine();
        var s = Console.ReadLine().Trim();
        var s2 = s.Replace(" ", "");
        Console.ReadLine();
        var t = Console.ReadLine().Trim();
        var t2 = t.Replace(" ", "");
        Console.WriteLine(t2.CompareTo(s2) == 1 ? 1 : 0);
    }
}



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

const ll p = 1e9+7;
const int MAXN = 1e5+5;

ll prod = 1;
ll l[MAXN], r[MAXN], n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> l[i];
	for (int i = 1; i <= n; ++i)
		cin >> r[i];
	for (int i = 1; i <= n; ++i) {
		if (l[i] < l[i-1] || r[i] < r[i+1]) {
			cout << "0\n"; return 0;
		} if (l[i] != l[i-1] && r[i] != r[i+1]) {
			if (l[i] != r[i]) {
				cout << "0\n"; return 0;
			} else
				continue;
		} if (l[i] != l[i-1]) {
			if (l[i] > r[i]) {
				cout << "0\n"; return 0;
			} continue;
		} if (r[i] != r[i+1]) {
			if (r[i] > l[i]) {
				cout << "0\n"; return 0;
			} continue;
		}

		prod = prod*min(l[i], r[i])%p;
	}

	cout << prod << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<int> A(N+1);
  long long sum = 0;
  for(int i = 0;i < N+1;i++) {
    cin >> A[i];
    sum += A[i];
  }

  long long ans = -1;
  if(N == 0) {
    if(A[0] == 1) ans = 1;
    cout << ans << endl;
    return 0; 
  }

  if(A[0] != 0) {
    cout << ans << endl;
    return 0;
  }

  ans = 1;
  long long cur = 1;

  for(int i = 1;i < N+1;i++) {
    cur *= 2;
    if(cur < A[i]) {
      cout << -1 << endl;
      return 0;
    }

    ans += min(cur,sum);
    cur = min(cur,sum) - A[i];
    sum -= A[i];
  }


  cout << ans << endl;


  

}


Measured memory_bytes: 3788
<?php
  
  $tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}

$A = $tmp[0];
$B = $tmp[1];
$C = $tmp[2];
$X = (int)$tmp[3];

$count = 0;
for ($i = 0; $i <= $A; $i++)
    for ($p = 0; $p <= $B; $p++)
        for ($q = 0; $q <= $C; $q++) {
            if (500 * $i + 100 * $p + 50 * $q === $X)
                $count++;
        }

echo $count;

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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e5+1,mod=1e9+7;


void solve(){
    ll n,a[N];
    cin>>n;
    ll s=0;
    ll ans=0;
    for(int i=0;i<n;i++)cin>>a[i],s+=a[i];
    for(int i=0;i<n;i++){
        s-=a[i];
        ans=(ans+a[i]%mod*(s%mod))%mod;
    }
    cout<<ans%mod;


}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


Measured memory_bytes: 5176
#include <iostream>
using namespace std;
int main() 
{
    long int n,s=0,q=0,ans=10000000000;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        q=q+a[i];
        ans=min(ans,abs(s-2*q));
    }
    cout<<ans<<endl;
}


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

long minf(long a,long b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}
int main(){
  long n;
  long k;
  long a[100010] = {};
  long plus = 0;
  long minus = 0;
  long zero = 0;
  long min = 10000000007;
  long i = 0;
  scanf("%ld %ld",&n,&k);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  for(i=0;i+k-1<n;i++){
    if(a[i+k-1] >= 0 && a[i] >= 0){
      if(labs(a[i+k-1]) < min){
        min = labs(a[i+k-1]);
        //printf("#");
      }
    }else if(a[i+k-1] <= 0 && a[i] <= 0){
      if(labs(a[i]) < min){
        min = labs(a[i]);
      }
    }else{
      if(-a[i] <= a[i+k-1]){
        if(min > -2*a[i] + a[i+k-1]){
          min = -2*a[i] + a[i+k-1];
        }
      }else{
        if(min > -a[i] + 2*a[i+k-1]){
          min = -a[i] + 2*a[i+k-1];
        }
      }
    }
  }
  printf("%ld",min);
  return 0;
}
      
        
      
  
  
  

Measured memory_bytes: 896
# frozen_string_literal: true

# https://github.com/universato/ac-library-rb/blob/master/src/scc.rb
class SCCGraph
  # initialize graph with n vertices
  def initialize(n = 0)
    @n, @edges = n, []
  end

  # add directed edge
  def add_edge(from, to)
    raise "invalid params" unless (0...@n).include? from and (0...@n).include? to

    @edges << [from, to]
  end

  # returns list of strongly connected components
  # the components are sorted in topological order
  # O(@n + @edges.size)
  def scc
    group_num, ids = scc_ids
    counts = [0] * group_num
    ids.each { |x| counts[x] += 1 }
    groups = Array.new(group_num) { [] }
    ids.each_with_index { |x, i| groups[x] << i }
    groups
  end

  private

  def scc_ids
    start, elist = csr
    now_ord = group_num = 0
    visited, low, ord, ids = [], [], [-1] * @n, []
    dfs = ->(v) {
      low[v] = ord[v] = now_ord
      now_ord += 1
      visited << v
      (start[v]...start[v + 1]).each do |i|
        to = elist[i]
        low[v] = if ord[to] == -1
                   dfs.(to)
                   [low[v], low[to]].min
                 else
                   [low[v], ord[to]].min
                 end
      end
      if low[v] == ord[v]
        loop do
          u = visited.pop
          ord[u] = @n
          ids[u] = group_num
          break if u == v
        end
        group_num += 1
      end
    }
    @n.times { |i| dfs.(i) if ord[i] == -1 }
    ids = ids.map { |x| group_num - 1 - x }
    [group_num, ids]
  end

  def csr
    start, elist = [0] * (@n + 1), [nil] * @edges.size
    @edges.each { |(i, _)| start[i + 1] += 1 }
    @n.times { |i| start[i + 1] += start[i] }
    counter = start.dup
    @edges.each do |(i, j)|
      elist[counter[i]] = j
      counter[i] += 1
    end
    [start, elist]
  end
end

# TwoSat
# Reference: https://github.com/atcoder/ac-library/blob/master/atcoder/twosat.hpp
class TwoSat
  def initialize(n = 0)
    @n = n
    @answer = Array.new(n)
    @scc = SCCGraph.new(2 * n)
  end

  attr_reader :answer

  def add_clause(i, f, j, g)
    @scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0))
    @scc.add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0))
    nil
  end

  def satisfiable
    id = @scc.send(:scc_ids)[1]
    @n.times do |i|
      return false if id[2 * i] == id[2 * i + 1]

      @answer[i] = id[2 * i] < id[2 * i + 1]
    end
    true
  end
end

n, d = gets.split.map(&:to_i)
x, y = n.times.map { gets.split.map(&:to_i) }.transpose
ts = TwoSat.new(n)

n.times do |i|
  (i + 1...n).each do |j|
    ts.add_clause(i, false, j, false) if (x[i] - x[j]).abs < d
    ts.add_clause(i, false, j, true) if (x[i] - y[j]).abs < d
    ts.add_clause(i, true, j, false) if (y[i] - x[j]).abs < d
    ts.add_clause(i, true, j, true) if (y[i] - y[j]).abs < d
  end
end

if ts.satisfiable
  puts 'Yes'
  ts.answer.each_with_index do |ans, i|
    puts ans ? x[i] : y[i]
  end
else
  puts 'No'
end


Measured memory_bytes: 14484
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


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

    int ans = n;
    REP(i, n + 1) {
        int cnt = 0;
        int t = i;
        while(t > 0) cnt += t % 6, t /= 6;
        t = n - i;
        while(t > 0) cnt += t % 9, t /= 9;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int k;
  cin>>k;
  ll ans=0;
  REP1(i,k){
    if( i&1 ) continue;
    else{
      REP1(j,k)if( j&1 ) ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 892
module app;

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;

void main(string[] argv){
    // input
    int n;
    n = to!int(readln().chop());

    int[] a1;
    a1 = map!(to!int)(readln().chop().split()).array();

    int[] a2;
    a2 = map!(to!int)(readln().chop().split()).array();

    int answer;
    foreach(temp; map!((x) => get_candies_num(x,a1,a2))(iota(0,n))) {
        if(answer < temp){
            answer = temp;
        }
    }

    writeln(answer);
}

// x行目で曲がった時に回収できる飴の個数
int get_candies_num(int x, int[] a1, int[] a2){
    int result;
    result = a1[0..x+1].sum() + a2[x..$].sum();
    return result;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var k = int.Parse(Console.ReadLine());

			if(k < 10)
			{
				Console.WriteLine(k);
				return;
			}

			long count = 9;

			var digitList = new List<int>();
			digitList.Add(0);
			digitList.Add(1);

			while(true)
			{
				var digitListCount = digitList.Count;

				var isLunlun = true;

				for(int i = 0; i < digitList.Count - 1; i++)
				{
					if(Math.Abs(digitList[i] - digitList[i + 1]) > 1)
					{
						isLunlun = false;

						if(digitList[i] > digitList[i + 1])
						{
							for (int j = 0; j <= i; j++)
							{
								digitList[j] = 0;
							}

							for (int j = i + 1; j < digitListCount; j++)
							{
								if (digitList[j] != 9)
								{
									digitList[j]++;
									break;
								}
								else
								{
									digitList[j] = 0;
								}
							}
							if (digitList.All(value => value == 0))
							{
								digitList.Add(1);
							}
						}
						else
						{
							digitList[i] = digitList[i + 1] - 1;
							for(int j = i - 1; j >= 0; j--)
							{
								if(digitList[j + 1] > 0)
								{
									digitList[j] = digitList[j + 1] - 1;
								}
								else
								{
									digitList[j] = 0;
								}
							}
						}


						break;
					}
				}

				if(isLunlun)
				{
					count++;
					if(count == k)
					{
						break;
					}
					for (int i = 0; i < digitListCount; i++)
					{
						if (digitList[i] != 9)
						{
							digitList[i]++;
							break;
						}
						else
						{
							digitList[i] = 0;
						}
					}
					if (digitList.All(value => value == 0))
					{
						digitList.Add(1);
					}
				}
			}

			digitList.Reverse();
			var stringBuilder = new StringBuilder();
			foreach(var digit in digitList)
			{
				stringBuilder.Append(digit);
			}
			Console.WriteLine(stringBuilder.ToString());
		}
	}
}


Measured memory_bytes: 15312
from itertools import combinations_with_replacement
N, M, Q = [int(x) for x in input().split()]
lst = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for seq in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for a, b, c, d in lst:
        if (seq[b-1] - seq[a-1] == c):
            tmp += d
    ans = max(ans, tmp)
print(ans)


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

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


int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<vector<int>> A(n, vector<int>(m));
    vector<int> money(n);
    rep(i, n) {
        cin >> money[i];
        rep(j, m) {
            cin >> A[i][j];
        }
    }


    vector<int> r(m, 0);
    int ans = 99999999;
    int tmp = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                tmp += money[i];
                rep(j, m) {
                    r[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        rep(i, m) {
            if (r[i] < x) ok = false;
            r[i] = 0;
        }
        if(ok) ans = min(ans, tmp);
        tmp = 0;
    }

    if(ans== 99999999){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;


int cal(int x1, int y1, int x2, int y2, vector<vector<int> >& board)
{
  int ret = board[y2][x2] - board[y2][x1] - board[y1][x2] + board[y1][x1];
  return ret;
}

int main()
{
  int N, K;
  scanf("%d %d", &N, &K);
  vector<vector<int> > board(4 * K + 1, vector<int>(4 * K + 1, 0));
  for (int i = 0; i < N; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    if (c == 'W') { x += K; }
    x %= (2 * K);
    y %= (2 * K);
    ++board[y + 1][x + 1];
  }

  for (int y = 1; y <= 4 * K; ++y) {
    for (int x = 1; x <= 4 * K; ++x) {
      board[y][x] += board[y][x - 1] + board[y - 1][x] - board[y - 1][x - 1];
    }
  }
  int ans = 0;
  for (int x = 1; x <= 2 * K; ++x) {
    for (int y = 1; y <= 2 * K; ++y) {
      int x0 = 0, y0 = 0;
      int x1 = max(0, x - K), y1 = max(0, y - K);
      int x2 = x, y2 = y;
      int x3 = min(x + K, 2 * K), y3 = min(y + K, 2 * K);
      int x4 = 2 * K, y4 = 2 * K;
      int cnt = cal(x0, y0, x1, y1, board) +
        cal(x2, y0, x3, y1, board) +
        cal(x1, y1, x2, y2, board) +
        cal(x3, y1, x4, y2, board) +
        cal(x0, y2, x1, y3, board) +
        cal(x2, y2, x3, y3, board) +
        cal(x1, y3, x2, y4, board) +
        cal(x3, y3, x4, y4, board);
      ans = max(ans, cnt);
    }
  }
  printf("%d\n", ans);

  return 0;
}


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

int main()
{
        int a,b,c;
        cin >> a >> b >> c;
        if(a<b) swap(a,b);
        if(a<c) swap(a,c);
        if(b<c) swap(b,c);

        int ans=0;
        b=a-b;
        c=a-c;
        if((b+c)%2==0) ans=(b+c)/2;
        else ans=(b+c)/2+2;
        cout << ans << endl;

        return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005, P = 998244353;

int n, a[N], b[N], f[N];
char tmp[N];

int main() {
	read(n);
	readStr(tmp);
	for (int i = 0; i < n; ++i) {
		a[i] = tmp[i] ^ '0';
	}
	for (int d = 1; d <= n; ++d) {
		if (n % d == 0 && (n / d) & 1) {
			f[d] = 0;
			for (int i = 0; i < d; ++i) {
				f[d] = (2 * f[d] + a[i]) % P;
				b[i] = a[i];
			}
			for (int i = d; i < n; ++i) {
				b[i] = !b[i - d];
			}
			if (!std::lexicographical_compare(a, a + n, b, b + n)) {
				f[d] = (f[d] + 1) % P;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (n % i == 0 && (n / i) & 1) {
			ans = (ans + 1ll * i * f[i]) % P;
			for (int j = 3; j <= n / i; j += 2) {
				f[i * j] = (f[i * j] + P - f[i]) % P;
			}
		}
	}
	print(2 * ans % P);
}


Measured memory_bytes: 6324
#abc150d
def gcd(a,b):
 while b:
  a,b=b,a%b
 return a
def lcm(a,b):
 return a/gcd(a,b)*b
import sys
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
LCM=1
for i in range(n):
 LCM=lcm(LCM,a[i])
for i in range(n):
 if LCM/a[i]%2==0:
  print 0
  sys.exit()
res=(m/(LCM/2)+1)/2
print res


Measured memory_bytes: 11316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    string s;
    cin >> s;

    string rs = s;
    reverse(ALL(rs));

    if (rs == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

set<int> s[100000];
 
int main() {
   int i,n,m,p,h,g,ans;
   unsigned int d;
   while (cin >> n >> m && n+m>0) {
	   ans=0; h=0;
	   for (i=0;i<m;i++) s[i].clear();
	   for (i=0;i<n;i++) { cin >> d; h=(h+(d % m)) % m; if (h>ans) ans=h; s[h].insert(i); if (i==0) p=h;}
	   h=m; g=0;
	   for (i=0;i<m;i++) {
		 p=(p+m-1) % m; h--;
		 if (s[p].empty()) continue;
		 if (s[p].upper_bound(g)!=s[p].end() && ans<h) ans=h;
		 g=*(s[p].begin()); h=m;
	   }
	   cout << ans << endl;	 
	}
	return 0;
} 

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

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define mn 1000000

using namespace std;

string res;
int dp[3001][3001];
string a,b;
int bek[3001][3001];

void backtrack (int i, int j) {
    if (bek[i][j] == 2) { res += a[i-1]; backtrack(i-1,j-1); }
    else if (bek[i][j] == 0) backtrack(i-1, j);
    else if (bek[i][j] == 1) backtrack(i,j-1);
}

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,m;

    cin>>a>>b;

    if (a.length() < b.length()) swap(a,b);

    n = a.size();
    m = b.size();

    MS(dp, -1);
    MS(bek, -1);

    for (int i = 0; i<n; i++) dp[i][0] = 0;
    for (int i = 0; i<m; i++) dp[0][i] = 0;

    for (int i = 1; i<=n; i++) {
        for (int j = 1; j<=m; j++) {
            if (dp[i-1][j] > dp[i][j-1]) {
                dp[i][j] = dp[i-1][j];
                bek[i][j] = 0;
            } else {
                dp[i][j] = dp[i][j-1];
                bek[i][j] = 1;
            }

            if (a[i-1] == b[j-1]) {
                dp[i][j] = dp[i-1][j-1]+1;
                bek[i][j] = 2;
            }
        }
    }

    backtrack(n,m);

    reverse(res.begin(), res.end());

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 70656
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}

string s;

main(){
	cin>>s;
	map<char,int> a;
	rep(i,s.size()){
		amp(a,s[i]);
	}
	if(a.size()==2){
		int ok=1;
		for(auto x:a)if(x.se!=2)ok=0;
		if(ok)dump("Yes");
	}else{
		dump("No");
	}
}



Measured memory_bytes: 256
N = int(input())
st = [list(input().split()) for i in range(N)]
X = input()

#print(st)
suma = 0

T = 0

for i in range(N):
    if T == 1:
        suma += int(st[i][1])
    if st[i][0] == X:
        T = 1

print(suma)

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//最大公約数 複数個
int gcd(const vector<int> &v) {
  int ret = v[0];
  for (int i = 1; i < v.size(); i++)
    ret = gcd(ret, v[i]);
  return ret;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, X;
  cin >> N >> X;
  vector<int> v(N);
  rep(i, 0, N) {
    cin >> v[i];
    v[i] = abs(X - v[i]);
  }
  cout<<gcd(v)<<endl;
  

  return 0;
}


Measured memory_bytes: 640
#include<iostream> 
#include<cstring> 
using namespace std; 
int main(){ 
	char a[65000]; 
	int b,i,j=0,k=0,sum,s; 
	cin>>a; 
	sum=strlen(a); 
	for(i=0;i<sum;i++){ 
		if(a[i]=='C') k=1;
		if(k==1&&a[i]=='F'){
			cout<<"Yes";return 0;
		} 
	} 
	cout<<"No"; 
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#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...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int l = -1e18, r = 1e18, res;
	while(l <= r) {
		int mid = (l + r) / 2;
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] == 0) {
				if(mid > 0) {
					cnt += n - 1;
				}
			}
			else if(a[i] < 0) {
				int val;
				if(mid >= 0) {
					if(mid % (-a[i]) == 0) {
						val = (mid / a[i]);
					}
					else {
						val = (mid / a[i]) - 1;
					}
				}
				else {
					val = (mid / a[i]);
				}
				cnt += a + n - upper_bound(a, a + n, val);
				if(a[i] > val) {
					cnt--;
				}
			}
			else {
				int val;
				if(mid < 0) {
					val = (mid / a[i]);
				}
				else {
					val = ((mid + a[i] - 1) / a[i]);
				}
				cnt += lower_bound(a, a + n, val) - a;
				if(a[i] < val) {
					cnt--;
				}
			}
		}
		cnt /= 2;
		if(cnt < k) {
			res = mid;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	cout << res;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a,b,c,i=0;
  while(1){
    scanf("%d %d %d",&a,&b,&c);
    if(a==-1&&b==-1&&c==-1) break;
    i=0;
    if(a==-1||b==-1){
      printf("F\n");
      i++;
    }
    if(a+b>=80&&i==0){
      printf("A\n");
    }
    if(a+b>=65&&a+b<80&&i==0){
      printf("B\n");
    }
    if(a+b>=50&&a+b<65&&i==0){
      printf("C\n");
    }
    if(a+b>=30&&a+b<50&&i==0){
      if(c>=50){
	printf("C\n");
      } else{
	printf("D\n");
      }
    }
    if(a+b<30&&i==0){
      printf("F\n");
    }
  }
  return(0);
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll n,k;
   cin>>n>>k;
   ll ans=0;
   ll ar[n];
   for(int i=0;i<n;i++)
    cin>>ar[i];
    ll e=n/2;
    ll fl=0;
   for(int i=60;i>=0;i--)
   {
       ll r=0;ll t=1;
       t<<=i;
       ll g=k&t;
       if(fl||g){
       for(int j=0;j<n;j++)
       {
            ll d=ar[j]&t;
            if(d)r++;
       }
       if(!(r>e))ans+=t;
       else fl=1;
       }
   }
   ll su=0;
   for(int i=0;i<n;i++)
    su+=(ar[i]^ans);
   cout<<su<<"\n";

   return 0;

}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = 0;
    int sum = 0;
    int ans = 100000;
    
    for(int i = 1; i <= n/2; i++){
      
        a = n-i;
        String I = String.valueOf(i);
        String A = String.valueOf(a);
        char[] ii = I.toCharArray();
        char[] aa = A.toCharArray();
        for(int j = 0; j < ii.length; j++){
          int itmp = Character.getNumericValue(ii[j]);
          sum += itmp;
        }
        for(int k = 0; k < aa.length; k++){
          int atmp = Character.getNumericValue(aa[k]);
          sum += atmp;
        }
        
        if(sum < ans){
          ans = sum;
        }
      
      sum = 0;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 45488
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N;
    cin >> N;
    char c[100];
    for(int i = 0; i < N; ++i) cin >> c[i];
    set<char> st(c, c+N);
    if(st.size() == 3)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;
    return 0;
}

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

using namespace std;


int main(void){

	map<string, int> pro;
	int n;
	int num;
	string name;
    map<string, int>::iterator it;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> name >> num;
		if (pro.find(name) != pro.end()) pro[name] += num;
		else pro[name] = num;
	}

	for (int i = 1; i <= 5; i++){
		it = pro.begin();
		while (it != pro.end()){
			if ((*it).first.size() == i){
				cout << (*it).first << " " << (*it).second << endl;
			}
			it++;
		}
	}

	return 0;
}

Measured memory_bytes: 1224
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


char alpha[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'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

const ll big = 1e12;

int main(){
    int n, k; cin >> n >> k;
    mcf_graph<int , ll> g(2*n + 2);
    int s = 2 * n, t = 2 * n + 1;
    REP(i, 0, n){
        g.add_edge(s, i, k, 0);
        g.add_edge(n+i, t, k, 0);
    }

    REP(i, 0, n){
        REP(l, 0, n){
            ll a; cin >> a;
            g.add_edge(i, n+l, 1, big - a);
        }
    }
    g.add_edge(s, t, n * k, big);
    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * big - result.second << endl;

    vector<string> grid(n, string(n, '.'));
    for(auto e : g.edges()){
        if(e.from == s || e.to == t || e.flow == 0) continue;
        grid[e.from][e.to - n] = 'X';
    }
    REP(i, 0, n){
        cout << grid[i] << endl;
    }
}

Measured memory_bytes: 3948
N = int(input())
S = []
for i in range(N):
    S.append(list(input()))
    
X = []
for i in range(len(S[0])):
    check=True
    for j in range(1,N):
        if S[0][i] not in S[j]:
            check = False
        else:
            S[j].remove(S[0][i])
    
    if check:
        X.append(S[0][i])

X.sort()
print("".join(X))

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

int main(){
  int h, w;
  cin >> h >> w;

  string board[50];

  for(int i = 0; i < h; ++i) cin >> board[i];

  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(board[i][j] == '#') continue;

      int num = 0;
      for(int d = 0; d < 8; ++d){
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni < 0 || h <= ni) continue;
        if(nj < 0 || w <= nj) continue;
        if(board[ni][nj] == '#') num++;
      }

      board[i][j] = num + '0';
    }
  }

  for(int i = 0; i < h; ++i) cout << board[i] << endl;

  return 0;
}

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

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int ans = 0;
  int num = 1;
  int a;
  bool ok = false;
  rep(i, n)
  {
    cin >> a;
    if(num != a) ++ans;
    else {++num;ok = true;}
  }
  if(!ok) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int a, p;
  std::cin >> a >> p;
  int shards = 3*a+p;
  std::cout << shards/2 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    char s[10];
    scanf("%s",s);
    int i,sum,min=10000,max;
    int n=strlen(s);
    for(i=0;i<=n-3;i++)
    {
        sum=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        max=fabs((int)sum-753);
        if(max<min)
            min=max;
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
int a[334], dp[334];
signed main() {
	int n;
	cin >> n;
	rep(i, n)cin >> a[i];
	a[0] = 0;
	int ans = 0;
	rep(i, n) {
		if (a[i] > a[i - 1]) { ans += a[i] - a[i - 1]; }
		else { ans += 0; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 5; i++) cout << s[i];
  cout << " ";
  for(int i = 6; i < 13; i++) cout << s[i];
  cout << " ";
  for(int i = 14; i < 19; i++) cout << s[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,K = map(int, input().split())
X = []
L = B-A+1
if 2*K>=L:
    for i in range(L):
        print(A+i)
else:
    for j in range(K):
        print(A+j)
    for k in range(K):
        print(B-K+1+k)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(){
  int i,n,x[100],y[100];
  double D,d;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&y[i]);
  }
  
  for(i=0;i<n;i++){
    D+=sqrt(pow(x[i]-y[i],2));
  }
  printf("%lf\n",D);
  D=0;
  
  for(i=0;i<n;i++){
    D+=pow(x[i]-y[i],2);
  }
  printf("%lf\n",sqrt(D));
  D=0;
  
  for(i=0;i<n;i++){
    d+=pow(sqrt(pow(x[i]-y[i],2)),3);
  }
  D=pow(d,1.0/3.0);
  printf("%lf\n",D);
  D=0;
  
  for(i=0;i<n;i++){
    d=sqrt(pow(x[i]-y[i],2));
    if(D<d)D=d;
  }
  printf("%lf\n",D);
  return 0; 
}




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

using namespace std;

const int N = 100100;

int n, m;
vector<int> g[N];
int deg[N];
int ans_deg[N];
bool visit[N];
int par[N];
bool used[N];

void dfs(int u) {
   visit[u] = true;
   for (int v : g[u]) {
      if (!visit[v]) {
         par[v] = u;
         deg[u]++;
         dfs(v);
      }
   }
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> n >> m;
   if (m & 1) {
      cout << -1 << "\n";
      return 0;
   }
   for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
   }
   dfs(1);
   queue<int> q;
   vector<pair<int, int>> ans;
   for (int i = 1; i <= n; ++i) {
      if (deg[i] == 0) {
         q.push(i);
      }
   }
   while (!q.empty()) {
      int u = q.front(); q.pop();
      used[u] = true;
      vector<int> ng;
      for (int v : g[u]) {
         if (!used[v]) {
            ng.push_back(v);
         }
      }
      if ((ans_deg[u] + ng.size()) & 1) {
         ans.emplace_back(ng.back(), u);
         ans_deg[ng.back()]++;
         ng.pop_back();
      }
      for (int v : ng) {
         ans.emplace_back(u, v);
      }
      if (--deg[par[u]] == 0) {
         q.push(par[u]);
      }
   }
   for (auto p : ans) {
      cout << p.first << " " << p.second << "\n";
   }
}


Measured memory_bytes: 13812