akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<map>
using namespace std;
#include<vector>
#define int long long int
int function(vector<int> &vec2,int initial,int final,int memo[][101],int total)
{
	if(total>75)
	    return 0;
	if(initial>final)
	{
		if(total==75)
		   return 1;
		else
		   return 0;
	}
	if(memo[initial][total]!=-1)
	     return memo[initial][total];
	else
	{
		int answer=0;
		int val=vec2[initial];
		int j;
		for(j=0;j<=val;j++)
		{
			answer+=function(vec2,initial+1,final,memo,total*(j+1));
		}
		memo[initial][total]=answer;
		return answer;
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	map<int,int> mp;
	int j;
	for(j=1;j<=n;j++)
	{
		int x=j;
		int i;
		for(i=2;i*i<=x;i++)
		{
			if(x%i==0)
			{
				while(x%i==0)
				{
					x/=i;
					mp[i]++;
				}
			}
		}
		if(x!=1)
		{
			mp[x]++;
		}
	}
	vector<int> vec1,vec2;
	for(auto p:mp)
	{
		vec1.push_back(p.first);
		vec2.push_back(p.second);
	}
	int s=vec1.size();
	int memo[s+1][101];
	int i;
	for(i=0;i<=s;i++)
	{
		for(j=0;j<=100;j++)
		{
			memo[i][j]=-1;
		}
	}
	int answer=function(vec2,0,s-1,memo,1);
	cout<<answer<<endl;
}



Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    CIN(int, n);
    COUT(n == 7 || n == 5 || n == 3 ? "YES" : "NO");
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, ma, mb;

map<pair<int, int>, int> m;

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> ma >> mb;

    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        auto it = m.rbegin();
        while (it != m.rend()) {
            auto nxt = next(it);
            pair<int, int> v = it->first;
            if (m.count({v.first + a, v.second + b})) {
                m[{v.first + a, v.second + b}] = min(m[{v.first + a, v.second + b}], m[{v.first, v.second}] + c);
            } else {
                m[{v.first + a, v.second + b}] = m[{v.first, v.second}] + c;
            }
            it = nxt;
        }   
        if (m.count({a, b})) m[{a, b}] = min(m[{a, b}], c);
        else m[{a, b}] = c;
    }

    int ans = -1;
    for (auto i : m) {
        if (i.first.first % ma == 0 && i.first.second % mb == 0) {
            if (i.first.first / ma == i.first.second / mb) {
                if (ans == -1) ans = i.second;
                else ans = min(ans, i.second);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 4936
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int N = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int M = int.Parse(input[1]);

		// M個の地点の入力
    string[] points = Console.ReadLine().Split(' ');

    // N >= M の場合、移動する必要がないので出力は0
    if(N >= M){
      Console.WriteLine("0");
      return;
    }

		// 文字列の入力
		//string s = Console.ReadLine();

    // M個の地点をintのリストにする
    var list = new List<int>();
    for(int i =0; i<points.Length; i++){
      list.Add(int.Parse(points[i]));
    }
    // M個の地点をソートする
    list.Sort();

    // M個の地点の移動距離を一つずつ出す
    var dist = new List<long>();
    for(int i=1; i<list.Count; i++){
      long d = list[i] - list[i-1];
      dist.Add(d);
    }

    // 移動距離をソートする
    dist.Sort();
    
    // M - N個の地点だけ移動する必要があるので、最小移動回数は
    long route = 0;
    for(int i = 0; i< M-N; i++){
      route += dist[i];
    }

		//出力
		Console.WriteLine(route + "");
	}
}


Measured memory_bytes: 19808
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		
    		if(a<=8&&b<=8) {
    			System.out.print("Yay!");
    		}else {
    			System.out.print(":(");
    		}


    		
     
    }
    }
// end 

Measured memory_bytes: 21844
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)

Measured memory_bytes: 86620
// #include "vacation.h"
#include <algorithm>
#include <iostream>
#include <vector>

using ActivityData = std::vector<int>;
using Activities = std::vector<ActivityData>;

namespace {

constexpr size_t num_activities{3};
std::vector<size_t> activity_types{0u, 1u, 2u};

} // namespace

int helper(const Activities& activities, size_t day, size_t prev_activity)
{
    if (day >= activities.size())
        return 0;

    int ans{0};
    for (auto activity : {0u, 1u, 2u}) {
        if (activity == prev_activity)
            continue;
        ans = std::max(ans,
                       activities[day][activity] +
                           helper(activities, day + 1, activity));
    }
    return ans;
}

int max_happiness(const Activities& activities)
{
    std::vector<std::vector<int>> dp(activities.size(),
                                     std::vector<int>(num_activities, 0));
    dp.front() = activities.front();

    for (size_t day = 1; day < activities.size(); ++day) {
        for (auto activity : activity_types) {
            auto& happiness = activities[day][activity];
            for (auto prev_activity : activity_types) {
                if (activity == prev_activity)
                    continue;
                dp[day][activity] = std::max(
                    dp[day][activity], happiness + dp[day - 1][prev_activity]);
            }
        }
    }

    return *std::max_element(dp.back().cbegin(), dp.back().cend());
}

int main(int argc, char* argv[])
{
    size_t n;
    std::cin >> n;
    Activities activities(n, std::vector<int>(num_activities));
    for (size_t i = 0; i < n; ++i) {
        size_t a, b, c;
        std::cin >> a >> b >> c;
        activities[i][0] = a;
        activities[i][1] = b;
        activities[i][2] = c;
    }
    std::cout << max_happiness(activities) << std::endl;
    return 0;
}


Measured memory_bytes: 11136
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m, c = 0; cin>>n>>m;
	vector<int> a(m+1, 0);
	for (int i=0; i<n; ++i){
		int k; cin>>k;
		while(k--){
			int x; cin>>x;
			a[x]++;
		}
	}
	for (int i=1; i<=m; ++i) if (a[i] == n) c++;
	cout<<c;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
int ans[maxn],x;
int main (){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x%2==1&&i%2==1) ans++;
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 3760
#include <stdio.h>
int prime(int x) {
    int i;
    if (x<2) return 0;
    if (x==2) return 1;
    if(x%2==0) return 0;
    
    for (i=3; i*i<=x; i+=2)
    if(x%i==0) return 0;
    
    return 1;
}

int main(void){
    int i,n,c=0,a;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a);
        c+=prime(a);
    }
    
    printf("%d\n", c);
    
    return 0;
    
}


Measured memory_bytes: 2040
const stdin = require('process').stdin;
var input = "";
stdin.on('data', x => input += x);
stdin.on('end', () => {
    var ab = input.split(' ').map(x=>x.trim()).map(parseFloat);
    var j = 0;
    for(var i = 1; i < ab[1] - ab[0]; i++) { j += i; }
    console.log(j - ab[0]);
});

Measured memory_bytes: 7500
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

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

    vector<int> B(M);
    rep(i, 0, M) cin >> B[i];

    int ans = 0;
    rep(i, 0, N) {
        int cnt = 0;
        rep(i, 0, M) {
            int a;
            cin >> a;
            cnt += a * B[i];
        }
        if (cnt + C > 0) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M,0);
  for(int i=0;i<M;i++){
    cin >> B[i];
  }

  int count=0;
  int sum=0;
  for(int j=0;j<N;j++){
    for(int i=0;i<M;i++){
      int Ai;
      cin >> Ai;
      sum+=Ai*B[i];
    }
    if(sum+C>0){
      count++;
    }
    sum=0;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
let s =
    stdin.ReadLine()
    |> Seq.map (fun c -> int c - 48)
    |> Seq.toList

let rec countChange cnt prev xs =
    match xs with
    | x :: xs ->
        if x = prev then
            countChange (cnt + 1) (if x = 1 then 0
                                   else 1) xs
        else countChange cnt x xs
    | _ -> cnt

min (countChange 0 -1 s) (countChange 0 -1 (s |> List.rev)) |> printfn "%d"


Measured memory_bytes: 22744
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let s = readl!(String);
    let mut s = s.into_bytes();
    let t = readl!(String);
    let t = t.into_bytes();
    let n = s.len();
    let m = t.len();
    let mut f = false;
    for i in (0..(n-m+1)).rev() {
        let mut mf = true;
        // debug!(i);
        for j in 0..m {
            // debug!(s[i+j] as char);
            if s[i+j] != t[j] && s[i+j] != '?' as u8 {
                mf = false;
                // break;
            }
        }
        if mf {
            for j in 0..m {
                s[i+j] = t[j];
            }
            f = true;
            break;
        }
    }
    for e in &mut s {
        if *e == '?' as u8 {
            *e = 'a' as u8;
        }
    }
    let ans: String = s.into_iter().map(|x| x as char).collect();
    if f {
        println!("{}", ans);
    } else {
        println!("UNRESTORABLE");
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

const int INF = 10000000;

int city[101][101];

int solve( int s, int d, int c, int n ){
	int dist[11][101];
	int history[11][101];

	for( int i = 0;i < 11;i++ ){
		for( int j = 1;j < 101;j++ ){
			dist[i][j] = INF;
			history[i][j] = 0;
		}
	}


	for( int i = 0;i < 11;i++ ) dist[i][s] = 0;

	typedef pair<int,int> data;
	typedef pair<int,data> graph;
	priority_queue<graph,vector<graph>,greater<graph> > q;

	q.push( graph( 0, data( s, c ) ) );

	while( !q.empty() ){
		graph a = q.top();
		int u = a.second.first;
		int uc = a.second.second;
		q.pop();
		history[uc][u] = 1;

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

			if( history[uc][i] ) continue;
			if( dist[uc][i] > dist[uc][u] + city[u][i] ){
				dist[uc][i] = dist[uc][u] + city[u][i];
				q.push( graph( dist[uc][i], data( i, uc ) ) );
			}

			if( uc && dist[uc - 1][i] > dist[uc][u] + city[u][i] / 2 ){
				dist[uc - 1][i] = dist[uc][u] + city[u][i] / 2;
				q.push( graph( dist[uc - 1][i], data( i, uc - 1 ) ) );
			}
		}
	}
	int answer = INF;
	for( int i = 0;i < 11;i++ ) answer = min( dist[i][d], answer );
	return answer;

}

int main(int argc, char const* argv[])
{
	int c,n,m,s,d;

	while( cin >> c >> n >> m >> s >> d && c != 0 ){
		int a,b,f;
		for( int i = 1;i < 101;i++ ){
			for( int j = 1;j < 101;j++ ){
				city[i][j] = INF * 2;
			}
		}
		for( int i = 0;i < m;i++ ){
			cin >> a >> b >> f;
			city[a][b] = f;
			city[b][a] = f;
		}

		cout << solve( s, d, c, n ) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,k = mi()
    p = li()
    p = list(sorted(p))
    ans = 0
    for i in range(k):
        ans+=p[i]
    print(ans)

main()




Measured memory_bytes: 9988
#include <bits/stdc++.h>
using namespace std;
 
typedef long double LD;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define REP(i,n) for (ll i = 0; i < n; i++)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REPD(i,n) for (ll i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (ll i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define rsort(v) sort(v.begin(), v.end(), greater <>());
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type,vector<type>,greater<type> >
#define ITR :: iterator it
#define WL(t) while(t--)
#define SZ(x) ((int)(x).size())
#define TR(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define i1(x) cin>>x
#define i2(x,n) cin>>x>>n
#define o1(x) cout<<x
#define o2(x,n) cout<<x<<n
int main(){
    ll x,y,z;
    i2(x,y)>>z;
    o2(z," ")<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

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;}


int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }
#include <iomanip>


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


int a,b;
cin >> a >> b;
cout << a*b << endl;


//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int        long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
bool cust(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} 
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll x,a,b;
	cin>>x>>a>>b;
	x-=a;
	x=x%b;
	cout<<x;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> a(N);
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  int64_t sum = 0;
  for(int i = 0; i < N; ++i) sum += a[i];
  std::sort(a.begin(), a.end());
  if(a.back() < N) fin(0);

  int64_t sum2 = 0;
  for(int i = 0; i <= N; ++i) {
    for(auto& v: a) v %= N+1;
    std::sort(a.begin(), a.end());
    if(a.back() == N-1) {
      int64_t cur = 0;
      for(int64_t v: a) cur += v;
      if(cur < sum) sum2 = std::max(sum2, cur);
    }
    for(auto& v: a) ++v;
  }
  fin(sum - sum2);
  return 0;
}


Measured memory_bytes: 256
t[9999],W,N,a,b,i;
main(c){
	for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",c++,t[W],i),memset(t,0,W*9)){
		for(scanf("%d",&N);N--&&scanf("%d,%d",&a,&b);){
			for(i=W;i>=b;i--)t[i]=fmax(t[i],t[i-b]+a);
		}
		for(i=0;t[i]-t[W];i++);
	}
}

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

int main() {
  int N;
  string S;
  bool four = false;
  cin >> N;
  for(int i = 0;i < N;i++)
  {
    cin >> S;
    if(S == "Y")
    {
      four = true;
      break;
    }
    
  }

  if(four)
  {
    cout << "Four" << endl;
  }
  else
  {
     cout << "Three" << endl;
  }

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 64).readLine());
		int val = 100;//壱百千円
		for (; 0 < period; period--) {
			val = val * 105 % 100 == 0 ? (int) (val * 1.05) : (int) (val * 1.05) + 1;
		}
		System.out.println(val * 1000);
	}
}

Measured memory_bytes: 16844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  int N,K,ans=0;
  cin>>N>>K;
  
  int A[N+1];
  REP(i,N+1) A[i]=0;
  
  REP(i,K){
    int D;
    cin>>D;
    REP(j,D){
      int h;
      cin>>h;
      A[h]++;
    }
  }
  
  RREP(i,N){
    if(A[i]==0) ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;

int dist[1005][1005];
int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    string grid[h];
    for (int i = 0; i < h; i++) cin >> grid[i];
    queue<p> que;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dist[i][j] = -1;
            if (grid[i][j] == '#') {
                que.push(p(i, j));
                dist[i][j] = 0;
            }
        }
    }
    int ans = 0;
    while (!que.empty()) {
        int ci = que.front().first;
        int cj = que.front().second;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ni = ci + di[i];
            int nj = cj + dj[i];
            if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            if (grid[ni][nj] == '.') {
                grid[ni][nj] = '#';
                dist[ni][nj] = dist[ci][cj] + 1;
                ans = max(ans, dist[ni][nj]);
                que.push(p(ni, nj));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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



int main(){
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  ll i,n,k,x,y,t;
  // cin>>t;
  // while(t--)
  {
  cin>>n;
  ll ans=0;
  for(i=1;i<=n;i++){
    cin>>k;
    if(i%2 && k%2)ans++;
  }
  cout<<ans;
  }
}

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

namespace OthloKyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            /* 101*/
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var sum = 0;
            foreach(var i in a)
            {
                sum += i;
            }
            Console.WriteLine(sum / a.Count());


        }
    }
}

Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,M;
    string S;
    cin >> N >> M >> S;
    vector<int>ans;
    int res = S.size()-2;
    int i = S.size()-1;
    while (true) {
        int now = -1;
        for(int j = max(0LL,i-M); j <= res; j++) {
            if(S[j] == '0') {
                now = j;
                break;
            }
        }
        if(now == -1) {
            cout << -1 << endl;
            return 0;
        }
        res = max(0LL,i-M-1);
        ans.push_back(i-now);
        i = now;
        if(now == 0) {
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << ((i+1 == ans.size())?"\n":" ");
    }
}


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

signed main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a.begin(), a.end());
    
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll a, b, n;



void solve()
{
	cin >> a >> b >> n;
	cout << ((a*min(b - 1, n))/b) << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3648
import sys
def dfs(tiles, W, H, x, y):
    tiles[y][x] = '0'
    for dx,dy in ((-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)):
        if 0<=x+dx<W and 0<=y+dy<H and tiles[y+dy][x+dx]=='1':
            dfs(tiles, W, H, x+dx, y+dy)
    return

def main():
    while True:
        W,H = [int(x) for x in input().split()]
        if W==0 and H==0:
            exit()
        tiles = [input().split() for h in range(H)]
        cnt = 0
        for h in range(H):
            for w in range(W):
                if tiles[h][w] == '1':
                    cnt += 1
                    dfs(tiles, W, H, w, h)
        print(cnt)

if __name__ == '__main__':
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 9636
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define one first
#define two second
#define rint read<int>
#define int long long
#define pb push_back
#define db double
#define ull unsigned long long
#define lowbit(x) ( x & ( - x ) )

using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
       while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
       return f * x ;
    }

int a , b ;

signed main (int argc , char * argv[]) {
    a = rint () ; b = rint () ;
    if ( a >= 1 && a <= 9 && b >= 1 && b <= 9 ) printf ("%lld\n" , a * b ) ;
    else puts ("-1") ; return 0 ;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	string S; cin >> S;
	int K;    cin >> K;
	int N = S.size();

	char bottom = 'a';

	set<string> candidates;

	while (candidates.size() < K) {
		F0R(i, N) if (S[i] == bottom) {
			F0R(j, K) candidates.insert(S.substr(i, j+1));
		}
		++bottom;
	}

	F0R(i, K-1) {
		candidates.erase(candidates.begin());
	}
	print((*candidates.begin()));
}

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

string string_swap(string &s) {
  string t;
  t = s.at(s.size() - 1);
  t += s;
  t.erase(t.size() - 1);
  return t;
}

int main() {
  string s, t;
  cin >> s >> t;
  vector<string> ans;
  for (int j = 0; j < s.size(); j++) {
    s = string_swap(s);
    ans.push_back(s);
  }

  for (int i = 0; i < ans.size(); i++) {
    if (ans.at(i) == t) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


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

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

    map<long long, long long> drink;
    long long A, B;
    for (int i=0; i<N; i++) {
        cin >> A >> B;
        drink[A] += B;
    }

    long long res = 0;
    for (auto i = drink.begin(); i != drink.end(); i++) {
        long long cost = i->first, stock = i->second;
        // cout << cost << "->" << stock << endl;
        if (M - stock >= 0) {
            res += cost * stock;
            M -= stock;
        }
        else {
            res += cost * M;
            break;
        }
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 6528
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	ll n;
	cin >> n;

	vector<ll>a(n);

	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	vector<ll> t(a[n-1]+1);

	for (ll i = 0; i < a[n - 1] + 1; i++) {
		t[i] = 0;
	}

	for (ll i = 0; i < n; i++) {
		for (ll j = 1; a[i] * j <= a[n - 1]; j++) {
			t[a[i] * j] += 1;
		}
	}

	int h = 0;

	for (ll i = 0; i < n; i++) {
	
		if (t[a[i]] == 1) {
			h++;
		}
	}

	cout << h;
	return 0;
}

Measured memory_bytes: 12648
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(Int x = start; x > end; x--)

using namespace std;

#define MAX_V 10000

vector<Int> graph[MAX_V];
bool used_v[MAX_V],used_e[MAX_V][MAX_V];
Int ord[MAX_V],lowlink[MAX_V];
Int k=0;
vector<Int> aps;

void dfs(Int v, Int parent) {
  used_v[v] = true;
  ord[v]=lowlink[v]=k++;
  bool isAp = false;
  Int childCnt = 0;
  
  for (Int u: graph[v]) {
    if(!used_v[u]) {
      childCnt++;
      used_e[v][u] = true;
      dfs(u, v);
      lowlink[v] = min(lowlink[v], lowlink[u]);
      isAp |= parent != -1 && lowlink[u] >= ord[v];
    }
    else if(!used_e[u][v]) {
      lowlink[v] = min(lowlink[v], ord[u]);
    }
  }
  
  isAp |= parent == -1 && childCnt >= 2;
  if (isAp) aps.push_back(v);
}

Int main(void) {
  Int n, e, u, v;
  cin >> n >> e;
  loop(i,0,e) {
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(0, -1);
  sort(aps.begin(), aps.end());
  for (Int v: aps) cout << v << endl;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
  ll N; cin >> N;
  string c; cin >> c;
  ll R_C=0;
  ll W_C=0;
  FOR(i, 0, N){
    if(c[i]=='R') R_C++;
    if(c[i]=='W') W_C++;
  }

  ll W_Wrong = 0;
  ll R_Wrong = 0;

  FOR(i, 0, R_C){
    if(c[i]=='W') W_Wrong++;
  }

  FOR(i, R_C, N){
    if(c[i]=='R') R_Wrong++;
  }

  cout << max(W_Wrong, R_Wrong) << endl;
}


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

int str_compar(const void *str1, const void *str2) {
    return strcmp(*(char **)str1, *(char **)str2);
}


int main(void)
{
    int N;
    char **S;
    int result = 0;
    char r[11];

    scanf("%d", &N);

    S = (char**)malloc(sizeof(char*) * N);
    // 全て読み込む
    for (int i = 0; i < N; i++) {
        S[i] = (char*)malloc(sizeof(char) * 11);
        scanf("%s", S[i]);
    }

    // ソート
    qsort(S, N, sizeof(char*), str_compar);

    // 数える
    strcpy(r, S[0]);
    result = 1;
    for (int i = 1; i < N; i++) {
        if (strcmp(r, S[i]) == 0) continue;
        result++;
        strcpy(r, S[i]);
    }

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

    return 0;
}

Measured memory_bytes: 11112
#include <stdio.h>

int main()
{
	const int x[8] = {1, 0, -1, 0, 1, -1, -1, 1};
	const int y[8] = {0, 1, 0, -1, 1, 1, -1, -1};
	int H, W, i, j, k;
	scanf("%d %d", &H, &W);
	char squares[H + 1][W + 1];
	for (i = 0; i < H; ++i) scanf("%s", squares[i]);
	
	for (i = 0; i < H; ++i) {
		for (j = 0; j < W; ++j) {
			if (squares[i][j] == '#') continue;
			int num = 0;
			for (k = 0; k < 8; ++k) {
				const int ni = i + y[k];
				const int nj = j + x[k];
				if (ni < 0 || H <= ni) continue;
				if (nj < 0 || W <= nj) continue;
				if (squares[ni][nj] == '#') num++;
			}
			squares[i][j] = (char)(num + '0');
		}
	}

	for (i = 0; i < H; ++i) printf("%s\n", squares[i]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(s.length()<=k) cout << s << "\n";
    else{
        for(int i=0;i<k;i++){
            cout << s[i];

        }
        cout << "...";
        cout << "\n";
    }

}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T;
  cin >> N >> T;
  int c, t;
  int ans = 1100;
  for (int i = 0; i < N; i++) {
  cin >> c >> t;
    if (t<=T){
      ans = min(ans, c);
  }
  }
  if(ans < 1100) cout << ans << endl;
  else if(ans == 1100){
    cout << "TLE" << endl;
  }
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	string s;
	cin >> s;
	if(s[a] != '-')
	{
		puts("No");
		return 0;
	}
	for(int i=0;i<a+b+1;i++)
		if(i != a && (s[i]<'0' || s[i]>'9' ) )
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;		
}

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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

int n, W, w[110], v[110];
ll dp[110][100010];

int main(){
	scanf("%d%d", &n, &W);

	for(int i = 1; i <= n; i++) scanf("%d%d", &w[i], &v[i]);

	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= 100000; j++){
			dp[i][j] = 1e9 + 1;
		}
	}

	dp[0][0] = 0;

	for(int i = 1; i <= n; i++){
		dp[i][0] = 0;
		for(int j = 1; j <= 100000; j++){
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
		}
	}

	int ans = -1;
	for(int i = 100000; i >= 0; i--){
		if(dp[n][i] <= W) {ans = i; break;}
	}

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

	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 4000000000000000001


int main(){

	int N,K;
	cin>>N>>K;
	
	vector<long long> x(N),y(N);
	
	vector<pair<long long,long long>> P(N);
	
	for(int i=0;i<N;i++){
		cin>>P[i].first>>P[i].second;
		x[i] = P[i].first;
		y[i] = P[i].second;
	}
	
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	long long ans = Inf;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=0;k<N;k++){
				for(int l=k+1;l<N;l++){
					
					int cnt = 0;
					for(int ind=0;ind<N;ind++){
						if(x[i]<=P[ind].first&&x[j]>=P[ind].first&&y[k]<=P[ind].second&&y[l]>=P[ind].second){
							cnt++;
						}
					}
					if(cnt>=K){
						ans = min(ans,(x[j]-x[i])*(y[l]-y[k]));
					}
					
					
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 256
def takahashis_information(C: list) -> bool:
    for a1 in range(C[0][0] + 1):
        b1 = C[0][0] - a1
        b2 = C[0][1] - a1
        b3 = C[0][2] - a1

        if b1 < 0 or b2 < 0 or b3 < 0:
            continue

        # check a2
        if C[1][0] - b1 != C[1][1] - b2:
            continue
        if C[1][1] - b2 != C[1][2] - b3:
            continue

        # check a3
        if C[2][0] - b1 != C[2][1] - b2:
            continue
        if C[2][1] - b2 != C[2][2] - b3:
            continue

        return True

    return False


if __name__ == "__main__":
    C = [[int(s) for s in input().split()] for _ in range(3)]
    yes = takahashis_information(C)
    print('Yes' if yes else 'No')


Measured memory_bytes: 3064
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
 
const int maxn = 2000010;
char s[maxn];
 
set <int> S;
int nextt[maxn][30];
int now[30];
int now_tot[maxn];
 
void doit(){
    scanf("%s",s);
    int len=strlen(s);
    int tot=0;
    for (int i=len;i>=1;i--)
    {
        S.insert( s[i-1]-'a' );
        now_tot[i]=tot;
        if (S.size()==26)
        {
            tot++;
            S.clear();
        }
    }
    
   if (tot==0)
        {
        for (int i=0;i<26;i++)
            if (S.count (i )==0)
                {
                    printf("%c",i+'a');
                    return ;
                }
        }
    memset(now,0,sizeof(now));
    
    for (int i=len;i>=1;i--)
    {
        for (int j=0;j<26;j++)
            nextt[i][j]=now[j];
        now[ s[i-1]-'a' ]=i;
    }
    
    int tmp=0;
    for (int i=0;i<26;i++)
        if (S.count (i)==0)
        {
            tmp=now[i];
            break;
        }
        
    printf("%c",s[tmp-1]);
    
    for (int i=1;i<tot;i++)
        {
            for (int j=0;j<26;j++)
                if (now_tot [ nextt[ tmp ][ j ] ]==now_tot [ tmp ] -1 )
                    {
                        tmp=nextt[ tmp ][ j ];
                        printf("%c",s[tmp-1]);
                        break;
                    }
        }
    for (int i=0;i<26;i++)
        if (nextt[ tmp ][ i ]==0)
            {
                printf("%c",i+'a');
                break;
            }
}
 
 
int main(){
    doit();
    return 0;
}


Measured memory_bytes: 29696
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 99999999999
#define N 200
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , m , a[N][N] , d[N][N];
int main(){
fcin;
	n = 3;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			cin>>a[i][j];
		}
	}
	int q;
	cin>>q;
	while(q--){
		int r;
		cin>>r;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				if(a[i][j]==r) d[i][j]  = 1;
				}
			}
	}

	for(int i = 0 ; i < n ; i++){
		if(d[i][0]==d[i][1] && d[i][1]==d[i][2] && d[i][0]==1) {cout<<"Yes\n"; return 0;}
	}
	for(int j = 0 ; j < n ; j++){
		if(d[0][j]==d[1][j] && d[1][j]==d[2][j] &&  d[0][j]==1) {cout<<"Yes\n"; return 0;}
	}
	if(d[0][0]==d[1][1] && d[1][1]==d[2][2] && d[0][0]==1) {cout<<"Yes\n"; return 0;}
	if(d[0][2]==d[1][1] && d[1][1]==d[2][0] && d[2][0]==1) {cout<<"Yes\n"; return 0;}
	cout<<"No\n";

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<functional>
#include<queue>
using namespace std;
long long p[400][400], q[400][400], n; bool OK = true;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> p[i][j]; q[i][j] = p[i][j]; } }
	for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { q[i][j] = min(q[i][j], q[i][k] + q[k][j]); } } }
	for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] != q[i][j])OK = false; } }
	if (OK == false)cout << "-1" << endl;
	else {
		long long sum = 0;
		for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { bool OK = true; for (int k = 0; k < n; k++) { if (k != i && k != j && p[i][j] == p[i][k] + p[k][j])OK = false; }if (OK == true)sum += p[i][j]; } }
		cout << sum / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[4][MAXN],inv[2],flip[2];
int tr[MAXN * 3];
int lowbit(int x) {return x & (-x);}
void insert(int x,int v) {
    while(x <= 3 * N) {
	tr[x] += v;
	x += lowbit(x);
    }
}
int query(int x) {
    int r = 0;
    while(x > 0) {
	r += tr[x];
	x -= lowbit(x);
    }
    return r;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= 3 ; ++i) {
	for(int j = 1 ; j <= N ; ++j) read(a[i][j]);
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(a[2][i] % 3 != 2) {puts("No");return;}
	if((a[2][i] / 3 + 1 & 1) != (i & 1)) {puts("No");return;}
	int b = a[1][i],c = a[3][i];
	if(b > c) swap(b,c);
	if(b != a[2][i] - 1 || c != a[2][i] + 1) {puts("No");return;}
	if(a[2][i] - 1 == a[3][i]) flip[i & 1] ^= 1;
    }
    for(int i = 1 ; i <= N ; i += 2) {
	inv[i & 1] ^= query(3 * N) - query(a[2][i]) & 1;
	insert(a[2][i],1);
    }
    memset(tr,0,sizeof(tr));
    for(int i = 2 ; i <= N ; i += 2) {
	inv[i & 1] ^= query(3 * N) - query(a[2][i]) & 1;
	insert(a[2][i],1);
    }
    if(flip[0] != inv[1]) {puts("No");return;}
    if(flip[1] != inv[0]) {puts("No");return;}
    puts("Yes");
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var n, m int

const INFTY = 1 << 21

type Node struct {
	prev, dist int
}

func bfs(nodes []Node, e [][]int) {
	init := Node{-1, INFTY}
	for i := 1; i < n; i++ {
		nodes[i] = init
	}
	nodes[0] = Node{-1, 0}
	var q []int
	q = append(q, 0)
	for len(q) > 0 {
		v := q[0]
		//queueから取り出したノードに隣接するノードについて
		for _, u := range e[v] {
			if nodes[u].dist > nodes[v].dist+1 {
				nodes[u].prev = v
				nodes[u].dist = nodes[v].dist + 1
				q = append(q, u)
			}
		}
		q = q[1:]
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m = nextInt(), nextInt()

	//隣接するノードを保持
	e := make([][]int, n)
	for i := 0; i < m; i++ {
		u, v := nextInt(), nextInt()
		u--
		v--
		e[u] = append(e[u], v)
		e[v] = append(e[v], u)
	}

	nodes := make([]Node, n)
	bfs(nodes, e)
	//fmt.Println(nodes)

	for i := 0; i < n; i++ {
		if nodes[i].dist == INFTY {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		fmt.Println(nodes[i].prev + 1)
	}
}


Measured memory_bytes: 18540
data = [int(n) for n in input().split()]
LIM = 10**9 + 7

if (data[0] - data[1] > 1) or (data[1] - data[0] > 1):
    print(0)
else:
    a = max(data[0], data[1])
    b = min(data[0], data[1])

    tmp = 1
    for i in range(a):
        tmp = (tmp * (i+1)) % LIM
    for i in range(b):
        tmp = (tmp * (i+1)) % LIM
    if a == b:
        tmp = (2 * tmp) % LIM

    print(tmp)


Measured memory_bytes: 39280