akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        int former = Integer.parseInt(s[0] + s[1]);
        int latter = Integer.parseInt(s[2] + s[3]);
        if ((former < 1 || former > 12)
                && (latter < 1 || latter > 12)) {
            System.out.println("NA");
            return;
        }
        if ((former >= 1 && former <= 12)
                && (latter >= 1 && latter <= 12)) {
            System.out.println("AMBIGUOUS");
            return;
        }
        if (former >= 1 && former <= 12) {
            System.out.println("MMYY");
            return;
        }
        System.out.println("YYMM");
    }

}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    int a, max_value = 1;
    
    cin >> a;
    for(int i = 2; i < a; i++){
        int temp = i * i;
        while(temp <= a){
            max_value = max(max_value, temp);
            temp = temp * i;
        }
    }
    
    cout << max_value << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
using namespace std;
    int main() 
{
   	int N, d;
   	set<int>moti;
   	cin >> N;
   	for (int i = 0;i < N;i++)
    {
    cin >> d;
	moti.insert(d);
	}
	cout << moti.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int alfa[n][30]={};
  for(int i=0;i<n;i++){
    string s;cin>>s;
    for(int j=0;j<s.size();j++){
      alfa[i][s[j]-'a']++;
    }
  }
  for(int i=0;i<26;i++){
    int mi=1000000000;
    for(int j=0;j<n;j++){
      mi=min(mi,alfa[j][i]);
    }
    for(int j=0;j<mi;j++)
      cout<<(char)(i+'a');
  }
  cout<<endl;
  return 0;
}


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

int main(void){
   int A,B,C,X,Y;
   cin>>A>>B>>C>>X>>Y;
   int sum_1;
   sum_1=C*min(X,Y)*2;
   if(X==min(X,Y)){
       sum_1+=B*(Y-min(X,Y));
   }else{
       sum_1+=A*(X-min(X,Y));
   }
   int sum_2=A*X+B*Y;
   int sum_3=C*max(X,Y)*2;
   cout<<min(min(sum_1,sum_2),sum_3)<<endl;
   return 0;
}



Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = s
        .chars()
        .map(|c| match c {
            'o' => 100,
            'x' => 0,
            _ => unreachable!(),
        })
        .fold(700, |acc, x| acc + x);
    println!("{}", ans);
}


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

int compar(const int *val1,const int *val2){
    return *val1-*val2;
}

int main(void){
    int n,map[1000],i,min;
    for(;min=1000001,scanf("%d",&n),n;){
        for(i=0;i<n;i++)
            scanf("%d",&map[i]);
        qsort(map,n,sizeof(int),(int (*)(const void *,const void *))compar);
        for(i=0;i<n-1;i++){
            if(min > map[i+1]-map[i])
                min=map[i+1]-map[i];
        }
        printf("%d\n",min);
    }
    return 0;
}

Measured memory_bytes: 652
import java.io.*;
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
        solve();
      out.close();
  }

  private static void solve() {
      //String s = sc.next();
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] arr = sc.readArray(n);
      Queue<Integer> queue = new LinkedList<>();
      StringBuilder sb = new StringBuilder();
      for(int i = 0; i < n; i++) {
        queue.offer(arr[i]);
        if(i >= k) {
          int num = queue.poll();
          if(num < arr[i])
            sb.append("Yes\n");
          else
            sb.append("No\n");
        }
      }
      out.print(sb.toString());
  }

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
 
  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }
      
      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}

Measured memory_bytes: 60348
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 55
#define M 2500
#define P 100
#define inf 0x3f3f3f3f
using namespace std;
struct Ahri
{
	int v,n;
}e[M];
int head[N],cnt;
inline void add(int u,int v)
{
	e[++cnt].v=v;
	e[cnt].n=head[u];
	head[u]=cnt;
}
bool f[P+5][N][N];
int dis[N],n,m,A,B,C;
int da[N],db[N],dc[N];
void getf()
{
	int i,j,k,l;
	for(i=1;i<=n;i++)f[0][i][i]=1;
	for(k=1;k<=P;k++)
		for(j=1;j<=n;j++)
			for(i=head[j];i;i=e[i].n)
				for(l=1;l<=n;l++)
					f[k][l][e[i].v]|=(f[k-1][l][j]);
}
queue<int>q;
void bfs()
{
	while(!q.empty())q.pop();
	memset(dis,-1,sizeof dis);
	memset(da,0,sizeof da);
	memset(db,0,sizeof db);
	memset(dc,0,sizeof dc);
	
	int i,u;
	q.push(n),dis[n]=0;
	
	while(!q.empty())
	{
		u=q.front(),q.pop();

		for(i=1;i<=n;i++)if(dis[i]==-1)
		{
			if(!da[i]&&f[A][i][u])da[i]=dis[u]+1;
			if(!db[i]&&f[B][i][u])db[i]=dis[u]+1;
			if(!dc[i]&&f[C][i][u])dc[i]=dis[u]+1;
			if(da[i]&&db[i]&&dc[i])
				dis[i]=max(da[i],max(db[i],dc[i])),q.push(i);
		}
	}
}

int main()
{
//	freopen("test.in","r",stdin);
	int i,j,k;
	scanf("%d%d%d%d%d",&n,&m,&A,&B,&C);
	while(m--)
	{
		scanf("%d%d",&i,&j);
		add(i,j);
	}
	getf();
	bfs();
	if(dis[1]==-1)puts("IMPOSSIBLE");
	else printf("%d\n",dis[1]);
	
	return 0;
}
/*/asdasdasdasdasd**/

Measured memory_bytes: 1512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a_1,a_2,a_3;
  cin>>a_1>>a_2>>a_3;
  cout<<max(a_1,max(a_2,a_3))-min(a_1,min(a_2,a_3))<<endl;
}


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

int main() {
	string s;
	cin >> s;
	int pos;

	bool update = true;
	while(update) {
		update = false;
		pos = s.find("mew");
		if(pos != string::npos) {
			string f = s.substr(0, pos);
			string b = s.substr(pos+3, s.size());
			s = f + 'X' + b;
			update = true;
			goto next;
		}
		pos = s.find("mXew");
		if(pos != string::npos) {
			string f = s.substr(0, pos);
			string b = s.substr(pos+4, s.size());
			s = f + 'X' + b;
			update = true;
			goto next;
		}
		pos = s.find("meXw");
		if(pos != string::npos) {
			string f = s.substr(0, pos);
			string b = s.substr(pos+4, s.size());
			s = f + 'X' + b;
			update = true;
			goto next;
		}
		pos = s.find("mXeXw");
		if(pos != string::npos) {
			string f = s.substr(0, pos);
			string b = s.substr(pos+5, s.size());
			s = f + 'X' + b;
			update = true;
			goto next;
		}

		next:;
	}

	if(s == "" || s == "X") {
		cout << "Cat" << endl;
	} else {
		cout << "Rabbit" << endl;
	}

	return 0;
}

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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = n / 100 % 10;
  c = n % 100 / 10;
  d = n % 10;

  if ((a == b && b == c) ||  (b == c &&c == d)) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  return 0;
}


Measured memory_bytes: 256
//Copyright@3_soon,From Hangzhou No.2 High School Baimahu
//Problem:
//Result:

#include<bits/stdc++.h>
using namespace std;
#define re register
#define LL long long
#define DB double
#define il inline
#define For(x,a,b) for(re int x=a;x<=b;x++)
#define For2(x,a,b) for(re int x=a;x>=b;x--)
#define LFor(x,a,b) for(re LL x=a;x<=b;x++)
#define LFor2(x,a,b) for(re LL x=a;x>=b;x--)
#define Abs(x) ((x>0)? x:-x)
#define mod (LL)1000000007
int gi()
{
    int res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
LL gl()
{
    LL res=0,fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    return fh*res;
}
struct ARR{
    LL n[3][3];
};
ARR rre;
ARR operator *(const ARR &a,const ARR &b)
{
    For(i,0,2){
	For(j,0,2){
	    rre.n[i][j]=0;
	    For(k,0,2) (rre.n[i][j]+=a.n[i][k]*b.n[k][j])%=mod;
	}
    }
    return rre;
}

int m;
LL n,x[100005];
ARR C,ans;
void mi(LL y){
    while(y){
	if(y&1) ans=ans*C;
	C=C*C;
	y>>=1;
    }
}

int main()
{
    n=gl(),m=gi();
    For(i,1,m) x[i]=gi();
    x[++m]=n;
    sort(x+1,x+1+m);
    ans=(ARR){{{1,0,0},{0,0,0},{0,0,0}}};
    x[0]=-1;
    For(i,1,m){
	LL len=x[i]-(x[i-1]+1);
	C=(ARR){{{1,2,1},{0,1,1},{1,2,2}}};
	mi(len);
	if (i==m) break;
	C=(ARR){{{1,2,1},{0,1,1},{0,0,1}}};
	ans=ans*C;
    }	
    printf("%lld\n",ans.n[0][2]);
}
/*
 */

Measured memory_bytes: 1024
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
//#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int a,b,c,d,val,val1;
	string s;
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	val=a-b-c-d;
	val1=a+b+c+d;
	if(val==7){
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
	}
	else if(val1==7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
	}
	else if(val+2*b==7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
	}
	else if(val+2*c==7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
	}
	else if(val+2*d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
	}
	else if(val1-2*b==7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
	}
	else if(val1-2*c==7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
	}
	else{
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
	}
} 


Measured memory_bytes: 256
import 'dart:io';

void main(List<String> args) {
  final K = int.parse(stdin.readLineSync());
  final S = stdin.readLineSync();
  if (S.length <= K) {
    print(S);
  } else {
    final sub = S.substring(0, K);
    print('$sub...');
  }
}


Measured memory_bytes: 13148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

bool isPalindrome(string s){
	int sz=s.size();
	bool res=true;
	for(int i=0; i<sz; ++i){
		res=res&&(s[i]==s[sz-1-i]);
	}
	return res;
}

int main() {
	string S;
	cin >> S;
	if(isPalindrome(S) && isPalindrome(S.substr(0, (S.size()-1)/2))){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
STDIN.each_slice(2){|a,b|(lambda{|a,b|t,f=[0,0];a.each_with_index{|c,i|p=b.index(c);p==i ? t+=1 : f+=1 unless p.nil?};puts"#{t} #{f}"}).call((a.split.map &:to_i),(b.split.map &:to_i))}

Measured memory_bytes: 6100
# coding: utf-8

# https://atcoder.jp/contests/abc098/tasks/abc098_b


def main():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1, N):
        X = S[:i]
        Y = S[i:]
        tmp = 0
        for code in range(97, 97+26):
            c = chr(code)
            if c in X and c in Y:
                tmp += 1
        
        if tmp > ans:
            ans = tmp
        
    return ans


print(main())


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int A,B;

bool condition(int N){ int sum = 0;
  while( N > 0){
    sum += N % 10;
    N /= 10;}
     if( A <= sum && sum <= B){ return true;}
     else{return false;} }
                    
                      




int main(){
int N;cin >> N >> A >> B; int S = 0;
  for(int i = 1; i <= N; i++){
    if(condition(i)){ S += i;}}
  
  cout << S << endl; return 0;}


Measured memory_bytes: 256
N, M = map(int, input().split())
inputs = [int(i) for i in input().split()]

inputs.sort()
diff = []
for i in range(M-1):
    diff.append(inputs[i+1] - inputs[i])

diff.sort(reverse=True)

print(inputs[-1] - inputs[0] - sum(diff[:N-1]))


Measured memory_bytes: 13840
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
LL S[100005];
LL D[100005];

LL treeMin[100005 * 4];
void build(int at, int l, int r) {
	if (l == r) {
		treeMin[at] = D[l];
		return;
	}
	int m = (l + r) / 2;
	build(at * 2, l, m);
	build(at * 2 + 1, m + 1, r);
	treeMin[at] = MIN(treeMin[at * 2], treeMin[at * 2 + 1]);
}

LL query(int at, int l, int r, int L, int R) {

	if (R < L || R < l || r < L) return 1000000000000000000LL;
	if (L <= l && r <= R) {
		return treeMin[at];
	}
	int m = (l + r) / 2;
	LL a = query(at * 2, l, m, L, R);
	LL b = query(at * 2 + 1, m + 1, r, L, R);
	return MIN(a, b);
}

set<pair<LL, int>> SS;
LL MOD = 1000000007;
LL dp[100005][2];
LL A, B;

int Find(LL y) {
	set<pair<LL, int>>::iterator iS = SS.lower_bound(make_pair(y, 0));
	iS--;
	return iS->second;
}

int main()
{
	scanf("%d", &n);
	scanf("%lld %lld", &A, &B);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &S[i]);
		SS.insert(make_pair(S[i], i));
	}
	for (int i = 1; i < n; i++) {
		D[i] = S[i + 1] - S[i];
	}
	if (n > 1) build(1, 1, n - 1);

	dp[n + 1][0] = dp[n + 1][1] = 1;
	for (int i = n; i >= 1; i--) {
		LL y;
		// dp[i][0]
		y = S[i] + A;
		int where = Find(y);
		// (i + 1) ... (where) must be in B.
		if (where == i) {
			if (i == n) dp[i][0] = 1;
			else dp[i][0] = (dp[i + 1][0] + dp[i + 1][1]) % MOD;
		}
		else {
			LL q = query(1, 1, n - 1, i + 1, where - 1);
			if (q < B) {
				dp[i][0] = 0;
			}
			else {
				dp[i][0] = dp[where][1];
			}
		}


		y = S[i] + B;
		where = Find(y);
		// (i + 1) ... (where) must be in A.
		if (where == i) {
			if (i == n) dp[i][1] = 1;
			else dp[i][1] = (dp[i + 1][0] + dp[i + 1][1]) % MOD;
		}
		else {
			LL q = query(1, 1, n - 1, i + 1, where - 1);
			if (q < A) {
				dp[i][1] = 0;
			}
			else {
				dp[i][1] = dp[where][0];
			}
		}



	}
	LL ans = dp[1][0] + dp[1][1];
	ans %= MOD;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 11776
n=int(input())
ac=0
wa=0
tle=0
re=0

for i in range(n):
  judge=input()
  if judge=="AC":
    ac+=1
  elif judge=="WA":
    wa+=1
  elif judge=="TLE":
    tle+=1
  elif judge=="RE":
    re+=1
    
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  	long long N, K;
  	cin >> N >> K;
  	vector<long long> A(N);
  	for(int i=0;i<N;i++) cin >> A[i];
  	long long max = *max_element(A.begin(), A.end()), min = 0;
  	while (1){
      	long long X = (max + min)/2;
      	//cout << max << " " << min << endl;
      	if(X == min) break;
      	long long Kreal = 0;
      	for(int i=0;i<N;i++) Kreal += (A[i]+X-1)/X -1;
      	if(Kreal <= K) max = X;
        else min = X;
    }
  	cout << max << endl;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<998244353>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, s;
  cin >> n >> s;
  vector<mint> dp(s + 1);
  dp[0] = 1;
  mint res;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    vector<mint> ndp(s + 1);
    for (int j = 0; j <= s; ++j) {
      ndp[j] = 2 * dp[j];
    }
    for (int j = s - a; j >= 0; --j) {
      ndp[j + a] += dp[j];
    }
    swap(dp, ndp);
  }
  cout << dp[s].v << '\n';
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

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

int main()

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

    string s;

    cin >> s;

    if (s == "SUN") cout << "7";
    else if (s == "MON") cout << "6";
    else if (s == "TUE") cout << "5";
    else if (s == "WED") cout << "4";
    else if (s == "THU") cout << "3";
    else if (s == "FRI") cout << "2";
    else cout << "1";

    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    long long ans = 0;
    int n; cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 1; i < n; i++){
        if (arr[i-1] > arr[i]){
            ans += arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

int n,k;

int a[N],dp[N];

int main(){
		
	NFS

	cin >> n >> k;
	
	for(int i=1;i<=n;i++){
		cin >> a[i];
		dp[i]=inf;
	}
	
	dp[1]=0;
	
	for(int i=2;i<=n;i++){
		for(int j=max(1,i-k);j<i;j++){
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	
	cout << dp[n] << endl;	
	
	ioi
}

Measured memory_bytes: 1024
from collections import defaultdict

def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


N = I()
d = defaultdict(int)
for i in range(N):
    s = input()
    d[s] += 1

m = max(d.values())
ans = list()
for s, cnt in d.items():
    if cnt == m:
        ans.append(s)
ans.sort()
for x in ans:
    print(x)


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

using namespace std;

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

  int n, m, c, a;
  cin >> n >> m >> c;
  vector<int> B(m);
  for (auto &b : B) cin >> b;
  int res = 0;
  while (n--) {
    int sum = 0;
    for (int i = 0; i < m; ++i) {
      cin >> a;
      sum += a * B[i];
    }
    if (sum + c > 0) 
      res++;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

int main(){
  ll n,q;
  string s;
  cin>>n>>q>>s;
  vll cnt(n,0);
  for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C')cnt[i]++;
    cnt[i]+=cnt[i-1];
  }

  vll l(q),r(q);
  for(int i=0;i<q;i++){
    cin>>l[i]>>r[i];
    l[i]--,r[i]--;
  }

  for(int i=0;i<q;i++){
    cout<<cnt[r[i]]-cnt[l[i]]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  vector<int> a(n),b(n),c(n-1);
  rep(i,n){ cin >> a[i];a[i]--;}
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  int res = 0;
  rep(i,n){
    res += b[a[i]];
    if(i != n - 1){
      if(a[i] + 1 == a[i+1]) res += c[a[i]];
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007
    val N = readInt()
    val w = readString()
    val set = mutableSetOf(w)
    var last = w.last()
    var ans = "Yes"
    for(n in 0 until N-1) {
        val w = readString()
        if (w.first() != last || w in set) ans = "No"

        set.add(w)
        last = w.last()
    }
    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 36160
#include<cstdio>

using namespace std;

int main(){
	for(int n,p;scanf("%d%d",&n,&p),n;){
		int bowl=p,got[50]={};
		for(int i=0;;i=(i+1)%n){
			if(bowl>0)	got[i]++,bowl--;
			else		bowl+=got[i],got[i]=0;
			if(got[i]==p){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 756
#include<stdio.h>
#include <string.h>

int main(){

int n,a,b,c,d,cnt=0,max=0,k,cnt2=0;
char s[200000];

scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
scanf("%s",&s);

k=c>d?c:d;

for(int j=a;j<k-1;j++){
	if(s[j]=='#'&&s[j+1]=='#'){printf("No");return 0;}
	}
		
		
if(c>d){
	for(int i=b-1;i<d;i++){
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
			printf("Yes");
			return 0;
			}
	}
	printf("No");
	return 0;
}
if(d>c){
	printf("Yes");
}
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string x; cin >> x;

    stack<char> st;
    for(int i = 0; i < x.size(); i++) {
        if(st.empty()) st.push(x[i]);
        else {
            if(x[i] == 'S') st.push(x[i]);
            if(x[i] == 'T' && st.top() == 'T') st.push(x[i]);
            if(x[i] == 'T' && st.top() == 'S') st.pop();
        }
    }

    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 644
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, x, t = map(int, readline().split())
    print((n + x - 1) // x * t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61760
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

vector<int> neighbor_friends[100005];
vector<int> neighbor_block[100005];
int group[100005];
int group_cnt[100005];

int main(int argc, const char * argv[]) {
    int n,m,k; cin >> n >> m >> k;
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        neighbor_friends[a].push_back(b);
        neighbor_friends[b].push_back(a);
                
    }
    for(int i=0;i<k;i++){
        int c,d; cin >> c >> d;
        c--; d--;
        neighbor_block[c].push_back(d);
        neighbor_block[d].push_back(c);
    }
    for(int i=0;i<100005;i++) group[i]=-1;
    
    queue<int> que;

    
    
    for(int i=0;i<n;i++){
        group_cnt[i]=0;
        if(group[i]==-1){
            group[i]=i;
            group_cnt[i]++;
            que.push(i);
            while(!que.empty()){
                int node = que.front(); que.pop();
                for(int j : neighbor_friends[node]){
                    if(group[j]!=-1) continue;
                    group[j]=group[i];
                    group_cnt[group[j]]++;
                    que.push(j);
                }
            }
        }
        
    }
    
//    for(int i=0;i<n;i++){
//        cout << i<<"のグループは" <<group[i] << "  グループ内のノード数は" << group_cnt[group[i]] << endl;
//    }
    
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j : neighbor_block[i]){
            if(group[j]==group[i]){
                cnt++;
            }
        }
        cout << group_cnt[group[i]] - (1 + neighbor_friends[i].size() + cnt) << " ";
    }
    cout << endl;

    
    

//    cout << neighbor[1][1] << endl;
    
    
    return 0;
}




Measured memory_bytes: 13048
n,a,b = map(int,input().split())
s = input()
cnt = 0
ovs = 0
for i in range(n):
    if s[i]=="a":
        if cnt < a+b:
            print("Yes")
            cnt +=1
        else:
            print('No')
    elif s[i]=="b":
        if cnt < a+b and ovs < b:
            print("Yes")
            cnt +=1
            ovs += 1
        else:
            print('No')
    else:
        print('No')
        

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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
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; }

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

int main(){
    ll N, K;
    cin >> N >> K;
    // if(N == 1){
    //     print(1);
    //     return 0;
    // }
    ll ma = 1;
    ll cnt = 1;
    while(N > ma){
        ma *= K;
        if(ma <= N) cnt++; 
    }
    string ans;
    while(cnt > 0){
        if(N >= pow(K, cnt)) ans += '1';
        else ans += '0';
        cnt--;
    }
    print(ans.length());
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a = read(&mut stdin_lock, &mut buf, b' ');
    let b = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(a, b));
}

fn solve(a: i32, b: i32) -> i32 {
    if b % a == 0 {
        a + b
    } else {
        b - a
    }
}

#[test]
fn example1() {
    assert_eq!(16, solve(4, 12))
}

#[test]
fn example2() {
    assert_eq!(12, solve(8, 20))
}

#[test]
fn example3() {
    assert_eq!(2, solve(1, 1))
}


Measured memory_bytes: 4352
import math
A = [int(input()) for _ in range(5)]
B = 10
ans = 0
for i in range(5):
  if 0 < A[i] % 10 < B:
    B = A[i] % 10
    ans = -10+B
for j in A:
  ans += math.ceil(j/10)*10
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,X,x;
    cin >> n >> X;
    ll ans;
    rep(i,n){
        cin >> x;
        if (i == 0) ans = abs(x-X);
        else ans = gcd(ans,abs(x-X));
    }
    PRINT(ans);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define mod 1000000007
#define lli long long
#define fi first
#define se second
#define pb emplace_back
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(x,v) for(auto x : v)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MAXC 200005
// %
vector < int > prime, lp;

void linearSieve(int UP){
    lp.resize(UP, 0);
    for (int i = 2; i < UP; i++) {
        if (!lp[i]) {
            prime.pb(i);
            lp[i] = i;
        }
        for (auto p : prime) {
            if (p * i >= UP) {
                break;
            }
            lp[p * i] = p;
            if (i % p == 0) {
                break;
            }
        }
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector < int > v(n);
    int gc = 0, ok = 1;
    linearSieve(1e6+1);
    map< int, int > pri;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        gc = __gcd(gc, v[i]);
        set < int > S;
        while (v[i] != 1) {
            S.insert(lp[v[i]]);
            v[i] /= lp[v[i]];
        }
        for (int x : S) {
            pri[x]++;
            ok &= (pri[x] <= 1);
        }
    }
    cout << (ok? "pairwise coprime" : gc == 1? "setwise coprime" : "not coprime") << '\n';    
}

Measured memory_bytes: 15000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin>>c;
    if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
    cout<<"vowel"<<endl;
    }
    else{
    cout<<"consonant"<<endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>cnt(1e5+1,0);
    ll sum=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin>>a;
        cnt[a]++;
        sum+=a;
    }
    ll q;cin >>q;
    for (int i = 0; i < q; ++i) {
        ll b,c;cin >>b>>c;
        sum=sum+(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout <<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4032
import fractions
def main():
    N, St = map(int, input().split())
    X = [int(a) for a in input().split()]
    X.append(St)
    X.sort()

    D = list()
    for i in range(len(X)-1):
      d = X[i+1] - X[i]
      D.append(d)
    ans = D[0]

    for i in range(1, len(D)):
        ans = fractions.gcd(ans, D[i])
    
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 16276
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vivi=vector<vi>;

int main(){
    int N,M,X;
    scanf("%d%d%d",&N,&M,&X);
    vivi book(N,vi(M+1));
    int mi=0;
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<M+1;j++)
        {
            cin>>book.at(i).at(j);
            
        }
    }
    

    bool bl=true;

    int sum=0;
   
        if(bl)
        {
            
            for(int tmp=0;tmp<(1<<N);tmp++)
            {
                bitset<12> wi(tmp);
                int current=0;
                queue<int> qi;//やはりフローチャートは書くべき
                for(int i=0;i<N;i++){
                    if(wi.test(i))
                    {
                        qi.push(i);
                        current+=book.at(i).at(0);
                    }
                }
                bool over=true;
                auto memo=qi;
                if(mi==0||current<mi){
                    for(int i=1;i<M+1;i++)
                    {
                        qi=memo;
                        sum=0;
    
                        while(!qi.empty())
                        {
                            
                            sum+=book.at(qi.front()).at(i);
                            
                            qi.pop();
                        }
                      
                        if(sum<X){
                 
                            over=false;
                            break;
                        }

                        
                    }
                    if(over)
                    {
                       
                        
                        mi = current;
                       
                    }
                    
                }
                               
            }
            if(mi!=0)
            {
                cout<<mi<<endl;
            }
            else
            {
                cout<<-1<<endl;
            }
       }    
      
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int A[N], B[N], C[N];
	int total_a = 0, total_b = 0;
	rep(i, 0, N) {
		cin >> A[i] >> B[i] >> C[i];
		total_a += A[i];
		total_b += B[i];
	}
	ll dp[N + 1][total_a + 1][total_b + 1];
	rep(i, 0, N + 1) rep(j, 0, total_a + 1) rep(k, 0, total_b + 1) dp[i][j][k] = INF;

	dp[0][0][0] = 0;
	rep(i, 0, N) rep(a, 0, total_a + 1) rep(b, 0, total_b + 1) {
		dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
		if(a - A[i] >= 0 and b - B[i] >= 0) {
			dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a - A[i]][b - B[i]] + C[i]);
		}
	}

	ll rsl = INF;
	rep(a, 1, total_a + 1) rep(b, 1, total_b + 1) {
		if(Ma * b == Mb * a) rsl = min(rsl, dp[N][a][b]);
	}

	if(rsl == INF) cout << -1 << endl;
	else cout << rsl << endl;


}


Measured memory_bytes: 18560
n = int (input())
a = int(n / 10)
h = [2, 4, 5, 7, 9]
p = [0, 1, 6, 8]
if n - a * 10 in h:
  print ("hon")
elif n - a * 10 in p:
  print ("pon")
else:
  print("bon")

Measured memory_bytes: 9092
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int res = 0;
		for (int i=N; 0<i; i--) {
			int t = (int)Math.sqrt(i);
			if (Math.pow(t, 2) == i) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
def solve():
  n = int(input())
  if n == 0:
    exit()
  C = [c for c in input().split()]

  V = [0] * 26

  for i, c in enumerate(C, 1):
    V[ord(c) - ord('A')] += 1
    maxi = 0
    ma1 = 0
    ma2 = 0
    for j, v in enumerate(V):
      if v > ma1:
        ma1, ma2 = v, ma1
        maxi = j
      elif v > ma2:
        ma2 = v

    if ma1 - ma2 > n - i:
      print(chr(ord('A') + maxi), i)
      return

  print('TIE')

while True:
  solve()


Measured memory_bytes: 5624
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//vector<int> is passed by &
#define maxStones 100000

int dp[maxStones];
vector<int> heights;

int getCostfromIndex(int index, int K)
{

	if(dp[index]!=-1)
	{		
		return dp[index];
	}

	if(index == heights.size()-1)
		return 0;

	if(index + K > heights.size()-1)
		return dp[index]=abs(heights[heights.size()-1]-heights[index]); 

	int mincost=INT_MAX;
	for(int i=1;i<=K;i++)
	{
		int x=abs( heights[index+i] - heights[index] ) + getCostfromIndex(index+i,K);
		if( x < mincost)
			mincost = x;
	}		
	dp[index]=mincost;
	
	return mincost;		
}


int main()
{
	for(int i=0;i<maxStones;i++)
		dp[i]=-1;

	int n,k;	
	cin >> n >> k;
	int t;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		heights.push_back(t);
	}
	cout << getCostfromIndex(0,k) <<endl;
	return 0;
}

Measured memory_bytes: 12024
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<math.h>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll n, a[100],k,cnt=547283908723495053;
string str;
//-------------------関数----------------------//


int main() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
	}
	for (int i = -200; i <=200; i++)
	{
		ll mini=0;
		REP(j, n) {
			mini += pow(a[j]-i, 2);
		}
		cnt = min(cnt, mini);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
lis = [[float("inf")] * N for i in range(N)]
flis = [[False] * N for i in range(N)]
ans = 0

for i in range(N):
    lis[i][i] = 0

for i in range(M):

    a,b,c = map(int,input().split())

    a -= 1
    b -= 1

    lis[a][b] = c
    lis[b][a] = c

    flis[a][b] = True
    flis[b][a] = True

for k in range(N):

    for i in range(N):

        for j in range(N):

            if lis[i][j] > lis[i][k] + lis[k][j]:
                lis[i][j] = lis[i][k] + lis[k][j]

                if flis[i][j]:
                    flis[i][j] = False
                    flis[j][i] = False
                    ans += 1

print (ans)


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

int main(void){
  int N;
  scanf("%d",&N);
  int A[N-1];
  int list[N];
  list[0]=0;
  for(int i=1;i<N;i++){
    scanf("%d",&A[i]);
    list[i]=0;
    list[A[i]-1]++;
  }
  for(int i=0;i<N;i++){
    printf("%d\n",list[i]);
  }
  return 0;
}


Measured memory_bytes: 3236
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
A = LI()
c = [0]*(n+1)
d = [0]*(n+1)
for a in A:
    c[a-1] += 1
# print(c)
def nc2(num):  # num >= 0
    return int(num*(num-1)/2)
for i in range(n):
    d[i] = nc2(c[i])
# print(d)
dsum = sum(d)
for i in range(n):
    a = A[i] - 1
    print(dsum - nc2(c[a]) + nc2(c[a]-1))


Measured memory_bytes: 111816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll ans = N - 1;
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

int n,k,a[MAXN],f[MAXN];

int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	for (int i=1;i<n;i++){
		f[i]=INF;
		for (int j=max(i-k,0);j<i;j++){
			f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
		}
	}
	cout<<f[n-1]<<endl;
	re 0;
}

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

int main(){
    int n,y=0;cin>>n;
    for(int i=0;i<n;i++){
        char x;
        cin>>x;
        if(x=='Y') y++;
    }
    if(y!=0) cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}

Measured memory_bytes: 256